Merging etc


Merging /etc

The /etc/ directory contains system and program configuration information. When a program is changed, the configuration file format or syntax may also change. If you try to run a program on an obsolete configuration file, the program might not run correctly. You absolutely must update /etc before running your system! We covered /etc/ in expansive detail in Chapter 14 and particular pieces of /etc/ throughout this book. If you're not familiar with UNIX, you may want to keep this book at hand as a reference when trying to update /etc/.

No automated process can know how your machine is supposed to behave, so you must handle any changes to /etc/ yourself. You'll have to compare almost every file under /etc/ to its counterpart under /usr/src/etc and handle any changes that you find. This is a very tedious process to do by hand, but OpenBSD has tools to make this much simpler.

Preparations

After running the upgrade program, remove the OpenBSD boot media from your system and reboot your computer into single-user mode (Chapter 6).

 boot> boot -s 1 booting hd0a:/bsd: ... Enter pathname of shell or RETURN for sh: /bin/sh 2 # 

You can set any 1 other boot-time flags that don't interfere with a single-user boot, such as setting a tty to boot with a serial console. To get an actual shell prompt in single-user mode, you can just 2 hit ENTER or enter a full path to a shell other than sh. This alternate shell must be statically linked, as shared libraries are not yet available on the system. I recommend always sticking with /bin/sh in single-user mode.

Once you have a command prompt, perform some basic system setup. First, mount all of your usual partitions so you can have access to their files. Set a terminal type as well, so you can use vi(1) to edit system configurations.

 # mount -a # TERM=vt220; export TERM # 

You might also want to run df(1) to confirm that all your expected partitions are available.

Annoyingly, the "etc.tgz" distribution also contains the documentation for OpenBSD's integrated Apache web server. The program that is used to integrate changes to files within the /etc/ directory, mergemaster(8) will pick up these changed files as part of its comparison process and by default will ask you about each of these files. This can be extremely annoying, to say the least, and can make the /etc/ merging process much longer and far more tedious. The simplest way to get around this is to install the updated documentation from the installed source code, so that mergemaster(8) detects that the documents are up-to-date. Just run:

 # cd /usr/src/usr.sbin/httpd # make -f Makefile.bsd-wrapper distribution 

Installing Mergemaster

The mergemaster(8) program compares the files in /etc/ to the files in the source code for /etc/, displays any differences, and allows you to update your /etc/, reject the changes, or manually merge the two files together.

You want to be certain to have the latest version of mergemaster before running it, however. This generally means that you want the version that's available for the version you just upgraded to. Check your installation media for the mergemaster package, and check /var/db/pkg/ to see if you already have mergemaster. If you have the latest mergemaster installed, you're ready. If you have an older version than that available on your installation media, uninstall it with pkg_delete(1). You can then install the mergemaster script from a package or port (/usr/ports/sysutils/mergemaster).

The Network in Single-User Mode During an Upgrade

You may notice that your network connection doesn't come up in single-user mode, which is a problem if you need to grab mergemaster from a FTP server. The script /etc/netstart should bring up your network, but that script is written for the older version of OpenBSD on your system. I recommend trying the following things in order to configure the network. First, try running /etc/netstart, which will probably function as expected.

 # /bin/sh /etc/netstart 

This might fail if some of the network configuration commands have changed to expect different arguments. If so, try running the new version of /etc/netstart from the source code on your local system.

 # /bin/sh /usr/src/etc/netstart 

This may still fail, because the configuration files in /etc/rc.conf are not synchronized with what that script expects. If so, you need to bring up the network by hand. See ifconfig(8) and route(8) for some hints. If the two previous methods failed, you might have most but not all of your network set up and only have to add a route or add a flag to an ifconfig(8) statement.

This sort of headache is typical of the sort of things you can expect to have to deal with until your /etc/ directory is fully updated.

Running Mergemaster

Once installed, mergemaster(8) can be found in /usr/local/sbin. The script will create an up-to-date "shadow" root directory in /var/tmp/temproot, and then compare the contents of the existing /etc/ directory. This can take quite some time, and generates a huge amount of output.

 # /usr/local/sbin/mergemaster *** Creating the temporary root environment in /var/tmp/temproot  *** /var/tmp/temproot ready for use  *** Creating and populating directory structure in /var/tmp/temproot ... 

This sort of thing will go on for quite some time but eventually, mergemaster starts to compare the files.

 *** Beginning comparison  *** Temp ./dev/MAKEDEV and installed are the same, deleting 

Here, mergemaster found a file that was the same on the installed system as it was in the source code. Because these files are identical, and either keeping the old file or installing the new one makes no difference whatsoever, it doesn't waste your time and deletes the temporary copy. This is actually not uncommon. Files with differences between versions are much more interesting, however.

   *** Displaying differences between ./etc/ssh/sshd_config 1 and installed version --- /etc/ssh/sshd_config        Sat Apr 13 16:04:49 2002 +++ ./etc/ssh/sshd_config       Mon Nov 11 12:27:59 2002 @@ -1,7 +1,7 @@ 2 -#      $OpenBSD: sshd_config,v 1.49 2002/03/21 20:51:12 markus Exp $ 3 +#      $OpenBSD: sshd_config,v 1.59 2002/09/25 11:17:16 markus Exp $ 

