Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 10 Feb 2009 20:08:18 +0200 (EET)
From:      Jaakko Heinonen <jh@saunalahti.fi>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   bin/131569: [patch] stat(1) -x doesn't print the file mode correctly
Message-ID:  <200902101808.n1AI8HPh005866@ws64.jh.dy.fi>
Resent-Message-ID: <200902101810.n1AIA1gk060140@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         131569
>Category:       bin
>Synopsis:       [patch] stat(1) -x doesn't print the file mode correctly
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Feb 10 18:10:01 UTC 2009
>Closed-Date:
>Last-Modified:
>Originator:     Jaakko Heinonen
>Release:        FreeBSD 7.1-STABLE / 8.0-CURRENT
>Organization:
>Environment:

	
>Description:

The octal representation of the file mode displayed with stat(1) -x option
ignores suid, sgid and sticky bits.

This was reported on -stable:
http://lists.freebsd.org/pipermail/freebsd-stable/2008-October/046195.html

>How-To-Repeat:

$ touch foo
$ chmod 4755 foo
$ stat -x foo | grep Mode
  Mode: (0755/-rwsr-xr-x)         Uid: ( 1000/  jaakko)  Gid: (    0/   wheel)

After applying the patch:

$ stat -x foo | grep Mode
  Mode: (4755/-rwsr-xr-x)         Uid: ( 1000/  jaakko)  Gid: (    0/   wheel)

>Fix:

--- stat--x-file-mode.diff begins here ---
Index: usr.bin/stat/stat.c
===================================================================
--- usr.bin/stat/stat.c	(revision 186786)
+++ usr.bin/stat/stat.c	(working copy)
@@ -108,7 +108,8 @@ __FBSDID("$FreeBSD$");
 #define LINUX_FORMAT \
 	"  File: \"%N\"%n" \
 	"  Size: %-11z  FileType: %HT%n" \
-	"  Mode: (%04OLp/%.10Sp)         Uid: (%5u/%8Su)  Gid: (%5g/%8Sg)%n" \
+	"  Mode: (%OMp%03OLp/%.10Sp)         " \
+	"Uid: (%5u/%8Su)  Gid: (%5g/%8Sg)%n" \
 	"Device: %Hd,%Ld   Inode: %i    Links: %l%n" \
 	"Access: %Sa%n" \
 	"Modify: %Sm%n" \
--- stat--x-file-mode.diff ends here ---


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200902101808.n1AI8HPh005866>