Bug 41949 - sysinstall(8): sysinstall sorts /etc/rc.conf during netboot
Summary: sysinstall(8): sysinstall sorts /etc/rc.conf during netboot
Status: Closed Overcome By Events
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 4.5-RELEASE
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-sysinstall (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-08-23 17:50 UTC by hburch
Modified: 2015-11-10 09:12 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description hburch 2002-08-23 17:50:04 UTC
Sysinstall sorts /etc/rc.conf after a netboot.  If packages append to the rc.conf, this can cause bad behavior (especially multiline ifs, for example).

This sort seems fraught with danger, including putting a "inetd_enable=YES" after a package-added "inetd_enable=NO" (or vice-versa, depending on what you think the behavior "should be").

There are many hacks around it, but I do not like anf of the ones I've heard.  You could also use rc.conf.local, which sysinstall does not appear to mess with, but I would prefer to save that for truly "local" configurations to the machine, not things we plan to do on all of our systems.

Amusingly, it reorders the comments that sysinstall itself adds to the file.

Fix: 

Delete lines 416-419 of /usr/src/release/sysinstall/config.c that do the sorting.
However, this was probably deliberately added for a reason, so does not really address whatever that reason was.
It does, however, make tracking changes easier, especially if the "sysinstall generated deltas" was timestamped.

Another option is to add "rc.conf.sysinstall" to rc_conf_files in /etc/defaults/rc.conf, listed first, and change where sysinstall does its changes, but then there's another file to worry about and check.
How-To-Repeat: Create a package that appends multiline ifs to /etc/rc.conf and install a FreeBSD system including it via netboot.
Comment 1 Johan Karlsson freebsd_committer freebsd_triage 2002-08-23 20:40:38 UTC
Responsible Changed
From-To: freebsd-bugs->freebsd-qa

Over to maintainer group.
Comment 2 hburch 2003-09-10 21:33:05 UTC
Proposed fix.

This patch adds two variables to config:
quickInstall (default NO)
  YES turns off sleep(2) after starting shell on VTY4 and sleep(1) after
     successful installation of package

sortRcConf (default YES)
  NO turns off the sort of /etc/rc.conf even when running as init.

Also fixes parantheses bug in tcpip.c: was doing DITEM_STATUS(foo ==
DITEM_SUCCESS) instead of DITEM_STATUS(foo) == DITEM_SUCCESS.  I did
not find any operational difficulties with this.

Note that this patch was made before sysinstall was moved to usr.sbin.

diff -c /usr/src/release/sysinstall/config.c ./config.c
*** /usr/src/release/sysinstall/config.c	Mon Sep 30 16:18:47 2002
--- ./config.c	Mon Oct 21 23:23:28 2002
***************
*** 415,421 ****
      fclose(rcSite);
      /* Tidy up the resulting file if it's late enough in the installation
  	for sort and uniq to be available */
!     if (RunningAsInit && file_readable("/usr/bin/sort") && file_readable("/usr/bin/uniq"))
  	(void)vsystem("sort /etc/rc.conf | uniq > /etc/rc.conf.new && mv /etc/rc.conf.new /etc/rc.conf");
  }
  
--- 415,421 ----
      fclose(rcSite);
      /* Tidy up the resulting file if it's late enough in the installation
  	for sort and uniq to be available */
!     if (RunningAsInit && file_readable("/usr/bin/sort") && file_readable("/usr/bin/uniq") && !variable_cmp(VAR_SORT_RCCONF,"NO"))
  	(void)vsystem("sort /etc/rc.conf | uniq > /etc/rc.conf.new && mv /etc/rc.conf.new /etc/rc.conf");
  }
  
Common subdirectories: /usr/src/release/sysinstall/help and ./help
diff -c /usr/src/release/sysinstall/package.c ./package.c
*** /usr/src/release/sysinstall/package.c	Mon Oct 21 22:47:14 2002
--- ./package.c	Mon Oct 28 17:07:03 2002
***************
*** 239,245 ****
  	    /* Now catch any stragglers */
  	    while (wait3(&tot, WNOHANG, NULL) > 0);
  
! 	    sleep(1);
  	    restorescr(w);
  	}
      }
--- 239,246 ----
  	    /* Now catch any stragglers */
  	    while (wait3(&tot, WNOHANG, NULL) > 0);
  
! 	    if (ret != DITEM_SUCCESS || variable_cmp(VAR_QUICK, "YES") != 0) 
! 		    sleep(1);
  	    restorescr(w);
  	}
      }
