From: Theodore Tso Date: Thu, 5 Oct 1995 21:59:01 +0000 (+0000) Subject: If the log file can't be opened, print an intelligent error message X-Git-Tag: krb5-1.0-beta6~938 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=9e564172a7fe21eca5a2ce21fd1e4bf2237f3481;p=krb5.git If the log file can't be opened, print an intelligent error message git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@6930 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/lib/kadm/ChangeLog b/src/lib/kadm/ChangeLog index a9c54843b..d25cf5865 100644 --- a/src/lib/kadm/ChangeLog +++ b/src/lib/kadm/ChangeLog @@ -1,3 +1,8 @@ +Mon Oct 2 15:08:53 1995 Theodore Y. Ts'o + + * logger.c (krb5_klog_init): If the log file can't be opened, + print an intelligent error message. + Thu Oct 5 12:06:35 1995 Ezra Peisach * alt_prof.c (krb5_read_realm_params): If secure flag is set in diff --git a/src/lib/kadm/logger.c b/src/lib/kadm/logger.c index 58c28149a..1c2d5dbfb 100644 --- a/src/lib/kadm/logger.c +++ b/src/lib/kadm/logger.c @@ -357,6 +357,7 @@ krb5_klog_init(kcontext, ename, whoami, do_com_err) char savec; int error; int do_openlog, log_facility; + FILE *f; /* Initialize */ do_openlog = 0; @@ -417,18 +418,16 @@ krb5_klog_init(kcontext, ename, whoami, do_com_err) /* * Check for append/overwrite, then open the file. */ - if (cp[4] == ':') { - if (log_control.log_entries[i].lfu_filep = - fopen(&cp[5], "a+")) { - log_control.log_entries[i].log_type = K_LOG_FILE; - log_control.log_entries[i].lfu_fname = &cp[5]; - } - } - else if (cp[4] == '=') { - if (log_control.log_entries[i].lfu_filep = - fopen(&cp[5], "w")) { + if (cp[4] == ':' || cp[4] == '=') { + f = fopen(&cp[5], (cp[4] == ':') ? "a+" : "w"); + if (f) { + log_control.log_entries[i].lfu_filep = f; log_control.log_entries[i].log_type = K_LOG_FILE; log_control.log_entries[i].lfu_fname = &cp[5]; + } else { + fprintf(stderr,"Couldn't open log file %s: %s\n", + &cp[5], error_message(errno)); + continue; } } }