From ad46e4d3ed1997e6b3f718a7a8be9a37eb63388d Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Thu, 22 Dec 2011 12:23:18 +0100 Subject: Use initgroups() as well when dropping privileges. Closes bug #852. --- unix.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'unix.c') diff --git a/unix.c b/unix.c index 07215c07..2ad2edfc 100644 --- a/unix.c +++ b/unix.c @@ -40,6 +40,7 @@ #include #include #include +#include #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 */ -- cgit v1.2.3