* 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;
+}
+
+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)
{
{
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;
}
{
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;
}