11/*
22 * Authentication functions for CUPS.
33 *
4- * Copyright © 2020-2024 by OpenPrinting.
4+ * Copyright © 2020-2026 by OpenPrinting.
55 * Copyright © 2007-2019 by Apple Inc.
66 * Copyright © 1997-2007 by Easy Software Products.
77 *
@@ -92,7 +92,6 @@ static void cups_gss_printf(OM_uint32 major_status, OM_uint32 minor_status,
9292# define cups_gss_printf (major , minor , message )
9393# endif /* DEBUG */
9494#endif /* HAVE_GSSAPI */
95- static int cups_is_local_connection (http_t * http );
9695static int cups_local_auth (http_t * http );
9796
9897
@@ -948,14 +947,6 @@ cups_gss_printf(OM_uint32 major_status,/* I - Major status code */
948947# endif /* DEBUG */
949948#endif /* HAVE_GSSAPI */
950949
951- static int /* O - 0 if not a local connection */
952- /* 1 if local connection */
953- cups_is_local_connection (http_t * http ) /* I - HTTP connection to server */
954- {
955- if (!httpAddrLocalhost (http -> hostaddr ) && _cups_strcasecmp (http -> hostname , "localhost" ) != 0 )
956- return 0 ;
957- return 1 ;
958- }
959950
960951/*
961952 * 'cups_local_auth()' - Get the local authorization certificate if
@@ -967,13 +958,7 @@ static int /* O - 0 if available */
967958 /* -1 error */
968959cups_local_auth (http_t * http ) /* I - HTTP connection to server */
969960{
970- #if defined(_WIN32 ) || defined(__EMX__ )
971- /*
972- * Currently _WIN32 and OS-2 do not support the CUPS server...
973- */
974-
975- return (1 );
976- #else
961+ #if !_WIN32 && !__EMX__ && defined(AF_LOCAL )
977962 int pid ; /* Current process ID */
978963 FILE * fp ; /* Certificate file */
979964 char trc [16 ], /* Try Root Certificate parameter */
@@ -998,7 +983,7 @@ cups_local_auth(http_t *http) /* I - HTTP connection to server */
998983 * See if we are accessing localhost...
999984 */
1000985
1001- if (! cups_is_local_connection ( http ))
986+ if (httpAddrFamily ( httpGetAddress ( http )) != AF_LOCAL )
1002987 {
1003988 DEBUG_puts ("8cups_local_auth: Not a local connection!" );
1004989 return (1 );
@@ -1072,15 +1057,14 @@ cups_local_auth(http_t *http) /* I - HTTP connection to server */
10721057 }
10731058# endif /* HAVE_AUTHORIZATION_H */
10741059
1075- # if defined( SO_PEERCRED ) && defined( AF_LOCAL )
1060+ # ifdef SO_PEERCRED
10761061 /*
10771062 * See if we can authenticate using the peer credentials provided over a
10781063 * domain socket; if so, specify "PeerCred username" as the authentication
10791064 * information...
10801065 */
10811066
1082- if (http -> hostaddr -> addr .sa_family == AF_LOCAL &&
1083- !getenv ("GATEWAY_INTERFACE" ) && /* Not via CGI programs... */
1067+ if (!getenv ("GATEWAY_INTERFACE" ) && /* Not via CGI programs... */
10841068 cups_auth_find (www_auth , "PeerCred" ))
10851069 {
10861070 /*
@@ -1104,7 +1088,7 @@ cups_local_auth(http_t *http) /* I - HTTP connection to server */
11041088 return (0 );
11051089 }
11061090 }
1107- # endif /* SO_PEERCRED && AF_LOCAL */
1091+ # endif /* SO_PEERCRED */
11081092
11091093 if ((schemedata = cups_auth_find (www_auth , "Local" )) == NULL )
11101094 return (1 );
@@ -1164,7 +1148,7 @@ cups_local_auth(http_t *http) /* I - HTTP connection to server */
11641148 return (0 );
11651149 }
11661150 }
1151+ #endif /* !_WIN32 && !__EMX__ && AF_LOCAL */
11671152
11681153 return (1 );
1169- #endif /* _WIN32 || __EMX__ */
11701154}
0 commit comments