[comp.bugs.sys5] Enhancing lp WAS:Re: SysV lp spooler a security hole

rjk@mrstve.UUCP (09/17/87)

In article <15000001@bradley> john@bradley.UUCP writes:
>
>kitty.UUCP!Larry (Larry Lippman) Writes:
>
>|1.	There is no reason why more than one printer name cannot be associated
>|with _one_ physical printer using _one_ physical I/O port.  The usefulness
>|here is to invoke the _same_ printer in a different fashion merely by
>|specifying a different printer name as an lp(1) argument....
>
>I can think of one reason NOT to do just this....The lpsched program 
>just checks to see if a job is currently printing on the named printer.  It
>DOESN'T check to see if the physical port is busy.  At least on SYSV 2.0, 2.1
>			    ---------------------
>I patched our lpsched program so that it will check to see if there are ANY
>printers busy which are connected to the  same physical port as the requested 
>printer.  Other than that, I really like setting up printers this way....

OR...  We've written a little program (to be run from the shell) to play with
semaphores -- we call it `shsem'.  Since we don't have source, we can't hack
lpsched.  Besides, shsem has proved to be extremely useful for other things
as well (as in, how did we get along without it?).  We use it in the shell
interfact as follows:

# lp interface for Toshiba line printer with banner pages
#
/usr/local/bin/shsem -w /dev/tty15
trap "/usr/local/bin/shsem -u /dev/tty15; echo '\014\033\032I\c'; exit 1" 1 2 3 15
#
# interface code here...
#
/usr/local/bin/shsem -u /dev/tty15

The same code is in every other interface which uses the printer on
/dev/tty15.

`shsem -w /dev/tty15' attempts to lock a semaphore associated with the
file /dev/tty15, creating it if it doesn't already exist.  The -w
indicates that we want to wait if we can't lock it right now.  The -u
simply says to unlock it.  We haven't had any problems yet.
lpstat does indicate that 2 jobs are printing simultaneously on the same
device, but they don't inter-mix.

If anyone is interested in shsem, drop me a note.  It's not too large.
-- 
				       !pur-ee!pur-phy!mrstve!rjk
Rich Kuhns	{ihnp4, decvax, etc...}
				       !itivax!mrstve!rjk