inetd fd leak?
Doug Graham
dgraham at nortel.com
Fri Sep 4 21:55:16 UTC 2009
Denys Vlasenko wrote:
>> This isn't just an academic question. uClibc 0.9.30 doesn't set FD_CLOEXEC
>> on the logging descriptor.
>>
>
> It does. uClibc-0.9.30/libc/misc/syslog/syslog.c
>
> void
> openlog(const char *ident, int logstat, int logfac)
> {
> int logType = SOCK_DGRAM;
>
> __UCLIBC_MUTEX_LOCK(mylock);
>
> if (ident != NULL)
> LogTag = ident;
> LogStat = logstat;
> if (logfac != 0 && (logfac &~ LOG_FACMASK) == 0)
> LogFacility = logfac;
> if (LogFile == -1) {
> retry:
> if (LogStat & LOG_NDELAY) {
> if ((LogFile = socket(AF_UNIX, logType, 0)) == -1) {
> goto DONE;
> }
> HERE ====> fcntl(LogFile, F_SETFD, 1); /* 1 == FD_CLOEXEC */
> /* We don't want to block if e.g. syslogd is SIGSTOPed */
> fcntl(LogFile, F_SETFL, O_NONBLOCK | fcntl(LogFile, F_GETFL));
> }
> }
>
Oops, I missed the tricky (and strange) hardcoding of the constant,
because id-utils doesn't
index comments. I did also use strace to verify on an actual running
system that uClibc wasn't
setting FD_CLOEXEC, but that system is using uClibc-0.9.29. So it looks
like this was fixed
in 0.9.30. I'd bet that there are still lots of systems using older
versions of uClibc though.
--Doug.
> ...
>
More information about the busybox
mailing list