diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-07-27 15:20:10 +0400 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-07-27 15:20:10 +0400 |
commit | 3734b946bfef55c8f63d367422da5c7aa7b972db (patch) | |
tree | 1bdd3e14523002dc8276d167b17f900e40fa6dff /coreutils | |
parent | 661f6fad77b672a5f6648b01275eb9ff19c59139 (diff) |
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')
-rw-r--r-- | coreutils/id.c | 17 | ||||
-rw-r--r-- | coreutils/whoami.c | 3 |
2 files changed, 10 insertions, 10 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 @@ #define JUST_USER 4 #define JUST_GROUP 8 #if ENABLE_SELINUX -#define JUST_CONTEXT 16 +#define JUST_CONTEXT 16 #endif -static short printf_full(unsigned int id, const char *arg, const char prefix) +static int printf_full(unsigned int id, const char *arg, const char prefix) { const char *fmt = "%cid=%u"; - short status = EXIT_FAILURE; + int status = EXIT_FAILURE; if (arg) { fmt = "%cid=%u(%s)"; @@ -71,8 +71,8 @@ int id_main(int argc, char **argv) if (flags & (JUST_GROUP | JUST_USER USE_SELINUX(| JUST_CONTEXT))) { /* JUST_GROUP and JUST_USER are mutually exclusive */ if (flags & NAME_NOT_NUMBER) { - /* bb_getpwuid and bb_getgrgid exit on failure so puts cannot segfault */ - puts((flags & JUST_USER) ? bb_getpwuid(NULL, uid, -1 ) : bb_getgrgid(NULL, gid, -1 )); + /* bb_getXXXid(-1) exit on failure, puts cannot segfault */ + puts((flags & JUST_USER) ? bb_getpwuid(NULL, -1, uid) : bb_getgrgid(NULL, -1, gid)); } else { if (flags & JUST_USER) { printf("%u\n", uid); @@ -100,11 +100,10 @@ int id_main(int argc, char **argv) } /* Print full info like GNU id */ - /* bb_getpwuid doesn't exit on failure here */ - status = printf_full(uid, bb_getpwuid(NULL, uid, 0), 'u'); + /* bb_getpwuid(0) doesn't exit on failure (returns NULL) */ + status = printf_full(uid, bb_getpwuid(NULL, 0, uid), 'u'); putchar(' '); - /* bb_getgrgid doesn't exit on failure here */ - status |= printf_full(gid, bb_getgrgid(NULL, gid, 0), 'g'); + status |= printf_full(gid, bb_getgrgid(NULL, 0, gid), 'g'); #if ENABLE_SELINUX if (is_selinux_enabled()) { diff --git a/coreutils/whoami.c b/coreutils/whoami.c index 156516fa7..3718358d5 100644 --- a/coreutils/whoami.c +++ b/coreutils/whoami.c @@ -19,7 +19,8 @@ int whoami_main(int argc, char **argv) if (argc > 1) bb_show_usage(); - puts(bb_getpwuid(NULL, geteuid(), -1)); + /* Will complain and die if username not found */ + puts(bb_getpwuid(NULL, -1, geteuid())); return fflush(stdout); } |