]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
2728. [bug] dnssec-keygen, dnssec-keyfromlabel and
authorEvan Hunt <each@isc.org>
Sat, 24 Oct 2009 00:00:06 +0000 (00:00 +0000)
committerEvan Hunt <each@isc.org>
Sat, 24 Oct 2009 00:00:06 +0000 (00:00 +0000)
dnssec-signzone now warn immediately if asked to
write into a nonexistent directory. [RT #20278]

CHANGES
bin/dnssec/dnssec-keyfromlabel.c
bin/dnssec/dnssec-keygen.c
bin/dnssec/dnssec-signzone.c
bin/dnssec/dnssectool.c
bin/dnssec/dnssectool.h

diff --git a/CHANGES b/CHANGES
index 073154d949409d4228b714c9aba60667fee15b55..2150496a03c12aa92459329601dcfbe71a6045be 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -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]
 
index d51efbd449a5ff4af94ee2e52489310d2e0a320a..58eb349aaab84f1665cec5596fb7e308ac88e163 100644 (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;
index 1d192974679ab4ed770c3b3a1bb02529c83ec2eb..0631af15b7361d0fe3e4f71b1ec4bb7a96113b45 100644 (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)
index 4739dfc290782e9102e43ae29534cf537742595c..2f3da0f99075e7b7b875f2e02c4a3d825bc267b6 100644 (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':
index 38ab8c200654dec2b159005c231bdf61faed2a73..541dda0b12de414df5916d636216c1baa7fe8583 100644 (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);
+}
index 82e1d62fefd9410e92597a17142bc892a696dbb6..c1a0ee1767ea6051ad294fff6a3ee547d3fe11b8 100644 (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 */