- unbound-checkconf -f prints chroot with pidfile path.

git-svn-id: file:///svn/unbound/trunk@3316 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
Wouter Wijngaards 2015-01-16 14:31:02 +00:00
parent 92e26a89ad
commit 4de0734ec8
3 changed files with 20 additions and 5 deletions

View file

@ -1,6 +1,7 @@
16 January 2015: Wouter 16 January 2015: Wouter
- unit test for local unix connection. Documentation and log_addr - unit test for local unix connection. Documentation and log_addr
does not inspect port for AF_LOCAL. does not inspect port for AF_LOCAL.
- unbound-checkconf -f prints chroot with pidfile path.
13 January 2015: Wouter 13 January 2015: Wouter
- iana portlist update. - iana portlist update.

View file

@ -13,6 +13,7 @@ unbound\-checkconf
.SH "SYNOPSIS" .SH "SYNOPSIS"
.B unbound\-checkconf .B unbound\-checkconf
.RB [ \-h ] .RB [ \-h ]
.RB [ \-f ]
.RB [ \-o .RB [ \-o
.IR option ] .IR option ]
.RI [ cfgfile ] .RI [ cfgfile ]
@ -29,6 +30,9 @@ The available options are:
.B \-h .B \-h
Show the version and commandline option help. Show the version and commandline option help.
.TP .TP
.B \-f
Print full pathname, with chroot applied to it. Use with the -o option.
.TP
.B \-o\fI option .B \-o\fI option
If given, after checking the config file the value of this option is If given, after checking the config file the value of this option is
printed to stdout. For "" (disabled) options an empty line is printed. printed to stdout. For "" (disabled) options an empty line is printed.

View file

@ -78,6 +78,7 @@ usage()
printf(" Checks unbound configuration file for errors.\n"); printf(" Checks unbound configuration file for errors.\n");
printf("file if omitted %s is used.\n", CONFIGFILE); printf("file if omitted %s is used.\n", CONFIGFILE);
printf("-o option print value of option to stdout.\n"); printf("-o option print value of option to stdout.\n");
printf("-f output full pathname with chroot applied, eg. with -o pidfile.\n");
printf("-h show this usage help.\n"); printf("-h show this usage help.\n");
printf("Version %s\n", PACKAGE_VERSION); printf("Version %s\n", PACKAGE_VERSION);
printf("BSD licensed, see LICENSE in source package for details.\n"); printf("BSD licensed, see LICENSE in source package for details.\n");
@ -90,10 +91,15 @@ usage()
* @param cfg: config * @param cfg: config
* @param opt: option name without trailing :. * @param opt: option name without trailing :.
* This is different from config_set_option. * This is different from config_set_option.
* @param final: if final pathname with chroot applied has to be printed.
*/ */
static void static void
print_option(struct config_file* cfg, const char* opt) print_option(struct config_file* cfg, const char* opt, int final)
{ {
if(strcmp(opt, "pidfile") == 0 && final) {
printf("%s\n", fname_after_chroot(cfg->pidfile, cfg, 1));
return;
}
if(!config_get_option(cfg, opt, config_print_func, stdout)) if(!config_get_option(cfg, opt, config_print_func, stdout))
fatal_exit("cannot print option '%s'", opt); fatal_exit("cannot print option '%s'", opt);
} }
@ -456,7 +462,7 @@ check_hints(struct config_file* cfg)
/** check config file */ /** check config file */
static void static void
checkconf(const char* cfgfile, const char* opt) checkconf(const char* cfgfile, const char* opt, int final)
{ {
struct config_file* cfg = config_create(); struct config_file* cfg = config_create();
if(!cfg) if(!cfg)
@ -467,7 +473,7 @@ checkconf(const char* cfgfile, const char* opt)
exit(1); exit(1);
} }
if(opt) { if(opt) {
print_option(cfg, opt); print_option(cfg, opt, final);
config_delete(cfg); config_delete(cfg);
return; return;
} }
@ -493,6 +499,7 @@ extern char* optarg;
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
int c; int c;
int final = 0;
const char* f; const char* f;
const char* opt = NULL; const char* opt = NULL;
const char* cfgfile = CONFIGFILE; const char* cfgfile = CONFIGFILE;
@ -505,8 +512,11 @@ int main(int argc, char* argv[])
cfgfile = CONFIGFILE; cfgfile = CONFIGFILE;
#endif /* USE_WINSOCK */ #endif /* USE_WINSOCK */
/* parse the options */ /* parse the options */
while( (c=getopt(argc, argv, "ho:")) != -1) { while( (c=getopt(argc, argv, "fho:")) != -1) {
switch(c) { switch(c) {
case 'f':
final = 1;
break;
case 'o': case 'o':
opt = optarg; opt = optarg;
break; break;
@ -523,7 +533,7 @@ int main(int argc, char* argv[])
if(argc == 1) if(argc == 1)
f = argv[0]; f = argv[0];
else f = cfgfile; else f = cfgfile;
checkconf(f, opt); checkconf(f, opt, final);
checklock_stop(); checklock_stop();
return 0; return 0;
} }