From owner-freebsd-amd64@FreeBSD.ORG Fri Feb 17 09:30:05 2006 Return-Path: X-Original-To: freebsd-amd64@hub.freebsd.org Delivered-To: freebsd-amd64@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id CAD4216A420 for ; Fri, 17 Feb 2006 09:30:05 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5D05A43D4C for ; Fri, 17 Feb 2006 09:30:05 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id k1H9U5kg006776 for ; Fri, 17 Feb 2006 09:30:05 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id k1H9U5mH006775; Fri, 17 Feb 2006 09:30:05 GMT (envelope-from gnats) Resent-Date: Fri, 17 Feb 2006 09:30:05 GMT Resent-Message-Id: <200602170930.k1H9U5mH006775@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-amd64@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Michael Szklarski Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D883616A422 for ; Fri, 17 Feb 2006 09:24:31 +0000 (GMT) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [216.136.204.117]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6B75843D5F for ; Fri, 17 Feb 2006 09:24:27 +0000 (GMT) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.13.1/8.13.1) with ESMTP id k1H9OQqS009114 for ; Fri, 17 Feb 2006 09:24:26 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.13.1/8.13.1/Submit) id k1H9OQh8009113; Fri, 17 Feb 2006 09:24:26 GMT (envelope-from nobody) Message-Id: <200602170924.k1H9OQh8009113@www.freebsd.org> Date: Fri, 17 Feb 2006 09:24:26 GMT From: Michael Szklarski To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-2.3 Cc: Subject: amd64/93469: uninitialised struct stat in lpd prevents it from normal operation X-BeenThere: freebsd-amd64@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the AMD64 platform List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Feb 2006 09:30:06 -0000 >Number: 93469 >Category: amd64 >Synopsis: uninitialised struct stat in lpd prevents it from normal operation >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-amd64 >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Fri Feb 17 09:30:04 GMT 2006 >Closed-Date: >Last-Modified: >Originator: Michael Szklarski >Release: 6.0 >Organization: ABG Ster-Projekt >Environment: FreeBSD Tygrytron 6.0-RELEASE FreeBSD 6.0-RELEASE #0: Sat Feb 11 00:30:29 CET 2006 msz@Tygrytron:/usr/src/sys/amd64/compile/Tygrytron amd64 >Description: Already reported in: http://www.freebsd.org/cgi/query-pr.cgi?pr=amd64/93413 now I have traced down the problem: After first-time installation of spool directories, e.g. /var/spool/lpd/rattan , as seen in the Handbook, these directories are of course empty. Running first time printout is successful, lpd creates "lock" file in the spool directory, but it has following (strange) attributes: ---xrwS--T 1 root daemon 20 Feb 16 01:03 lock Unfortunately, running printout for the next time does not work - lpr queues the job and nothing happens ! It is due to a sw-bug in /usr/src/usr.sbin/lpr/lpd/printjob.c, in function void printjob(struct printer* pp); i.e. look at the following lines of code: [203] if (stat(pp->lock_file, &stb) == 0 && (stb.st_mode & LFM_PRINT_DIS)) exit(0); Seems OK, but if NO LOCK FILE EXIST, "stb" remains uninitialized ! Unfortunately, this sets "+x" attribute, which is defined elsewhere as #define LFM_PRINT_DIS (S_IXUSR) and it results in executing exit(0) in the line mentioned above, but only for the second time. Further in the code one can find fchmod(lfd,stb.st_mode), which uses uninitialised "stb". >How-To-Repeat: kill lpd. remove spool directories. recreate spool directories. run lpd. try to print twice (or more). >Fix: /usr/src/usr.sbin/lpr/lpd/printjob.c: function void printjob(struct printer* pp), line 203: replace those 2 lines mentioned above with: if (stat(pp->lock_file, &stb) == 0) { if (stb.st_mode & LFM_PRINT_DIS) { exit(0); /* printing disabled */ } } else { stb.st_mode = LOCK_FILE_MODE; } rebuild and install lpd. Works for me. Workaround: create lock files after creating spool directories: mkdir /var/spool/lpd/rattan touch /var/spool/lpd/rattan/lock and/or change attributes of lock file: chmod 664 /var/spool/lpd/rattan/lock >Release-Note: >Audit-Trail: >Unformatted: