From owner-freebsd-bugs@FreeBSD.ORG Thu Jan 12 08:20:12 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 4D8C81065672 for ; Thu, 12 Jan 2012 08:20:12 +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 268618FC16 for ; Thu, 12 Jan 2012 08:20:12 +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 q0C8KCgV088321 for ; Thu, 12 Jan 2012 08:20:12 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id q0C8KB4k088320; Thu, 12 Jan 2012 08:20:11 GMT (envelope-from gnats) Resent-Date: Thu, 12 Jan 2012 08:20:11 GMT Resent-Message-Id: <201201120820.q0C8KB4k088320@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Dirk-Willem van Gulik Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 64451106564A for ; Thu, 12 Jan 2012 08:15:25 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22]) by mx1.freebsd.org (Postfix) with ESMTP id 350D28FC13 for ; Thu, 12 Jan 2012 08:15:25 +0000 (UTC) Received: from red.freebsd.org (localhost [127.0.0.1]) by red.freebsd.org (8.14.4/8.14.4) with ESMTP id q0C8FOAv062155 for ; Thu, 12 Jan 2012 08:15:24 GMT (envelope-from nobody@red.freebsd.org) Received: (from nobody@localhost) by red.freebsd.org (8.14.4/8.14.4/Submit) id q0C8FONo062154; Thu, 12 Jan 2012 08:15:24 GMT (envelope-from nobody) Message-Id: <201201120815.q0C8FONo062154@red.freebsd.org> Date: Thu, 12 Jan 2012 08:15:24 GMT From: Dirk-Willem van Gulik To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: 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 08:20:12 -0000 >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 root@foem.leiden.webweaving.org:/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: