Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 771843

Summary: Better document ls behaviour for formatting options('ls -Zl' and 'ls -lZ' show different results)
Product: Red Hat Enterprise Linux 6 Reporter: ryo fujita <rfujita>
Component: coreutilsAssignee: Ondrej Vasik <ovasik>
Status: CLOSED ERRATA QA Contact: qe-baseos-daemons
Severity: low Docs Contact:
Priority: medium    
Version: 6.2CC: azelinka, kdudka, meyering, prc
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: coreutils-8.4-17.el6 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-06-20 14:34:25 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description ryo fujita 2012-01-05 08:18:11 UTC
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'.

Comment 2 Kamil Dudka 2012-01-05 10:03:24 UTC
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"

Comment 3 Ondrej Vasik 2012-01-05 11:24:36 UTC
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.

Comment 8 errata-xmlrpc 2012-06-20 14:34:25 UTC
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