]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Include cupsJobPassword keyword in generated PPDs (Issue #5265)
authorMichael R Sweet <michael.r.sweet@gmail.com>
Mon, 19 Mar 2018 17:18:28 +0000 (13:18 -0400)
committerMichael R Sweet <michael.r.sweet@gmail.com>
Mon, 19 Mar 2018 17:18:28 +0000 (13:18 -0400)
CHANGES.md
cups/ppd-cache.c
doc/help/spec-ppd.html

index 025d33d977910769809bb73eefe5f3e2a68fb187..39d8567a06f49ba14ae6ad2ccd301afaa86bf5c2 100644 (file)
@@ -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
index 906a1dfec1b08ee66ff60e28b972183f962e76b0..d67a19bfeb2c9985d70f3123303d8fa26d6ffb7d 100644 (file)
@@ -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...
   */
index 06f5769a844d773850643b0f13b545c161ace322..3b7c783629ef167ce2667956d216af63b23982d0 100644 (file)
@@ -1758,7 +1758,20 @@ http://www.vendor.com/help"
 
 <p class='summary'>*cupsJobPassword: "format"</p>
 
-<p>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.</p>
+<p>This keyword defines the format of the "job-password" IPP attribute, if supported by the printer. The following format characters are supported:</p>
+
+<ul>
+       <li><code>1</code>: US ASCII digits.</li>
+       <li><code>A</code>: US ASCII letters.</li>
+       <li><code>C</code>: US ASCII letters, numbers, and punctuation.</li>
+       <li><code>.</code>: Any US ASCII printable character (0x20 to 0x7e).</li>
+       <li><code>N</code>: Any Unicode digit character.</li>
+       <li><code>U</code>: Any Unicode letter character.</li>
+       <li><code>*</code>: Any Unicode (utf-8) character.</li>
+</ul>
+
+<p>The format characters are repeated to indicate the length of the
+password string.  For example, "1111" indicated a 4-digit US ASCII PIN code.</p>
 
 <p>Example:</p>