From: Andreas Gustafsson Date: Mon, 11 Jun 2001 16:58:39 +0000 (+0000) Subject: pullup: X-Git-Tag: v9.1.3rc2~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e26fdc705c8949411490e30c1a1d8bd95c237f90;p=thirdparty%2Fbind9.git pullup: set the permissions on a symmetric keyfile before anything is written to it, rather than after it is closed --- diff --git a/lib/dns/sec/dst/dst_api.c b/lib/dns/sec/dst/dst_api.c index 47c8c6a0513..43704768127 100644 --- a/lib/dns/sec/dst/dst_api.c +++ b/lib/dns/sec/dst/dst_api.c @@ -19,7 +19,7 @@ /* * Principal Author: Brian Wellington - * $Id: dst_api.c,v 1.67.2.3 2001/05/10 21:12:36 gson Exp $ + * $Id: dst_api.c,v 1.67.2.4 2001/06/11 16:58:39 gson Exp $ */ #include @@ -1041,6 +1041,14 @@ write_public_key(const dst_key_t *key, const char *directory) { if ((fp = fopen(filename, "w")) == NULL) return (DST_R_WRITEERROR); + if (key->func->issymmetric()) { + access = 0; + isc_fsaccess_add(ISC_FSACCESS_OWNER, + ISC_FSACCESS_READ | ISC_FSACCESS_WRITE, + &access); + (void)isc_fsaccess_set(filename, access); + } + ret = dns_name_print(key->key_name, fp); if (ret != ISC_R_SUCCESS) return (ret); @@ -1058,14 +1066,6 @@ write_public_key(const dst_key_t *key, const char *directory) { fputc('\n', fp); fclose(fp); - if (key->func->issymmetric()) { - access = 0; - isc_fsaccess_add(ISC_FSACCESS_OWNER, - ISC_FSACCESS_READ | ISC_FSACCESS_WRITE, - &access); - (void)isc_fsaccess_set(filename, access); - } - return (ISC_R_SUCCESS); }