NetBSD Problem Report #48379

From www@NetBSD.org  Wed Nov 13 17:27:23 2013
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "Postmaster NetBSD.org" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 10424A6159
	for <gnats-bugs@gnats.NetBSD.org>; Wed, 13 Nov 2013 17:27:23 +0000 (UTC)
Message-Id: <20131113172721.8404AA61BB@mollari.NetBSD.org>
Date: Wed, 13 Nov 2013 17:27:21 +0000 (UTC)
From: abs@absd.org
Reply-To: abs@absd.org
To: gnats-bugs@NetBSD.org
Subject: resolv.conf symlink changes not picked up by resolver
X-Send-Pr-Version: www-1.0

>Number:         48379
>Category:       bin
>Synopsis:       resolv.conf symlink changes not picked up by resolver
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Nov 13 17:30:00 +0000 2013
>Last-Modified:  Thu Nov 14 00:00:00 +0000 2013
>Originator:     David Brownlee
>Release:        NetBSD-6.1
>Organization:
>Environment:
NetBSD forsaken.absd.org 6.1_STABLE NetBSD 6.1_STABLE (GENERIC) #0: Thu Oct 24 13:50:23 BST 2013  abs@cerberus.social-events.net:/var/obj/nbbuild-6-amd64/objdir/sys/arch/amd64/compile/GENERIC amd64

>Description:
The system automatically detects changes to /etc/resolv.conf and reloads as required.

This works fine if /etc/resolv.conf is a file and changes, or if /etc/resolv.conf is a symlink and the contents of the file linked to changes, but fails if /etc/resolv.conf is a symlink to one file and changes to a symlink to another file.


>How-To-Repeat:
Assuming working nameserver at 192.168.1.1 and no nameserver at 192.168.99.99

cd /etc
echo 'nameserver 192.168.99.99' > resolv.1
ln -sf resolv.1 resolv.conf
[start app such as firefox, enter url with hostname, confirm it fails]
echo 'nameserver 192.168.1.1' > resolv.2
ln -sf resolv.2 resolv.conf
[try URL in firefox - it should now work, but fails]
touch resolv.1
[try URL in firefox - it now works, presumably as the system is checking for updates to resolv.1]



>Fix:
The system would need to handle the case of symlink specifically, and reload if readlink() changes, or the timestamp of the (final) linked to file changes.

>Audit-Trail:
From: Joerg Sonnenberger <joerg@britannica.bec.de>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: bin/48379: resolv.conf symlink changes not picked up by resolver
Date: Wed, 13 Nov 2013 18:34:42 +0100

 On Wed, Nov 13, 2013 at 05:30:00PM +0000, abs@absd.org wrote:
 > >Synopsis:       resolv.conf symlink changes not picked up by resolver

 I don't think it is reasonable to expect that to work.
 The system would have to monitor not only the symlink, but e.g. all
 directories involved. Consider

 /etc/resolv.conf -> /a/b

 and someone renames a. This is a classic case of "Don't do this" for
 me...

 Joerg

From: David Brownlee <abs@absd.org>
To: "gnats-bugs@netbsd.org" <gnats-bugs@netbsd.org>
Cc: "gnats-admin@netbsd.org" <gnats-admin@netbsd.org>, netbsd-bugs@netbsd.org
Subject: Re: bin/48379: resolv.conf symlink changes not picked up by resolver
Date: Wed, 13 Nov 2013 17:44:21 +0000

 On 13 November 2013 17:35, Joerg Sonnenberger <joerg@britannica.bec.de> wrote:
 > The following reply was made to PR bin/48379; it has been noted by GNATS.
 >
 >  > >Synopsis:       resolv.conf symlink changes not picked up by resolver
 >
 >  I don't think it is reasonable to expect that to work.
 >  The system would have to monitor not only the symlink, but e.g. all
 >  directories involved. Consider
 >
 >  /etc/resolv.conf -> /a/b

 I would have thought checking readlink() plus dev+ino would be pretty
 comprehensive.

 The PR was a followup to a question from Christos. I'd also be quite
 happy if the current mechanism and limitations was documented in
 resolver(3) or similar - right now from a user perspective its just
 magic. Very cool magic, but undocumented and uncertain in the face of
 symlinks.

From: Alan Barrett <apb@cequrux.com>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: bin/48379: resolv.conf symlink changes not picked up by resolver
Date: Wed, 13 Nov 2013 21:42:05 +0200

 On Wed, 13 Nov 2013, Joerg Sonnenberger wrote:
 > I don't think it is reasonable to expect that to work.
 > The system would have to monitor not only the symlink, but e.g. all
 > directories involved. Consider
 >
 > /etc/resolv.conf -> /a/b
 >
 > and someone renames a. This is a classic case of "Don't do this" for
 > me...

 I agree that noticing such changes immediately is unreasonable, 
 but the resolver code could stat("/etc/resolv.conf") every now and 
 again and notice changes in st_dev or st_ino.  It might as well 
 look at st_mtime and st_size at the same time, as a safety net in 
 case kqueue is broken or not available.

 --apb (Alan Barrett)

From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/48379 CVS commit: src/lib/libc/net
Date: Wed, 13 Nov 2013 18:58:51 -0500

 Module Name:	src
 Committed By:	christos
 Date:		Wed Nov 13 23:58:51 UTC 2013

 Modified Files:
 	src/lib/libc/net: resolver.3

 Log Message:
 PR/48379: mention kqueue functionality


 To generate a diff of this commit:
 cvs rdiff -u -r1.26 -r1.27 src/lib/libc/net/resolver.3

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.