Permalink
Browse files

add supplementary groups support

  • Loading branch information...
1 parent 8db49a6 commit cee857b0d0c9a3c165ddd3811389b906ffd02e31 @mind04 mind04 committed with mind04 Apr 22, 2013
Showing with 12 additions and 4 deletions.
  1. +12 −4 pdns/unix_utility.cc
View
@@ -99,11 +99,19 @@ void Utility::dropPrivs( int uid, int gid )
else
theL()<<Logger::Info<<"Set effective group id to "<<gid<<endl;
- if(setgroups(0, NULL)<0) {
- theL()<<Logger::Critical<<"Unable to drop supplementary gids: "<<stringerror()<<endl;
- exit(1);
+ struct passwd *pw=getpwuid(uid);
+ if(!pw) {
+ theL()<<Logger::Warning<<"Unable to determine user name for uid "<<uid<<endl;
+ if (setgroups(0, NULL)<0) {
+ theL()<<Logger::Critical<<"Unable to drop supplementary gids: "<<stringerror()<<endl;
+ exit(1);
+ }
+ } else {
+ if (initgroups(pw->pw_name, gid)<0) {
+ theL()<<Logger::Critical<<"Unable to set supplementary groups: "<<stringerror()<<endl;
+ exit(1);
+ }
}
-
}
if(uid) {

0 comments on commit cee857b

Please sign in to comment.