svn rev #23819: trunk/src/clients/kpasswd/

ghudson@MIT.EDU ghudson at MIT.EDU
Thu Mar 18 13:37:32 EDT 2010


http://src.mit.edu/fisheye/changelog/krb5/?cs=23819
Commit By: ghudson
Log Message:
ticket: 6683
target_version: 1.8.1
tags: pullup

Fix the kpasswd fallback from the ccache principal name to the
username in the case where the ccache doesn't exist.



Changed Files:
U   trunk/src/clients/kpasswd/kpasswd.c
Modified: trunk/src/clients/kpasswd/kpasswd.c
===================================================================
--- trunk/src/clients/kpasswd/kpasswd.c	2010-03-18 17:17:31 UTC (rev 23818)
+++ trunk/src/clients/kpasswd/kpasswd.c	2010-03-18 17:37:31 UTC (rev 23819)
@@ -47,7 +47,7 @@
 {
     krb5_error_code ret;
     krb5_context context;
-    krb5_principal princ;
+    krb5_principal princ = NULL;
     char *pname;
     krb5_ccache ccache;
     krb5_get_init_creds_opt *opts = NULL;
@@ -84,23 +84,27 @@
             com_err(argv[0], ret, "parsing client name");
             exit(1);
         }
-    } else if ((ret = krb5_cc_default(context, &ccache)) != KRB5_CC_NOTFOUND) {
-        if (ret) {
+    } else {
+        ret = krb5_cc_default(context, &ccache);
+        if (ret != 0) {
             com_err(argv[0], ret, "opening default ccache");
             exit(1);
         }
 
-        if ((ret = krb5_cc_get_principal(context, ccache, &princ))) {
+        ret = krb5_cc_get_principal(context, ccache, &princ);
+        if (ret != 0 && ret != KRB5_CC_NOTFOUND && ret != KRB5_FCC_NOFILE) {
             com_err(argv[0], ret, "getting principal from ccache");
             exit(1);
         }
 
-        if ((ret = krb5_cc_close(context, ccache))) {
+        ret = krb5_cc_close(context, ccache);
+        if (ret != 0) {
             com_err(argv[0], ret, "closing ccache");
             exit(1);
         }
-    } else {
-        get_name_from_passwd_file(argv[0], context, &princ);
+
+        if (princ == NULL)
+            get_name_from_passwd_file(argv[0], context, &princ);
     }
 
     if ((ret = krb5_get_init_creds_opt_alloc(context, &opts))) {




More information about the cvs-krb5 mailing list