From jedgar@pawn.primelocation.net Sun Aug  1 12:36:38 1999
Return-Path: <jedgar@pawn.primelocation.net>
Received: from pawn.primelocation.net (pawn.primelocation.net [205.161.238.235])
	by hub.freebsd.org (Postfix) with ESMTP id 3A04914CC2
	for <FreeBSD-gnats-submit@freebsd.org>; Sun,  1 Aug 1999 12:36:36 -0700 (PDT)
	(envelope-from jedgar@pawn.primelocation.net)
Received: by pawn.primelocation.net (Postfix, from userid 1003)
	id B2098F818; Sun,  1 Aug 1999 15:36:23 -0400 (EDT)
Message-Id: <19990801193623.B2098F818@pawn.primelocation.net>
Date: Sun,  1 Aug 1999 15:36:23 -0400 (EDT)
From: jedgar@fxp.org
Sender: jedgar@pawn.primelocation.net
Reply-To: jedgar@fxp.org
To: FreeBSD-gnats-submit@freebsd.org
Subject: [PATCH] lpd leaves lock file permissions afoul
X-Send-Pr-Version: 3.2

>Number:         12912
>Category:       bin
>Synopsis:       [PATCH] lpd leaves lock file permissions afoul
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Aug  1 12:40:00 PDT 1999
>Closed-Date:    Wed Dec 15 15:04:20 PST 1999
>Last-Modified:  Wed Dec 15 15:05:31 PST 1999
>Originator:     Chris D. Faulhaber
>Release:        FreeBSD 3.2-STABLE i386
>Organization:
>Environment:

	FreeBSD earth.fxp 3.2-STABLE FreeBSD 3.2-STABLE #12: Sun Aug  1 10:29:14 EDT 1999

>Description:

	When using a custom definition in /etc/printcap (for a remote printer in my case,
	modeled of the example therein) and the lock file does not exist, lpd leaves 
	permissions on the lock file as follows:

		-------rwx   1 root     daemon         22 Aug  1 15:16 lock

	which leave the printer disabled until the permissions are fixed.  If the lock
	file exists, permissions are left as normal:

		-rw-rw-r--   1 root     daemon         22 Aug  1 15:20 lock

	In addition, the lock file file-descriptor (lfd) is never closed.

>How-To-Repeat:

	Create a custom /etc/printcap entry:

	lp|sol printer:\
		:sh:\
		:mx#0:\
		:rm=sol:sd=/var/spool/output/sol:lf=/var/log/lpd-errs:

	create the spool directory, but do not create the lock file itself. After
	restarting lpd and printing something, the lock file's permissions will be
	left as 0007.

>Fix:
	
	Either create the lock file (though shouldn't be necessary), or apply the
	following patch.

--- /usr/src/usr.sbin/lpr/lpd/printjob.c.orig	Fri Sep 11 14:49:32 1998
+++ /usr/src/usr.sbin/lpr/lpd/printjob.c	Sun Aug  1 15:16:21 1999
@@ -311,6 +311,10 @@
 					     strlen(pp->trailer));
 		}
 		(void) close(ofd);
+		if (fchmod(lfd, LOG_FILE_MODE) < 0)
+			syslog(LOG_ERR, "%s: %s: %m", pp->printer,
+			       pp->lock_file);
+		(void) close(lfd);
 		(void) wait(NULL);
 		(void) unlink(tempfile);
 		exit(0);


>Release-Note:
>Audit-Trail:

From: "Chris D. Faulhaber" <jedgar@fxp.org>
To: freebsd-gnats-submit@freebsd.org
Cc:  
Subject: Re: bin/12912: [PATCH] lpd leaves lock file permissions afoul
Date: Thu, 18 Nov 1999 21:35:14 -0500 (EST)

 This problem doesn't seem to be reproducible using 3.3-RELEASE/-STABLE or
 4.0-CURRENT...feel free to close.
 
 -----
 Chris D. Faulhaber               |  You can ISO9001 certify the process of 
 System/Network Administrator,    |  shooting yourself in the foot, so long
 Reality Check Information, Inc.  |  as the process is documented and reliably
 <jedgar@fxp.org>                 |  produces the proper result.
 
 
State-Changed-From-To: open->closed  
State-Changed-By: cpiazza 
State-Changed-When: Wed Dec 15 15:04:20 PST 1999 
State-Changed-Why:  
Originator reports that the problem can't be reproduced on 3.3/4.0 
>Unformatted:
