TEPATCHE - OpenBSD automatic system patcher / Parchador Automático de sistema OpenBSD
RATIONALE
OpenBSD is a stable, robust and secure operating system. Systems administrators running OpenBSD tend to be also more security conscious than administrators running other operating systems. Nevertheless, patching an OpenBSD system can be a tedious process for many people. If a person manages multiple OpenBSD servers, patching each of them can be a long and repetitive task, ideal for automatization.
Tepatche will periodically check the FTP site we indicate it to, and if there is a new patch to be applied, downloads, applies, builds and installs it. Tepatche mantains a small status database to know in what is the status of each of the system’s patches.
REQUIREMENTS
- A full OpenBSD installation (including source code in /usr/src and kernel source in /usr/src/sys). This code was tested with OpenBSD release 3.1, but while designing it, patches for 2.9 and 3.0 were also studied and, as the format is the same, they should work. It is important to mention that version 2.9 and older releases ARE NO LONGER MANTAINED, no new patches will be issued for them. It is important to upgrade if you are running an older version.
- Tepatche uses Perl's Net::FTP module. You can install it from ports (p5-libnet) or from the CPAN. Tepatche was developed and tested with p5-libnet-1.0901, the version in 3.1's ports.
NOTES
- Tepatche is released under a BSD license - read the COPYING file.
- This is EXPERIMENTAL code. It works for me. However, it is code intended to be run as root and to modify vital system binaries, and a programming error can have nasty consequences.
- Tepatche assumes that the patches published in the specified ftphost is trustable. If the ftphost (typically ftp.openbsd.org or one of its mirrors) were to be comprimised, anything can happen. If Tepatche installed a compromised patch, you can revert it with patch's option -R (see man patch(1)). Note that tepatche will not run any command it finds in a patch, only what it can recognize... but there is still plenty of space there.
- If applying a patch requires kernel compilation, the system administrator MUST DO SO MANUALLY. Tepatche will patch the sources, but building the kernel involves many steps that do require manual operator involvement.
- Tepatche will ONLY patch the base system - If you use any extra ports, they WILL NOT be patched. Please refer to the note on ports and the security audit at http://www.openbsd.org/ports.html
USAGE
Tepatche consists of one program file (/usr/local/sbin/tepatche), a configuration file (/etc/tepatche.conf) and a data directory (/var/db/tepatche/). The configuration file has the following fields:
- ftphost: Which FTP server to connect to (i.e. ftp.openbsd.org)
- ftpdir: Which is the base FTP directory for the patches (i.e. /pub/OpenBSD/patches/3.1)
- ftppasv: Whether passive FTP mode is required (1) or not (0)
- ftplogin: username and password to log in (separated by comma, i.e. anonymous, gwolf@gwolf.cx)
- archs: Comma-separated list of architectures to download (i.e. i386, common) Please remember to include common!
- patchdir: Where are the patches stored in our computer (i.e. /var/db/tepatche)
- statusfile: Where is the status file (i.e. /var/db/tepatche/statusfile)
With this file in place, Tepatche can be run simply with no arguments, just /usr/local/sbin/tepatche. I suggest you to run it from your crontab (see man crontab(5)). I suggest running it once a day, at most once an hour - please don’t flood ftp.openbsd.org with requests every minute ;-)
STATUS FILE
Tepatche keeps the information it needs about the state of the system in the ‘statusfile’ (by default, located at /var/db/tepatche/statusfile). This is a plain-text file following the format:
<descriptor>::<status>
Where ‘descriptor’ is an alphanumeric string, and ‘status’ is a valid status number. Valid status numbers are:
- 1: new - The patch has just been downloaded
- 2: applied - The patch has been applied to the source tree
- 3: built - The relevant binaries have been generated in the source tree
- 4: installed - The binaries have been installed in their place. The patch is completely applied now.
- 5: kernel - The patch requires the kernel to be recompiled. When tepatche reaches this stage, the patch has been applied, but not yet built.
- 10: error - There was an error at some point in the patching process
The descriptor is usually in the form <arch>/<num>_<description>.patch - It states the architecture for which it was created, the consecutive patch number, a very short description on what it does, and the ‘.patch’ suffix. This is the standard nomenclature followed by the OpenBSD team. a sample name would be:
common/001_sshafs.patch
This shows that the patch will be applied to all architectures (common), it is the first patch produced for this release (001), and it fixes a problem related to ‘sshafs’.
If you want to modify this file (of course, always AT YOUR VERY OWN RISK), you can follow this conventions to let Tepatche know the new status of the patch. For example, in the 3.1 release a very dangerous bug appeared in OpenSSH. The OpenBSD team advised to upgrade to OpenSSH 3.4, overwriting the /usr/src/usr.bin/ssh directory. Later, they published a patch (common/006_sshpreauth.patch) to fix the vulnerability for people who prefered not to upgrade. Many people already have the 3.4 tree installed, and the patch files to be applied. You should then edit /var/db/tepatche/statusfile and replace
common/006_sshpreauth.patch::10
by
common/006_sshpreauth.patch::4</pre>
TO DO
At least:
- Make output more friendly (half-done)
- Handle error cases more reliably (half-done)
- Add a non-paranoic option (maybe?)
- Add some more levels to the statusfile, explaining the reasons for a failure
- Add a tool to easily edit the statusfile from the command line (maybe?)
- Add some extra accepted commands for the builder (checking them with regexes)
- Re-sync this page with the Spanish translation :)
- Handle different transfer protocols (i.e., CVS over SSH)
- Test, test,test
DOWNLOAD
You can get your Tepatche (currently at version 0.85) right here. If you are interested in reading the article I wrote on it for the December 2003 issue of Sysadmin, you can find it here.
WHY TEPATCHE?
Tepache is a popular, slightly alcoholic drink in Mexico, where I live and where this program was devised. Tepache is the result of fermenting pineapple in water. Quoting from http://www.fao.org/docrep/x0560e/x0560e09.htm :
Tepache is a light, refreshing beverage prepared and consumed throughout Mexico. In the past, tepache was prepared from maize, but nowadays various fruits such as pineapple, apple and orange are used. The pulp and juice of the fruit are allowed to ferment for one or two days in water with some added brown sugar. The mixture is contained in a lidless wooden barrel called a "tepachera", which is covered with cheese cloth. After a day or two, the tepache is a sweet and refreshing beverage. If fermentation is allowed to proceed longer, it turns into an alcoholic beverage and later into vinegar. The microorganisms associated with the product include Bacillus subtilis, B. graveolus and the yeasts, Torulopsis insconspicna, Saccharomyces cerevisiae and Candida queretana (Aidoo, 1986).
If you are curious, you can find recipes to prepare tepache (in Spanish) at http://www.chi.itesm.mx/chihuahua/arte_cultura/cocina/bebidas/tepache.html and http://mexico.udg.mx/cocina/bebidas/tepache.html
I found a recipe in German (I cannot tell if it is right or not ;-) ) at: http://www.mexiko-lindo.de/rezepte/getraenke.htm
THANKS
First and foremost, I want to thank the OpenBSD team for the incredible amount of work they have thrown into this great project.
On a smaller scale, Tepatche would not have been possible without the help of OpenBSD México. In this specific project, I recieved great help from Alex Juárez, César Yáñez and Karl Heinz Holtschmit.
Of course, I want to thank my workplace, UNAM FES Iztacala, for granting me time to work in security and Free Software for already three years - and I expect many more.
Attachments
tepatche-0.85.tar_.gz (10 KB)
tepatche_sysadmin.txt (11 KB)