2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-29 05:28:00 +00:00

Make possible not printing written path

Changes written path from stderr to stdout if enabled.
Adds -q parameter to hide written path.
This commit is contained in:
Petr Menšík 2020-05-22 20:40:06 +02:00 committed by Ondřej Surý
parent a746166f7a
commit 4748202fac
3 changed files with 14 additions and 1 deletions

View File

@ -198,5 +198,4 @@ write_key_file(const char *keyfile, const char *user, const char *keyname,
if (fclose(fd)) { if (fclose(fd)) {
fatal("fclose(%s) failed\n", keyfile); fatal("fclose(%s) failed\n", keyfile);
} }
fprintf(stderr, "wrote key file \"%s\"\n", keyfile);
} }

View File

@ -76,6 +76,7 @@ Usage:\n\
-c keyfile: specify an alternate key file (requires -a)\n\ -c keyfile: specify an alternate key file (requires -a)\n\
-k keyname: the name as it will be used in named.conf and rndc.conf\n\ -k keyname: the name as it will be used in named.conf and rndc.conf\n\
-p port: the port named will listen on and rndc will connect to\n\ -p port: the port named will listen on and rndc will connect to\n\
-q: suppress printing written key path\n\
-s addr: the address to which rndc should connect\n\ -s addr: the address to which rndc should connect\n\
-t chrootdir: write a keyfile in chrootdir as well (requires -a)\n\ -t chrootdir: write a keyfile in chrootdir as well (requires -a)\n\
-u user: set the keyfile owner to \"user\" (requires -a)\n", -u user: set the keyfile owner to \"user\" (requires -a)\n",
@ -104,6 +105,7 @@ main(int argc, char **argv) {
char *chrootdir = NULL; char *chrootdir = NULL;
char *user = NULL; char *user = NULL;
bool keyonly = false; bool keyonly = false;
bool quiet = false;
int len; int len;
keydef = keyfile = RNDC_KEYFILE; keydef = keyfile = RNDC_KEYFILE;
@ -164,6 +166,9 @@ main(int argc, char **argv) {
isc_commandline_argument); isc_commandline_argument);
} }
break; break;
case 'q':
quiet = true;
break;
case 'r': case 'r':
fatal("The -r option has been deprecated."); fatal("The -r option has been deprecated.");
break; break;
@ -227,6 +232,9 @@ main(int argc, char **argv) {
if (keyonly) { if (keyonly) {
write_key_file(keyfile, chrootdir == NULL ? user : NULL, write_key_file(keyfile, chrootdir == NULL ? user : NULL,
keyname, &key_txtbuffer, alg); keyname, &key_txtbuffer, alg);
if (!quiet) {
printf("wrote key file \"%s\"\n", keyfile);
}
if (chrootdir != NULL) { if (chrootdir != NULL) {
char *buf; char *buf;
@ -236,6 +244,9 @@ main(int argc, char **argv) {
(*keyfile != '/') ? "/" : "", keyfile); (*keyfile != '/') ? "/" : "", keyfile);
write_key_file(buf, user, keyname, &key_txtbuffer, alg); write_key_file(buf, user, keyname, &key_txtbuffer, alg);
if (!quiet) {
printf("wrote key file \"%s\"\n", buf);
}
isc_mem_put(mctx, buf, len); isc_mem_put(mctx, buf, len);
} }
} else { } else {

View File

@ -86,6 +86,9 @@ Arguments
Specifies the command channel port where ``named`` listens for Specifies the command channel port where ``named`` listens for
connections from ``rndc``. The default is 953. connections from ``rndc``. The default is 953.
**-q**
Omits printing written path in automatic configuration mode.
**-s** address **-s** address
Specifies the IP address where ``named`` listens for command channel Specifies the IP address where ``named`` listens for command channel
connections from ``rndc``. The default is the loopback address connections from ``rndc``. The default is the loopback address