Bugzilla (bugzilla.redhat.com) will be under maintenance for infrastructure upgrades and will not be available on July 31st between 12:30 AM - 05:30 AM UTC. We appreciate your understanding and patience. You can follow status.redhat.com for details.
Bug 524202 - "ls -lZ" is not the same as "ls -Zl"
Summary: "ls -lZ" is not the same as "ls -Zl"
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: coreutils
Version: rawhide
Hardware: i386
OS: Linux
low
low
Target Milestone: ---
Assignee: Ondrej Vasik
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2009-09-18 11:08 UTC by Stephen Pritchard
Modified: 2009-09-18 18:05 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2009-09-18 11:51:14 UTC
Type: ---


Attachments (Terms of Use)

Description Stephen Pritchard 2009-09-18 11:08:16 UTC
---- ---- ---- ---- ----
System Info

[root@foo selinux]# uname -a
Linux foo.localdomain 2.6.18-128.7.1.el5 #1 SMP Mon Aug 24 08:20:55 EDT
2009 i686 i686 i386 GNU/Linux

[root@foo selinux]# cat /etc/*release
CentOS release 5.3 (Final)

---- ---- ---- ---- ----

I'm not sure whether this is by design or not, but I'd like to point out
for some reason "ls" doesn't see "ls -lZ" as the same as "ls -Zl"


[root@foo selinux]# ls -lZ ./custom-policy/modules/active/base.pp
-rw-------  root root root:object_r:semanage_store_t
./custom-policy/modules/active/base.pp
 
[root@foo selinux]# ls -Zl ./custom-policy/modules/active/base.pp
-rw------- 1 root:object_r:semanage_store_t   root root 13383956 Sep 14
20:33 ./custom-policy/modules/active/base.pp

With "-Zl" I believe the time stamp is correctly shown for the file,
where as with "-lZ" it is not.

Comment 1 Kamil Dudka 2009-09-18 11:42:36 UTC
I can reproduce the issue even in rawhide, but not with upstream coreutils. It seems to be caused by the downstream SELinux patch.

Comment 2 Ondrej Vasik 2009-09-18 11:51:14 UTC
Thanks for report, but sorry - it's not a bug. In ls is one rule - last format option specified is used. So -Z sets security format (equivalent of --scontext) - without timestamp - and -l sets long format - with timestamp. Output format depends on the order of short options, but this is expected - try e.g. ls -ml vs. ls -lm . Closing NOTABUG.
However - maybe documenting that general behaviour at least in info documentation might be good idea. It seems that this information is missing at first sight.

Comment 3 Ondrej Vasik 2009-09-18 11:55:03 UTC
Kamil: it's because upstream doesn't use SELinux format - they use just boolean whether display SELinux context or not... in Red Hat based distros with that SELinux patch we have --context (equivalent to -Z - like long, but context is shown instead of timestamp) , --lcontext (context and timestamp shown) and --scontext(just name and context).

Comment 4 Kamil Dudka 2009-09-18 14:19:03 UTC
My line of thinking ... we have mutually exclusive options, the last option holds -- we can mention it in the info documentation, but it's sort of  expected behavior in GNU coreutils.

But this is more likely about the side effect of -Z. I figured out that -lZ is equivalent to --context, however -Zl is equivalent --lcontext. This is what we *should* document in case we want to keep it this way.

Comment 5 Stephen Pritchard 2009-09-18 14:32:53 UTC
Thanks for clearing this up. Glad it's not a bug, however, I agree maybe the documentation needs updating.

Possible Suggestion:
"...
      SELinux options:

       -Z, --context
              Display security context so it fits on most displays.   Displays  only  mode,  user,  group,
              security context and file name.

       -Zl --lcontext
              Display security context with long listing.  Lines with long listing and security context will probably be too wide for most displays.

       --scontext
              Display only security context and file name.
 ..."

Maybe the "ls has a rule - last format option specified is used." should be documented too with an example.  Though this will probably be missed by 90% of people skimming the man page.

You know best. Thanks for the response.

Comment 6 Ondrej Vasik 2009-09-18 18:05:43 UTC
Ok, as we already have the burden of SELinux distro-specific modifications, more specific info about those --<X>context options should be done. I'm ok with it.

We'll see what's the upstream opinion about the info improvement about "last format option".


Note You need to log in before you can comment on or make changes to this bug.