uid_wrapper: Add uwrap_setresgid().
authorAndreas Schneider <asn@samba.org>
Sat, 8 Oct 2011 08:52:02 +0000 (10:52 +0200)
committerAndreas Schneider <asn@samba.org>
Thu, 27 Oct 2011 11:32:01 +0000 (13:32 +0200)
lib/uid_wrapper/uid_wrapper.c
lib/uid_wrapper/uid_wrapper.h

index 442e3493184c07366c8d3ebaba25b36980e537eb..c43dbc1436828bd1319d0e42553073d91763796c 100644 (file)
@@ -1,5 +1,6 @@
 /*
    Copyright (C) Andrew Tridgell 2009
+   Copyright (c) 2011      Andreas Schneider <asn@samba.org>
  
    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();
index 27b7abccb3f903a22f8e1d72990631b3110a4bc0..7cb97af8dfbe1456c1f51687e203fa84b6ac41e2 100644 (file)
@@ -1,5 +1,6 @@
 /*
    Copyright (C) Andrew Tridgell 2009
+   Copyright (c) 2011      Andreas Schneider <asn@samba.org>
  
    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