Bug 99896 - [patch] lpr(1): lpr -r flag has no effect
Summary: [patch] lpr(1): lpr -r flag has no effect
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 5.3-RELEASE
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs (Nobody)
Depends on:
Reported: 2006-07-08 00:50 UTC by george
Modified: 2017-12-31 22:36 UTC (History)
0 users

See Also:

file.diff (302 bytes, patch)
2006-07-08 00:50 UTC, george
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description george 2006-07-08 00:50:16 UTC
The -r flag (remove file after printing) of lpr has no effect.

Fix: Apply the following patch:

How-To-Repeat: 	cp <existing text file> foo.txt
	lpr foo.txt
	After file prints, observe that foo.txt still exists.
Comment 1 george 2006-07-11 20:54:40 UTC
In the example given of how to reproduce, I made a typo.  The example
should read as follows:

	cp <existing text file> foo.txt
	lpr -r foo.txt
	After file prints, observe that foo.txt still exists.

-- George Mitchell
Comment 2 george 2006-08-01 22:08:50 UTC
To complete this fix, lprm also needs a patch as follows:

--- usr.sbin/lpr/common_source/rmjob.c.orig     Thu Dec 30 16:36:28 2004
+++ usr.sbin/lpr/common_source/rmjob.c  Sun Jul 30 18:14:01 2006
@@ -206,7 +206,7 @@
         while (getline(cfp)) {
                 switch (line[0]) {
                 case 'U':  /* unlink associated files */
-                       if (strchr(line+1, '/') || strncmp(line+1, "df", 2))
+                       if (strncmp(line+1, "df", 2))
Comment 3 Brooks Davis freebsd_committer 2006-08-14 23:02:34 UTC
Responsible Changed
From-To: freebsd-bugs->gad

gad requests review of lpr changes so pass to him.
Comment 4 Garance A Drosehn freebsd_committer 2006-08-14 23:36:38 UTC
I will need to review the original code, and make sure
this is the right fix.  '-r' did used to work, but it
was disabled for security reasons.  See revision 1.5 at


(it fixed a CERT advisory at the time, back in 1997).
I *think* I made some other changes which should make
this safer to do now, but I have to be sure about that.

Garance Alistair Drosehn     =      gad@gilead.netel.rpi.edu
Senior Systems Programmer               or   gad@FreeBSD.org
Rensselaer Polytechnic Institute;             Troy, NY;  USA
Comment 5 Eitan Adler freebsd_committer freebsd_triage 2017-12-31 07:59:55 UTC
For bugs matching the following criteria:

Status: In Progress Changed: (is less than) 2014-06-01

Reset to default assignee and clear in-progress tags.

Mail being skipped