From owner-freebsd-current@FreeBSD.ORG Fri Aug 1 17:38:54 2003 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6341C37B401 for ; Fri, 1 Aug 2003 17:38:54 -0700 (PDT) Received: from mail.dada.it (mail2.dada.it [195.110.100.2]) by mx1.FreeBSD.org (Postfix) with SMTP id 1A41743FB1 for ; Fri, 1 Aug 2003 17:38:51 -0700 (PDT) (envelope-from riccardo@torrini.org) Received: (qmail 16246 invoked from network); 2 Aug 2003 00:38:43 -0000 Received: from unknown (HELO trudy.torrini.home) (195.110.114.101) by mail.dada.it with SMTP; 2 Aug 2003 00:38:43 -0000 Received: from trudy.torrini.home (localhost.torrini.home [127.0.0.1]) by trudy.torrini.home (8.12.9/8.12.9) with ESMTP id h720ck5M084839; Sat, 2 Aug 2003 02:38:46 +0200 (CEST) (envelope-from riccardo@trudy.torrini.home) Received: (from riccardo@localhost) by trudy.torrini.home (8.12.9/8.12.9/Submit) id h720cjRN084838; Sat, 2 Aug 2003 02:38:45 +0200 (CEST) Date: Sat, 2 Aug 2003 02:38:45 +0200 From: Riccardo Torrini To: freebsd-current@FreeBSD.ORG Message-ID: <20030802003845.GE73426@trudy.torrini.home> References: <20030802000332.GD73426@trudy.torrini.home> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030802000332.GD73426@trudy.torrini.home> User-Agent: Mutt/1.4.1i Subject: Re: newsyslog problems with -C X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Aug 2003 00:38:54 -0000 On Sat, Aug 02, 2003 at 02:03:32AM +0200, Riccardo Torrini wrote: > Without creating by hand /var/tmp/{foo,bar} this command fail > # newsyslog -vvvvv -F -C -f /usr/local/etc/rotatemailbackup.conf > --> [creating entry for /var/tmp/foo] > --> [creating entry for /var/tmp/bar] > /var/tmp/foo <7Z>: does not exist -> will create. > newsyslog: can't fchmod temp file '/var/tmp/foo.z8FjDcW': \ Bad file descriptor Found (I think :-) # truss newsyslog -vvvvv -CC -F -f \ /usr/local/etc/rotatemailbackup.conf /var/tmp/foo [...] lstat("/var/tmp",0xbfbffad0) = 0 (0x0) gettimeofday(0xbfbff500,0x0) = 0 (0x0) getpid() = 84801 (0x14b41) open("/dev/urandom",0x0,00) = 3 (0x3) read(0x3,0xbfbff50c,0x74) = 116 (0x74) close(3) = 0 (0x0) stat("/var/tmp",0xbfbff610) = 0 (0x0) open("/var/tmp/foo.zM4kxLE",0xa02,0600) = 3 (0x3) fchown(0x3,0x3e9,0x6) = 0 (0x0) close(3) = 0 (0x0) fchmod(0x3,0x180) ERR#9 'Bad file descriptor' [...] It seems that last two lines are reversed (close before fchmod). Looking into sources I found two close(fd). Here is the patch: -----8<-----[ patch ]-----8<----- # diff -u newsyslog.c.orig newsyslog.c --- newsyslog.c.orig Sun May 25 18:46:13 2003 +++ newsyslog.c Sat Aug 2 02:28:50 2003 @@ -1764,7 +1764,6 @@ failed = fchown(fd, ent->uid, ent->gid); if (failed) err(1, "can't fchown temp file %s", tempfile); - (void) close(fd); } } -----8<-----[ patch ]-----8<----- Now it works, here is the correct flow: [...] open("/dev/urandom",0x0,00) = 3 (0x3) read(0x3,0xbfbff4bc,0x74) = 116 (0x74) close(3) = 0 (0x0) stat("/var/tmp",0xbfbff5c0) = 0 (0x0) open("/var/tmp/foo.zKXXcYJ",0xa02,0600) = 3 (0x3) fchown(0x3,0x3e9,0x6) = 0 (0x0) fchmod(0x3,0x180) = 0 (0x0) rename(0xbfbff680,0x8058060) = 0 (0x0) close(3) = 0 (0x0) --> [freeing entry for /var/tmp/foo] [...] Please commit on both 4.8 and -CURRENT because newsyslog.c 1.25.2.21 (4.8) and newsyslog.c 1.70 (-CURRENT) are equal but the headers. Thanks. -- Riccardo. ( http://www.GUFI.org/~vic/ )