OpenPrinting / cups

OpenPrinting CUPS Sources
https://openprinting.github.io/cups
Apache License 2.0
958 stars 174 forks source link

Ignores job-originating-host-name #916

Closed psz2036 closed 3 months ago

psz2036 commented 3 months ago

CUPS ignores (overrides) the value of job-originating-host-name sent. Issue observed at version 2.4.2 in Debian bookworm, present still in current "master" version. Patch tested against Debian, but for current version, below (in plain-text and as attached file).

Cheers, Paul

Paul Szabo psz@maths.usyd.edu.au www.maths.usyd.edu.au/u/psz School of Mathematics and Statistics University of Sydney Australia

--- scheduler/ipp.c.ORIG    2024-03-31 07:47:17.630302410 +1100
+++ scheduler/ipp.c 2024-03-31 07:49:31.802244933 +1100
@@ -1635,9 +1635,20 @@
     * Request contains a job-originating-host-name attribute; validate it...
     */

+   /*
+    * PSz 18 Mar 24
+    * Override if the value is clearly wrong or impossible, or if
+    * the value is "localhost" but relative to some remote machine.
+    * Do not override just because we are not talking to localhost;
+    * in particular, keep and treasure the value sent to us from
+    * some intermediate or proxy server.
+    *if (attr->value_tag != IPP_TAG_NAME ||
+    *    attr->num_values != 1 ||
+    *    strcmp(con->http->hostname, "localhost"))
+    */
     if (attr->value_tag != IPP_TAG_NAME ||
         attr->num_values != 1 ||
-        strcmp(con->http->hostname, "localhost"))
+        !strcmp(attr->values[0].string.text, "localhost"))
     {
      /*
       * Can't override the value if we aren't connected via localhost.

psz-patch.txt

michaelrsweet commented 3 months ago

No. The intent of this feature is to allow a local proxy (cups-lpd, samba, etc.) to pass through the hostname from its remote connection. Changing things like this makes the value of job-originating-host-name less valid.

psz2036 commented 3 months ago

I knew that was your intent, but your code did not do that. Your code, your bug.