Bug 5129 - Are You Sure rewindstdin Works?
Are You Sure rewindstdin Works?
Status: CLOSED RAWHIDE
Product: Red Hat Linux
Classification: Retired
Component: rhs-printfilters (Show other bugs)
6.0
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Bernhard Rosenkraenzer
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 1999-09-14 10:38 EDT by Tony Kocurko
Modified: 2008-05-01 11:37 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2000-02-10 10:06:37 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Tony Kocurko 1999-09-14 10:38:07 EDT
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 10:45:59 EDT
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 12:24:59 EST
Thanks for the patch...
Looking into it now.
Comment 3 Bernhard Rosenkraenzer 2000-02-10 10:06:59 EST
Thanks, it's in CVS now.
Comment 4 Harvey Stein 2000-03-16 11:15:59 EST
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.