Bug 738412

Summary: [F14] textonly filter won't work as a pipe with copies=1
Product: [Fedora] Fedora Reporter: Bryan Mason <bmason>
Component: cupsAssignee: Tim Waugh <twaugh>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: medium    
Version: 15CC: azelinka, cww, jpopelka, pknirsch, prc, psklenar, twaugh
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: cups-1.5.2-1.fc16 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 660518 Environment:
Last Closed: 2012-02-21 01:32:48 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Bryan Mason 2011-09-14 18:08:09 UTC
+++ This bug was initially created as a clone of Bug #660518 +++

Description of problem:

    If the textonly filter is used as a pipe (i.e. no filename is specified
    on the command line, and the number of copies is "1", then it fails.

Version-Release number of selected component (if applicable):

    cups-1.3.7-11.el5_4.3

How reproducible:

    100%  

Steps to Reproduce:

    $ export PPD=/usr/share/cups/model/textonly.ppd
    $ cat /etc/fstab | /usr/lib/cups/filter/textonly 1 me hi 1 "" 

    (the "export PPD..." command isn't strictly necessary, but it
    eliminates an unrelated error message from grep)
  
Actual results:

    /usr/lib/cups/filter/textonly: line 109: : No such file or directory

Expected results:

    The contents of /etc/fstab.

Additional info:

    This is a real-world problem.  To enable printing of C-language
    source files on a text-only printer, I needed to add the line:

        application/x-csource text/plain    10  textonly

    to /etc/cups/local.convs, but then the textonly filter failed as
    described above.

    Line 31 in /usr/lib/cups/filter/textonly:

        if [ "$COPIES" -gt 1 ] && [ $# -lt 6 ]; then

    doesn't make sense to me.  The purpose of that code block (lines
    31-38) is to copy the input file to a temporary file so that the
    next code block (lines 40-50) can perform some LF->CRLF
    translation on the file.  BUT ... the temporary file doesn't get
    created if the number of copies is 1.  As a result,
    the sed command fails and no data is sent to the printer.

    It would seem to me that line 31 should read:

        if [ $# -lt 6 ]; then

    which would create the temp file regardless of the number of copies.

    Making the change above resolved the issue in my testing.

    This is also a problem in Fedora and RHEL 6.

(In reply to comment #0)
> Actual results:
>     /usr/lib/cups/filter/textonly: line 109: : No such file or directory
> ...
>     This is also a problem in Fedora and RHEL 6.

I can confirm that I see this warning with cups-1.5.0 (F-16) and cups-1.4.2 (RHEL-6) but in RHEL-5 I see:

sed: can't read : No such file or directory

Maybe you posted the warning from RHEL-6 ?
However your suggested solution fixes the problem.

Have you ever reported this upstream ? Are you going to do that ? Do you want me to do that ?

--- Additional comment from bmason on 2011-09-14 13:58:06 EDT ---

Hmmm . . . yes, it appears I might have copied the wrong error message. In RHEL 5, I get:

    sed: can't read : No such file or directory

and in RHEL 6 & Fedora 14 I get:

    /usr/lib/cups/filter/textonly: line 109: : No such file or directory

I haven't yet reported this upstream (or cloned this for RHEL 6 and Fedora), but will do so now.

--- Additional comment from bmason on 2011-09-14 14:01:10 EDT ---

Actually, it looks like the textonly filter doesn't exist upstream.  It was added by Red Hat.

Comment 1 Fedora Update System 2012-02-06 11:49:00 UTC
cups-1.5.2-1.fc16 has been submitted as an update for Fedora 16.
https://admin.fedoraproject.org/updates/cups-1.5.2-1.fc16

Comment 2 Fedora Update System 2012-02-07 07:49:59 UTC
Package cups-1.5.2-1.fc16:
* should fix your issue,
* was pushed to the Fedora 16 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing cups-1.5.2-1.fc16'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2012-1381/cups-1.5.2-1.fc16
then log in and leave karma (feedback).

Comment 3 Fedora Update System 2012-02-21 01:32:48 UTC
cups-1.5.2-1.fc16 has been pushed to the Fedora 16 stable repository.  If problems still persist, please make note of it in this bug report.