apple / cups

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

When CGIs output anything but text/html client browser does not get anything #2159

Closed michaelrsweet closed 17 years ago

michaelrsweet commented 17 years ago

Version: 1.2.7 CUPS.org User: opher

I created this plaintext.cgi file on two machines: one running CUPS 1.1.22 the other 1.2.7 (/etc/cups/cgi.types contains this single line: application/x-httpd-cgi cgi) ---------------- plaintext.cgi start ----------------

!/bin/sh

This is a test shell script for CUPS

alias echo='echo -e' echo 'Content-type: text/plain' echo echo 'This is a specially crafted plain text ducument.' ---------------- plaintext.cgi end ---------------- It ran OK on CUPS 1.1.22 but NOT on 1.2.7 !!

On CUPS 1.2.7 the client browser waits and eventually times-out. The same thing happens for application/postscript.

Cheers, Opher Shachar.

michaelrsweet commented 17 years ago

CUPS.org User: mike

Strange, I just tried this on a RH9 system and everything works as expected.

What operating system, kernel, distro, etc?

michaelrsweet commented 17 years ago

CUPS.org User: opher

Hi Michael, I run CUPS 1.2.7 on a FedoraCore 6 box.

output for: uname -a Linux fc6.iula.org.il 2.6.18-1.2849.fc6 #1 SMP Fri Nov 10 12:36:14 EST 2006 i686 i686 i386 GNU/Linux

output for: rpm -qa|grep cups hal-cups-utils-0.6.2-4.2 cups-1.2.7-1.5.fc6 cups-pdf-2.4.2-2.fc6 cups-libs-1.2.7-1.5.fc6 cups-lpd-1.2.7-1.5.fc6 libgnomecups-0.2.2-8

output for: rpm -qa|grep kernel kernel-devel-2.6.18-1.2849.fc6 kernel-2.6.18-1.2849.fc6 kernel-headers-2.6.18-1.2849.fc6

output for: cat cgi.types application/x-httpd-cgi cgi

in mime.convs I changed:

text/plain application/postscript 33 texttopaps to < text/plain application/postscript 33 texttops

In the next few days I'm setting up a classroom with FC6 - default install, no update. Out of the box it comes with CUPS 1.2.4 and I'll check to see if it's any different.

Regards, Opher Shachar.

michaelrsweet commented 17 years ago

CUPS.org User: mike

OK, let me know what you see.

Also, if you can test the standard CUPS software (not the patched version provided by Red Hat) that might point to a Red Hat bug, in which case you can file a bug with them instead... :)

michaelrsweet commented 17 years ago

CUPS.org User: opher

Hi, This is one of those instances that drive you nuts. As it happens, the original script: ---------------- badplaintext.cgi start ----------------

!/bin/sh

############################################

This is a test shell script for CUPS

############################################ alias echo='echo -e' echo 'Content-type: text/plain' echo echo 'This is a specially crafted plain text document.' ---------------- badplaintext.cgi end ---------------- runs fine on CUPS 1.1.22 and 1.2.4 but NOT on 1.2.7 .

This script however: ---------------- goodplaintext.cgi start ----------------

!/bin/sh

############################################

This is a test shell script for CUPS

############################################ alias echo='echo -e' echo 'Content-type: text/plain

This is a specially crafted plain text document.' ---------------- goodplaintext.cgi end ---------------- runs fine on ALL three versions of CUPS !!

Notice that the difference between the two scripts is that the latter is ONE echo command.

Could it be that versions of CUPS prior to 1.2.7 quit reading the CGI's stdout only after the CGI exits?

Thanks, Opher Shachar.

michaelrsweet commented 17 years ago

CUPS.org User: opher

Hi Michael, After some more testing it's not a mime type issue. Rather it's an issue with how output from the CGI is done. I'm no expert in the Linux affairs but, at least, with regard for shell scripts CGIs in version 1.2.7 it only works when the whole output is done with a single echo/cat command.

Side note: here http://www.cups.org/newsgroups.php?gcups.general+v:28031 you mention that CUPS will set the Content-length header field. I redid that test (with my new-found knowledge) and still found this is not done with CUPS 1.2.7 . I have to set Content-length otherwise the browser shows nothing for size.

Regards, Opher Shachar.

michaelrsweet commented 17 years ago

CUPS.org User: mike

No, the code that reads the CGI output hasn't changed.

michaelrsweet commented 17 years ago

CUPS.org User: mike

Re: the Content-Length, cupsd handles that by using the chunked transfer encoding (otherwise we'd need to buffer the entire output from the CGI...)

michaelrsweet commented 17 years ago

CUPS.org User: mike

This STR has not been updated by the submitter for two or more weeks and has been closed as required by the CUPS Configuration Management Plan. If the issue still requires resolution, please re-submit a new STR.