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

Function cupsDoAuthentication

cups/auth.c:107–342  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

105 */
106
107int /* O - 0 on success, -1 on error */
108cupsDoAuthentication(
109 http_t *http, /* I - Connection to server or @code CUPS_HTTP_DEFAULT@ */
110 const char *method, /* I - Request method ("GET", "POST", "PUT") */
111 const char *resource) /* I - Resource path */
112{
113 const char *password, /* Password string */
114 *www_auth, /* WWW-Authenticate header */
115 *schemedata; /* Scheme-specific data */
116 char scheme[256], /* Scheme name */
117 prompt[1024]; /* Prompt for user */
118 int localauth; /* Local authentication result */
119 _cups_globals_t *cg = _cupsGlobals(); /* Global data */
120
121
122 DEBUG_printf(("cupsDoAuthentication(http=%p, method=\"%s\", resource=\"%s\")", (void *)http, method, resource));
123
124 if (!http)
125 http = _cupsConnect();
126
127 if (!http || !method || !resource)
128 return (-1);
129
130 DEBUG_printf(("2cupsDoAuthentication: digest_tries=%d, userpass=\"%s\"",
131 http->digest_tries, http->userpass));
132 DEBUG_printf(("2cupsDoAuthentication: WWW-Authenticate=\"%s\"",
133 httpGetField(http, HTTP_FIELD_WWW_AUTHENTICATE)));
134
135 /*
136 * Clear the current authentication string...
137 */
138
139 httpSetAuthString(http, NULL, NULL);
140
141 /*
142 * See if we can do local authentication...
143 */
144
145 if (http->digest_tries < 3)
146 {
147 if ((localauth = cups_local_auth(http)) == 0)
148 {
149 DEBUG_printf(("2cupsDoAuthentication: authstring=\"%s\"",
150 http->authstring));
151
152 if (http->status == HTTP_STATUS_UNAUTHORIZED)
153 http->digest_tries ++;
154
155 return (0);
156 }
157 else if (localauth == -1)
158 {
159 http->status = HTTP_STATUS_CUPS_AUTHORIZATION_CANCELED;
160 return (-1); /* Error or canceled */
161 }
162 }
163
164 /*

Callers 6

cupsGetFdFunction · 0.85
cupsPutFdFunction · 0.85
mainFunction · 0.85
cupsGetDevicesFunction · 0.85
cupsGetResponseFunction · 0.85
cupsSendRequestFunction · 0.85

Calls 15

_cupsGlobalsFunction · 0.85
_cupsConnectFunction · 0.85
httpGetFieldFunction · 0.85
httpSetAuthStringFunction · 0.85
cups_local_authFunction · 0.85
cups_auth_schemeFunction · 0.85
_cups_strcasecmpFunction · 0.85
httpAddrFamilyFunction · 0.85
httpGetAddressFunction · 0.85
cups_auth_paramFunction · 0.85
cupsLangDefaultFunction · 0.85
cupsSetUserFunction · 0.85

Tested by 1

mainFunction · 0.68