From: Thomas Jarosch Date: Thu, 15 Sep 2011 14:22:32 +0000 (+0200) Subject: Add initgroups() call to drop_root_privileges X-Git-Tag: v2.6~47 X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=dcd37d35a22f3685e434d5367f256647297904ea;p=libi2ncommon Add initgroups() call to drop_root_privileges --- diff --git a/src/daemonfunc.cpp b/src/daemonfunc.cpp index ab541cd..b9a9402 100644 --- a/src/daemonfunc.cpp +++ b/src/daemonfunc.cpp @@ -91,6 +91,10 @@ bool drop_root_privileges(const std::string &username, return false; } + // Initialize additional groups the user is a member of + if (initgroups(username.c_str(), getgid() == -1)) + return false; + if (setuid(my_user.Uid)) return false; }