aboutsummaryrefslogtreecommitdiff
path: root/coreutils/id.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-07-27 11:20:10 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-07-27 11:20:10 +0000
commit3734b946bfef55c8f63d367422da5c7aa7b972db (patch)
tree1bdd3e14523002dc8276d167b17f900e40fa6dff /coreutils/id.c
parent661f6fad77b672a5f6648b01275eb9ff19c59139 (diff)
downloadbusybox-w32-3734b946bfef55c8f63d367422da5c7aa7b972db.tar.gz
busybox-w32-3734b946bfef55c8f63d367422da5c7aa7b972db.tar.bz2
busybox-w32-3734b946bfef55c8f63d367422da5c7aa7b972db.zip
bb_getpwuid, bb_getgrgid: change order of arguments to more intuitive one;
comment thoroughly when they die and when they dont.
Diffstat (limited to 'coreutils/id.c')
-rw-r--r--coreutils/id.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/coreutils/id.c b/coreutils/id.c
index 27fb26e77..614d6d064 100644
--- a/coreutils/id.c
+++ b/coreutils/id.c
@@ -20,13 +20,13 @@
20#define JUST_USER 4 20#define JUST_USER 4
21#define JUST_GROUP 8 21#define JUST_GROUP 8
22#if ENABLE_SELINUX 22#if ENABLE_SELINUX
23#define JUST_CONTEXT 16 23#define JUST_CONTEXT 16
24#endif 24#endif
25 25
26static short printf_full(unsigned int id, const char *arg, const char prefix) 26static int printf_full(unsigned int id, const char *arg, const char prefix)
27{ 27{
28 const char *fmt = "%cid=%u"; 28 const char *fmt = "%cid=%u";
29 short status = EXIT_FAILURE; 29 int status = EXIT_FAILURE;
30 30
31 if (arg) { 31 if (arg) {
32 fmt = "%cid=%u(%s)"; 32 fmt = "%cid=%u(%s)";
@@ -71,8 +71,8 @@ int id_main(int argc, char **argv)
71 if (flags & (JUST_GROUP | JUST_USER USE_SELINUX(| JUST_CONTEXT))) { 71 if (flags & (JUST_GROUP | JUST_USER USE_SELINUX(| JUST_CONTEXT))) {
72 /* JUST_GROUP and JUST_USER are mutually exclusive */ 72 /* JUST_GROUP and JUST_USER are mutually exclusive */
73 if (flags & NAME_NOT_NUMBER) { 73 if (flags & NAME_NOT_NUMBER) {
74 /* bb_getpwuid and bb_getgrgid exit on failure so puts cannot segfault */ 74 /* bb_getXXXid(-1) exit on failure, puts cannot segfault */
75 puts((flags & JUST_USER) ? bb_getpwuid(NULL, uid, -1 ) : bb_getgrgid(NULL, gid, -1 )); 75 puts((flags & JUST_USER) ? bb_getpwuid(NULL, -1, uid) : bb_getgrgid(NULL, -1, gid));
76 } else { 76 } else {
77 if (flags & JUST_USER) { 77 if (flags & JUST_USER) {
78 printf("%u\n", uid); 78 printf("%u\n", uid);
@@ -100,11 +100,10 @@ int id_main(int argc, char **argv)
100 } 100 }
101 101
102 /* Print full info like GNU id */ 102 /* Print full info like GNU id */
103 /* bb_getpwuid doesn't exit on failure here */ 103 /* bb_getpwuid(0) doesn't exit on failure (returns NULL) */
104 status = printf_full(uid, bb_getpwuid(NULL, uid, 0), 'u'); 104 status = printf_full(uid, bb_getpwuid(NULL, 0, uid), 'u');
105 putchar(' '); 105 putchar(' ');
106 /* bb_getgrgid doesn't exit on failure here */ 106 status |= printf_full(gid, bb_getgrgid(NULL, 0, gid), 'g');
107 status |= printf_full(gid, bb_getgrgid(NULL, gid, 0), 'g');
108 107
109#if ENABLE_SELINUX 108#if ENABLE_SELINUX
110 if (is_selinux_enabled()) { 109 if (is_selinux_enabled()) {