]> 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:15:56 +0000 (13:15 -0400)
committerMichael R Sweet <michael.r.sweet@gmail.com>
Mon, 19 Mar 2018 17:15:56 +0000 (13:15 -0400)
cups/ppd-cache.c
doc/help/spec-ppd.html

index efc103b2fe46f210250cfe4672c06084fb578b7b..9b268560d3a98684523c4fba06f331b217483dd3 100644 (file)
@@ -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...
   */
index 85602be268f63946f3298acf3d85c78a9b84b4e9..53f156bb77e8192b11d4f72713a8dc4aca82662f 100644 (file)
@@ -1882,7 +1882,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>