diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-12-03 19:05:55 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-12-03 19:05:55 +0000 |
commit | d7a805efafd83203e72c334089c3f88204231ac7 (patch) | |
tree | d69521a26d050432f89cf5713aa1516f655b136f /libbb/bb_pwd.c | |
parent | ac1c96f6737799d1d7f85515237df80e9da71346 (diff) |
libbb: introduce and use xgetpwnam. ~ -150 bytes.
Diffstat (limited to 'libbb/bb_pwd.c')
-rw-r--r-- | libbb/bb_pwd.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/libbb/bb_pwd.c b/libbb/bb_pwd.c index 5e44edc90..5dbc58d9f 100644 --- a/libbb/bb_pwd.c +++ b/libbb/bb_pwd.c @@ -15,7 +15,15 @@ * pointers to static data (getpwuid) */ -/* TODO: add xgetpwnam, this construct is used a lot */ +struct passwd* FAST_FUNC xgetpwnam(const char *name) +{ + struct passwd *pw = getpwnam(name); + if (!pw) + bb_error_msg_and_die("unknown user %s", name); + return pw; +} + +/* xgetgrnam too? */ struct passwd* FAST_FUNC xgetpwuid(uid_t uid) { @@ -73,10 +81,7 @@ long FAST_FUNC xuname2uid(const char *name) { struct passwd *myuser; - myuser = getpwnam(name); - if (myuser == NULL) - bb_error_msg_and_die("unknown user %s", name); - + myuser = xgetpwnam(name); return myuser->pw_uid; } |