How I keep FreeBSD up to date
I'm using a somewhat automated process in order to keep my FreeBSD 6.0 server free from obvious flaws and vulnerabilities. I use the unoffical (as in not supported by the Freebsd security team) program
FreeBSD Update is a system for automatically building, distributing, fetching, and applying binary security updates for FreeBSD. This makes it possible to easily track the FreeBSD security branches without the need for fetching the source tree and recompiling (except on the machine building the updates, of course). Updates are cryptographically signed; they are also distributed as binary diffs using my binary diff tool, which dramatically reduces the bandwidth used
This system serves me with an e-mail when patches are available. The binary nature of this system is especially nice, since my host is somewhat slow, and applying these patches just takes a moment compared to what a recompilation would take. This system can actually be compared to Debian's APT.
Freebsd-update is not part of the base system, which means it has to be installed afterwards. Luckily, it is available as a package, and we use pkg-add with the suffix -r to fetch the package from a remote source. (if you are running cornshell, csh, use rehash to make the command available after installation)
onesome# pkg-add -r freebsd-update
Now copy the default configuration-file in place
onesome# cp /usr/local/etc/freebsd-update.conf.sample /usr/local/etc/freebsd-update.conf
Freebsd-update is now ready to be used, and patches is checked for availability and fetched if executed with the fetch-switch.
onesome# freebsd-update fetch
Fetching updates signature...
Fetching hash list signature...
Examining local system...
Fetching updates...
/boot/kernel/ipfw.ko...
/usr/bin/cpio...
/usr/bin/edit...
/usr/bin/ee...
/usr/bin/ree...
/usr/bin/texindex...
/usr/share/man/man1/cpio.1.gz...
Updates fetched
In this case, 7 updates/patches were available. We use freebsd-update install to install them
onesome# freebsd-update install
Backing up /boot/kernel/ipfw.ko...
Installing new /boot/kernel/ipfw.ko...
Backing up /usr/bin/cpio...
Installing new /usr/bin/cpio...
Backing up /usr/bin/edit...
Installing new /usr/bin/edit...
Backing up /usr/bin/ee...
Recreating hard link from /usr/bin/edit to /usr/bin/ee...
Backing up /usr/bin/ree...
Recreating hard link from /usr/bin/edit to /usr/bin/ree...
Backing up /usr/bin/texindex...
Installing new /usr/bin/texindex...
Backing up /usr/share/man/man1/cpio.1.gz...
Installing new /usr/share/man/man1/cpio.1.gz...
The boot/kernel/ipfw.ko affects the kernel, which makes a reboot appropriate for the patch to be activated.
In order to find out about available patches, I run freebsd-update with the cron-argument. The following row in /etc/crontab checks for patches every night at 5, and delivers an e-mail to root (which I have forwarded to an active mail-account) if patches are found .
0 5 * * * root /usr/local/sbin/freebsd-update cron
The mail does the same thing and has the same output as freebsd-update fetch, with the mail-part as extra functionality. I recommend checking out the manpage for freebsd-update, as it has more functionality than what I've presented here (like rollbacks).
