* src/krb5-auth-dialog.c(krb5_gtk_prompter): rename to avoid polluting
authornalin <nalin@517b70f8-ed25-0410-8bf6-f5db08f7b76e>
Wed, 1 Feb 2006 22:11:34 +0000 (22:11 +0000)
committernalin <nalin@517b70f8-ed25-0410-8bf6-f5db08f7b76e>
Wed, 1 Feb 2006 22:11:34 +0000 (22:11 +0000)
the krb5 namespace.
* src/krb5-auth-dialog.c: don't use time() to figure out what time it
is -- we always compare against a krb5_timestamp, so use the libkrb5
routines which return the current time instead.

git-svn-id: http://svn.gnome.org/svn/krb5-auth-dialog/trunk@60 517b70f8-ed25-0410-8bf6-f5db08f7b76e

ChangeLog
src/krb5-auth-dialog.c

index 0c8c56cc97a63bee83c5847ecbbb9515e7ea6a24..213ad66904e85d50e7f46b77866a617f0558ac9c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2006-02-01  Nalin Dahyabhai <nalin@redhat.com>
+       * src/krb5-auth-dialog.c(krb5_gtk_prompter): rename to avoid polluting
+       the krb5 namespace.
+       * src/krb5-auth-dialog.c: don't use time() to figure out what time it
+       is -- we always compare against a krb5_timestamp, so use the libkrb5
+       routines which return the current time instead.
+
 2006-02-01  Nalin Dahyabhai <nalin@redhat.com>
        * README: correct a typo
        * src/krb5-auth-dialog.c(renew_credentials): fix a warning where we
index 1fa5aeea7931bf5c0354a970a9a9bdc1f11877ec..471c15c82fde329496d8c80a9bde2aa28ad65b22 100644 (file)
@@ -38,9 +38,9 @@
 static GladeXML *xml = NULL;
 static krb5_context kcontext;
 static krb5_principal kprincipal;
+static krb5_timestamp creds_expiry;
 static gboolean invalid_password;
 static gboolean always_run;
-static gint creds_expiry;
 
 static int renew_credentials ();
 static gboolean get_tgt_from_ccache (krb5_context context, krb5_creds *creds);
@@ -71,12 +71,17 @@ krb5_auth_dialog_wrong_label_update_expiry (gpointer data)
 {
        GtkWidget *label = GTK_WIDGET(data);
        int minutes_left;
+       krb5_timestamp now;
        gchar *expiry_text;
        gchar *expiry_markup;
 
        g_return_val_if_fail (label != NULL, FALSE);
 
-       minutes_left = (creds_expiry - time(0)) / 60;
+       if (krb5_timeofday(kcontext, &now) != 0) {
+               return TRUE;
+       }
+
+       minutes_left = (creds_expiry - now) / 60;
 
        expiry_text = minutes_to_expiry_text (minutes_left);
 
@@ -140,7 +145,14 @@ krb5_auth_dialog_setup (GtkWidget *dialog,
                        wrong_text = g_strdup (_("The password you entered is invalid"));
                else
                {
-                       int minutes_left = (creds_expiry - time(0)) / 60;
+                       krb5_timestamp now;
+                       int minutes_left;
+
+                       if (krb5_timeofday(kcontext, &now) == 0) {
+                               minutes_left = (creds_expiry - now) / 60;
+                       } else {
+                               minutes_left = 0;
+                       }
 
                        wrong_text = minutes_to_expiry_text (minutes_left);
                }
@@ -160,12 +172,12 @@ krb5_auth_dialog_setup (GtkWidget *dialog,
 }
 
 static krb5_error_code
-krb5_gtk_prompter (krb5_context ctx,
-                   void *data,
-                   const char *name,
-                   const char *banner,
-                   int num_prompts,
-                   krb5_prompt prompts[])
+auth_dialog_prompter (krb5_context ctx,
+                      void *data,
+                      const char *name,
+                      const char *banner,
+                      int num_prompts,
+                      krb5_prompt prompts[])
 {
        GtkWidget *dialog;
        GtkWidget *wrong_label;
@@ -256,6 +268,7 @@ static gboolean
 credentials_expiring_real (void)
 {
        krb5_creds my_creds;
+       krb5_timestamp now;
        gboolean retval = FALSE;
 
        if (!get_tgt_from_ccache (kcontext, &my_creds)) {
@@ -268,7 +281,8 @@ credentials_expiring_real (void)
                krb5_copy_principal(kcontext, my_creds.client, &kprincipal);
        }
        creds_expiry = my_creds.times.endtime;
-       if (time(NULL) + MINUTES_BEFORE_PROMPTING * 60 > my_creds.times.endtime)
+       if ((krb5_timeofday(kcontext, &now) == 0) &&
+           (now + MINUTES_BEFORE_PROMPTING * 60 > my_creds.times.endtime))
                retval = TRUE;
 
        krb5_free_cred_contents(kcontext, &my_creds);
@@ -401,7 +415,7 @@ renew_credentials (void)
        }
 
        retval = krb5_get_init_creds_password(kcontext, &my_creds, kprincipal,
-                                              NULL, krb5_gtk_prompter, NULL,
+                                              NULL, auth_dialog_prompter, NULL,
                                               0, NULL, &opts);
        if (retval)
        {