From: Michael R Sweet Date: Mon, 19 Mar 2018 17:15:56 +0000 (-0400) Subject: Include cupsJobPassword keyword in generated PPDs (Issue #5265) X-Git-Tag: v2.3b4~17 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=658c64bf2ed2553121c3679eb24c7beda99a7ddc;p=thirdparty%2Fcups.git Include cupsJobPassword keyword in generated PPDs (Issue #5265) --- diff --git a/cups/ppd-cache.c b/cups/ppd-cache.c index efc103b2fe..9b268560d3 100644 --- a/cups/ppd-cache.c +++ b/cups/ppd-cache.c @@ -3171,6 +3171,41 @@ _ppdCreateFromIPP(char *buffer, /* I - Filename buffer */ httpClose(http); } + /* + * 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 85602be268..53f156bb77 100644 --- a/doc/help/spec-ppd.html +++ b/doc/help/spec-ppd.html @@ -1882,7 +1882,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: