2000-11-07 05:52:12 +08:00
|
|
|
#!/bin/sh
|
|
|
|
# make sure mkdir's -p options works properly
|
|
|
|
|
2006-10-23 01:37:31 +08:00
|
|
|
# Copyright (C) 2000, 2004, 2006 Free Software Foundation, Inc.
|
2006-08-18 03:58:17 +08:00
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
2007-07-10 18:21:15 +08:00
|
|
|
# the Free Software Foundation; either version 3 of the License, or
|
2006-08-18 03:58:17 +08:00
|
|
|
# (at your option) any later version.
|
|
|
|
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
|
|
# 02110-1301, USA.
|
|
|
|
|
2000-11-07 05:52:12 +08:00
|
|
|
if test "$VERBOSE" = yes; then
|
|
|
|
set -x
|
|
|
|
mkdir --version
|
|
|
|
fi
|
|
|
|
|
|
|
|
pwd=`pwd`
|
|
|
|
tmp=parents-$$
|
2006-10-23 01:37:31 +08:00
|
|
|
trap 'status=$?; cd "$pwd" && rm -rf $tmp && exit $status' 0
|
2000-11-07 05:52:12 +08:00
|
|
|
trap '(exit $?); exit' 1 2 13 15
|
|
|
|
|
|
|
|
framework_failure=0
|
|
|
|
|
|
|
|
# Record absolute path of srcdir.
|
|
|
|
cd $srcdir || framework_failure=1
|
|
|
|
abs_srcdir=`pwd`
|
|
|
|
|
2006-10-23 01:37:31 +08:00
|
|
|
cd "$pwd" || framework_failure=1
|
2000-11-07 05:52:12 +08:00
|
|
|
mkdir $tmp || framework_failure=1
|
|
|
|
cd $tmp || framework_failure=1
|
2000-11-10 06:22:41 +08:00
|
|
|
mkdir -m 700 e-dir || framework_failure=1
|
2000-11-07 05:52:12 +08:00
|
|
|
|
|
|
|
if test $framework_failure = 1; then
|
|
|
|
echo 'failure in testing framework'
|
2004-06-23 23:07:00 +08:00
|
|
|
(exit 1); exit 1
|
2000-11-07 05:52:12 +08:00
|
|
|
fi
|
|
|
|
|
2006-10-26 17:03:30 +08:00
|
|
|
. "$abs_srcdir/../setgid-check"
|
2000-11-07 05:52:12 +08:00
|
|
|
|
2000-11-23 22:59:05 +08:00
|
|
|
fail=0
|
2000-11-10 06:22:41 +08:00
|
|
|
|
2000-11-07 05:52:12 +08:00
|
|
|
# Make sure `mkdir -p existing-dir' succeeds
|
|
|
|
# and that `mkdir existing-dir' fails.
|
|
|
|
mkdir -p e-dir || fail=1
|
|
|
|
mkdir e-dir > /dev/null 2>&1 && fail=1
|
|
|
|
|
2000-11-07 05:53:08 +08:00
|
|
|
# Create an existing directory.
|
2000-11-07 05:52:12 +08:00
|
|
|
umask 077
|
|
|
|
mode_str=drwxr-x-wx
|
2006-10-26 17:03:30 +08:00
|
|
|
mode_arg=`"$abs_srcdir/../rwx-to-mode" $mode_str`
|
2000-11-07 05:52:12 +08:00
|
|
|
mkdir -m $mode_arg a || fail=1
|
|
|
|
|
2000-11-07 05:53:08 +08:00
|
|
|
# this `mkdir -p ...' shouldn't change perms of existing dir `a'.
|
2000-11-07 05:52:12 +08:00
|
|
|
d_mode_str=drwx-w--wx
|
2006-10-26 17:03:30 +08:00
|
|
|
d_mode_arg=`"$abs_srcdir/../rwx-to-mode" $d_mode_str`
|
2000-11-07 05:52:12 +08:00
|
|
|
mkdir -p -m $d_mode_arg a/b/c/d
|
|
|
|
|
|
|
|
# Make sure the permissions of `a' haven't been changed.
|
ls: Add support for SELinux and a slightly modified -Z option.
I started with the patches from Red Hat.
The entries below tell how the code evolved.
* src/ls.c (print_long_format, print_file_name_and_frills): When
there is no security context (due to getfilecon/lgetfilecon failing
with e.g. ENOTSUP), print it as "?", not "".
* src/ls.c (print_file_name_and_frills): Make -Z work without -l.
(length_of_file_name_and_frills): Likewise.
* src/ls.c: Remove the --lcontext and --scontext options.
Change the way -Z, --context work so that it no longer implies -l.
Thus, -Z -l will work like -lcontext and -Z without -l will work
like --scontext.
Adjust tests to reflect new 'ls -l' syntax -- affects only
systems with SELinux when operating on a file with no ACL.
These tests assumed that everything before the first space on
each line is the 10-byte mode string. But there may also be a "+"
in the 11th column, just before the space. However, note that this
is not new. The same thing would have happened even without the
change below, when listing a file with an ACL.
* tests/chmod/equals, tests/cp/cp-parents, tests/cp/fail-perm:
* tests/cp/link-preserve, tests/install/basic-1, tests/misc/mknod:
* tests/mkdir/parents, tests/mkdir/special-1, tests/mv/partition-perm:
Don't make compilation depend on USE_ACL. An SELinux security
context counts as an "alternate access control method", so ls
must output a "+" for each file with a security context.
* src/ls.c [struct fileinfo] (have_acl): Declare unconditionally.
(FILE_HAS_ACL): Remove macro definition. Use f->have_acl directly.
(gobble_file): Record whether a file has a security context, and
update the condition used to determine whether to print the "+".
(gobble_file): Call getfilecon/lgetfilecon also when
format == long_format, so that we get the "+".
* src/ls.c (gobble_file): Add a comment explaining why (with a
security context option) ls doesn't exit nonzero due to e.g.,
getfilecon failing with errno == ENOTSUP.
* src/ls.c (gobble_file): Ignore failure of getfilecon if it's due
to ENOTSUP.
* src/ls.c (gobble_file): Factor out three small blocks using
getfilecon and lgetfilecon.
Don't ignore return value from getfilecon and lgetfilecon.
* src/ls.c (print_long_format): Don't use ?: (empty 2nd arg with C
ternary operator).
(print_scontext_format): Likewise.
(print_scontext): Declare to be "bool", not int. Adjust uses.
* src/Makefile.am (dir_LDADD, ls_LDADD, vdir_LDADD): Add $(LIB_SELINUX).
* tests/misc/chcon: New file.
* tests/misc/chcon-fail: New file.
* tests/Makefile.am (check-root): Run new, root-only misc/chcon test.
* tests/misc/Makefile.am (TESTS): Add chcon and chcon-fail.
* tests/misc/Makefile.am (TESTS): Add selinux.
* tests/misc/selinux: New file.
* tests/help-version: Skip chcon.
2007-01-06 01:23:54 +08:00
|
|
|
p=`ls -ld a|cut -b-10`; case $p in $mode_str);; *) fail=1;; esac
|
2000-11-07 05:52:12 +08:00
|
|
|
# `b's and `c's should reflect the umask
|
ls: Add support for SELinux and a slightly modified -Z option.
I started with the patches from Red Hat.
The entries below tell how the code evolved.
* src/ls.c (print_long_format, print_file_name_and_frills): When
there is no security context (due to getfilecon/lgetfilecon failing
with e.g. ENOTSUP), print it as "?", not "".
* src/ls.c (print_file_name_and_frills): Make -Z work without -l.
(length_of_file_name_and_frills): Likewise.
* src/ls.c: Remove the --lcontext and --scontext options.
Change the way -Z, --context work so that it no longer implies -l.
Thus, -Z -l will work like -lcontext and -Z without -l will work
like --scontext.
Adjust tests to reflect new 'ls -l' syntax -- affects only
systems with SELinux when operating on a file with no ACL.
These tests assumed that everything before the first space on
each line is the 10-byte mode string. But there may also be a "+"
in the 11th column, just before the space. However, note that this
is not new. The same thing would have happened even without the
change below, when listing a file with an ACL.
* tests/chmod/equals, tests/cp/cp-parents, tests/cp/fail-perm:
* tests/cp/link-preserve, tests/install/basic-1, tests/misc/mknod:
* tests/mkdir/parents, tests/mkdir/special-1, tests/mv/partition-perm:
Don't make compilation depend on USE_ACL. An SELinux security
context counts as an "alternate access control method", so ls
must output a "+" for each file with a security context.
* src/ls.c [struct fileinfo] (have_acl): Declare unconditionally.
(FILE_HAS_ACL): Remove macro definition. Use f->have_acl directly.
(gobble_file): Record whether a file has a security context, and
update the condition used to determine whether to print the "+".
(gobble_file): Call getfilecon/lgetfilecon also when
format == long_format, so that we get the "+".
* src/ls.c (gobble_file): Add a comment explaining why (with a
security context option) ls doesn't exit nonzero due to e.g.,
getfilecon failing with errno == ENOTSUP.
* src/ls.c (gobble_file): Ignore failure of getfilecon if it's due
to ENOTSUP.
* src/ls.c (gobble_file): Factor out three small blocks using
getfilecon and lgetfilecon.
Don't ignore return value from getfilecon and lgetfilecon.
* src/ls.c (print_long_format): Don't use ?: (empty 2nd arg with C
ternary operator).
(print_scontext_format): Likewise.
(print_scontext): Declare to be "bool", not int. Adjust uses.
* src/Makefile.am (dir_LDADD, ls_LDADD, vdir_LDADD): Add $(LIB_SELINUX).
* tests/misc/chcon: New file.
* tests/misc/chcon-fail: New file.
* tests/Makefile.am (check-root): Run new, root-only misc/chcon test.
* tests/misc/Makefile.am (TESTS): Add chcon and chcon-fail.
* tests/misc/Makefile.am (TESTS): Add selinux.
* tests/misc/selinux: New file.
* tests/help-version: Skip chcon.
2007-01-06 01:23:54 +08:00
|
|
|
p=`ls -ld a/b|cut -b-10`; case $p in drwx------);; *) fail=1;; esac
|
|
|
|
p=`ls -ld a/b/c|cut -b-10`; case $p in drwx------);; *) fail=1;; esac
|
2000-11-07 05:52:12 +08:00
|
|
|
|
|
|
|
# `d's perms are determined by the -m argument.
|
ls: Add support for SELinux and a slightly modified -Z option.
I started with the patches from Red Hat.
The entries below tell how the code evolved.
* src/ls.c (print_long_format, print_file_name_and_frills): When
there is no security context (due to getfilecon/lgetfilecon failing
with e.g. ENOTSUP), print it as "?", not "".
* src/ls.c (print_file_name_and_frills): Make -Z work without -l.
(length_of_file_name_and_frills): Likewise.
* src/ls.c: Remove the --lcontext and --scontext options.
Change the way -Z, --context work so that it no longer implies -l.
Thus, -Z -l will work like -lcontext and -Z without -l will work
like --scontext.
Adjust tests to reflect new 'ls -l' syntax -- affects only
systems with SELinux when operating on a file with no ACL.
These tests assumed that everything before the first space on
each line is the 10-byte mode string. But there may also be a "+"
in the 11th column, just before the space. However, note that this
is not new. The same thing would have happened even without the
change below, when listing a file with an ACL.
* tests/chmod/equals, tests/cp/cp-parents, tests/cp/fail-perm:
* tests/cp/link-preserve, tests/install/basic-1, tests/misc/mknod:
* tests/mkdir/parents, tests/mkdir/special-1, tests/mv/partition-perm:
Don't make compilation depend on USE_ACL. An SELinux security
context counts as an "alternate access control method", so ls
must output a "+" for each file with a security context.
* src/ls.c [struct fileinfo] (have_acl): Declare unconditionally.
(FILE_HAS_ACL): Remove macro definition. Use f->have_acl directly.
(gobble_file): Record whether a file has a security context, and
update the condition used to determine whether to print the "+".
(gobble_file): Call getfilecon/lgetfilecon also when
format == long_format, so that we get the "+".
* src/ls.c (gobble_file): Add a comment explaining why (with a
security context option) ls doesn't exit nonzero due to e.g.,
getfilecon failing with errno == ENOTSUP.
* src/ls.c (gobble_file): Ignore failure of getfilecon if it's due
to ENOTSUP.
* src/ls.c (gobble_file): Factor out three small blocks using
getfilecon and lgetfilecon.
Don't ignore return value from getfilecon and lgetfilecon.
* src/ls.c (print_long_format): Don't use ?: (empty 2nd arg with C
ternary operator).
(print_scontext_format): Likewise.
(print_scontext): Declare to be "bool", not int. Adjust uses.
* src/Makefile.am (dir_LDADD, ls_LDADD, vdir_LDADD): Add $(LIB_SELINUX).
* tests/misc/chcon: New file.
* tests/misc/chcon-fail: New file.
* tests/Makefile.am (check-root): Run new, root-only misc/chcon test.
* tests/misc/Makefile.am (TESTS): Add chcon and chcon-fail.
* tests/misc/Makefile.am (TESTS): Add selinux.
* tests/misc/selinux: New file.
* tests/help-version: Skip chcon.
2007-01-06 01:23:54 +08:00
|
|
|
p=`ls -ld a/b/c/d|cut -b-10`; case $p in $d_mode_str);; *) fail=1;; esac
|
2000-11-07 05:52:12 +08:00
|
|
|
|
2004-06-23 23:07:00 +08:00
|
|
|
(exit $fail); exit $fail
|