diff options
author | Michael R Sweet <michael.r.sweet@gmail.com> | 2018-03-19 13:18:28 -0400 |
---|---|---|
committer | Michael R Sweet <michael.r.sweet@gmail.com> | 2018-03-19 13:18:28 -0400 |
commit | e8953be3553846e06b5ef2bfbb1068dd6e122c3a (patch) | |
tree | d5ce907ee953d531df5857e7e7cb4fd7b3be15ef /cups | |
parent | 782bcf6974da882c8f5ce38bc27883dc2b701513 (diff) |
Include cupsJobPassword keyword in generated PPDs (Issue #5265)
Diffstat (limited to 'cups')
-rw-r--r-- | cups/ppd-cache.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/cups/ppd-cache.c b/cups/ppd-cache.c index 906a1dfec..d67a19bfe 100644 --- a/cups/ppd-cache.c +++ b/cups/ppd-cache.c @@ -3118,6 +3118,41 @@ _ppdCreateFromIPP(char *buffer, /* I - Filename buffer */ 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... */ |