diff -c /usr/src/release/sysinstall/sysinstall.h ./sysinstall.h
*** /usr/src/release/sysinstall/sysinstall.h	Mon Oct 21 23:10:52 2002
--- ./sysinstall.h	Mon Oct 21 23:23:41 2002
***************
*** 166,171 ****
--- 166,172 ----
  #define VAR_PORTS_PATH			"ports"
  #define VAR_PPP_ENABLE			"ppp_enable"
  #define VAR_PPP_PROFILE			"ppp_profile"
+ #define VAR_QUICK			"quickInstall"
  #define VAR_RELNAME			"releaseName"
  #define VAR_ROOT_SIZE			"rootSize"
  #define VAR_ROUTER			"router"
***************
*** 173,178 ****
--- 174,180 ----
  #define VAR_ROUTERFLAGS			"router_flags"
  #define VAR_SERIAL_SPEED		"serialSpeed"
  #define VAR_SLOW_ETHER			"slowEthernetCard"
+ #define VAR_SORT_RCCONF			"sortRcConf"
  #define VAR_SWAP_SIZE			"swapSize"
  #define VAR_TAPE_BLOCKSIZE		"tapeBlocksize"
  #define VAR_TRY_DHCP			"tryDHCP"
diff -c /usr/src/release/sysinstall/system.c ./system.c
*** /usr/src/release/sysinstall/system.c	Mon Oct 21 23:10:52 2002
--- ./system.c	Mon Oct 28 17:07:23 2002
***************
*** 511,517 ****
  	        WINDOW *w = savescr();
  
  	        msgNotify("Starting an emergency holographic shell on VTY4");
! 	        sleep(2);
  	        restorescr(w);
  	    }
  	    else {
--- 511,517 ----
  	        WINDOW *w = savescr();
  
  	        msgNotify("Starting an emergency holographic shell on VTY4");
! 		if (variable_cmp(VAR_QUICK,"YES") != 0) sleep(2);
  	        restorescr(w);
  	    }
  	    else {
diff -c /usr/src/release/sysinstall/tcpip.c ./tcpip.c
*** /usr/src/release/sysinstall/tcpip.c	Mon Oct 21 23:10:52 2002
--- ./tcpip.c	Mon Oct 21 23:32:01 2002
***************
*** 649,662 ****
  	    return devs[0];
      }
      if (cnt == 1) {
! 	if (DITEM_STATUS(tcpOpenDialog(devs[0]) == DITEM_SUCCESS))
  	    rval = devs[0];
      }
      else if (variable_get(VAR_NONINTERACTIVE) && variable_get(VAR_NETWORK_DEVICE)) {
  	devs = deviceFind(variable_get(VAR_NETWORK_DEVICE), DEVICE_TYPE_NETWORK);
  	cnt = deviceCount(devs);
  	if (cnt) {
! 	    if (DITEM_STATUS(tcpOpenDialog(devs[0]) == DITEM_SUCCESS))
  		rval = devs[0];
  	}
      }
--- 649,662 ----
  	    return devs[0];
      }
      if (cnt == 1) {
! 	if (DITEM_STATUS(tcpOpenDialog(devs[0])) == DITEM_SUCCESS)
  	    rval = devs[0];
      }
      else if (variable_get(VAR_NONINTERACTIVE) && variable_get(VAR_NETWORK_DEVICE)) {
  	devs = deviceFind(variable_get(VAR_NETWORK_DEVICE), DEVICE_TYPE_NETWORK);
  	cnt = deviceCount(devs);
  	if (cnt) {
! 	    if (DITEM_STATUS(tcpOpenDialog(devs[0])) == DITEM_SUCCESS)
  		rval = devs[0];
  	}
      }
Comment 3 Gavin Atkinson freebsd_committer freebsd_triage 2010-07-13 14:48:57 UTC
Responsible Changed
From-To: freebsd-bugs->freebsd-sysinstall

Over to maintainer(s)
Comment 4 Enji Cooper freebsd_committer freebsd_triage 2015-11-10 09:07:50 UTC
sysinstall has been replaced by bsdinstall in FreeBSD 9.x. Closing.
Comment 5 Enji Cooper freebsd_committer freebsd_triage 2015-11-10 09:12:25 UTC
sysinstall has been replaced by bsdinstall in FreeBSD 9.x. Closing.