- Fix #876: [FR] can unbound-checkconf be silenced when configuration

is valid?
This commit is contained in:
Yorgos Thessalonikefs 2024-04-26 14:50:39 +02:00
parent 82c0207fa6
commit cd4a017e96
2 changed files with 13 additions and 4 deletions

View file

@ -6,6 +6,10 @@
the ecs reply expires. the ecs reply expires.
- Add unit tests for cachedb and subnet cache expired data. - Add unit tests for cachedb and subnet cache expired data.
26 April 2024: Yorgos
- Fix #876: [FR] can unbound-checkconf be silenced when configuration
is valid?
25 April 2024: Wouter 25 April 2024: Wouter
- Fix configure flto check error, by finding grep for it. - Fix configure flto check error, by finding grep for it.
- Merge #1041: Stub and Forward unshare. This has one structure - Merge #1041: Stub and Forward unshare. This has one structure

View file

@ -88,6 +88,7 @@ usage(void)
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("-f output full pathname with chroot applied, eg. with -o pidfile.\n");
printf("-q quiet (suppress output on success).\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");
@ -965,7 +966,7 @@ check_auth(struct config_file* cfg)
/** check config file */ /** check config file */
static void static void
checkconf(const char* cfgfile, const char* opt, int final) checkconf(const char* cfgfile, const char* opt, int final, int quiet)
{ {
char oldwd[4096]; char oldwd[4096];
struct config_file* cfg = config_create(); struct config_file* cfg = config_create();
@ -998,7 +999,7 @@ checkconf(const char* cfgfile, const char* opt, int final)
check_fwd(cfg); check_fwd(cfg);
check_hints(cfg); check_hints(cfg);
check_auth(cfg); check_auth(cfg);
printf("unbound-checkconf: no errors in %s\n", cfgfile); if(!quiet) { printf("unbound-checkconf: no errors in %s\n", cfgfile); }
config_delete(cfg); config_delete(cfg);
} }
@ -1012,6 +1013,7 @@ int main(int argc, char* argv[])
{ {
int c; int c;
int final = 0; int final = 0;
int quiet = 0;
const char* f; const char* f;
const char* opt = NULL; const char* opt = NULL;
const char* cfgfile = CONFIGFILE; const char* cfgfile = CONFIGFILE;
@ -1024,7 +1026,7 @@ 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, "fho:")) != -1) { while( (c=getopt(argc, argv, "fhqo:")) != -1) {
switch(c) { switch(c) {
case 'f': case 'f':
final = 1; final = 1;
@ -1032,6 +1034,9 @@ int main(int argc, char* argv[])
case 'o': case 'o':
opt = optarg; opt = optarg;
break; break;
case 'q':
quiet = 1;
break;
case '?': case '?':
case 'h': case 'h':
default: default:
@ -1045,7 +1050,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, final); checkconf(f, opt, final, quiet);
checklock_stop(); checklock_stop();
return 0; return 0;
} }