| 11873 | */ |
| 11874 | |
| 11875 | static int /* O - 1 if permitted, 0 otherwise */ |
| 11876 | validate_user(cupsd_job_t *job, /* I - Job */ |
| 11877 | cupsd_client_t *con, /* I - Client connection */ |
| 11878 | const char *owner, /* I - Owner of job/resource */ |
| 11879 | char *username, /* O - Authenticated username */ |
| 11880 | size_t userlen) /* I - Length of username */ |
| 11881 | { |
| 11882 | cupsd_printer_t *printer; /* Printer for job */ |
| 11883 | |
| 11884 | |
| 11885 | cupsdLogMessage(CUPSD_LOG_DEBUG2, "validate_user(job=%d, con=%d, owner=\"%s\", username=%p, userlen=" CUPS_LLFMT ")", job->id, con ? con->number : 0, owner ? owner : "(null)", (void *)username, CUPS_LLCAST userlen); |
| 11886 | |
| 11887 | /* |
| 11888 | * Validate input... |
| 11889 | */ |
| 11890 | |
| 11891 | if (!con || !owner || !username || userlen <= 0) |
| 11892 | return (0); |
| 11893 | |
| 11894 | /* |
| 11895 | * Get the best authenticated username that is available. |
| 11896 | */ |
| 11897 | |
| 11898 | strlcpy(username, get_username(con), userlen); |
| 11899 | |
| 11900 | /* |
| 11901 | * Check the username against the owner... |
| 11902 | */ |
| 11903 | |
| 11904 | printer = cupsdFindDest(job->dest); |
| 11905 | |
| 11906 | return (cupsdCheckPolicy(printer ? printer->op_policy_ptr : DefaultPolicyPtr, |
| 11907 | con, owner) == HTTP_OK); |
| 11908 | } |
no test coverage detected