From 60c35c486a2ea1c6ea8920c599abf992b27542c5 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sun, 3 Aug 2014 15:50:10 -0500 Subject: Implement exec -user, -group, and -newer. Enable find in defconfig. --- lib/lib.h | 1 + lib/xwrap.c | 8 ++++++++ 2 files changed, 9 insertions(+) (limited to 'lib') diff --git a/lib/lib.h b/lib/lib.h index 521a8d6..de5f547 100644 --- a/lib/lib.h +++ b/lib/lib.h @@ -119,6 +119,7 @@ void xchroot(char *path); struct passwd *xgetpwuid(uid_t uid); struct group *xgetgrgid(gid_t gid); struct passwd *xgetpwnam(char *name); +struct group *xgetgrnam(char *name); void xsetuser(struct passwd *pwd); char *xreadlink(char *name); long xparsetime(char *arg, long units, long *fraction); diff --git a/lib/xwrap.c b/lib/xwrap.c index 4d8ad71..c9d1876 100644 --- a/lib/xwrap.c +++ b/lib/xwrap.c @@ -455,6 +455,14 @@ struct passwd *xgetpwnam(char *name) return up; } +struct group *xgetgrnam(char *name) +{ + struct group *gr = getgrnam(name); + + if (!gr) perror_exit("group '%s'", name); + return gr; +} + // setuid() can fail (for example, too many processes belonging to that user), // which opens a security hole if the process continues as the original user. -- cgit v1.2.3