[gtk+/gtk-2-24] print dialog: Fix authentication logic



commit 85825ebaf2c16bb48602d5d3ced5e9ecd6605852
Author: Jan RÄkorajski <baggins pld-linux org>
Date:   Wed Dec 14 14:09:48 2011 +0100

    print dialog: Fix authentication logic
    
    Reset state of CUPS requests correctly during authentization and
    check CUPS requests for errors.
    Don't initialize variables holding password and username with empty
    string (#664640).

 modules/printbackends/cups/gtkcupsutils.c |   15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)
---
diff --git a/modules/printbackends/cups/gtkcupsutils.c b/modules/printbackends/cups/gtkcupsutils.c
index 9fe79d1..4a3f0ad 100644
--- a/modules/printbackends/cups/gtkcupsutils.c
+++ b/modules/printbackends/cups/gtkcupsutils.c
@@ -273,6 +273,9 @@ gtk_cups_request_read_write (GtkCupsRequest *request, gboolean connect_only)
       else if (request->type == GTK_CUPS_GET)
         get_states[request->state] (request);
 
+      if (gtk_cups_result_is_error (request->result))
+        request->state = GTK_CUPS_REQUEST_DONE;
+
       if (request->attempts > _GTK_CUPS_MAX_ATTEMPTS &&
           request->state != GTK_CUPS_REQUEST_DONE)
         {
@@ -926,8 +929,8 @@ _get_auth (GtkCupsRequest *request)
  * The callback sets cups_password to NULL to signal that the 
  * password has been used.
  */
-static char *cups_password;
-static char *cups_username;
+static char *cups_password = NULL;
+static char *cups_username = NULL;
 
 static const char *
 passwordCB (const char *prompt)
@@ -963,6 +966,7 @@ _post_check (GtkCupsRequest *request)
 
       if (request->password_state == GTK_CUPS_PASSWORD_APPLIED)
         {
+          request->poll_state = GTK_CUPS_HTTP_IDLE;
           request->password_state = GTK_CUPS_PASSWORD_NOT_VALID;
           request->state = GTK_CUPS_POST_AUTH;
           request->need_password = TRUE;
@@ -980,7 +984,6 @@ _post_check (GtkCupsRequest *request)
         {
           if (request->password_state == GTK_CUPS_PASSWORD_NONE)
             {
-              cups_password = g_strdup ("");
               cups_username = request->username;
               cupsSetPasswordCB (passwordCB);
 
@@ -992,6 +995,7 @@ _post_check (GtkCupsRequest *request)
                   /* move to AUTH state to let the backend 
                    * ask for a password
                    */ 
+                  request->poll_state = GTK_CUPS_HTTP_IDLE;
                   request->state = GTK_CUPS_POST_AUTH;
                   request->need_password = TRUE;
 
@@ -1257,6 +1261,7 @@ _get_check (GtkCupsRequest *request)
 
       if (request->password_state == GTK_CUPS_PASSWORD_APPLIED)
         {
+          request->poll_state = GTK_CUPS_HTTP_IDLE;
           request->password_state = GTK_CUPS_PASSWORD_NOT_VALID;
           request->state = GTK_CUPS_GET_AUTH;
           request->need_password = TRUE;
@@ -1274,7 +1279,6 @@ _get_check (GtkCupsRequest *request)
         {
           if (request->password_state == GTK_CUPS_PASSWORD_NONE)
             {
-              cups_password = g_strdup ("");
               cups_username = request->username;
               cupsSetPasswordCB (passwordCB);
 
@@ -1286,6 +1290,7 @@ _get_check (GtkCupsRequest *request)
                   /* move to AUTH state to let the backend
                    * ask for a password
                    */
+                  request->poll_state = GTK_CUPS_HTTP_IDLE;
                   request->state = GTK_CUPS_GET_AUTH;
                   request->need_password = TRUE;
 
@@ -1332,7 +1337,7 @@ _get_check (GtkCupsRequest *request)
           return;
         }
 
-      request->state = GTK_CUPS_GET_SEND;
+      request->state = GTK_CUPS_GET_CONNECT;
       request->last_status = HTTP_CONTINUE;
 
      return;



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