newsyslog problems with -C
Riccardo Torrini
riccardo at torrini.org
Fri Aug 1 17:38:54 PDT 2003
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/ )
More information about the freebsd-current
mailing list