- Fixup that patch and uid lookup (only for daemon).

git-svn-id: file:///svn/unbound/trunk@3306 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
Wouter Wijngaards 2015-01-06 14:37:45 +00:00
parent f46bcc5b6f
commit a3f0a34efb
4 changed files with 22 additions and 10 deletions

View file

@ -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))

View file

@ -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.

View file

@ -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.

View file

@ -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