From e3e09104b3ca3c4c9b524a19c90c0219b5493588 Mon Sep 17 00:00:00 2001 From: Theodore Tso Date: Tue, 15 Jan 1991 18:25:41 +0000 Subject: [PATCH] Fixed update_ok_file to use com_err and so that it doesn't exit if it errors out. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@1631 dc483132-0cff-0310-8789-dd5450dbe970 --- src/admin/edit/dump.c | 43 +++++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/src/admin/edit/dump.c b/src/admin/edit/dump.c index 5a84ae0e2..465f7b98f 100644 --- a/src/admin/edit/dump.c +++ b/src/admin/edit/dump.c @@ -132,29 +132,28 @@ void dump_db(argc, argv) void update_ok_file (file_name) char *file_name; { - /* handle slave locking/failure stuff */ - char *file_ok; - int fd; - static char ok[]=".dump_ok"; + /* handle slave locking/failure stuff */ + char *file_ok; + int fd; + static char ok[]=".dump_ok"; - if ((file_ok = (char *)malloc(strlen(file_name) + strlen(ok) + 1)) - == NULL) { - fprintf(stderr, "%s: out of memory.\n", progname); - (void) fflush (stderr); - perror ("malloc"); - exit (1); - } - strcpy(file_ok, file_name); - strcat(file_ok, ok); - if ((fd = open(file_ok, O_WRONLY|O_CREAT|O_TRUNC, 0600)) < 0) { - fprintf(stderr, "Error creating 'ok' file, '%s'", file_ok); - perror(""); - (void) fflush (stderr); - exit (1); - } - free(file_ok); - close(fd); - return; + if ((file_ok = (char *)malloc(strlen(file_name) + strlen(ok) + 1)) + == NULL) { + com_err(progname, ENOMEM, + "while allocating filename for update_ok_file"); + return; + } + strcpy(file_ok, file_name); + strcat(file_ok, ok); + if ((fd = open(file_ok, O_WRONLY|O_CREAT|O_TRUNC, 0600)) < 0) { + com_err(progname, errno, "while creating 'ok' file, '%s'", + file_ok); + free(file_ok); + return; + } + free(file_ok); + close(fd); + return; } void load_db(argc, argv) -- 2.26.2