Commit ea6fe0d5 authored by Mark Andrews's avatar Mark Andrews

1451. [bug] rndc-confgen didn't exit with a error code for all

                        failures. [RT #5209]
parent f6732ece
1451. [bug] rndc-confgen didn't exit with a error code for all
failures. [RT #5209]
1450. [bug] Fetching expired glue failed under certian
circumstances. [RT #5124]
......
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: rndc-confgen.c,v 1.15 2001/11/30 01:09:11 gson Exp $ */
/* $Id: rndc-confgen.c,v 1.16 2003/03/03 05:08:56 marka Exp $ */
#include <config.h>
......@@ -90,31 +90,21 @@ write_key_file(const char *keyfile, const char *user,
FILE *fd;
fd = safe_create(keyfile);
if (fd == NULL) {
fprintf(stderr, "unable to create \"%s\"\n", keyfile);
return;
}
if (fd == NULL)
fatal( "unable to create \"%s\"\n", keyfile);
if (user != NULL) {
if (set_user(fd, user) == -1) {
fprintf(stderr, "unable to set file owner\n");
fclose(fd);
return;
}
if (set_user(fd, user) == -1)
fatal("unable to set file owner\n");
}
fprintf(fd, "key \"%s\" {\n\talgorithm hmac-md5;\n"
"\tsecret \"%.*s\";\n};\n", keyname,
(int)isc_buffer_usedlength(secret),
(char *)isc_buffer_base(secret));
fflush(fd);
if (ferror(fd)) {
fprintf(stderr, "write to %s failed\n", keyfile);
fclose(fd);
return;
}
if (fclose(fd)) {
fprintf(stderr, "fclose(%s) failed\n", keyfile);
return;
}
if (ferror(fd))
fatal("write to %s failed\n", keyfile);
if (fclose(fd))
fatal("fclose(%s) failed\n", keyfile);
fprintf(stderr, "wrote key file \"%s\"\n", keyfile);
}
......@@ -281,11 +271,8 @@ main(int argc, char **argv) {
char *buf;
len = strlen(chrootdir) + strlen(keyfile) + 2;
buf = isc_mem_get(mctx, len);
if (buf == NULL) {
fprintf(stderr, "isc_mem_get(%d) failed\n",
len);
goto cleanup;
}
if (buf == NULL)
fatal("isc_mem_get(%d) failed\n", len);
snprintf(buf, len, "%s/%s", chrootdir, keyfile);
write_key_file(buf, user, keyname, &key_txtbuffer);
......@@ -327,7 +314,6 @@ options {\n\
serveraddr, port, serveraddr, keyname);
}
cleanup:
if (show_final_mem)
isc_mem_stats(mctx, stderr);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment