Bug 5129 - Are You Sure rewindstdin Works?
Summary: Are You Sure rewindstdin Works?
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: rhs-printfilters
Version: 6.0
Hardware: i386
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Bernhard Rosenkraenzer
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 1999-09-14 14:38 UTC by Tony Kocurko
Modified: 2008-05-01 15:37 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2000-02-10 15:06:37 UTC
Embargoed:


Attachments (Terms of Use)

Description Tony Kocurko 1999-09-14 14:38:07 UTC
Hi,

  In trying to track down a problem in printing to a
PostScript printer (which turned out to be a problem NOT
with Red Hat but with the printer itself), I found what
might be a problem with one of the utility programs in
/usr/lib/rhs/rhs-printfilters: rewindstdin. If you feed
a PostScript file into the /var/spool/lpd/*/filter that
is installed for a generic PostScript printer, you will
see that, the first time that the variable "magic" is
found, it takes a value like this:

magic=standard input:           PostScript document text ...

At the second point that the variable "magic" is computed,
however, it gets a value like this:

magic=standard input:           English text

My suspicion is that the "rewindstdin" program doesn't work
the way that the author of "filter" thinks. In any case,
there is a little bit of extra work being done in "filter"
that can be avoided. Here is a diff file that I created
for the generic PostScript print filter. Note, though, that
I still think that "rewindstdin" isn't working as the author
believes it should.

Cheers,
Tony Kocurko - Memorial University of Newfoundland

--------------- here is the diff file ---------------------
*** filter	Tue Sep 14 12:03:34 1999
--- filter.new	Tue Sep 14 12:03:57 1999
***************
*** 166,193 ****
  # Figure out the magic of the input file
  #
      magic=$(file -)
-     $FPIDIR/rewindstdin
      magic=${magic#*: }
      if [ "$DEBUG_FILTER" != "" ]; then
        echo "Magic is |$magic|" >> /tmp/filter.debug
      fi
      case `echo $magic | tr 'A-Z' 'a-z'` in
          *packed*|*gzip*|*compress* )
!
DECOMPRESS="gzip -dc";;
          * )
!
DECOMPRESS="";;
      esac
-
- #
- # Figure out the magic of the input file
- #
-     if [ "$DECOMPRESS" = "" ]; then
-        magic=$(file -)
-     else
-        magic=$($DECOMPRESS - | file -)
-     fi
      $FPIDIR/rewindstdin
!     magic=${magic#*: }
      if [ "$DEBUG_FILTER" != "" ]; then
        echo "Magic is |$magic|" >> /tmp/filter.debug
      fi
--- 166,187 ----
  # Figure out the magic of the input file
  #
      magic=$(file -)
      magic=${magic#*: }
      if [ "$DEBUG_FILTER" != "" ]; then
        echo "Magic is |$magic|" >> /tmp/filter.debug
      fi
      case `echo $magic | tr 'A-Z' 'a-z'` in
          *packed*|*gzip*|*compress* )
!            DECOMPRESS="gzip -dc"
!            magic=$($DECOMPRESS - | file -)
!            magic=${magic#*: }
!            ;;
          * )
!            DECOMPRESS=""
!            ;;
      esac
      $FPIDIR/rewindstdin
!
      if [ "$DEBUG_FILTER" != "" ]; then
        echo "Magic is |$magic|" >> /tmp/filter.debug
      fi

Comment 1 Tony Kocurko 1999-09-14 14:45:59 UTC
Boy, is MY face red! Here is the proper patch file for the generic
PostScript print filter:

----------------------------------------------------------------------
*** filter	Tue Sep 14 12:12:08 1999
--- filter.new	Tue Sep 14 12:12:12 1999
***************
*** 166,196 ****
  # Figure out the magic of the input file
  #
      magic=$(file -)
-     $FPIDIR/rewindstdin
      magic=${magic#*: }
!     if [ "$DEBUG_FILTER" != "" ]; then
!       echo "Magic is |$magic|" >> /tmp/filter.debug
!     fi
      case `echo $magic | tr 'A-Z' 'a-z'` in
          *packed*|*gzip*|*compress* )
!                                               DECOMPRESS="gzip
-dc";;
          * )
!                                               DECOMPRESS="";;
      esac

- #
- # Figure out the magic of the input file
- #
-     if [ "$DECOMPRESS" = "" ]; then
-        magic=$(file -)
-     else
-        magic=$($DECOMPRESS - | file -)
-     fi
      $FPIDIR/rewindstdin
!     magic=${magic#*: }
      if [ "$DEBUG_FILTER" != "" ]; then
        echo "Magic is |$magic|" >> /tmp/filter.debug
      fi
      case `echo $magic | tr 'A-Z' 'a-z'` in
          *empty* )
  	                                      exit;;
--- 166,191 ----
  # Figure out the magic of the input file
  #
      magic=$(file -)
      magic=${magic#*: }
!
      case `echo $magic | tr 'A-Z' 'a-z'` in
          *packed*|*gzip*|*compress* )
!            $FPIDIR/rewindstdin
!            DECOMPRESS="gzip -dc"
!            magic=$($DECOMPRESS - | file -)
!            magic=${magic#*: }
!            ;;
          * )
!            DECOMPRESS=""
!            ;;
      esac

      $FPIDIR/rewindstdin
!
      if [ "$DEBUG_FILTER" != "" ]; then
        echo "Magic is |$magic|" >> /tmp/filter.debug
      fi
+
      case `echo $magic | tr 'A-Z' 'a-z'` in
          *empty* )
  	                                      exit;;

Comment 2 Bernhard Rosenkraenzer 1999-11-22 17:24:59 UTC
Thanks for the patch...
Looking into it now.

Comment 3 Bernhard Rosenkraenzer 2000-02-10 15:06:59 UTC
Thanks, it's in CVS now.

Comment 4 Harvey Stein 2000-03-16 16:15:59 UTC
Are you sure it's really broken?  When I turn on DEBUG_FILTER and DEBUG_TREE in
the filter file & use lpr to print things, it seems to work fine.  However, I
almost sent the same bug report because rewindstdin works on redirections but
*not* on pipes.  So, when I tried to test the filter script by "cat file |
filter >output" it wouldn't work - the 2nd invocation of file inside of the
filter script would just return "data".  However, when I tested it by "filter
file >output", it worked fine.  It seems that it's invoked by lpr in the latter
fashion, and thus is ok.

Of course, your patch is certainly cleaner than the original, so it should stay,
but I don't think it has anything to do with rewindstdin being broken.


Note You need to log in before you can comment on or make changes to this bug.