aboutsummaryrefslogtreecommitdiff
path: root/lib/xwrap.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2013-11-28 20:18:04 -0600
committerRob Landley <rob@landley.net>2013-11-28 20:18:04 -0600
commit9e44a5841f0ab9bc03cefb5631c80f3e4e5a60fe (patch)
tree1a849db3a91432452eba881a75039bb43edb90ed /lib/xwrap.c
parent9fff257357fee7a90e7e8b5b44c0abc18d019b64 (diff)
downloadtoybox-9e44a5841f0ab9bc03cefb5631c80f3e4e5a60fe.tar.gz
Move xgetpwuid() and xgetgrgid() into xwrap.c
Diffstat (limited to 'lib/xwrap.c')
-rw-r--r--lib/xwrap.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/xwrap.c b/lib/xwrap.c
index 98b4300e..71ea9209 100644
--- a/lib/xwrap.c
+++ b/lib/xwrap.c
@@ -399,6 +399,20 @@ void xsetuid(uid_t uid)
if (setuid(uid)) perror_exit("xsetuid");
}
+struct passwd *xgetpwuid(uid_t uid)
+{
+ struct passwd *pwd = getpwuid(uid);
+ if (!pwd) error_exit(NULL);
+ return pwd;
+}
+
+struct group *xgetgrgid(gid_t gid)
+{
+ struct group *group = getgrgid(gid);
+ if (!group) error_exit(NULL);
+ return group;
+}
+
// This can return null (meaning file not found). It just won't return null
// for memory allocation reasons.
char *xreadlink(char *name)