Mon Nov 1 14:42:08 2010 UTC ()
From Anon Ymous:
Send the SIGALRM to the correct process when we timeout. See the note
in src/etc/rc regarding RC_PID.

The former code would leave you with a root shell when the prompt
timed out (if the tty is marked secure) while continuing the boot
process in another shell.  This was easily hidden if you started
xdm(1) at boot, while the root shell remains on another tty
(accessible with CTL-ALT-F1).


(christos)
diff -r1.13 -r1.14 src/etc/rc.d/bootconf.sh

cvs diff -r1.13 -r1.14 src/etc/rc.d/bootconf.sh (switch to unified diff)

--- src/etc/rc.d/bootconf.sh 2009/09/12 17:40:01 1.13
+++ src/etc/rc.d/bootconf.sh 2010/11/01 14:42:08 1.14
@@ -1,87 +1,86 @@ @@ -1,87 +1,86 @@
1#!/bin/sh 1#!/bin/sh
2# 2#
3# $NetBSD: bootconf.sh,v 1.13 2009/09/12 17:40:01 apb Exp $ 3# $NetBSD: bootconf.sh,v 1.14 2010/11/01 14:42:08 christos Exp $
4# 4#
5 5
6# PROVIDE: bootconf 6# PROVIDE: bootconf
7# REQUIRE: mountcritlocal 7# REQUIRE: mountcritlocal
8# KEYWORD: interactive 8# KEYWORD: interactive
9 9
10$_rc_subr_loaded . /etc/rc.subr 10$_rc_subr_loaded . /etc/rc.subr
11 11
12name="bootconf" 12name="bootconf"
13start_cmd="bootconf_start" 13start_cmd="bootconf_start"
14stop_cmd=":" 14stop_cmd=":"
15 15
16bootconf_start() 16bootconf_start()
17{ 17{
18 # Refer to newbtconf(8) for more information 18 # Refer to newbtconf(8) for more information
19 # 19 #
20 20
21 if [ ! -e /etc/etc.current ]; then 21 if [ ! -e /etc/etc.current ]; then
22 return 0 22 return 0
23 fi 23 fi
24 if [ -h /etc/etc.default ]; then 24 if [ -h /etc/etc.default ]; then
25 def=$(ls -ld /etc/etc.default 2>&1) 25 def=$(ls -ld /etc/etc.default 2>&1)
26 default="${def##*-> *etc.}" 26 default="${def##*-> *etc.}"
27 else 27 else
28 default=current 28 default=current
29 fi 29 fi
30 if [ "$default" = "current" ]; then 30 if [ "$default" = "current" ]; then
31 def=$(ls -ld /etc/etc.current 2>&1) 31 def=$(ls -ld /etc/etc.current 2>&1)
32 default="${def##*-> *etc.}" 32 default="${def##*-> *etc.}"
33 fi 33 fi
34 34
35 spc="" 35 spc=""
36 for i in /etc/etc.*; do 36 for i in /etc/etc.*; do
37 name="${i##/etc/etc.}" 37 name="${i##/etc/etc.}"
38 case $name in 38 case $name in
39 current|default|\*) 39 current|default|\*)
40 continue 40 continue
41 ;;  41 ;;
42 *) 42 *)
43 if [ "$name" = "$default" ]; then 43 if [ "$name" = "$default" ]; then
44 echo -n "${spc}[${name}]" 44 echo -n "${spc}[${name}]"
45 else 45 else
46 echo -n "${spc}${name}" 46 echo -n "${spc}${name}"
47 fi 47 fi
48 spc=" " 48 spc=" "
49 ;; 49 ;;
50 esac 50 esac
51 done 51 done
52 echo 52 echo
53 master=$$ 
54 _DUMMY=/etc/passwd 53 _DUMMY=/etc/passwd
55 conf=${_DUMMY} 54 conf=${_DUMMY}
56 while [ ! -d /etc/etc.$conf/. ]; do 55 while [ ! -d /etc/etc.$conf/. ]; do
57 trap "conf=$default; echo; echo Using default of $default" ALRM 56 trap "conf=$default; echo; echo Using default of $default" ALRM
58 echo -n "Which configuration [$default] ? " 57 echo -n "Which configuration [$default] ? "
59 (sleep 30 && kill -ALRM $master) >/dev/null 2>&1 & 58 (sleep 30 && kill -ALRM $RC_PID) >/dev/null 2>&1 &
60 read conf 59 read conf
61 trap : ALRM 60 trap : ALRM
62 if [ -z $conf ] ; then 61 if [ -z $conf ] ; then
63 conf=$default 62 conf=$default
64 fi 63 fi
65 if [ ! -d /etc/etc.$conf/. ]; then 64 if [ ! -d /etc/etc.$conf/. ]; then
66 conf=${_DUMMY} 65 conf=${_DUMMY}
67 fi 66 fi
68 done 67 done
69 68
70 print_rc_metadata "note:Using configuration \"${conf}\"" 69 print_rc_metadata "note:Using configuration \"${conf}\""
71 70
72 case $conf in 71 case $conf in
73 current|default) 72 current|default)
74 ;; 73 ;;
75 *) 74 *)
76 rm -f /etc/etc.current 75 rm -f /etc/etc.current
77 ln -s etc.$conf /etc/etc.current 76 ln -s etc.$conf /etc/etc.current
78 ;; 77 ;;
79 esac 78 esac
80 79
81 if [ -f /etc/rc.conf ] ; then 80 if [ -f /etc/rc.conf ] ; then
82 . /etc/rc.conf 81 . /etc/rc.conf
83 fi 82 fi
84} 83}
85 84
86load_rc_config $name 85load_rc_config $name
87run_rc_command "$1" 86run_rc_command "$1"