* Copyright (C) 2000 by Randolph Chung <tausq@debian.org>
* Copyright (C) 2008 by Tito Ragusa <farmatito@tiscali.it>
*
- * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
+ * Licensed under GPLv2 or later, see file LICENSE in this source tree.
*/
/* BB_AUDIT SUSv3 compliant. */
#endif
};
-static int print_common(unsigned id,
- char* FAST_FUNC bb_getXXXid(char *name, int bufsize, long uid),
- const char *prefix)
+static int print_common(unsigned id, const char *name, const char *prefix)
{
- const char *name = bb_getXXXid(NULL, 0, id);
-
if (prefix) {
printf("%s", prefix);
}
static int print_group(gid_t id, const char *prefix)
{
- return print_common(id, bb_getgrgid, prefix);
+ return print_common(id, gid2group(id), prefix);
}
static int print_user(uid_t id, const char *prefix)
{
- return print_common(id, bb_getpwuid, prefix);
+ return print_common(id, uid2uname(id), prefix);
}
/* On error set *n < 0 and return >= 0
/* Don't allow -n -r -nr -ug -rug -nug -rnug -uZ -gZ -GZ*/
/* Don't allow more than one username */
opt_complementary = "?1:u--g:g--u:G--u:u--G:g--G:G--g:r?ugG:n?ugG"
- USE_SELINUX(":u--Z:Z--u:g--Z:Z--g:G--Z:Z--G");
- opt = getopt32(argv, "rnugG" USE_SELINUX("Z"));
+ IF_SELINUX(":u--Z:Z--u:g--Z:Z--g:G--Z:Z--G");
+ opt = getopt32(argv, "rnugG" IF_SELINUX("Z"));
username = argv[optind];
if (username) {
- struct passwd *p = getpwnam(username);
- if (!p)
- bb_error_msg_and_die("unknown user %s", username);
+ struct passwd *p = xgetpwnam(username);
euid = ruid = p->pw_uid;
egid = rgid = p->pw_gid;
} else {
}
} else if (n < 0) { /* error in get_groups() */
if (!ENABLE_DESKTOP)
- bb_error_msg_and_die("cannot get groups");
+ bb_error_msg_and_die("can't get groups");
else
return EXIT_FAILURE;
}