diff options
author | Jim Meyering <jim@meyering.net> | 2007-01-05 18:23:54 +0100 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2007-03-29 21:37:05 +0200 |
commit | 3ea540c7570a76bf72ae697c4040e77dad5bea6d (patch) | |
tree | 6d22f047af49512ccaf7551b1834c0d2ab6fa682 /tests/mkdir | |
parent | 85d6c618b08d8e8e5c8d9d51d65b8c526ec22164 (diff) | |
download | coreutils-3ea540c7570a76bf72ae697c4040e77dad5bea6d.tar.xz |
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.
Diffstat (limited to 'tests/mkdir')
-rwxr-xr-x | tests/mkdir/parents | 8 | ||||
-rwxr-xr-x | tests/mkdir/special-1 | 8 |
2 files changed, 8 insertions, 8 deletions
diff --git a/tests/mkdir/parents b/tests/mkdir/parents index f0ead6ee8..d956e39d7 100755 --- a/tests/mkdir/parents +++ b/tests/mkdir/parents @@ -65,12 +65,12 @@ d_mode_arg=`"$abs_srcdir/../rwx-to-mode" $d_mode_str` mkdir -p -m $d_mode_arg a/b/c/d # Make sure the permissions of `a' haven't been changed. -p=`ls -ld a|sed 's/ .*//'`; case $p in $mode_str);; *) fail=1;; esac +p=`ls -ld a|cut -b-10`; case $p in $mode_str);; *) fail=1;; esac # `b's and `c's should reflect the umask -p=`ls -ld a/b|sed 's/ .*//'`; case $p in drwx------);; *) fail=1;; esac -p=`ls -ld a/b/c|sed 's/ .*//'`; case $p in drwx------);; *) fail=1;; esac +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 # `d's perms are determined by the -m argument. -p=`ls -ld a/b/c/d|sed 's/ .*//'`; case $p in $d_mode_str);; *) fail=1;; esac +p=`ls -ld a/b/c/d|cut -b-10`; case $p in $d_mode_str);; *) fail=1;; esac (exit $fail); exit $fail diff --git a/tests/mkdir/special-1 b/tests/mkdir/special-1 index a5b65043b..7f8dc7405 100755 --- a/tests/mkdir/special-1 +++ b/tests/mkdir/special-1 @@ -33,8 +33,8 @@ output_mode_string=drwxr-x-wT mkdir -m$set_mode_string $tmp || fail=1 test -d $tmp || fail=1 -set -- `ls -ld $tmp` -case "$1" in +mode=`ls -ld $tmp|cut -b-10` +case "$mode" in $output_mode_string) ;; *) fail=1 ;; esac @@ -49,8 +49,8 @@ mkdir -m$set_mode_string $tmp2 2> /dev/null && fail=1 mkdir --parents -m$set_mode_string $tmp2 || fail=1 test -d $tmp2 || fail=1 -set -- `ls -ld $tmp2` -case "$1" in +mode=`ls -ld $tmp2|cut -b-10` +case "$mode" in $output_mode_string) ;; *) fail=1 ;; esac |