apple / cups

Apple CUPS Sources
https://www.cups.org
Apache License 2.0
1.96k stars 464 forks source link

mime.types fix for long PJL headers using rastertohp #2386

Closed michaelrsweet closed 14 years ago

michaelrsweet commented 17 years ago

Version: 1.1.19 CUPS.org User: twaugh.redhat

This patch (made originally against 1.1.22 but still needed) extends the search area for skipping PJL headers to 2048 bytes. This seems to be needed for some files.

michaelrsweet commented 17 years ago

CUPS.org User: pipitas

Setting one option unsets the other. Here is the patch.

I was about to fill in a similar thing in an STR, when I discovered this report. (But to me it does not look as clean-cut as "setting one option unsets the other"). Since I've already wrote up the thingie in my hotel room last night, I'll just copy it here, because I think it provides additional information:

------------- snip ------------------------------------------------------

The web interface configuration of "Basic Server Settings" does not work reliably for CUPS 1.2.11. (I'm using openSUSE-made packages for 10.2, provided by http://software.opensuse.org/download/Printing/openSUSE_10.2/).

I started playing with the web interface options on the localhost:631/admin page. I clicked "Edit Configuration File", then "Use Default Configuration File" and "Save Changes". (Which probably means that I now have the original CUPS-provided file, unless SUSE packagers have fiddled with that [which I think is unlikely]).

It comes back with these settings in the web interface:

[x] Show printers shared by other systems [ ] Share published printers connected to this system [ ] Allow remote administration [ ] Allow users to cancel any job (not just their own) [ ] Save debugging information for troubleshooting

(which I will name "settings=10000" for brevity from now on). If change these settings to these:

[x] Show printers shared by other systems [x] Share published printers connected to this system [x] Allow remote administration [ ] Allow users to cancel any job (not just their own) [x] Save debugging information for troubleshooting

(which I will name "settings=11101") after the cupsd restart, they return like this:

[ ] Show printers shared by other systems [x] Share published printers connected to this system [x] Allow remote administration [ ] Allow users to cancel any job (not just their own) [x] Save debugging information for troubleshooting

("settings=01101"). Since this is obviously not what I asked for, I tested a few more variants to see if more things go wrong. Summary Table of some results :

"INPUT" --> "OUTPUT"


11101   -->  01101 (flaw)     change in 1st from 1 to 0

10101   -->  10001 (flaw)     change in 3rd from 1 to 0

(a) 11001 --> 01101 (flaw) change in 1st from 1 to 0, and in 3rd from 0 to 1 (b) 11001 --> 01001 (flaw) change in 1st from 1 to 0 # another result sometimes (c) 11001 --> 10001 (flaw) change in 2nd from 1 to 0 # another result sometimes

00101   -->  10001 (flaw)     change in 1st from 0 to 1, and in 3rd from 1 to 0

(a) 11101 --> 10101 (flaw) change in 2nd from 1 to 0 (b) 11101 --> 01101 (flaw) change in 1st from 1 to 0 # another result sometimes

(a) 10001 --> 00001 (flaw) change in 1st from 1 to 0 # another result sometimes (a) 10001 --> 10001 (flawless)

01101   -->  01101 (flawless)

00001   -->  00001 (flawless)

00010   -->  00010 (flawless)

00100   -->  00010 (flawless)

Another thing I noticed in the course of playing with the web interface: it changed a part of the section. At one time it went from this representation:

Require user @OWNER @SYSTEM Order deny,allow Order deny,allow

to this representation:

Require user @OWNER @SYSTEM Order deny,allow Order deny,allow Order deny,allow Require user @OWNER @SYSTEM

which is basically the same (so no bug).... but isn't it "dangerous" to try and re-write the policy settings, if not even the basic stuff works reliably?

I could post my cupsd.conf file, but since you can reproduce this bug by using the default one provided by the web interface, this shouldn't be necessary.

------------- snip ------------------------------------------------------

So, the "additional information" from my experiments is that there may be conditions where the 3rd checkbox ("Allow remote administration") can unintentionally/automatically change from "on" to "off" (or the reverse way) as well.

I'm sorry, I can't test the patch right now since I do not have an environment that allows me to compile stuff.

michaelrsweet commented 17 years ago

CUPS.org User: pipitas

Sorry, I must have confused the tabs in my browser to post the above comment here.

It was meant to go towards STR #2393

michaelrsweet commented 17 years ago

CUPS.org User: mike

Fixed in Subversion repository.

FWIW, the existing raw rules looked in the first 4k of the file, so I've increased the PS/PJL checks and the HP-GL/2 checks to use the same limit.

michaelrsweet commented 14 years ago

CUPS.org User: enacoste

I using rastertohp and PJL instructions in PPD are not in job; adjusted mime.types and mime.convs but still PJL does not appear in job. Possibly rastertohp filter does not pass the PJL instructions to the job.

The question is does rastertohp transfer the PJL instructions once it is done?

once the mime.types and mime.convs were updated, restrted cups.

below is configuration where mime.types represents statements in mime.types and the same for mime.convs and ppd

CUPS: 1.2

mime.types: application/postscript ai eps ps string(0,%!) string(0,<04>%!) mime.types: application/vnd.cups-postscript contains(0,128,<1B>%-12345X) + \ (contains(9,512,"LANGUAGE=POSTSCRIPT") \ contains(9,512,"LANGUAGE = Postscript") \ contains(9,512,"LANGUAGE = POSTSCRIPT")) mime.types: application/vnd.cups-raster string(0,"RaS") mime.types: application/vnd.cups-raw (string(0,<1B>E) + !string(2,<1B>%0B)) \ string(0,<1B>@) \ (contains(0,128,<1B>%-12345X) + \ (contains(0,1024,"LANGUAGE=PCL") \ contains(0,1024,"LANGUAGE = PCL"))) mime.types: application/octet-stream mime.convs: application/octet-stream application/vnd.cups-raw 0 - mime.convs: application/vnd.cups-postscript application/vnd.cups-raster 100 pstoraster

ppd: cupsFilter: "application/vnd.cups-raster 0 rastertohp" ppd: Protocols: PJL ppd: JCLBegin: "<1B>%-12345X<0A>@PJL COMMENT XXX PPD<0A>" ppd: JCLToPSInterpreter: "@PJL ENTER LANGUAGE = PCL<0A>" ppd: *JCLEnd: "<1B>%-12345X@PJL EOJ<0A>"

michaelrsweet commented 14 years ago

"cups-1.1.22-search-ps.patch":

--- cups-1.1.22rc1-orig/conf/mime.types 2004-09-24 00:30:19.000000000 +1000 +++ cups-1.1.22rc1/conf/mime.types 2007-03-22 14:55:04.000000000 +1000 @@ -74,10 +74,10 @@ application/pdf pdf string(0,%PDF) application/postscript ai eps ps string(0,%!) string(0,<04>%!) \ contains(0,128,<1B>%-12345X) + \