From: Wouter Wijngaards Date: Tue, 6 Jan 2015 14:37:45 +0000 (+0000) Subject: - Fixup that patch and uid lookup (only for daemon). X-Git-Tag: release-1.5.2rc1~26 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a3f0a34efbc4d50f4e222fbd3de66c92c48feac8;p=thirdparty%2Funbound.git - Fixup that patch and uid lookup (only for daemon). git-svn-id: file:///svn/unbound/trunk@3306 be551aaa-1e26-0410-a405-d3ace91eadb9 --- diff --git a/daemon/unbound.c b/daemon/unbound.c index 1663fa29b..a31b0392f 100644 --- a/daemon/unbound.c +++ b/daemon/unbound.c @@ -651,6 +651,7 @@ run_daemon(const char* cfgfile, int cmdline_verbose, int debug_mode) log_warn("Continuing with default config settings"); } apply_settings(daemon, cfg, cmdline_verbose, debug_mode); + config_lookup_uid(cfg); /* prepare */ if(!daemon_open_shared_ports(daemon)) diff --git a/doc/Changelog b/doc/Changelog index 81c7d4bf8..27ac55d1b 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -3,6 +3,7 @@ - patch for remote control over local sockets, from Dag-Erling Smorgrav, Ilya Bakulin. Use control-interface: /path/sock and control-use-cert: no. + - Fixup that patch and uid lookup (only for daemon). 5 January 2015: Wouter - getauxval test for ppc64 linux compatibility. diff --git a/util/config_file.c b/util/config_file.c index bb39cf9bd..12b00c9e4 100644 --- a/util/config_file.c +++ b/util/config_file.c @@ -805,16 +805,6 @@ config_read(struct config_file* cfg, const char* filename, const char* chroot) return 0; } -#ifdef HAVE_GETPWNAM - /* translate username into uid and gid */ - if(cfg->username && cfg->username[0]) { - struct passwd *pwd; - if((pwd = getpwnam(cfg->username)) == NULL) - log_err("user '%s' does not exist.", cfg->username); - cfg->uid = pwd->pw_uid; - cfg->gid = pwd->pw_gid; - } -#endif return 1; } @@ -1203,6 +1193,20 @@ config_apply(struct config_file* config) log_set_time_asc(config->log_time_ascii); } +void config_lookup_uid(struct config_file* cfg) +{ +#ifdef HAVE_GETPWNAM + /* translate username into uid and gid */ + if(cfg->username && cfg->username[0]) { + struct passwd *pwd; + if((pwd = getpwnam(cfg->username)) == NULL) + log_err("user '%s' does not exist.", cfg->username); + cfg->uid = pwd->pw_uid; + cfg->gid = pwd->pw_gid; + } +#endif +} + /** * Calculate string length of full pathname in original filesys * @param fname: the path name to convert. diff --git a/util/config_file.h b/util/config_file.h index fd35d7863..327eadc76 100644 --- a/util/config_file.h +++ b/util/config_file.h @@ -426,6 +426,12 @@ void config_delete(struct config_file* config); */ void config_apply(struct config_file* config); +/** + * Find username, sets uid and gid. + * @param config: the config structure. + */ +void config_lookup_uid(struct config_file* config); + /** * Set the given keyword to the given value. * @param config: where to store config