File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -99,11 +99,19 @@ void Utility::dropPrivs( int uid, int gid )
99
99
else
100
100
theL ()<<Logger::Info<<" Set effective group id to " <<gid<<endl;
101
101
102
- if (setgroups (0 , NULL )<0 ) {
103
- theL ()<<Logger::Critical<<" Unable to drop supplementary gids: " <<stringerror ()<<endl;
104
- exit (1 );
102
+ struct passwd *pw=getpwuid (uid);
103
+ if (!pw) {
104
+ theL ()<<Logger::Warning<<" Unable to determine user name for uid " <<uid<<endl;
105
+ if (setgroups (0 , NULL )<0 ) {
106
+ theL ()<<Logger::Critical<<" Unable to drop supplementary gids: " <<stringerror ()<<endl;
107
+ exit (1 );
108
+ }
109
+ } else {
110
+ if (initgroups (pw->pw_name , gid)<0 ) {
111
+ theL ()<<Logger::Critical<<" Unable to set supplementary groups: " <<stringerror ()<<endl;
112
+ exit (1 );
113
+ }
105
114
}
106
-
107
115
}
108
116
109
117
if (uid) {
You can’t perform that action at this time.
0 commit comments