If the log file can't be opened, print an intelligent error message
authorTheodore Tso <tytso@mit.edu>
Thu, 5 Oct 1995 21:59:01 +0000 (21:59 +0000)
committerTheodore Tso <tytso@mit.edu>
Thu, 5 Oct 1995 21:59:01 +0000 (21:59 +0000)
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@6930 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/kadm/ChangeLog
src/lib/kadm/logger.c

index a9c54843b033b3551839b942706357ad736d5c4d..d25cf5865f773649a9fa717fce92974c48bd79cb 100644 (file)
@@ -1,3 +1,8 @@
+Mon Oct  2 15:08:53 1995  Theodore Y. Ts'o  <tytso@dcl>
+
+       * 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  <epeisach@kangaroo.mit.edu>
 
        * alt_prof.c (krb5_read_realm_params): If secure flag is set in
index 58c28149a4b2766c69f8877ff29c479c4d257d04..1c2d5dbfb4ede38dfdbcb1047b9d2ac656b6aabf 100644 (file)
@@ -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;
                        }
                    }
                }