Move xgetpwuid() and xgetgrgid() into xwrap.c
This commit is contained in:
parent
9fff257357
commit
9e44a5841f
@ -111,6 +111,8 @@ char *xrealpath(char *path);
|
||||
void xchdir(char *path);
|
||||
void xmkpath(char *path, int mode);
|
||||
void xsetuid(uid_t uid);
|
||||
struct passwd *xgetpwuid(uid_t uid);
|
||||
struct group *xgetgrgid(gid_t gid);
|
||||
char *xreadlink(char *name);
|
||||
long xparsetime(char *arg, long units, long *fraction);
|
||||
void xpidfile(char *name);
|
||||
|
14
lib/xwrap.c
14
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)
|
||||
|
@ -52,20 +52,6 @@ static void showid(char *header, unsigned u, char *s)
|
||||
printf("%s%u(%s)", header, u, s);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
void do_id(char *username)
|
||||
{
|
||||
int flags, i, ngroups, cmd_groups = toys.which->name[0] == 'g';
|
||||
|
Loading…
Reference in New Issue
Block a user