Bug 47140

Summary: 5.0 with rc_ng and nis hangs at startup
Product: Base System Reporter: Mark Hannon <markhannon>
Component: binAssignee: Mike Makonnen <mtm>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 5.0-CURRENT   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
old_rc
none
new_rc
none
nsswitch.conf
none
dmesg_030120
none
nsswitch.conf
none
rc.conf none

Description Mark Hannon 2003-01-16 11:50:05 UTC
	
Clean install of 5.0-RC2, source upgrade to 5.0-CURRENT cvsuped a few hours ago.
Machine is a nis client, relevant sections of rc.conf are:

  nis_client_enable="YES"
  nisdomainname="home.lan"
  rpcbind_enable="YES"

At startup the machine hangs after the network interfaces have been 
configured and the results displayed.  Pressing Control-C allows the 
boot to continue.

Fix: 

Setting rc_ng="NO" gets things working.
Comment 1 Mike Makonnen 2003-01-16 16:37:58 UTC
Please put rc_debug=yes
in your rc.conf, reboot and send me the resulting output from the system log or 
copy and paste from console.

Cheers.
-- 
Mike Makonnen  | GPG-KEY: http://www.identd.net/~mtm/mtm.asc
mtm@identd.net | Fingerprint: D228 1A6F C64E 120A A1C9  A3AA DAE1 E2AF DBCC 68B9
Comment 2 Mark Hannon 2003-01-18 11:28:52 UTC
Mike Makonnen wrote:

>Please put rc_debug=yes
>in your rc.conf, reboot and send me the resulting output from the system log or 
>copy and paste from console.
>
>Cheers.
>  
>
Hi Mike,

Here are two files, one with the old rc system and one with the new.  In 
the new
case the system hangs after printing the line:

    /etc/rc.d/ipfilter: DEBUG: checkyesno: ipfilter_enable is set to NO.

Control-C allows the boot to proceed.

Regards/Mark

Comment 3 Mark Hannon 2003-01-19 22:43:16 UTC
Hello,

Some more clues.  Deleting /etc/nsswitch.conf and rebooting works fine. 
 A dummy
/etc/nsswitch.conf is created and the bootup continues.

My /etc/nsswitch.conf is attached.

/mark

Comment 4 Mike Makonnen freebsd_committer freebsd_triage 2003-01-20 00:21:37 UTC
Responsible Changed
From-To: freebsd-bugs->mtm

I'm working on this. 
Thanks for providing the extra info.
Comment 5 Mike Makonnen 2003-01-20 04:54:33 UTC
Hi Mark,

Can you try the following patch?
If it doesn't fix your problem can you grab the latest /etc/rc.subr (ver. 1.9)
and repost the rc startup log with rc_debug set. It would also be helpful if you
posted your *entire* rc.conf.

Cheers.
-- 
Mike Makonnen  | GPG-KEY: http://www.identd.net/~mtm/mtm.asc
mtm@identd.net | Fingerprint: D228 1A6F C64E 120A A1C9  A3AA DAE1 E2AF DBCC 68B9

Index: etc/rc.d/network1
===================================================================
RCS file: /home/ncvs/src/etc/rc.d/network1,v
retrieving revision 1.144
diff -u -r1.144 network1
--- etc/rc.d/network1	13 Dec 2002 23:36:31 -0000	1.144
+++ etc/rc.d/network1	20 Jan 2003 04:44:33 -0000
@@ -13,52 +13,50 @@
 start_cmd="network_start"
 stop_cmd="network_stop"
 