Here, we're examining the installed 1 /etc/ssh/sshd_config and the version of sshd_config found in the latest source code. Lines from the two different files are intermixed, but lines from the old (currently installed) version have a leading minus sign, while lines found in the new version have a leading plus sign. This example shows us that the version number of this file changed from 2 1.49 to 3 1.59. Although this is a trivial change, it indicates that later in the file we will find quite a few additional changes. For example, later in the mergemaster output we'll see this entry.

 -#LoginGraceTime 600 +#LoginGraceTime 120 

Here, the LoginGraceTime variable has been reduced to 120 in the newer version of OpenBSD. You'd have to look in the sshd(8) documentation to see what this variable means, but the important thing for our example is that information in this file has changed. You need to decide if you want to update to the new configuration, or if you rely upon the behavior in your old configuration.

Once you reach the end of the file, mergemaster will present you with several options.

   Use 1 'd' to delete the temporary ./etc/ssh/sshd_config   Use 2 'i' to install the temporary ./etc/ssh/sshd_config   Use 3 'm' to merge the temporary and installed versions   Use 'v' to view the diff results again   Default is to leave the temporary file to deal with by hand How should I deal with this? [Leave it for later] 

If the updated file can safely be plugged into your system as is, you want to 1 install it. Other files contain only system-specific information (i.e., master. passwd), and should not be replaced during an upgrade. You can just 3 delete the temporary copy of the new version of the file. The default is to not do anything and leave the file in the temporary directory, so you can later install this file by hand.

Some files have modifications local to the system, however, and replacing them will destroy the system configuration. This includes files such as /etc/rc. conf, which will include both local changes and new configuration options. I generally recommend that new users leave the new versions of these files in the temporary root directory (/var/tmp/temproot), and go back and merge the changes by hand. Mergemaster has the ability to create these files on the fly, however, using the 2 merge feature.

Merging Changes

The merge function in mergemaster is actually not that difficult to use, but requires close attention to detail. A mistake here can leave your system unbootable or damage data. We're going to walk through a merge of /etc/rc.conf when upgrading a system from 3.1 to 3.2. Once you view the differences between the two files, hit "m" to begin the merge. Lines with differences will be presented side-by-side.

 #   1 $OpenBSD: rc.conf,v 1.72 2002 | #    2 $OpenBSD: rc.conf,v 1.79 2002 % 

Both entries are severely truncated by being displayed side-by-side, but they're still usable. The entry on the 1 left is currently installed in /etc, while the entry on the 2 right is the one from the new version of OpenBSD.

Mergemaster will walk through the entire file, creating a new file to install in /etc. Lines that are identical in both versions will be automatically entered into this file, and you can choose between the left and right entries on lines that have differences. Enter "r" to choose the entry on the right, and "l" to choose the entry on the left.

 rdate_flags=NO          # for normal  | rdate_flags=NO          # for normal % 

On an entry such as this you could probably guess that the difference lies on the far right side of the line, as part of the comment. In this sort of case, you want the most recent version of the line — otherwise, the next time you upgrade, merge-master will complain about the line again! Enter "r".

 photurisd_flags=NO      # for normal  < % 

Here, there's an entry on the left but none on the right. This entry has been removed from the file, so no /etc/rc scripts will be looking for this function. Delete the line by choosing the entry on the right — enter "r".

You don't always want the latest entry in /etc/rc.conf, however.

 portmap=YES           # almost alwa | portmap=NO              # Note: inetd % 

The portmap daemon was set to YES, but the default is now NO. If you need portmap, don't turn it off during the upgrade! Choose "l".

Once you've processed the entire file, mergemaster(8) will give you some choices for your new file.

 1  Use 'i' to install merged file 2  Use 'r' to re-do the merge 3  Use 'v' to view the merged file  Default is to leave the temporary file to deal with by hand    *** How should I deal with the merged file? [Leave it for later] v 

If you want to double-check your work, enter 3 "v". If you're satisfied with the results, you can enter 1 "i" to install the file you created. If you made a mistake, you can start over with "r".

Some file changes, such /dev/MAKEDEV, require other commands be run after updating the system. Mergemaster will ask you if it may run these commands. Let it. If you say no, your system may not work as desired.

 *** Comparison complete Do you wish to delete what is left of /var/tmp/temproot? [no] 

If you have chosen to leave some files in /var/tmp/temproot to compare manually, you need to leave the directory. Otherwise, tell mergemaster to delete it. You never want to reuse the same /var/tmp/temproot between different upgrades.

Once all of your /etc files have been updated, reboot the system. You could theoretically just exit from single-user mode and boot into the new userland with new /etc/ files, but there is a small possibility for error. An extra reboot is a small price to make sure that your system starts perfectly cleanly.




Absolute Openbsd(c) Unix for the Practical Paranoid
Absolute OpenBSD: Unix for the Practical Paranoid
ISBN: 1886411999
EAN: 2147483647
Year: 2005
Pages: 298

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net