]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Add cups_is_local_connection() to check if connection is to localhost
authorSamuel Cabrero <scabrero@suse.de>
Tue, 27 Oct 2020 15:11:41 +0000 (16:11 +0100)
committerSamuel Cabrero <scabrero@suse.de>
Tue, 27 Oct 2020 16:30:33 +0000 (17:30 +0100)
Related: #5596

Signed-off-by: Samuel Cabrero <scabrero@suse.de>
cups/auth.c

index f2409350aa7bb8dc2fe1ebc6cf4199efc76e13b3..d2956438de0282d74bc74aa391cc1953210db499 100644 (file)
@@ -90,6 +90,7 @@ static void   cups_gss_printf(OM_uint32 major_status, OM_uint32 minor_status,
 #    define    cups_gss_printf(major, minor, message)
 #  endif /* DEBUG */
 #endif /* HAVE_GSSAPI */
+static int     cups_is_local_connection(http_t *http);
 static int     cups_local_auth(http_t *http);
 
 
@@ -916,6 +917,14 @@ cups_gss_printf(OM_uint32  major_status,/* I - Major status code */
 #  endif /* DEBUG */
 #endif /* HAVE_GSSAPI */
 
+static int                             /* O - 0 if not a local connection */
+                                       /*     1  if local connection */
+cups_is_local_connection(http_t *http) /* I - HTTP connection to server */
+{
+  if (!httpAddrLocalhost(http->hostaddr) && _cups_strcasecmp(http->hostname, "localhost") != 0)
+    return 0;
+  return 1;
+}
 
 /*
  * 'cups_local_auth()' - Get the local authorization certificate if
@@ -958,7 +967,7 @@ cups_local_auth(http_t *http)               /* I - HTTP connection to server */
   * See if we are accessing localhost...
   */
 
-  if (!httpAddrLocalhost(http->hostaddr) && _cups_strcasecmp(http->hostname, "localhost") != 0)
+  if (!cups_is_local_connection(http))
   {
     DEBUG_puts("8cups_local_auth: Not a local connection!");
     return (1);