[net.unix-wizards] dangerous bug in lprm

smk@MITRE-BEDFORD@sri-unix (07/29/82)

Date: Fri Jun 25 21:41:07 1982
When possible, lpr will link the file to be printed to the lf* file in
/usr/spool/lpd.  This cuts down costs of copying the file.  (This usually only
happens for files in /usr tree hierarchy on generic systems.)

BUT --
	For some odd reason, lprm will 'clean' out the file before removing.
(It does a close(creat(file, 0666)) and then unlink(file).)  Thus, for linked
files, it will wipe them out.
	To remove the bug, simply comment out the close(creat()) line in the
drop routine of /usr/src/cmd/lpr/lprm.c.  Otherwise, be prepared to zero out
files in the /usr file system!!

	Steve Kramer
	MITRE Corp.

ark (07/29/82)

If you are trying to kill a file in the line printer queue, you must
in fact truncate it before removing it.  Otherwise if it is being printed
at the instant you remove it, it will print to the end and there will be
nothing you can do.

thomson (07/29/82)

Re: sri-unix.2300
lprm truncates the spool file rather than just unlinking it so that the
printer daemon will immediately encounter an endfile and stop printing.
Unlinking the file, if the daemon already had it open, would not abort
printing.  If you adopt Steve Kramer's fix, you will be giving up this
ability.
						Brian Thomson
						decvax!utzoo!utcsrgv!thomson