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

Function password_cb

backend/ipp.c:3036–3088  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3034 */
3035
3036static const char * /* O - Password */
3037password_cb(const char *prompt, /* I - Prompt (not used) */
3038 http_t *http, /* I - Connection */
3039 const char *method, /* I - Request method (not used) */
3040 const char *resource, /* I - Resource path (not used) */
3041 int *password_tries) /* I - Password tries */
3042{
3043 char def_username[HTTP_MAX_VALUE]; /* Default username */
3044
3045
3046 fprintf(stderr, "DEBUG: password_cb(prompt=\"%s\", http=%p, method=\"%s\", "
3047 "resource=\"%s\", password_tries=%p(%d)), device_password=%p\n",
3048 prompt, (void *)http, method, resource, (void *)password_tries, *password_tries,
3049 (void *)device_password);
3050
3051 (void)prompt;
3052 (void)method;
3053 (void)resource;
3054
3055 if (!uri_credentials)
3056 {
3057 /*
3058 * Remember that we need to authenticate...
3059 */
3060
3061 if (httpGetSubField(http, HTTP_FIELD_WWW_AUTHENTICATE, "username",
3062 def_username))
3063 {
3064 char quoted[HTTP_MAX_VALUE * 2 + 4];
3065 /* Quoted string */
3066
3067 fprintf(stderr, "ATTR: auth-info-default=%s,\n",
3068 quote_string(def_username, quoted, sizeof(quoted)));
3069 }
3070 }
3071
3072 if (device_password && *device_password && *password_tries < 3)
3073 {
3074 (*password_tries) ++;
3075
3076 cupsSetUser(device_username);
3077
3078 return (device_password);
3079 }
3080 else
3081 {
3082 /*
3083 * Give up after 3 tries or if we don't have a password to begin with...
3084 */
3085
3086 return (NULL);
3087 }
3088}
3089
3090
3091/*

Callers

nothing calls this directly

Calls 3

httpGetSubFieldFunction · 0.85
cupsSetUserFunction · 0.85
quote_stringFunction · 0.70

Tested by

no test coverage detected