MCPcopy Create free account
hub / github.com/OpenPrinting/cups / cups_local_auth

Function cups_local_auth

cups/auth.c:956–1154  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

954 */
955
956static int /* O - 0 if available */
957 /* 1 if not available */
958 /* -1 error */
959cups_local_auth(http_t *http) /* I - HTTP connection to server */
960{
961#if !_WIN32 && !__EMX__ && defined(AF_LOCAL)
962 int pid; /* Current process ID */
963 FILE *fp; /* Certificate file */
964 char trc[16], /* Try Root Certificate parameter */
965 filename[1024]; /* Certificate filename */
966 const char *www_auth, /* WWW-Authenticate header */
967 *schemedata; /* Data for the named auth scheme */
968 _cups_globals_t *cg = _cupsGlobals(); /* Global data */
969# if defined(HAVE_AUTHORIZATION_H)
970 OSStatus status; /* Status */
971 AuthorizationItem auth_right; /* Authorization right */
972 AuthorizationRights auth_rights; /* Authorization rights */
973 AuthorizationFlags auth_flags; /* Authorization flags */
974 AuthorizationExternalForm auth_extrn; /* Authorization ref external */
975 char auth_key[1024]; /* Buffer */
976 char buffer[1024]; /* Buffer */
977# endif /* HAVE_AUTHORIZATION_H */
978
979
980 DEBUG_printf(("7cups_local_auth(http=%p) hostaddr=%s, hostname=\"%s\"", (void *)http, httpAddrString(http->hostaddr, filename, sizeof(filename)), http->hostname));
981
982 /*
983 * See if we are accessing localhost...
984 */
985
986 if (httpAddrFamily(httpGetAddress(http)) != AF_LOCAL)
987 {
988 DEBUG_puts("8cups_local_auth: Not a local connection!");
989 return (1);
990 }
991
992 www_auth = httpGetField(http, HTTP_FIELD_WWW_AUTHENTICATE);
993
994# if defined(HAVE_AUTHORIZATION_H)
995 /*
996 * Delete any previous authorization reference...
997 */
998
999 if (http->auth_ref)
1000 {
1001 AuthorizationFree(http->auth_ref, kAuthorizationFlagDefaults);
1002 http->auth_ref = NULL;
1003 }
1004
1005 if (!getenv("GATEWAY_INTERFACE") && (schemedata = cups_auth_find(www_auth, "AuthRef")) != NULL && cups_auth_param(schemedata, "key", auth_key, sizeof(auth_key)))
1006 {
1007 status = AuthorizationCreate(NULL, kAuthorizationEmptyEnvironment, kAuthorizationFlagDefaults, &http->auth_ref);
1008 if (status != errAuthorizationSuccess)
1009 {
1010 DEBUG_printf(("8cups_local_auth: AuthorizationCreate() returned %d",
1011 (int)status));
1012 return (-1);
1013 }

Callers 1

cupsDoAuthenticationFunction · 0.85

Calls 10

_cupsGlobalsFunction · 0.85
httpAddrStringFunction · 0.85
httpAddrFamilyFunction · 0.85
httpGetAddressFunction · 0.85
httpGetFieldFunction · 0.85
cups_auth_findFunction · 0.85
cups_auth_paramFunction · 0.85
httpEncode64_2Function · 0.85
httpSetAuthStringFunction · 0.85
cupsUserFunction · 0.85

Tested by

no test coverage detected