From: Bert Hubert Date: Sat, 13 Feb 2010 18:48:26 +0000 (+0000) Subject: make sure we setuid() before launching threads, improving the error message (which... X-Git-Tag: rec-3.2~17 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=138435cbd6ec5825798e01989bf34a7a80b54d72;p=pdns make sure we setuid() before launching threads, improving the error message (which was a crash) if the setuid failed git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@1523 d19b8d6e-7fed-0310-83ef-9ca221ded41b --- diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index e38e6c707..8a3512993 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -1648,7 +1648,26 @@ int serviceMain(int argc, char*argv[]) signal(SIGPIPE,SIG_IGN); writePid(); #endif - makeControlChannelSocket(); + makeControlChannelSocket(); + + int newgid=0; + if(!::arg()["setgid"].empty()) + newgid=Utility::makeGidNumeric(::arg()["setgid"]); + int newuid=0; + if(!::arg()["setuid"].empty()) + newuid=Utility::makeUidNumeric(::arg()["setuid"]); + +#ifndef WIN32 + if (!::arg()["chroot"].empty()) { + if (chroot(::arg()["chroot"].c_str())<0 || chdir("/") < 0) { + L<addReadFD(i->first, i->second); if(!t_id) { - int newgid=0; - if(!::arg()["setgid"].empty()) - newgid=Utility::makeGidNumeric(::arg()["setgid"]); - int newuid=0; - if(!::arg()["setuid"].empty()) - newuid=Utility::makeUidNumeric(::arg()["setuid"]); - -#ifndef WIN32 - if (!::arg()["chroot"].empty()) { - if (chroot(::arg()["chroot"].c_str())<0 || chdir("/") < 0) { - L<addReadFD(s_rcc.d_fd, handleRCC); // control channel } #endif