From owner-freebsd-bugs@FreeBSD.ORG Thu Jan 12 19:47:20 2012 Return-Path: Delivered-To: freebsd-bugs@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7A51F106564A; Thu, 12 Jan 2012 19:47:20 +0000 (UTC) (envelope-from dirkx@webweaving.org) Received: from pikmeer.webweaving.org (unknown [IPv6:2001:1af8:4100:b040::20]) by mx1.freebsd.org (Postfix) with ESMTP id 179CF8FC1C; Thu, 12 Jan 2012 19:47:19 +0000 (UTC) Received: from [10.11.0.172] (thuis [83.86.203.230]) (authenticated bits=0) by pikmeer.webweaving.org (8.14.5/8.14.5) with ESMTP id q0CJjEpN014703 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO); Thu, 12 Jan 2012 19:45:14 GMT (envelope-from dirkx@webweaving.org) Mime-Version: 1.0 (Apple Message framework v1251.1) Content-Type: text/plain; charset=windows-1252 From: Dirk-Willem van Gulik In-Reply-To: Date: Thu, 12 Jan 2012 20:47:18 +0100 Content-Transfer-Encoding: quoted-printable Message-Id: <32429C77-4BC1-44E3-BAF8-AB5A97058E9B@webweaving.org> References: <201201120815.q0C8FONo062154@red.freebsd.org> To: Matthew Story X-Mailer: Apple Mail (2.1251.1) X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.5 (pikmeer.webweaving.org [178.18.23.51]); Thu, 12 Jan 2012 19:45:14 +0000 (UTC) Cc: freebsd-bugs@freebsd.org, freebsd-gnats-submit@freebsd.org 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 List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Jan 2012 19:47:20 -0000 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=