]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Fix authentication issues.
authorMichael R Sweet <michaelrsweet@gmail.com>
Fri, 15 Dec 2017 05:03:21 +0000 (00:03 -0500)
committerMichael R Sweet <michaelrsweet@gmail.com>
Fri, 15 Dec 2017 05:03:21 +0000 (00:03 -0500)
cups/auth.c
scheduler/client.c

index 953fe900c0e0eba439ff1d89fdb1d496f80d9edb..f545b2331d7c623c986b6bfa678fcf5daeaa5de9 100644 (file)
@@ -597,14 +597,18 @@ cups_auth_find(const char *www_authenticate,      /* I - Pointer into WWW-Authenticat
   size_t       schemelen = strlen(scheme);     /* Length of scheme */
 
 
+  DEBUG_printf(("8cups_auth_find(www_authenticate=\"%s\", scheme=\"%s\"(%d))", www_authenticate, scheme, (int)schemelen));
+
   while (*www_authenticate)
   {
    /*
     * Skip leading whitespace and commas...
     */
 
+    DEBUG_printf(("9cups_auth_find: Before whitespace: \"%s\"", www_authenticate));
     while (isspace(*www_authenticate & 255) || *www_authenticate == ',')
       www_authenticate ++;
+    DEBUG_printf(("9cups_auth_find: After whitespace: \"%s\"", www_authenticate));
 
    /*
     * See if this is "Scheme" followed by whitespace or the end of the string.
@@ -616,6 +620,8 @@ cups_auth_find(const char *www_authenticate,        /* I - Pointer into WWW-Authenticat
       * Yes, this is the start of the scheme-specific information...
       */
 
+      DEBUG_printf(("9cups_auth_find: Returning \"%s\".", www_authenticate));
+
       return (www_authenticate);
     }
 
@@ -631,14 +637,21 @@ cups_auth_find(const char *www_authenticate,      /* I - Pointer into WWW-Authenticat
         * Skip quoted value...
         */
 
-        while (www_authenticate[1] && www_authenticate[1] != '\"')
+        www_authenticate ++;
+        while (*www_authenticate && *www_authenticate != '\"')
           www_authenticate ++;
+
+        DEBUG_printf(("9cups_auth_find: After quoted: \"%s\"", www_authenticate));
       }
 
       www_authenticate ++;
     }
+
+    DEBUG_printf(("9cups_auth_find: After skip: \"%s\"", www_authenticate));
   }
 
+  DEBUG_puts("9cups_auth_find: Returning NULL.");
+
   return (NULL);
 }
 
@@ -660,6 +673,8 @@ cups_auth_param(const char *scheme,         /* I - Pointer to auth data */
   int          param;                          /* Is this a parameter? */
 
 
+  DEBUG_printf(("8cups_auth_param(scheme=\"%s\", name=\"%s\", value=%p, valsize=%d)", scheme, name, (void *)value, (int)valsize));
+
   while (!isspace(*scheme & 255) && *scheme)
     scheme ++;
 
@@ -700,6 +715,8 @@ cups_auth_param(const char *scheme,         /* I - Pointer to auth data */
 
       *valptr = '\0';
 
+      DEBUG_printf(("9cups_auth_param: Returning \"%s\".", value));
+
       return (value);
     }
 
@@ -719,7 +736,8 @@ cups_auth_param(const char *scheme,         /* I - Pointer to auth data */
         * Skip quoted value...
         */
 
-        while (scheme[1] && scheme[1] != '\"')
+        scheme ++;
+        while (*scheme && *scheme != '\"')
           scheme ++;
       }
 
@@ -737,6 +755,8 @@ cups_auth_param(const char *scheme,         /* I - Pointer to auth data */
 
   *value = '\0';
 
+  DEBUG_puts("9cups_auth_param: Returning NULL.");
+
   return (NULL);
 }
 
@@ -760,6 +780,8 @@ cups_auth_scheme(const char *www_authenticate,      /* I - Pointer into WWW-Authentic
   int          param;                          /* Is this a parameter? */
 
 
+  DEBUG_printf(("8cups_auth_scheme(www_authenticate=\"%s\", scheme=%p, schemesize=%d)", www_authenticate, (void *)scheme, (int)schemesize));
+
   while (*www_authenticate)
   {
    /*
@@ -785,7 +807,8 @@ cups_auth_scheme(const char *www_authenticate,      /* I - Pointer into WWW-Authentic
         * Skip quoted value...
         */
 
-        while (www_authenticate[1] && www_authenticate[1] != '\"')
+        www_authenticate ++;
+        while (*www_authenticate && *www_authenticate != '\"')
           www_authenticate ++;
       }
     }
@@ -793,12 +816,17 @@ cups_auth_scheme(const char *www_authenticate,    /* I - Pointer into WWW-Authentic
     if (sptr > scheme && !param)
     {
       *sptr = '\0';
+
+      DEBUG_printf(("9cups_auth_scheme: Returning \"%s\".", start));
+
       return (start);
     }
   }
 
   *scheme = '\0';
 
+  DEBUG_puts("9cups_auth_scheme: Returning NULL.");
+
   return (NULL);
 }
 
@@ -1027,7 +1055,7 @@ cups_local_auth(http_t *http)             /* I - HTTP connection to server */
     http->auth_ref = NULL;
   }
 
-  if (!getenv("GATEWAY_INTERFACE") && (schemedata = cups_auth_find(www_auth, "AuthKey")) != NULL && cups_auth_param(schemedata, "key", auth_key, sizeof(auth_key)))
+  if (!getenv("GATEWAY_INTERFACE") && (schemedata = cups_auth_find(www_auth, "AuthRef")) != NULL && cups_auth_param(schemedata, "key", auth_key, sizeof(auth_key)))
   {
     status = AuthorizationCreate(NULL, kAuthorizationEmptyEnvironment, kAuthorizationFlagDefaults, &http->auth_ref);
     if (status != errAuthorizationSuccess)
@@ -1088,7 +1116,7 @@ cups_local_auth(http_t *http)             /* I - HTTP connection to server */
     return (1);
 #  endif /* HAVE_GSSAPI */
 #  ifdef HAVE_AUTHORIZATION_H
-  if (cups_auth_find(www_auth, "AuthKey"))
+  if (cups_auth_find(www_auth, "AuthRef"))
     return (1);
 #  endif /* HAVE_AUTHORIZATION_H */
 
index 0fd724daea10c6630d4dfaea58ef4c5e5dd42b8f..775265a8940c87533d7bf70bd11f59928e2f6352 100644 (file)
@@ -2390,6 +2390,8 @@ cupsdSendHeader(
            name;
           name = (char *)cupsArrayNext(con->best->names))
       {
+        cupsdLogClient(con, CUPSD_LOG_DEBUG2, "cupsdSendHeader: require \"%s\"", name);
+
 #ifdef HAVE_AUTHORIZATION_H
        if (!_cups_strncasecmp(name, "@AUTHKEY(", 9))
        {
@@ -2415,7 +2417,7 @@ cupsdSendHeader(
       }
 
       if (need_local)
-       strlcpy(auth_key, ", Local", auth_size);
+       strlcat(auth_key, ", Local", auth_size);
     }
 
     if (auth_str[0])