http_status_t /* I - 1 if OK, 0 otherwise */ cupsdCheckPolicy(cupsd_policy_t *p, /* I - Policy */ cupsd_client_t *con, /* I - Client connection */ const char *owner) /* I - Owner of object */ { cupsd_location_t *po; /* Current policy operation */ /* * Range check... */ if (!p || !con) { cupsdLogMessage(CUPSD_LOG_CRIT, "cupsdCheckPolicy: p=%p, con=%p!", p, con); return ((http_status_t)0); } /* * Find a match for the operation... */ if ((po = cupsdFindPolicyOp(p, con->request->request.op.operation_id)) == NULL) { cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdCheckPolicy: No matching operation, returning 0!"); return ((http_status_t)0); } con->best = po; /* * Return the status of the check... */ return (cupsdIsAuthorized(con, owner)); }
static char * /* O - String or NULL if none */ get_auth_info_required( cupsd_printer_t *p, /* I - Printer */ char *buffer, /* I - Value buffer */ size_t bufsize) /* I - Size of value buffer */ { cupsd_location_t *auth; /* Pointer to authentication element */ char resource[1024]; /* Printer/class resource path */ /* * If auth-info-required is set for this printer, return that... */ if (p->num_auth_info_required > 0 && strcmp(p->auth_info_required[0], "none")) { int i; /* Looping var */ char *bufptr; /* Pointer into buffer */ for (i = 0, bufptr = buffer; i < p->num_auth_info_required; i ++) { if (bufptr >= (buffer + bufsize - 2)) break; if (i) *bufptr++ = ','; strlcpy(bufptr, p->auth_info_required[i], bufsize - (size_t)(bufptr - buffer)); bufptr += strlen(bufptr); } return (buffer); } /* * Figure out the authentication data requirements to advertise... */ if (p->type & CUPS_PRINTER_CLASS) snprintf(resource, sizeof(resource), "/classes/%s", p->name); else snprintf(resource, sizeof(resource), "/printers/%s", p->name); if ((auth = cupsdFindBest(resource, HTTP_POST)) == NULL || auth->type == CUPSD_AUTH_NONE) auth = cupsdFindPolicyOp(p->op_policy_ptr, IPP_PRINT_JOB); if (auth) { int auth_type; /* Authentication type */ if ((auth_type = auth->type) == CUPSD_AUTH_DEFAULT) auth_type = cupsdDefaultAuthType(); switch (auth_type) { case CUPSD_AUTH_NONE : return (NULL); case CUPSD_AUTH_NEGOTIATE : strlcpy(buffer, "negotiate", bufsize); break; default : strlcpy(buffer, "username,password", bufsize); break; } return (buffer); } return ("none"); }