From owner-freebsd-current@FreeBSD.ORG Wed Feb 11 18:48:19 2015 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 67DF0182; Wed, 11 Feb 2015 18:48:19 +0000 (UTC) Received: from smtp.vangyzen.net (hotblack.vangyzen.net [199.48.133.146]) by mx1.freebsd.org (Postfix) with ESMTP id 49D219B5; Wed, 11 Feb 2015 18:48:18 +0000 (UTC) Received: from marvin.lab.vangyzen.net (c-24-125-214-90.hsd1.va.comcast.net [24.125.214.90]) by smtp.vangyzen.net (Postfix) with ESMTPSA id B1EF056467; Wed, 11 Feb 2015 12:48:17 -0600 (CST) Message-ID: <54DBA3EA.6050706@vangyzen.net> Date: Wed, 11 Feb 2015 13:48:10 -0500 From: Eric van Gyzen User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: =?windows-1252?Q?Jean-S=E9bastien_P=E9dron?= , freebsd-current@freebsd.org Subject: Re: unbound crashes on bootup References: <1264.1423227963@critter.freebsd.dk> <54DB9A0C.1010806@FreeBSD.org> In-Reply-To: <54DB9A0C.1010806@FreeBSD.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Feb 2015 18:48:19 -0000 On 02/11/2015 13:06, Jean-S=E9bastien P=E9dron wrote: > On 06.02.2015 14:06, Poul-Henning Kamp wrote: >> I just updated my -current to r278283, and unbound (still) croaks >> during bootup: > > Hi! > > I have a similar problem. Also, unbound crashes each time I start/stop > OpenVPN. I suppose the problem is the same in both cases. > > The crash happens in the config_lookup_uid() in > contrib/unbound/util/config_file.c. Here's the code: > > struct passwd *pwd; > if((pwd =3D getpwnam(cfg->username)) =3D=3D NULL) > log_err("user '%s' does not exist.", cfg->username); > cfg->uid =3D pwd->pw_uid; getpwnam() is not thread-safe. I'm surprised unbound would use it.=20 Calling it from multiple threads can cause trouble, although I don't know off-hand if it could cause this problem. As an experiment, you might change it to getpwnam_r() and see it the problem persists. Otherwise, adding errno to the log message might help. Be sure to zero errno before calling getpwnam(). > getpwnam(3) returns NULL: an error message is logged but the function > doesn't return. Therefore, the program segfaults on "pwd->pw_uid" on th= e > next line. > > But why did getpwnam(3) return NULL in the first place? It looks for th= e > "unbound" user which exists. getpwnam() calls _nsdispatch() which fails= =2E > > I have the default nsswitch.conf. I didn't look at the problem more > deeply yet, but could getpwnam()/_nsdispatch() be unhappy with the > absence of a working DNS resolver (unbound is being (re)started)? >