-convert_host_conf()
-{
-	host_conf=$1; shift;
-	nsswitch_conf=$1; shift;
-	awk '                                                               \
-	/^[:blank:]*#/       { next }                                       \
-	/(hosts|local|file)/ { nsswitch[c] = "files"; c++; next }           \
-	/(dns|bind)/         { nsswitch[c] = "dns";   c++; next }           \
-	/nis/                { nsswitch[c] = "nis";   c++; next }           \
-	{ printf "Warning: unrecognized line [%s]", $0 > "/dev/stderr" }    \
-	END {                                                               \
-		printf "hosts: ";                                           \
-		for (i in nsswitch) printf "%s ", nsswitch[i];              \
-		printf "\n";                                                \
-	}' < $host_conf > $nsswitch_conf
+convert_host_conf() {
+    host_conf=$1; shift;
+    nsswitch_conf=$1; shift;
+    awk '                                                                   \
+        /^[:blank:]*#/       { next }                                       \
+        /(hosts|local|file)/ { nsswitch[c] = "files"; c++; next }           \
+        /(dns|bind)/         { nsswitch[c] = "dns";   c++; next }           \
+        /nis/                { nsswitch[c] = "nis";   c++; next }           \
+        { printf "Warning: unrecognized line [%s]", $0 > "/dev/stderr" }    \
+        END {                                                               \
+                printf "hosts: ";                                           \
+                for (i in nsswitch) printf "%s ", nsswitch[i];              \
+                printf "\n";                                                \
+        }' < $host_conf > $nsswitch_conf
 }
 
-generate_host_conf()
-{
-	nsswitch_conf=$1; shift;
-	host_conf=$1; shift;
-
-	awk '
-	BEGIN {
-		xlat["files"] = "hosts";
-		xlat["dns"] = "bind";
-		xlat["nis"] = "nis";
-		cont = 0;
-	}
-	sub(/^[\t ]*hosts:/, "") || cont {
-		if (!cont)
-			srcs = ""
-		sub(/#.*/, "")
-		gsub(/[][]/, " & ")
-		cont = sub(/\\$/, "")
-		srcs = srcs " " $0
-	}
-	END {
-		print "# Auto-generated from nsswitch.conf, do not edit"
-		ns = split(srcs, s)
-		for (n = 1; n <= ns; ++n) {
-			if (s[n] in xlat)
-			    print xlat[s[n]]
-		}
-	}
-	' <$nsswitch_conf >$host_conf
+generate_host_conf() {
+    nsswitch_conf=$1; shift;
+    host_conf=$1; shift;
+    
+    awk '
+BEGIN {
+    xlat["files"] = "hosts";
+    xlat["dns"] = "bind";
+    xlat["nis"] = "nis";
+    cont = 0;
+}
+sub(/^[\t ]*hosts:/, "") || cont {
+    if (!cont)
+	srcs = ""
+    sub(/#.*/, "")
+    gsub(/[][]/, " & ")
+    cont = sub(/\\$/, "")
+    srcs = srcs " " $0
+}
+END {
+    print "# Auto-generated from nsswitch.conf, do not edit"
+    ns = split(srcs, s)
+    for (n = 1; n <= ns; ++n) {
+        if (s[n] in xlat)
+            print xlat[s[n]]
+    }
+}
+' <$nsswitch_conf >$host_conf
 }
 
 network_gif_setup() {
Comment 6 Mark Hannon 2003-01-20 12:27:05 UTC
Hi Mike,

Tried the attached patch, no luck, grabbed the latest rc.subr and
generated the
debug output you asked for.

Regards/mark
Comment 7 Mike Makonnen 2003-01-21 04:50:16 UTC
There is something that confuses me:
	/etc/rc.d/ipfilter: DEBUG: checkyesno: ipfilter_enable is set to NO.
	/etc/rc: DEBUG: run_rc_command: evaluating ().
	/etc/rc: DEBUG: checkyesno: firewall_enable is set to NO.
 
Between the ipfilter line and the next one should be a line checking the
value of ppp_enable, but it doesn't appear here. So, it seems that the boot may
have hung in the ppp-user script and have nothing to do with nis. But then why
would killing nsswitch.conf cure it....

Have you modified in any way the ppp configuration files or
/etc/defaults/rc.conf?

Can you also try and narrow the problem down. For example, by commenting out
each nis/nfs related line in rc.conf one by one and seeing which one causes the
hang?

Also, is nis or nfs hampered in any way after you Control-C?

What does ps(1) look like after it finishes booting?

Just so we're on the same page, you are rebooting between changes, right?
You're not just shutting down to single user and then bringing it back up.

I will try to setup a similar environment using the rc.conf you gave me and see
if I can reproduce the problem.

Cheers.
-- 
Mike Makonnen  | GPG-KEY: http://www.identd.net/~mtm/mtm.asc
mtm@identd.net | Fingerprint: D228 1A6F C64E 120A A1C9  A3AA DAE1 E2AF DBCC 68B9
Comment 8 Mike Makonnen 2003-02-10 09:44:22 UTC
Hi Mark,

Can you give the following patch a try. It definitely fixes a bug, and I have a
feeling it's related to your problem.

Cheers.
-- 
Mike Makonnen  | GPG-KEY: http://www.identd.net/~mtm/mtm.asc
mtm@identd.net | Fingerprint: D228 1A6F C64E 120A A1C9  A3AA DAE1 E2AF DBCC 68B9

Index: etc/rc.d/cleanvar
===================================================================
RCS file: /home/ncvs/src/etc/rc.d/cleanvar,v
retrieving revision 1.2
diff -u -r1.2 cleanvar
--- etc/rc.d/cleanvar	12 Oct 2002 10:31:31 -0000	1.2
+++ etc/rc.d/cleanvar	10 Feb 2003 09:32:53 -0000
@@ -33,7 +33,7 @@
 	fi
 }
 
-rm -f /var/run/clean_var /var/spool/lock/clean_var
+[ "$1" = "faststart" ] && rm -f /var/run/clean_var /var/spool/lock/clean_var
 if [ -d /var/run -a ! -f /var/run/clean_var ]; then
 	purgedir /var/run
 	# And an initial utmp file
Comment 9 Mike Makonnen freebsd_committer freebsd_triage 2003-02-16 21:22:35 UTC
State Changed
From-To: open->analyzed

The ppp-user service allows the admin to start ppp as a user other 
than root. As part of its chrooting facility /etc/rc.subr used 
id(1) to check if the current user == the ppp_user. If the user 
has provided an nsswitch.conf mapping for the passwd database 
specifying the 'nis' source before 'files', then getpwuid(3) times 
out trying to query an nis facility that doesn't yet exist. 
This is the specific problem here, but it can also manifest itself 
if any service or local customizations that try to use nis before it's 
setup. 

I'm not sure what to do about this. I'll look to see if the nsdispatch(3) 
reolver can be modified to fail gracefully.
Comment 10 Mike Makonnen freebsd_committer freebsd_triage 2003-04-19 22:40:34 UTC
State Changed
From-To: analyzed->closed

Fixed with the latest round of rc.d changes. 
The nisdomain script will not set the domain name 
untill after rpcbind is running.