mirror of
https://github.com/NLnetLabs/unbound.git
synced 2025-12-20 23:00:56 -05:00
Fixup #724 in unbound-checkconf and fname_after_chroot calls.
git-svn-id: file:///svn/unbound/trunk@3558 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
parent
128370ac14
commit
bb7b4db353
4 changed files with 29 additions and 19 deletions
|
|
@ -335,7 +335,9 @@ morechecks(struct config_file* cfg, const char* fname)
|
||||||
if(cfg->edns_buffer_size > cfg->msg_buffer_size)
|
if(cfg->edns_buffer_size > cfg->msg_buffer_size)
|
||||||
fatal_exit("edns-buffer-size larger than msg-buffer-size, "
|
fatal_exit("edns-buffer-size larger than msg-buffer-size, "
|
||||||
"answers will not fit in processing buffer");
|
"answers will not fit in processing buffer");
|
||||||
|
#ifdef UB_ON_WINDOWS
|
||||||
|
w_config_adjust_directory(cfg);
|
||||||
|
#endif
|
||||||
if(cfg->chrootdir && cfg->chrootdir[0] &&
|
if(cfg->chrootdir && cfg->chrootdir[0] &&
|
||||||
cfg->chrootdir[strlen(cfg->chrootdir)-1] == '/')
|
cfg->chrootdir[strlen(cfg->chrootdir)-1] == '/')
|
||||||
fatal_exit("chootdir %s has trailing slash '/' please remove.",
|
fatal_exit("chootdir %s has trailing slash '/' please remove.",
|
||||||
|
|
|
||||||
|
|
@ -1558,6 +1558,28 @@ w_lookup_reg_str(const char* key, const char* name)
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void w_config_adjust_directory(struct config_file* cfg)
|
||||||
|
{
|
||||||
|
if(cfg->directory && cfg->directory[0]) {
|
||||||
|
TCHAR dirbuf[2*MAX_PATH+4];
|
||||||
|
if(strcmp(cfg->directory, "%EXECUTABLE%") == 0) {
|
||||||
|
/* get executable path, and if that contains
|
||||||
|
* directories, snip off the filename part */
|
||||||
|
dirbuf[0] = 0;
|
||||||
|
if(!GetModuleFileName(NULL, dirbuf, MAX_PATH))
|
||||||
|
log_err("could not GetModuleFileName");
|
||||||
|
if(strrchr(dirbuf, '\\')) {
|
||||||
|
(strrchr(dirbuf, '\\'))[0] = 0;
|
||||||
|
} else log_err("GetModuleFileName had no path");
|
||||||
|
if(dirbuf[0]) {
|
||||||
|
/* adjust directory for later lookups to work*/
|
||||||
|
free(cfg->directory);
|
||||||
|
cfg->directory = memdup(dirbuf, strlen(dirbuf)+1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif /* UB_ON_WINDOWS */
|
#endif /* UB_ON_WINDOWS */
|
||||||
|
|
||||||
void errinf(struct module_qstate* qstate, const char* str)
|
void errinf(struct module_qstate* qstate, const char* str)
|
||||||
|
|
|
||||||
|
|
@ -741,6 +741,9 @@ void ub_c_error_msg(const char* fmt, ...) ATTR_FORMAT(printf, 1, 2);
|
||||||
* exist on an error (logged with log_err) was encountered.
|
* exist on an error (logged with log_err) was encountered.
|
||||||
*/
|
*/
|
||||||
char* w_lookup_reg_str(const char* key, const char* name);
|
char* w_lookup_reg_str(const char* key, const char* name);
|
||||||
|
|
||||||
|
/** Modify directory in options for module file name */
|
||||||
|
void w_config_adjust_directory(struct config_file* cfg);
|
||||||
#endif /* UB_ON_WINDOWS */
|
#endif /* UB_ON_WINDOWS */
|
||||||
|
|
||||||
#endif /* UTIL_CONFIG_FILE_H */
|
#endif /* UTIL_CONFIG_FILE_H */
|
||||||
|
|
|
||||||
|
|
@ -333,26 +333,9 @@ service_init(int r, struct daemon** d, struct config_file** c)
|
||||||
verbose(VERB_QUERY, "winservice - apply settings");
|
verbose(VERB_QUERY, "winservice - apply settings");
|
||||||
/* apply settings and init */
|
/* apply settings and init */
|
||||||
verbosity = cfg->verbosity + service_cmdline_verbose;
|
verbosity = cfg->verbosity + service_cmdline_verbose;
|
||||||
|
w_config_adjust_directory(cfg);
|
||||||
if(cfg->directory && cfg->directory[0]) {
|
if(cfg->directory && cfg->directory[0]) {
|
||||||
TCHAR dirbuf[2*MAX_PATH+4];
|
|
||||||
char* dir = cfg->directory;
|
char* dir = cfg->directory;
|
||||||
if(strcmp(dir, "%EXECUTABLE%") == 0) {
|
|
||||||
/* get executable path, and if that contains
|
|
||||||
* directories, snip off the filename part */
|
|
||||||
dirbuf[0] = 0;
|
|
||||||
if(!GetModuleFileName(NULL, dirbuf, MAX_PATH))
|
|
||||||
log_err("could not GetModuleFileName");
|
|
||||||
if(strrchr(dirbuf, '\\')) {
|
|
||||||
(strrchr(dirbuf, '\\'))[0] = 0;
|
|
||||||
} else log_err("GetModuleFileName had no path");
|
|
||||||
dir = dirbuf;
|
|
||||||
if(dirbuf[0]) {
|
|
||||||
/* adjust cfg->directory for the
|
|
||||||
* fname_after_chroot calls later to work */
|
|
||||||
free(cfg->directory);
|
|
||||||
cfg->directory = memdup(dir, strlen(dir)+1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(chdir(dir)) {
|
if(chdir(dir)) {
|
||||||
log_err("could not chdir to %s: %s",
|
log_err("could not chdir to %s: %s",
|
||||||
dir, strerror(errno));
|
dir, strerror(errno));
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue