2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-22 10:10:06 +00:00

2728. [bug] dnssec-keygen, dnssec-keyfromlabel and

dnssec-signzone now warn immediately if asked to
			write into a nonexistent directory. [RT #20278]
This commit is contained in:
Evan Hunt 2009-10-24 00:00:06 +00:00
parent 412b30659b
commit 8f0502e922
6 changed files with 38 additions and 8 deletions

View File

@ -1,3 +1,7 @@
2728. [bug] dnssec-keygen, dnssec-keyfromlabel and
dnssec-signzone now warn immediately if asked to
write into a nonexistent directory. [RT #20278]
2727. [func] The 'key-directory' option can now specify a relative
path. [RT #20154]

View File

@ -14,7 +14,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: dnssec-keyfromlabel.c,v 1.23 2009/10/22 02:21:30 each Exp $ */
/* $Id: dnssec-keyfromlabel.c,v 1.24 2009/10/24 00:00:06 each Exp $ */
/*! \file */
@ -188,6 +188,10 @@ main(int argc, char **argv) {
break;
case 'K':
directory = isc_commandline_argument;
ret = try_dir(directory);
if (ret != ISC_R_SUCCESS)
fatal("Cannot write to directory %s: %s",
directory, isc_result_totext(ret));
break;
case 'k':
options |= DST_TYPE_KEY;

View File

@ -29,7 +29,7 @@
* IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: dnssec-keygen.c,v 1.102 2009/10/22 02:21:30 each Exp $ */
/* $Id: dnssec-keygen.c,v 1.103 2009/10/24 00:00:06 each Exp $ */
/*! \file */
@ -281,6 +281,10 @@ main(int argc, char **argv) {
break;
case 'K':
directory = isc_commandline_argument;
ret = try_dir(directory);
if (ret != ISC_R_SUCCESS)
fatal("cannot write to directory %s: %s",
directory, isc_result_totext(ret));
break;
case 'k':
fatal("The -k option has been deprecated.\n"
@ -773,8 +777,7 @@ main(int argc, char **argv) {
if (conflict == ISC_TRUE) {
if (verbose > 0) {
isc_buffer_clear(&buf);
ret = dst_key_buildfilename(key, 0, directory,
&buf);
dst_key_buildfilename(key, 0, directory, &buf);
fprintf(stderr,
"%s: %s already exists, "
"generating a new key\n",
@ -782,7 +785,6 @@ main(int argc, char **argv) {
}
dst_key_free(&key);
}
} while (conflict == ISC_TRUE);
if (conflict)

View File

@ -29,7 +29,7 @@
* IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: dnssec-signzone.c,v 1.247 2009/10/13 23:48:12 tbox Exp $ */
/* $Id: dnssec-signzone.c,v 1.248 2009/10/24 00:00:06 each Exp $ */
/*! \file */
@ -3274,6 +3274,10 @@ main(int argc, char *argv[]) {
dsdir = isc_commandline_argument;
if (strlen(dsdir) == 0U)
fatal("DS directory must be non-empty string");
result = try_dir(dsdir);
if (result != ISC_R_SUCCESS)
fatal("Cannot write to directory %s: %s",
dsdir, isc_result_totext(result));
break;
case 'E':

View File

@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: dnssectool.c,v 1.55 2009/10/12 20:48:11 each Exp $ */
/* $Id: dnssectool.c,v 1.56 2009/10/24 00:00:06 each Exp $ */
/*! \file */
@ -28,6 +28,7 @@
#include <stdlib.h>
#include <isc/buffer.h>
#include <isc/dir.h>
#include <isc/entropy.h>
#include <isc/list.h>
#include <isc/mem.h>
@ -348,3 +349,16 @@ strtoclass(const char *str) {
fatal("unknown class %s", str);
return (rdclass);
}
isc_result_t
try_dir(const char *dirname) {
isc_result_t result;
isc_dir_t d;
isc_dir_init(&d);
result = isc_dir_open(&d, dirname);
if (result == ISC_R_SUCCESS) {
isc_dir_close(&d);
}
return (result);
}

View File

@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: dnssectool.h,v 1.27 2009/10/12 20:48:11 each Exp $ */
/* $Id: dnssectool.h,v 1.28 2009/10/24 00:00:06 each Exp $ */
#ifndef DNSSECTOOL_H
#define DNSSECTOOL_H 1
@ -68,4 +68,6 @@ strtotime(const char *str, isc_int64_t now, isc_int64_t base);
dns_rdataclass_t
strtoclass(const char *str);
isc_result_t
try_dir(const char *dirname);
#endif /* DNSSEC_DNSSECTOOL_H */