Subject: Re: re-reading /etc/resolv.conf on change
To: Perry E. Metzger <firstname.lastname@example.org>
From: Manuel Bouyer <email@example.com>
Date: 12/29/2003 21:41:51
On Sun, Dec 28, 2003 at 03:51:38PM -0500, Perry E. Metzger wrote:
> Manuel Bouyer <firstname.lastname@example.org> writes:
> > What I did is unconditionally call res_init() from other resolver functions.
> > In res_init(), I use kqueue to monitor changes to /etc/resolv.conf
> > (or to /etc/. if /etc/resolv.conf doens't exists). Every call to a resolver
> > function will call res_init(), which will check the kevent queue.
> > This adds a little overhead to the resolver functions (a function call,
> > and a system call), but I think it's worth it.
> One point -- I think that this is a great idea, but that we should
> really be updating our resolver to the one from Bind 9
> *before* we hack on it any further, or we will make it even harder to
> import a new version.
I don't think that these few lines would make the work really harder.
I'll be happy to redo this work for bind9 if needed (but maybe bind9
already solves this problem).
And it doen't look like the switch to the bind9 resolved will happen any
> (BTW, I think it would also be great if someone were to volunteer to
> do that work soon...)
> Also, does this code work correctly if resolv.conf is a symlink?
open() will follow the symlink, so the kevent filter will watch the target of
the symlink, not the symlink itself. I can see 2 ways to loose with this:
- if the symlink doens't point to a real file, and points outside of /etc/
in this case, open() will fail, and the kevent will be set on /etc.
Then we can recreate a file as the symlink's target, but the resolver won't
- if we change the symlink to point to another file.
I don't know how to deal properly with the first case. The second could
be dealt with a kevent on the symlink itself, but I'm not sure it's worth
the extra complexity (BTW how to we get a file descriptor to a symlink,
instead of the target of a symlink).
Note that if we move /etc as a whole, we loose too.
Manuel Bouyer <email@example.com>
NetBSD: 23 ans d'experience feront toujours la difference