[krb5-auth-dialog: 2/4] always reparse the principal name in grab_credentials



commit 082929a0feab7c2e05a7a72411d015c06bf2be7a
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.
---
 ChangeLog              |    9 +++++++++
 src/krb5-auth-dialog.c |   16 ++++++++--------
 2 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 18df8fa..f4b0f52 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+Thu Apr 23 11:17:28 CEST 2009 Guido Günther <agx sigxcpu org>
+
+	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 (ka_parse_name): Always parse principal
+	  property.
+	  (grab_credentials): Call ka_parse_name unconditionally.
+
 Thu Apr 23 11:14:37 CEST 2009 Guido Günther <agx sigxcpu org>
 
 	drop "Password:" label from dialog. It's in the kerberos prompt and
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]