From f53096032d271360225b71a4bd258f717ac8d6e2 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Sat, 8 Oct 2011 10:52:02 +0200 Subject: uid_wrapper: Add uwrap_setresgid(). --- lib/uid_wrapper/uid_wrapper.c | 18 ++++++++++++++++++ lib/uid_wrapper/uid_wrapper.h | 6 ++++++ 2 files changed, 24 insertions(+) (limited to 'lib') diff --git a/lib/uid_wrapper/uid_wrapper.c b/lib/uid_wrapper/uid_wrapper.c index 442e349318..c43dbc1436 100644 --- a/lib/uid_wrapper/uid_wrapper.c +++ b/lib/uid_wrapper/uid_wrapper.c @@ -1,5 +1,6 @@ /* Copyright (C) Andrew Tridgell 2009 + Copyright (c) 2011 Andreas Schneider This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -160,6 +161,23 @@ _PUBLIC_ int uwrap_setregid(gid_t rgid, gid_t egid) } #endif +#ifdef HAVE_SETRESGID +_PUBLIC_ int uwrap_setresgid(gid_t rgid, gid_t egid, gid_t sgid) +{ + uwrap_init(); + if (!uwrap.enabled) { + return setresgid(rgid, egid, sgid); + } + /* assume for now that the ruid stays as root */ + if (egid == 0) { + uwrap.egid = uwrap.mygid; + } else { + uwrap.egid = egid; + } + return 0; +} +#endif + _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 27b7abccb3..7cb97af8df 100644 --- a/lib/uid_wrapper/uid_wrapper.h +++ b/lib/uid_wrapper/uid_wrapper.h @@ -1,5 +1,6 @@ /* Copyright (C) Andrew Tridgell 2009 + Copyright (c) 2011 Andreas Schneider This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -57,6 +58,11 @@ gid_t uwrap_getgid(void); #endif #define setregid uwrap_setregid +#ifdef setresgid +#undef setresgid +#endif +#define setresgid uwrap_setresgid + #ifdef geteuid #undef geteuid #endif -- cgit