summaryrefslogtreecommitdiff
path: root/libbb/bb_pwd.c
diff options
context:
space:
mode:
Diffstat (limited to 'libbb/bb_pwd.c')
-rw-r--r--libbb/bb_pwd.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/libbb/bb_pwd.c b/libbb/bb_pwd.c
index 5dbc58d..d728577 100644
--- a/libbb/bb_pwd.c
+++ b/libbb/bb_pwd.c
@@ -23,7 +23,14 @@ struct passwd* FAST_FUNC xgetpwnam(const char *name)
return pw;
}
-/* xgetgrnam too? */
+struct group* FAST_FUNC xgetgrnam(const char *name)
+{
+ struct group *gr = getgrnam(name);
+ if (!gr)
+ bb_error_msg_and_die("unknown group %s", name);
+ return gr;
+}
+
struct passwd* FAST_FUNC xgetpwuid(uid_t uid)
{
@@ -89,10 +96,7 @@ long FAST_FUNC xgroup2gid(const char *name)
{
struct group *mygroup;
- mygroup = getgrnam(name);
- if (mygroup == NULL)
- bb_error_msg_and_die("unknown group %s", name);
-
+ mygroup = xgetgrnam(name);
return mygroup->gr_gid;
}