krb5_get_error_message cannot return NULL, and returns "Success" on
authorGreg Hudson <ghudson@mit.edu>
Mon, 1 Nov 2010 15:19:00 +0000 (15:19 +0000)
committerGreg Hudson <ghudson@mit.edu>
Mon, 1 Nov 2010 15:19:00 +0000 (15:19 +0000)
error code 0.  Simplify some overly paranoid code accordingly.

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@24489 dc483132-0cff-0310-8789-dd5450dbe970

src/kadmin/dbutil/dump.c
src/kdc/kdc_authdata.c
src/kdc/kdc_preauth.c
src/lib/kadm5/srv/kadm5_hook.c
src/lib/krb5/krb/fast.c
src/lib/krb5/os/trace.c

index caff137a40d92ca7812508168089002511895549..0e1b60959412e8a3a18d8d6d6f0dd72992dc19d7 100644 (file)
@@ -2514,18 +2514,8 @@ load_db(argc, argv)
 
         if((kret = krb5_db_create(kcontext, db5util_db_args))) {
             const char *emsg = krb5_get_error_message(kcontext, kret);
-            /*
-             * See if something (like DAL KDB plugin) has set a specific error
-             * message and use that otherwise use default.
-             */
-
-            if (emsg != NULL) {
-                fprintf(stderr, "%s: %s\n", progname, emsg);
-                krb5_free_error_message (kcontext, emsg);
-            } else {
-                fprintf(stderr, dbcreaterr_fmt,
-                        progname, dbname, error_message(kret));
-            }
+            fprintf(stderr, "%s: %s\n", progname, emsg);
+            krb5_free_error_message (kcontext, emsg);
             exit_status++;
             if (dumpfile) fclose(f);
             return;
@@ -2538,18 +2528,8 @@ load_db(argc, argv)
         if ((kret = krb5_db_open(kcontext, db5util_db_args,
                                  KRB5_KDB_OPEN_RW | KRB5_KDB_SRV_TYPE_ADMIN))) {
             const char *emsg = krb5_get_error_message(kcontext, kret);
-            /*
-             * See if something (like DAL KDB plugin) has set a specific
-             * error message and use that otherwise use default.
-             */
-
-            if (emsg != NULL) {
-                fprintf(stderr, "%s: %s\n", progname, emsg);
-                krb5_free_error_message (kcontext, emsg);
-            } else {
-                fprintf(stderr, dbinit_err_fmt,
-                        progname, error_message(kret));
-            }
+            fprintf(stderr, "%s: %s\n", progname, emsg);
+            krb5_free_error_message (kcontext, emsg);
             exit_status++;
             goto error;
         }
index a4f81a60a2c7eeac3a1b6f5ebe3381c3685982e1..5861e70488aade91c9615e7009e9c0461afcb53b 100644 (file)
@@ -291,12 +291,10 @@ load_authdata_plugins(krb5_context context)
                 ((initerr = (*server_init_proc)(context, &pctx)) != 0)) {
                 const char *emsg;
                 emsg = krb5_get_error_message(context, initerr);
-                if (emsg) {
-                    krb5_klog_syslog(LOG_ERR,
-                                     "authdata %s failed to initialize: %s",
-                                     ftable->name, emsg);
-                    krb5_free_error_message(context, emsg);
-                }
+                krb5_klog_syslog(LOG_ERR,
+                                 "authdata %s failed to initialize: %s",
+                                 ftable->name, emsg);
+                krb5_free_error_message(context, emsg);
                 memset(&authdata_systems[k], 0, sizeof(authdata_systems[k]));
 
                 continue;
@@ -329,12 +327,10 @@ load_authdata_plugins(krb5_context context)
                 ((initerr = (*server_init_proc)(context, &pctx)) != 0)) {
                 const char *emsg;
                 emsg = krb5_get_error_message(context, initerr);
-                if (emsg) {
-                    krb5_klog_syslog(LOG_ERR,
-                                     "authdata %s failed to initialize: %s",
-                                     ftable->name, emsg);
-                    krb5_free_error_message(context, emsg);
-                }
+                krb5_klog_syslog(LOG_ERR,
+                                 "authdata %s failed to initialize: %s",
+                                 ftable->name, emsg);
+                krb5_free_error_message(context, emsg);
                 memset(&authdata_systems[k], 0, sizeof(authdata_systems[k]));
 
                 continue;
index 52fb51a0c951f444c4f724b816d24303034b902f..397155542c25c64b1e32e881ccbf4bad1b2fc994 100644 (file)
@@ -471,12 +471,10 @@ load_preauth_plugins(krb5_context context)
                         if (initerr) {
                             const char *emsg;
                             emsg = krb5_get_error_message(context, initerr);
-                            if (emsg) {
-                                krb5_klog_syslog(LOG_ERR,
-                                                 "preauth %s failed to initialize: %s",
-                                                 ftable->name, emsg);
-                                krb5_free_error_message(context, emsg);
-                            }
+                            krb5_klog_syslog(LOG_ERR,
+                                             "preauth %s failed to initialize: %s",
+                                             ftable->name, emsg);
+                            krb5_free_error_message(context, emsg);
                             memset(&preauth_systems[k], 0,
                                    sizeof(preauth_systems[k]));
 
index 386715d72940506d544dfbdc63da79cb05d4e320..73016c8bdd2e40167c319a2b64ad9e320081c8cf 100644 (file)
@@ -117,10 +117,8 @@ log_failure(krb5_context context,
 {
     const char *e = krb5_get_error_message(context, ret);
 
-    if (e) {
-        krb5_klog_syslog(LOG_ERR, "kadm5_hook %s failed postcommit %s: %s",
-                         name, function, e);
-    }
+    krb5_klog_syslog(LOG_ERR, "kadm5_hook %s failed postcommit %s: %s",
+                     name, function, e);
     krb5_free_error_message(context, e);
 }
 
index 50321cc86c987b5995884a51d6f3bbd1663dc94f..cc9f899a7dee562d25b483f30ca6c6b319c15d67 100644 (file)
@@ -182,11 +182,9 @@ krb5int_fast_as_armor(krb5_context context,
         if (retval != 0) {
             const char * errmsg;
             errmsg = krb5_get_error_message(context, retval);
-            if (errmsg) {
-                krb5_set_error_message(context, retval,
-                                       "%s constructing AP-REQ armor", errmsg);
-                krb5_free_error_message(context, errmsg);
-            }
+            krb5_set_error_message(context, retval,
+                                   "%s constructing AP-REQ armor", errmsg);
+            krb5_free_error_message(context, errmsg);
         }
     }
     if (ccache)
index 3f31ea920dcd1a0d449563d9cda50ef9a8c29193..30942cd9752f56662a7173bbc5385a3eb8a25ac9 100644 (file)
@@ -179,8 +179,7 @@ trace_format(krb5_context context, const char *fmt, va_list ap)
         } else if (strcmp(tmpbuf, "kerr") == 0) {
            kerr = va_arg(ap, krb5_error_code);
             p = krb5_get_error_message(context, kerr);
-            krb5int_buf_add_fmt(&buf, "%ld/%s", (long) kerr,
-                                (kerr == 0) ? "success" : p);
+            krb5int_buf_add_fmt(&buf, "%ld/%s", (long) kerr, p);
             krb5_free_error_message(context, p);
         } else if (strcmp(tmpbuf, "keyblock") == 0) {
             keyblock = va_arg(ap, const krb5_keyblock *);