From george@m5p.com  Fri Jul  7 23:45:20 2006
Return-Path: <george@m5p.com>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 052A016A4DD
	for <FreeBSD-gnats-submit@freebsd.org>; Fri,  7 Jul 2006 23:45:20 +0000 (UTC)
	(envelope-from george@m5p.com)
Received: from mailhost.m5p.com (209-162-215-52.dq1sn.easystreet.com [209.162.215.52])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 8243643D46
	for <FreeBSD-gnats-submit@freebsd.org>; Fri,  7 Jul 2006 23:45:19 +0000 (GMT)
	(envelope-from george@m5p.com)
Received: from m5p.com (home.m5p.com [IPv6:2001:418:3fd::f4])
	by mailhost.m5p.com (8.13.7/8.13.7) with ESMTP id k67NjFEZ090788
	(version=TLSv1/SSLv3 cipher=DHE-DSS-AES256-SHA bits=256 verify=OK)
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 7 Jul 2006 16:45:15 -0700 (PDT)
Received: (from george@localhost)
	by m5p.com (8.13.7/8.13.7/Submit) id k67NjE6P080398;
	Fri, 7 Jul 2006 16:45:14 -0700 (PDT)
Message-Id: <200607072345.k67NjE6P080398@m5p.com>
Date: Fri, 7 Jul 2006 16:45:14 -0700 (PDT)
From: George Mitchell <george@m5p.com>
Reply-To: George Mitchell <george@m5p.com>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: lpr -r flag has no effect
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         99896
>Category:       bin
>Synopsis:       [patch] lpr(1): lpr -r flag has no effect
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    gad
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Jul 07 23:50:16 GMT 2006
>Closed-Date:    
>Last-Modified:  Thu May 01 07:02:18 UTC 2008
>Originator:     George Mitchell
>Release:        FreeBSD 5.3-RELEASE i386
>Organization:
Mitchell Voting Products, Inc.
>Environment:
All versions of FreeBSD, 4.0 through 6.1
System: FreeBSD parkstreet.m5p.com 5.3-RELEASE FreeBSD 5.3-RELEASE #2: Fri Jul 15 22:25:47 PDT 2005 george@parkstreet.m5p.com:/ad0/usr/src/sys/i386/compile/PARKSTREET i386


	
>Description:
The -r flag (remove file after printing) of lpr has no effect.
>How-To-Repeat:
	cp <existing text file> foo.txt
	lpr foo.txt
	After file prints, observe that foo.txt still exists.
>Fix:
	Apply the following patch:


--- usr.sbin/lpr/lpd/printjob.c.orig	Wed Aug 20 20:43:48 2003
+++ usr.sbin/lpr/lpd/printjob.c	Fri Jul  7 16:31:47 2006
@@ -583,8 +583,11 @@
 			continue;
 
 		case 'U':
+#if 0
 			if (strchr(line+1, '/'))
 				continue;
+/* This code negates the -r flag! */
+#endif
 			(void) unlink(line+1);
 		}
 	/*
>Release-Note:
>Audit-Trail:

From: George Mitchell <george@m5p.com>
To: bug-followup@FreeBSD.org, george@m5p.com
Cc:  
Subject: Re: bin/99896: [patch] lpr -r flag has no effect
Date: Tue, 11 Jul 2006 12:54:40 -0700

 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

From: George Mitchell <george@m5p.com>
To: bug-followup@FreeBSD.org, george@m5p.com
Cc:  
Subject: Re: bin/99896: [patch] lpr -r flag has no effect
Date: Tue, 01 Aug 2006 14:08:50 -0700

 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))
                                  break;
                          do_unlink(line+1);
                  }
Responsible-Changed-From-To: freebsd-bugs->gad 
Responsible-Changed-By: brooks 
Responsible-Changed-When: Mon Aug 14 22:02:34 UTC 2006 
Responsible-Changed-Why:  
gad requests review of lpr changes so pass to him. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=99896 

From: Garance A Drosehn <gad@FreeBSD.org>
To: bug-followup@FreeBSD.org, george@m5p.com
Cc:  
Subject: Re: bin/99896: [patch] lpr -r flag has no effect
Date: Mon, 14 Aug 2006 18:36:38 -0400

 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
 
 http://cvsweb.freebsd.org/src/usr.sbin/lpr/common_source/rmjob.c
 
 (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
 
>Unformatted:
