From nobody@FreeBSD.org  Thu Jul 30 16:53:25 2009
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 010C61065673
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 30 Jul 2009 16:53:25 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id E369D8FC17
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 30 Jul 2009 16:53:24 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id n6UGrOXA011463
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 30 Jul 2009 16:53:24 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id n6UGrODb011462;
	Thu, 30 Jul 2009 16:53:24 GMT
	(envelope-from nobody)
Message-Id: <200907301653.n6UGrODb011462@www.freebsd.org>
Date: Thu, 30 Jul 2009 16:53:24 GMT
From: Alex Keda <admin@lissyara.su>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Cannot update /etc/host.conf when root filesystems mount read-only
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         137271
>Category:       conf
>Synopsis:       [rc.d] Cannot update /etc/host.conf when root filesystems mount read-only
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-rc
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jul 30 17:00:04 UTC 2009
>Closed-Date:    
>Last-Modified:  Fri Jun 04 01:12:39 UTC 2010
>Originator:     Alex Keda
>Release:        7.2
>Organization:
USSR
>Environment:
FreeBSD router.local 7.2-RELEASE FreeBSD 7.2-RELEASE #0: Wed May 13 22:39:57 MSD 2009     lissyara@router.local:/usr/obj/usr/src/sys/GENERIC  i386
>Description:
if root filesystem mount read-only (nfs, or etc), when machine boot I see
Generating host.conf.
eval: cannot create /etc/host.conf: Read-only file system
eval: cannot create /etc/host.conf: Read-only file system
eval: cannot create /etc/host.conf: Read-only file system
========
in file /etc/rc.d/nsswitch I see:
router# grep -R generate_host_conf *
rc.d/nsswitch:generate_host_conf()
rc.d/nsswitch:          generate_host_conf /etc/nsswitch.conf /etc/host.conf

filename for host.conf is hardcoded =(
>How-To-Repeat:
boot with / mounted read-only
>Fix:
may be add variable into /etc/defaults/rc.conf?

>Release-Note:
>Audit-Trail:

From: Efstratios Karatzas <gpf.kira@gmail.com>
To: bug-followup@freebsd.org, admin@lissyara.su
Cc:  
Subject: Re: misc/137271: Cannot update /etc/host.conf when root filesystems 
	mount read-only
Date: Thu, 28 Jan 2010 23:18:00 +0200

 Hi!
 
 Not sure if this belongs in the PR database, but I have a couple of quick fixes.
 
 fix a)
 step 1:
 
 append the following line to your /etc/rc.conf file
 
 sudo echo "nsswitch_host_conf=\"/usr/local/etc/host.conf\" " >> /etc/rc.conf
 
 You can of course change the pathname to whatever you desire, as well
 as the variable name as long as it begins with a "nsswitch_" prefix
 
 step 2:
 goto /etc/rc.d/nsswitch
 
 As you can see, in lines 93, 94 & and 97 the "/etc/host.conf" is hardcoded
 Replace it with the variable defined in /etc/rc.conf
 
 For example, line 93 becomes
 if [ ! -f $nsswitch_host_conf -o \
 
 etc. So no more hardcoding!
 
 *But* I really doubt that changing the location of system
 configuration files is
 a wise thing to do. I would avoid this solution and go with the
 solution b instead.
 
 fix b)
 Just boot with read/write partition / so you can make /etc/host.conf a
 symbolic link
 to /usr/local/etc/host.conf or some other path of your picking. Then change to
 read only mode for the partition. Makes more sense and seems a lot safer.
 Hope this helps.
 
 Cheers
 
 -- 
 
 Efstratios "GPF" Karatzas
Responsible-Changed-From-To: freebsd-bugs->freebsd-rc 
Responsible-Changed-By: gavin 
Responsible-Changed-When: Sat Apr 10 09:14:30 UTC 2010 
Responsible-Changed-Why:  
Over to -rc maintainers 

http://www.freebsd.org/cgi/query-pr.cgi?pr=137271 
>Unformatted:
