From e8953be3553846e06b5ef2bfbb1068dd6e122c3a Mon Sep 17 00:00:00 2001 From: Michael R Sweet Date: Mon, 19 Mar 2018 13:18:28 -0400 Subject: [PATCH] Include cupsJobPassword keyword in generated PPDs (Issue #5265) --- CHANGES.md | 4 +++- cups/ppd-cache.c | 35 +++++++++++++++++++++++++++++++++++ doc/help/spec-ppd.html | 15 ++++++++++++++- 3 files changed, 52 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 025d33d977..39d8567a06 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,10 +1,12 @@ -CHANGES - 2.2.7 - 2018-03-12 +CHANGES - 2.2.7 - 2018-03-19 ============================ Changes in CUPS v2.2.7 ---------------------- +- The IPP Everywhere PPD generator did not include the `cupsJobPassword` + keyword, when supported (Issue #5265) - Systemd did not restart cupsd when configuration changes were made that required a restart (Issue #5263) - The Lexmark Optra E310 printer needs the "no-reattach" USB quirk rule diff --git a/cups/ppd-cache.c b/cups/ppd-cache.c index 906a1dfec1..d67a19bfeb 100644 --- a/cups/ppd-cache.c +++ b/cups/ppd-cache.c @@ -3117,6 +3117,41 @@ _ppdCreateFromIPP(char *buffer, /* I - Filename buffer */ cupsFilePuts(fp, "*cupsSNMPSupplies: False\n"); cupsFilePuts(fp, "*cupsLanguages: \"en\"\n"); + /* + * Password/PIN printing... + */ + + if ((attr = ippFindAttribute(response, "job-password-supported", IPP_TAG_INTEGER)) != NULL) + { + char pattern[33]; /* Password pattern */ + int maxlen = ippGetInteger(attr, 0); + /* Maximum length */ + const char *repertoire = ippGetString(ippFindAttribute(response, "job-password-repertoire-configured", IPP_TAG_KEYWORD), 0, NULL); + /* Type of password */ + + if (maxlen > (int)(sizeof(pattern) - 1)) + maxlen = sizeof(pattern) - 1; + + if (!repertoire || !strcmp(repertoire, "iana_us-ascii_digits")) + memset(pattern, '1', maxlen); + else if (!strcmp(repertoire, "iana_us-ascii_letters")) + memset(pattern, 'A', maxlen); + else if (!strcmp(repertoire, "iana_us-ascii_complex")) + memset(pattern, 'C', maxlen); + else if (!strcmp(repertoire, "iana_us-ascii_any")) + memset(pattern, '.', maxlen); + else if (!strcmp(repertoire, "iana_utf-8_digits")) + memset(pattern, 'N', maxlen); + else if (!strcmp(repertoire, "iana_utf-8_letters")) + memset(pattern, 'U', maxlen); + else + memset(pattern, '*', maxlen); + + pattern[maxlen] = '\0'; + + cupsFilePrintf(fp, "*cupsPassword: \"%s\"\n", pattern); + } + /* * Filters... */ diff --git a/doc/help/spec-ppd.html b/doc/help/spec-ppd.html index 06f5769a84..3b7c783629 100644 --- a/doc/help/spec-ppd.html +++ b/doc/help/spec-ppd.html @@ -1758,7 +1758,20 @@ http://www.vendor.com/help"

*cupsJobPassword: "format"

-

This keyword defines the format of the job-password IPP attribute, if supported by the printer. Currently the only supported format is "1111" indicating a 4-digit PIN code.

+

This keyword defines the format of the "job-password" IPP attribute, if supported by the printer. The following format characters are supported:

+ + + +

The format characters are repeated to indicate the length of the +password string. For example, "1111" indicated a 4-digit US ASCII PIN code.

Example:

-- 2.47.3