From a17bb5c13f72219383d2c16f702d5f9d8328a923 Mon Sep 17 00:00:00 2001 From: rpe <> Date: Fri, 30 Jun 2017 17:06:03 +0000 Subject: [PATCH] Improve reorder_kernel() - check for and exit if /usr/share is on a nfs mounted filesystem - add trap handlers that mail the logfile to the admin user - use $_compile instead of $_compile_dir like in the installer - use $_compile/$_kernel instead of $_kernel_dir - remove the now redundant sha256 -h ... after make newinstall - write stdout/stderr of the background subshell to a logfile OK tb@ deraadt@ --- src/etc/rc | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/src/etc/rc b/src/etc/rc index b1bcd2be..f078d8d8 100644 --- a/src/etc/rc +++ b/src/etc/rc @@ -1,4 +1,4 @@ -# $OpenBSD: rc,v 1.505 2017/06/27 03:42:00 tedu Exp $ +# $OpenBSD: rc,v 1.506 2017/06/30 17:06:03 rpe Exp $ # System startup script run by init on autoboot or after single-user. # Output and error are redirected to console by init, and the console is the @@ -222,33 +222,39 @@ reorder_libs() { # Re-link the kernel, placing the objects in a random order. # Replace current with relinked kernel and inform root about it. reorder_kernel() { + local _dkdev=$(df /usr/share | sed '1d;s/ .*//') + + # Skip if /usr/share is on a nfs mounted filesystem. + [[ $(mount | grep "^$_dkdev") == *" type nfs "* ]] && return + ( set -e - _compile_dir=/usr/share/compile + trap 'trap - EXIT; mail -s "$(hostname) Kernel relink failed" root \ + $_kernel_dir/log 2>&1 - make newinstall >>$_kernel_dir/log 2>&1 - (umask 077 && sha256 -h $_sha256 /bsd) - - (echo "Kernel has been relinked and is active on next reboot\n"; \ - cat $_sha256; echo "\nRelink log:\n"; cat $_kernel_dir/log ) | - mail -Es "$(hostname) Kernel relink info" root >/dev/null + cd $_compile/$_kernel + make newbsd + make newinstall - ) >/dev/null 2>&1 & + echo "\nKernel has been relinked and is active on next reboot.\n" + cat $_sha256 + ) >/var/log/kernel_relink.log 2>&1 & } # Run rc.* script and email output to root.