Date: Thu, 12 Jan 2012 20:47:18 +0100 From: Dirk-Willem van Gulik <dirkx@webweaving.org> To: Matthew Story <matthewstory@gmail.com> Cc: freebsd-bugs@freebsd.org, freebsd-gnats-submit@freebsd.org Subject: Re: conf/164048: /etc/rc.d/hostid is not symlink aware Message-ID: <32429C77-4BC1-44E3-BAF8-AB5A97058E9B@webweaving.org> In-Reply-To: <CAB%2B9ogdrZL9znurHyg2=5ST_Szg5aWuGCncSt%2BGtaucknZiikQ@mail.gmail.com> References: <201201120815.q0C8FONo062154@red.freebsd.org> <CAB%2B9ogdrZL9znurHyg2=5ST_Szg5aWuGCncSt%2BGtaucknZiikQ@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On 12 jan. 2012, at 17:48, Matthew Story wrote: > On Thu, Jan 12, 2012 at 3:15 AM, Dirk-Willem van Gulik = <dirkx@webweaving.org> 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=
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?32429C77-4BC1-44E3-BAF8-AB5A97058E9B>