[krb5-auth-dialog] always reparse the principal name in grab_credentials



commit bd9906921b319351916ced169e57574359b2c36d
Author: Guido Günther <agx sigxcpu org>
Date:   Thu Apr 9 12:55:16 2009 +0200

    always reparse the principal name in grab_credentials
    
    when acquireing credentials interacively we want to be sure we use the
    current principal name from gconf.
---
 src/krb5-auth-dialog.c |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/krb5-auth-dialog.c b/src/krb5-auth-dialog.c
index 32cc016..08f1c12 100644
--- a/src/krb5-auth-dialog.c
+++ b/src/krb5-auth-dialog.c
@@ -178,6 +178,7 @@ credentials_expiring_real (KaApplet* applet)
 		goto out;
 	}
 
+	/* copy principal from cache if any */
 	if (krb5_principal_compare (kcontext, my_creds.client, kprincipal)) {
 		krb5_free_principal(kcontext, kprincipal);
 		krb5_copy_principal(kcontext, my_creds.client, &kprincipal);
@@ -529,9 +530,11 @@ ka_parse_name(KaApplet* applet, krb5_context krbcontext, krb5_principal* kprinc)
 	krb5_error_code ret;
 	gchar *principal = NULL;
 
+	if (*kprinc != NULL)
+		krb5_free_principal(krbcontext, *kprinc);
+
 	g_object_get(applet, "principal", &principal, NULL);
-	ret = krb5_parse_name(krbcontext, principal,
-			      kprinc);
+	ret = krb5_parse_name(krbcontext, principal, kprinc);
 
 	g_free(principal);
 	return ret;
@@ -611,11 +614,9 @@ grab_credentials (KaApplet* applet)
 
 	memset(&my_creds, 0, sizeof(my_creds));
 
-	if (kprincipal == NULL) {
-		retval = ka_parse_name(applet, kcontext, &kprincipal);
-		if (retval)
-			goto out2;
-	}
+	retval = ka_parse_name(applet, kcontext, &kprincipal);
+	if (retval)
+		goto out2;
 
 	retval = krb5_cc_default (kcontext, &ccache);
 	if (retval)
@@ -780,7 +781,6 @@ using_krb5(void)
 		krb5_copy_principal(kcontext, creds.client, &kprincipal);
 		krb5_free_cred_contents (kcontext, &creds);
 	}
-
 	return have_tgt;
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]