svn rev #24489: trunk/src/ kadmin/dbutil/ kdc/ lib/kadm5/srv/ lib/krb5/krb/ lib/krb5/os/

ghudson@MIT.EDU ghudson at MIT.EDU
Mon Nov 1 11:19:00 EDT 2010


http://src.mit.edu/fisheye/changelog/krb5/?cs=24489
Commit By: ghudson
Log Message:
krb5_get_error_message cannot return NULL, and returns "Success" on
error code 0.  Simplify some overly paranoid code accordingly.



Changed Files:
U   trunk/src/kadmin/dbutil/dump.c
U   trunk/src/kdc/kdc_authdata.c
U   trunk/src/kdc/kdc_preauth.c
U   trunk/src/lib/kadm5/srv/kadm5_hook.c
U   trunk/src/lib/krb5/krb/fast.c
U   trunk/src/lib/krb5/os/trace.c
Modified: trunk/src/kadmin/dbutil/dump.c
===================================================================
--- trunk/src/kadmin/dbutil/dump.c	2010-10-27 17:05:05 UTC (rev 24488)
+++ trunk/src/kadmin/dbutil/dump.c	2010-11-01 15:19:00 UTC (rev 24489)
@@ -2514,18 +2514,8 @@
 
         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 @@
         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;
         }

Modified: trunk/src/kdc/kdc_authdata.c
===================================================================
--- trunk/src/kdc/kdc_authdata.c	2010-10-27 17:05:05 UTC (rev 24488)
+++ trunk/src/kdc/kdc_authdata.c	2010-11-01 15:19:00 UTC (rev 24489)
@@ -291,12 +291,10 @@
                 ((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 @@
                 ((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;

Modified: trunk/src/kdc/kdc_preauth.c
===================================================================
--- trunk/src/kdc/kdc_preauth.c	2010-10-27 17:05:05 UTC (rev 24488)
+++ trunk/src/kdc/kdc_preauth.c	2010-11-01 15:19:00 UTC (rev 24489)
@@ -471,12 +471,10 @@
                         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]));
 

Modified: trunk/src/lib/kadm5/srv/kadm5_hook.c
===================================================================
--- trunk/src/lib/kadm5/srv/kadm5_hook.c	2010-10-27 17:05:05 UTC (rev 24488)
+++ trunk/src/lib/kadm5/srv/kadm5_hook.c	2010-11-01 15:19:00 UTC (rev 24489)
@@ -117,10 +117,8 @@
 {
     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);
 }
 

Modified: trunk/src/lib/krb5/krb/fast.c
===================================================================
--- trunk/src/lib/krb5/krb/fast.c	2010-10-27 17:05:05 UTC (rev 24488)
+++ trunk/src/lib/krb5/krb/fast.c	2010-11-01 15:19:00 UTC (rev 24489)
@@ -182,11 +182,9 @@
         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)

Modified: trunk/src/lib/krb5/os/trace.c
===================================================================
--- trunk/src/lib/krb5/os/trace.c	2010-10-27 17:05:05 UTC (rev 24488)
+++ trunk/src/lib/krb5/os/trace.c	2010-11-01 15:19:00 UTC (rev 24489)
@@ -179,8 +179,7 @@
         } 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 *);




More information about the cvs-krb5 mailing list