aboutsummaryrefslogtreecommitdiffstats
path: root/unix.c
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2011-12-22 12:23:18 +0100
committerWilmer van der Gaast <wilmer@gaast.net>2011-12-22 12:23:18 +0100
commitad46e4d3ed1997e6b3f718a7a8be9a37eb63388d (patch)
treed42f7ec8c32775ed2344dc50fb816b5618830268 /unix.c
parentf1c870a20c1c8a1173fe6244952518f015fc1346 (diff)
Use initgroups() as well when dropping privileges. Closes bug #852.
Diffstat (limited to 'unix.c')
-rw-r--r--unix.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/unix.c b/unix.c
index 07215c07..2ad2edfc 100644
--- a/unix.c
+++ b/unix.c
@@ -40,6 +40,7 @@
#include <sys/wait.h>
#include <pwd.h>
#include <locale.h>
+#include <grp.h>
#if defined(OTR_BI) || defined(OTR_PI)
#include "otr.h"
@@ -151,9 +152,14 @@ int main( int argc, char *argv[] )
pw = getpwnam( global.conf->user );
if( pw )
{
+ initgroups( global.conf->user, pw->pw_gid );
setgid( pw->pw_gid );
setuid( pw->pw_uid );
}
+ else
+ {
+ log_message( LOGLVL_WARNING, "Failed to look up user %s.", global.conf->user );
+ }
}
/* Catch some signals to tell the user what's happening before quitting */