Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 12 Jan 2012 19:50:47 GMT
From:      Dirk-Willem van Gulik <dirkx@webweaving.org>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: conf/164048: /etc/rc.d/hostid is not symlink aware
Message-ID:  <201201121950.q0CJolTG009687@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR conf/164048; it has been noted by GNATS.

From: Dirk-Willem van Gulik <dirkx@webweaving.org>
To: Matthew Story <matthewstory@gmail.com>
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 =
 <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?201201121950.q0CJolTG009687>