From: Michael R Sweet Date: Wed, 16 Apr 2025 16:29:03 +0000 (-0400) Subject: Set job-originating-user-xxx attributes using OAuth values when possible (Issue ... X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c6de7afd3a864efd928d65ea0a3618cb9d38b4a7;p=thirdparty%2Fcups.git Set job-originating-user-xxx attributes using OAuth values when possible (Issue #246) --- diff --git a/scheduler/ipp.c b/scheduler/ipp.c index 6c49fe408d..a4997f1fe6 100644 --- a/scheduler/ipp.c +++ b/scheduler/ipp.c @@ -1524,7 +1524,14 @@ add_job(cupsd_client_t *con, /* I - Client connection */ add_job_uuid(job); apply_printer_defaults(printer, job); - if (con->username[0]) + if (con->realname[0]) + { + cupsdSetString(&job->username, con->realname); + + if (attr) + ippSetString(job->attrs, &attr, 0, con->realname); + } + else if (con->username[0]) { cupsdSetString(&job->username, con->username); @@ -1541,14 +1548,20 @@ add_job(cupsd_client_t *con, /* I - Client connection */ cupsdSetString(&job->username, "anonymous"); if (!attr) - ippAddString(job->attrs, IPP_TAG_JOB, IPP_TAG_NAME, - "job-originating-user-name", NULL, job->username); + { + ippAddString(job->attrs, IPP_TAG_JOB, IPP_TAG_NAME, "job-originating-user-name", NULL, job->username); + } else { ippSetGroupTag(job->attrs, &attr, IPP_TAG_JOB); ippSetName(job->attrs, &attr, "job-originating-user-name"); } + if (con->email[0]) + ippAddStringf(job->attrs, IPP_TAG_JOB, IPP_TAG_URI, "job-originating-user-uri", NULL, "mailto:", con->email); + else + ippAddStringf(job->attrs, IPP_TAG_JOB, IPP_TAG_URI, "job-originating-user-uri", NULL, "urn:sub:", con->username); + if (con->username[0] || auth_info) { save_auth_info(con, job, auth_info); @@ -7827,7 +7840,9 @@ get_username(cupsd_client_t *con) /* I - Connection */ ipp_attribute_t *attr; /* Attribute */ - if (con->username[0]) + if (con->realname[0]) + return (con->realname); + else if (con->username[0]) return (con->username); else if ((attr = ippFindAttribute(con->request, "requesting-user-name", IPP_TAG_NAME)) != NULL)