2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-29 05:28:00 +00:00

install logging configuration after relinquishing root privileges

to ensure that log files specified in named.conf are created as
the unprivileged user
This commit is contained in:
Andreas Gustafsson 2000-04-18 22:17:27 +00:00
parent e0a43acbb7
commit a8277d18aa

View File

@ -1292,8 +1292,18 @@ load_configuration(const char *filename, ns_server_t *server,
server->tkeyctx = t; server->tkeyctx = t;
} }
/*
* Relinquish root privileges.
*/
if (first_time)
ns_os_changeuser(ns_g_username);
/* /*
* Configure the logging system. * Configure the logging system.
*
* Do this after changing UID to make sure that any log
* files specified in named.conf get created by the
* unprivileged user, not root.
*/ */
if (ns_g_logstderr) { if (ns_g_logstderr) {
isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
@ -1322,9 +1332,6 @@ load_configuration(const char *filename, ns_server_t *server,
} }
} }
if (first_time)
ns_os_changeuser(ns_g_username);
if (dns_c_ctx_getpidfilename(cctx, &pidfilename) == if (dns_c_ctx_getpidfilename(cctx, &pidfilename) ==
ISC_R_NOTFOUND) ISC_R_NOTFOUND)
pidfilename = ns_g_defaultpidfile; pidfilename = ns_g_defaultpidfile;