bin/131569: [patch] stat(1) -x doesn't print the file mode correctly

Jaakko Heinonen jh at saunalahti.fi
Tue Feb 10 10:10:02 PST 2009


>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:


More information about the freebsd-bugs mailing list