From: Christopher Chan-Nui (channui@awdprime.austin.ibm.com)
Date: 09/01/93


From: channui@awdprime.austin.ibm.com (Christopher Chan-Nui)
Subject: (was Re: postscripton on BJ330) critique this printcap and filter? 
Date: Wed, 1 Sep 1993 22:44:54 GMT

Andreas Klemm (andreas@knobel.knirsch.de) wrote:
: hein@student.tu-clausthal.de (Jochen Hein) writes:

: >Hi all,
: >to avoid a security hole when running gs as a filter add -dSAFER to
: >it arguments:

: Ok, not bad !

Well, since people reading this thread seem to be knowledgeable about
printer setups I was wondering if anyone would mind critiquing this.
It works but I just want to make sure that I'm not missing anything.

Oh, also, one BIG question, running 0.99PL12 I have a problem that if I
boot with the printer on (a Deskjet Plus) the printer locks up and
refuses to respond to any panel commands (even reset) and when trying
to print something to it Linux responds with "lp0 off-line". I then
have to power the printer off, write something to the printer (e.g.
echo "" > /dev/lp0) and then everything works fine. If the printer is
off when I boot it works as well. The printer used to work under
0.99PL10 (and 9) but was recognized as lp1 then. Has anyone
encountered this problem? And does anyone have a fix? It's not a
major problem, just annyoing.

The machine "ryouga" has the following printcap
        lp|akane:sh:rm=akane:sd=/var/spool/lpd:mx#0:

The machine "akane" has the following printcap
        lp:sh:lp=/dev/lp0:sd=/usr/spool/lp:mx#0:if=/usr/lib/lpf:

and /usr/lib/lpf contains

#!/usr/local/bin/perl

# They want us to pass the thing through unmodified (with control chars...)
# Assuming -c is first argument, probably not a good assumption but that's
# what the stuff in the printing-FAQ assumes.
if ($#ARGV && @ARGV[0] eq "-c") {
    print <STDIN>;
    print "\f";
    exit 0;
}

# See if we want to do postscipt magic
sysread(STDIN, $buf, 2);
if ($buf eq "%!") {
    # forget rest of line ... it was a comment anyway....
    while ($buf ne "\n" && $buf ne "\r") {
        sysread(STDIN, $buf, 1);
    }

    # put ghostscript in our place in the pipe stream
    exec split (" ",
                "gs -q -sOutputFile=- -sDEVICE=deskjet -r300 " .
                "-dSAFER -dNOPAUSE -f -");
    exit 0;
}

# Make sure we don't lose the first couple characters
$buf =~ s/\n/\n\r/;
print "$buf";
while (<STDIN>) {
    # pad with newlines
    print "$_\r";
}
print "\f";

0;