>Number:         164048
>Category:       conf
>Synopsis:       /etc/rc.d/hostid is not symlink aware
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jan 12 08:20:11 UTC 2012
>Closed-Date:
>Last-Modified:
>Originator:     Dirk-Willem van Gulik
>Release:        FreeBSD 8 & 9
>Organization:
Webweaving
>Environment:
FreeBSD foem.leiden.webweaving.org 8.2-RELEASE-p2 FreeBSD 8.2-RELEASE-p2 #0: 
Tue Dec 27 15:40:46 CET 2011     
[email protected]:/usr/obj/usr/src/sys/FOEM  amd64

>Description:
/sbin/dhclient-script, /etc/rc.d/hostid and /etc/rc.d/sshd are the only three 
scripts that write in /etc. In some embedded environments, 
heavily-audited/secure, PXE boots, NFS root's and in, say, virtualbox or Xen, 
it can be very nice to have a fully-read only / and/or /etc.

dhclient-script and /etc/rc.d/sshd are both aware of the fact that the 
destination may be a symlink. /etc/rc.d/hostid is not (yet).

Below is a suggestion. Note that this is an alternative to setting the 
hostid_file to some place.


>How-To-Repeat:
Create a read only /etc; put a symlink for all the writable files:

   ln -s /var/run/resolv.conf /etc
   ln -s /var/run/hostid /etc
   ln -s /var/db/
   ln -s /var/db/ssh_host_dsa_key /etc/ssh
   ln -s /var/db/ssh_host_key /etc/ssh
   ln -s /var/db/ssh_host_rsa_key /etc/ssh
   ln -s /var/db/ssh_host_dsa_key.pub /etc/ssh
   ln -s /var/db/ssh_host_key.pub /etc/ssh
   ln -s /var/db/ssh_host_rsa_key.pub /etc/ssh
 
reboot - and observe that all works - but that

   cat /etc/hostid

shows it to be empty . Apply below - reboot and see that /var/run/hostid now 
contains the hostid - visible also as /etc/hostid.


>Fix:
--- /etc/rc.d/hostid    2011-02-17 03:19:40.000000000 +0100
+++ /tmp/hostid 2012-01-12 09:10:09.000000000 +0100
@@ -90,12 +90,15 @@
 
 hostid_start()
 {
-       # 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.
+       #
+       if [ -f ${hostid_file} ]; then
                hostid_set `cat ${hostid_file}`
        else
                # No hostid file, generate UUID.
-               hostid_generate
+               hostid_reset
        fi
 }

>Release-Note:
>Audit-Trail:
>Unformatted:
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "[email protected]"

Reply via email to