Re: bash: Fails to upgrade in kFreeBSD jails
Hi,
Steven Chamberlain wrote:
> Hmmm, I can't seem to reproduce the problem here, in a kfreebsd-i386
> jail environment on a GNU/kFreeBSD (9.0) host. I had bash 4.2-2 already
> installed though.
>
> I'm trying "apt-get --reinstall install bash" or directly running
> /var/lib/dpkg/info/bash.preinst
>
> Here's a system call trace:
>
> 72202 bash.preinst CALL open(0x8049678,0x1<><invalid>1,<unused>0)
> 72202 bash.preinst NAMI "/dev/null"
> 72202 bash.preinst RET open 3
> 72202 bash.preinst CALL fcntl(0x3,<invalid=3>,0x8149)
> 72202 bash.preinst RET fcntl 1
> 72202 bash.preinst CALL fcntl(0x3,<invalid=4>,0x1<><invalid>1)
> 72202 bash.preinst RET fcntl 0
>
> Successfully opened /dev/null as fd 0x3. I assume that is fcntl()
> F_GETFL returning flags = 0x1 (which actually means FD_CLOEXEC was
> already set), then F_SETFL returning 0 = success.
That's the first difference from Stefan's trace, so let's start there.
/dev/null is opened with
sink = open("/dev/null", O_WRONLY);
O_WRONLY == 1, so this matches the open call in your trace. So far so
good. Then we try to set the FD_CLOEXEC flag:
if (sink >= 0)
set_cloexec(sink);
set_cloexec() is defined in terms of fcntl calls that get and set the
file descriptor's flags:
int flags = fcntl(fd, F_GETFL);
if (flags < 0 || fcntl(fd, F_SETFL, flags | FD_CLOEXEC))
die_errno("cannot set close-on-exec flag");
F_GETFL is 3, so fcntl is being called correctly. But why does
fcntl(F_GETFL) return 1 (== FD_CLOEXEC)? This looks like a bug. What
kfreebsd-image-(foo) package are you using, and at what version?
Puzzled,
Jonathan
Reply to: