stat(1) -x option shows no setuid/setgid - patch

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: LEVAI Daniel
Date: Saturday, October 2, 2010 - 10:44 am

Hi!

I noticed that executin stat -x on a setuid or setgid file don't display
the setuid/setgid mode in the numeric Mode: field:

$ /usr/bin/stat -x /usr/bin/passwd                                                     
File: "/usr/bin/passwd"
Size: 22484        FileType: Regular File
Mode: (0555/-r-sr-xr-x) [...]
       ^


This patch solves it by removing some format characters:


Index: stat.c
===================================================================
RCS file: /cvs/src/usr.bin/stat/stat.c,v
retrieving revision 1.16
diff -p -u -r1.16 stat.c
--- stat.c	1 Sep 2010 06:35:05 -0000	1.16
+++ stat.c	2 Oct 2010 17:35:17 -0000
@@ -60,7 +60,7 @@
 #define LINUX_FORMAT \
 	"  File: \"%N\"%n" \
 	"  Size: %-11z  FileType: %HT%n" \
-	"  Mode: (%04OLp/%.10Sp)         Uid: (%5u/%8Su)  Gid: (%5g/%8Sg)%n" \
+	"  Mode: (%p/%.10Sp)         Uid: (%5u/%8Su)  Gid: (%5g/%8Sg)%n" \
 	"Device: %Hd,%Ld   Inode: %i    Links: %l%n" \
 	"Access: %Sa%n" \
 	"Modify: %Sm%n" \


After this:
$ /usr/bin/stat -x /usr/bin/passwd 
File: "/usr/bin/passwd"
Size: 22484        FileType: Regular File
Mode: (104555/-r-sr-xr-x)
       ^^^


Daniel

-- 
LIVAI Daniel
PGP key ID = 0x83B63A8F
Key fingerprint = DBEC C66B A47A DFA2 792D  650C C69B BE4C 83B6 3A8F
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
stat(1) -x option shows no setuid/setgid - patch, LEVAI Daniel, (Sat Oct 2, 10:44 am)
Re: stat(1) -x option shows no setuid/setgid - patch, Chris Palmer, (Sat Oct 2, 11:20 am)
Re: stat(1) -x option shows no setuid/setgid - patch, Philip Guenther, (Tue Oct 5, 2:46 pm)
Re: stat(1) -x option shows no setuid/setgid - patch, LEVAI Daniel, (Wed Oct 6, 12:31 am)
Re: stat(1) -x option shows no setuid/setgid - patch, Philip Guenther, (Thu Oct 28, 11:12 pm)