]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Fix Mac OS X AuthRef authorization (STR #2375)
authormike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Mon, 30 Apr 2007 21:44:43 +0000 (21:44 +0000)
committermike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Mon, 30 Apr 2007 21:44:43 +0000 (21:44 +0000)
git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@6499 7a7537e8-13f0-0310-91df-b6672ffda945

cups/auth.c
cups/globals.c
cups/globals.h
cups/http-private.h
cups/http.c
cups/request.c

index 8ac768852de39179a1b66f32489c5bfaa862b9e2..001ba153d9986fccce76b9810c007d57c67c127b 100644 (file)
@@ -468,17 +468,17 @@ cups_local_auth(http_t *http)             /* I - HTTP connection to server */
   * Delete any previous authorization reference...
   */
   
-  if (cg->auth_ref)
+  if (http->auth_ref)
   {
-    AuthorizationFree(cg->auth_ref, kAuthorizationFlagDefaults);
-    cg->auth_ref = NULL;
+    AuthorizationFree(http->auth_ref, kAuthorizationFlagDefaults);
+    http->auth_ref = NULL;
   }
 
   if (httpGetSubField2(http, HTTP_FIELD_WWW_AUTHENTICATE, "authkey", 
                       auth_key, sizeof(auth_key)))
   {
     status = AuthorizationCreate(NULL, kAuthorizationEmptyEnvironment, 
-                                kAuthorizationFlagDefaults, &cg->auth_ref);
+                                kAuthorizationFlagDefaults, &http->auth_ref);
     if (status != errAuthorizationSuccess)
     {
       DEBUG_printf(("cups_local_auth: AuthorizationCreate() returned %d (%s)\n",
@@ -499,11 +499,11 @@ cups_local_auth(http_t *http)             /* I - HTTP connection to server */
                 kAuthorizationFlagInteractionAllowed | 
                 kAuthorizationFlagExtendRights;
 
-    status = AuthorizationCopyRights(cg->auth_ref, &auth_rights, 
+    status = AuthorizationCopyRights(http->auth_ref, &auth_rights, 
                                     kAuthorizationEmptyEnvironment, 
                                     auth_flags, NULL);
     if (status == errAuthorizationSuccess)
-      status = AuthorizationMakeExternalForm(cg->auth_ref, &auth_extrn);
+      status = AuthorizationMakeExternalForm(http->auth_ref, &auth_extrn);
 
     if (status == errAuthorizationSuccess)
     {
index 661321f373e91173efc13a85f3ca9d2460c637a0..95f305e5127b84ab77fa6b6620b774dc5c439748 100644 (file)
@@ -180,11 +180,6 @@ globals_destructor(void *value)            /* I - Data to free */
 
   cupsFreeOptions(cg->cupsd_num_settings, cg->cupsd_settings);
 
-#ifdef HAVE_AUTHORIZATION_H
-  if (cg->auth_ref)
-    AuthorizationFree(cg->auth_ref, kAuthorizationFlagDefaults);
-#endif /* HAVE_AUTHORIZATION_H */
-
   free(value);
 }
 
index 0b605e999ee458552db2cdf470dddcd0e52400c5..542070b884d8527cc79ac52099263eef80211561 100644 (file)
 #    include <pthread.h>
 #  endif /* HAVE_PTHREAD_H */
 
-#  ifdef HAVE_AUTHORIZATION_H
-#    include <Security/Authorization.h>
-#  endif /* HAVE_AUTHORIZATION_H */
-
 
 /*
  * C++ magic...
@@ -130,11 +126,6 @@ typedef struct _cups_globals_s             /**** CUPS global state data ****/
                                        /* Default printer */
   char                 ppd_filename[HTTP_MAX_URI];
                                        /* PPD filename */
-
-#ifdef HAVE_AUTHORIZATION_H
-  /* auth.c */
-  AuthorizationRef     auth_ref;       /* Authorization ref */
-#endif /* HAVE_AUTHORIZATION_H */
 } _cups_globals_t;
 
 
index 60178e2ad0f6f140fd87589701e020e9100142ee..b3f0717b1bbae939886acd93860dede7fbe4526d 100644 (file)
 #    endif /* !HAVE_GSS_C_NT_HOSTBASED_SERVICE */
 #  endif /* HAVE_GSSAPI */
 
+#  ifdef HAVE_AUTHORIZATION_H
+#    include <Security/Authorization.h>
+#  endif /* HAVE_AUTHORIZATION_H */
+
 #  if defined(__sgi) || (defined(__APPLE__) && !defined(_SOCKLEN_T))
 /*
  * IRIX and MacOS X 10.2.x do not define socklen_t, and in fact use an int instead of
@@ -193,6 +197,9 @@ struct _http_s                              /**** HTTP connection structure. ****/
   gss_ctx_id_t         gssctx;         /* Authentication context @since CUPS 1.3@ */
   gss_name_t           gssname;        /* Authentication server name @since CUPS 1.3@ */
 #  endif /* HAVE_GSSAPI */
+#  ifdef HAVE_AUTHORIZATION_H
+  AuthorizationRef     auth_ref;       /* Authorization ref */
+#  endif /* HAVE_AUTHORIZATION_H */
 };
 
 
index 21849d417491d3eb1c3c5bc8299264b997a1cc89..09e9b5fa7ed9dd375a668bf5aff069dadd92c1f8 100644 (file)
@@ -335,6 +335,11 @@ httpClose(http_t *http)                    /* I - HTTP connection */
     major_status = gss_release_name(&minor_status, &http->gssname);
 #endif /* HAVE_GSSAPI */
 
+#ifdef HAVE_AUTHORIZATION_H
+  if (http->auth_ref)
+    AuthorizationFree(http->auth_ref, kAuthorizationFlagDefaults);
+#endif /* HAVE_AUTHORIZATION_H */
+
   httpClearFields(http);
 
   if (http->authstring && http->authstring != http->_authstring)
@@ -2574,10 +2579,12 @@ http_send(http_t       *http,   /* I - HTTP connection */
   httpClearFields(http);
 
  /*
-  * The Kerberos authentication string can only be used once...
+  * The Kerberos and AuthRef authentication strings can only be used once...
   */
 
-  if (http->authstring && !strncmp(http->authstring, "Negotiate", 9))
+  if (http->authstring && 
+      (!strncmp(http->authstring, "Negotiate", 9) || 
+       !strncmp(http->authstring, "AuthRef", 7)))
   {
     http->_authstring[0] = '\0';
 
index 7b1c86759d8e166a45ac448fa358d9e166db0c9e..55ebe76dab8821d6e2a921a8542f65b60f14a797 100644 (file)
@@ -71,9 +71,6 @@ cupsDoFileRequest(http_t     *http,   /* I - HTTP connection to server */
   int          bytes;                  /* Number of bytes read/written */
   char         buffer[32768];          /* Output buffer */
   http_status_t        expect;                 /* Expect: header to use */
-#ifdef HAVE_AUTHORIZATION_H
-  _cups_globals_t *cg = _cupsGlobals();        /* Global data */
-#endif /* HAVE_AUTHORIZATION_H */
 
 
   DEBUG_printf(("cupsDoFileRequest(%p, %p, \'%s\', \'%s\')\n",
@@ -450,18 +447,6 @@ cupsDoFileRequest(http_t     *http,        /* I - HTTP connection to server */
     }
   }
 
-#ifdef HAVE_AUTHORIZATION_H
- /*
-  * Delete any authorization reference created for this request...
-  */
-  
-  if (cg->auth_ref)
-  {
-    AuthorizationFree(cg->auth_ref, kAuthorizationFlagDefaults);
-    cg->auth_ref = NULL;
-  }
-#endif /* HAVE_AUTHORIZATION_H */
-
   return (response);
 }