Hide Forgot
Description of problem: 'ls -Zl' and 'ls -lZ' show different results on RHEL6.2. Version-Release number of selected component (if applicable): coreutils-8.4-16.el6 How reproducible: Always. Steps to Reproduce: 1. Issuing 'ls -Zl' and 'ls -lZ' Actual results: 'ls -Zl' shows a list like followings. # ls -Zl total 130 dr-xr-xr-x. 2 system_u:object_r:bin_t:s0 root root 4096 Jan 5 17:08 bin dr-xr-xr-x. 5 system_u:object_r:boot_t:s0 root root 1024 Nov 30 20:36 boot drwxr-xr-x. 10 system_u:object_r:cgroup_t:s0 root root 4096 Nov 30 20:59 cgroup drwxr-xr-x. 19 system_u:object_r:device_t:s0 root root 3980 Jan 5 17:08 dev drwxr-xr-x. 123 system_u:object_r:etc_t:s0 root root 12288 Jan 5 17:08 etc drwxr-xr-x. 4 system_u:object_r:home_root_t:s0 root root 4096 Nov 30 21:03 home dr-xr-xr-x. 12 system_u:object_r:lib_t:s0 root root 4096 Jan 5 17:04 lib 'ls -lZ' shows another one. # ls -lZ dr-xr-xr-x. root root system_u:object_r:bin_t:s0 bin dr-xr-xr-x. root root system_u:object_r:boot_t:s0 boot drwxr-xr-x. root root system_u:object_r:cgroup_t:s0 cgroup drwxr-xr-x. root root system_u:object_r:device_t:s0 dev drwxr-xr-x. root root system_u:object_r:etc_t:s0 etc drwxr-xr-x. root root system_u:object_r:home_root_t:s0 home dr-xr-xr-x. root root system_u:object_r:lib_t:s0 lib Expected results: We can get same results even if the order of options is changed. Additional info: In coreutils/src/ls.c patched with SELinux.patch, 1696 case 'l': 1697 format = long_format; 1698 break; 1940 case 'Z': 1941 print_scontext = 1; 1942 format = security_format; 1943 break; If 'Z' option precedes 'l', the variant 'format' is set to 'long_format'. But 'l' option precedes 'Z', it's set to 'security_format'.
Please have a look at the following bugs: bug 448903 - Incorrect output of ls -lZ bug 524202 - "ls -lZ" is not the same as "ls -Zl"
Although it is not a bug, as there are more such reports, I think it would be good to improve the ls info documentation a bit.
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. http://rhn.redhat.com/errata/RHBA-2012-0933.html