From owner-freebsd-bugs@FreeBSD.ORG Thu Jan 12 19:50:48 2012 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 270D210656E1 for ; Thu, 12 Jan 2012 19:50:48 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id D04418FC08 for ; Thu, 12 Jan 2012 19:50:47 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id q0CJolvI009690 for ; Thu, 12 Jan 2012 19:50:47 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id q0CJolTG009687; Thu, 12 Jan 2012 19:50:47 GMT (envelope-from gnats) Date: Thu, 12 Jan 2012 19:50:47 GMT Message-Id: <201201121950.q0CJolTG009687@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Dirk-Willem van Gulik Cc: Subject: Re: conf/164048: /etc/rc.d/hostid is not symlink aware X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Dirk-Willem van Gulik List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Jan 2012 19:50:48 -0000 The following reply was made to PR conf/164048; it has been noted by GNATS. From: Dirk-Willem van Gulik To: Matthew Story Cc: freebsd-gnats-submit@freebsd.org, freebsd-bugs@freebsd.org Subject: Re: conf/164048: /etc/rc.d/hostid is not symlink aware Date: Thu, 12 Jan 2012 20:47:18 +0100 On 12 jan. 2012, at 17:48, Matthew Story wrote: > On Thu, Jan 12, 2012 at 3:15 AM, Dirk-Willem van Gulik = wrote:=20 > [...snip]=20 > # If ${hostid_file} already exists, we take UUID from there. > - if [ -r ${hostid_file} ]; then > + # If ${hostid_file} already exists, we take UUID from there. = We use > + # a -f rather than a -r check as the histid_file may in fact = be > + # a symbolic link. >=20 > per the test man-page, `-r' tests for readability, regardless of type, = and `-f' tests for the existence of a regular file. `-r' does include = an implicit test for existence, so `-r' will in fact work for symlinks, = and fail reliably if the symlink source_file does not exist (relevant = bits from the test man-page at the bottom of this message): =85. > with this patch, if ${hostid_file} exists, and is non-readable, cat = ${hostid_file} will fail, and yield no $1 to hostid_set (effectively = identical to a hostid_file that is empty). this is not the desired = behavior: Totally understood - but wanted to stay close to the behavior of = dhclient-script as I understand it. And this happens to also make the = behavior of /etc/rc.d/sshd on first run the same. Keep in mind that one = can always set the rc variable. ... > This line is actually why you are seeing a hostid_file on restart. = The hostid_file does not exist on your system, and per the comment, and = implementation, if a hostid_file does not exist, one is generated and = set via sysctl (via the hostid_set function). Agreed - as _set is better. > There is a small race condition in this file (unless rc.d is doing = some locking on hostid_file in the caller) =85. Right - which in this case is one we should not worry about - this is = during boot - as the rc.d files are ran one by one; and generally not = twice. However - the lock issue does affect /sbin/dhclient-script - and = I've seen this behaviour there in the wild. Dw=