From 17f1276feadae1cfeea559e46e44ad136c438251 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Thu, 6 Oct 2011 16:52:03 +0200 Subject: uid_wrapper: Add uwrap_setregid(). --- lib/uid_wrapper/uid_wrapper.c | 11 +++++++++++ lib/uid_wrapper/uid_wrapper.h | 6 ++++++ 2 files changed, 17 insertions(+) (limited to 'lib') diff --git a/lib/uid_wrapper/uid_wrapper.c b/lib/uid_wrapper/uid_wrapper.c index 091678f27b..07ab6da7c7 100644 --- a/lib/uid_wrapper/uid_wrapper.c +++ b/lib/uid_wrapper/uid_wrapper.c @@ -104,6 +104,17 @@ _PUBLIC_ int uwrap_setegid(gid_t egid) return 0; } +_PUBLIC_ int uwrap_setregid(gid_t rgid, gid_t egid) +{ + uwrap_init(); + if (!uwrap.enabled) { + return setregid(rgid, egid); + } + /* assume for now that the ruid stays as root */ + uwrap.egid = egid; + return 0; +} + _PUBLIC_ uid_t uwrap_getegid(void) { uwrap_init(); diff --git a/lib/uid_wrapper/uid_wrapper.h b/lib/uid_wrapper/uid_wrapper.h index c0aebcfafc..78b6c388ed 100644 --- a/lib/uid_wrapper/uid_wrapper.h +++ b/lib/uid_wrapper/uid_wrapper.h @@ -24,6 +24,7 @@ int uwrap_seteuid(uid_t euid); int uwrap_setreuid(uid_t reuid, uid_t euid); uid_t uwrap_geteuid(void); int uwrap_setegid(gid_t egid); +int uwrap_setregid(gid_t egid); uid_t uwrap_getegid(void); int uwrap_setgroups(size_t size, const gid_t *list); int uwrap_getgroups(int size, gid_t *list); @@ -45,6 +46,11 @@ gid_t uwrap_getgid(void); #endif #define setegid uwrap_setegid +#ifdef setregid +#undef setregid +#endif +#define setregid uwrap_setegid + #ifdef geteuid #undef geteuid #endif -- cgit