From: Remi Gacogne Date: Fri, 2 Nov 2018 15:11:06 +0000 (+0100) Subject: rec: Drop remaining capabilities after startup X-Git-Tag: rec-4.2.0-alpha1~58^2~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1f2b341eb3371e0209c85276b442b58be75480b3;p=thirdparty%2Fpdns.git rec: Drop remaining capabilities after startup --- diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index 622cc2b83e..83a0548d3c 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -3768,6 +3768,16 @@ static int serviceMain(int argc, char*argv[]) makeControlChannelSocket( ::arg().asNum("processes") > 1 ? forks : -1); Utility::dropUserPrivs(newuid); + try { + /* we might still have capabilities remaining, for example if we have been started as root + without --setuid (please don't do that) or as an unprivileged user with ambient capabilities + like CAP_NET_BIND_SERVICE. + */ + dropCapabilities(); + } + catch(const std::exception& e) { + g_log<