From eec686b45b9ab4889e17a2c615f49bcd3fbfa4c2 Mon Sep 17 00:00:00 2001 From: kn <> Date: Tue, 19 Feb 2019 20:41:52 +0000 Subject: [PATCH] Simplify NFS check in reorder_libs() Loop over df(1)'s output directly, ensure the resulting list of block devices is unique to avoid later duplicity checks and redundant mount(8) invocations. This allows direct bail out on invalid types and simpler saving for later remount. OK deraadt --- src/etc/rc | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/etc/rc b/src/etc/rc index 6788879c..eab4aca0 100644 --- a/src/etc/rc +++ b/src/etc/rc @@ -1,4 +1,4 @@ -# $OpenBSD: rc,v 1.532 2019/01/26 10:59:07 florian Exp $ +# $OpenBSD: rc,v 1.533 2019/02/19 20:41:52 kn 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 @@ -175,13 +175,11 @@ reorder_libs() { # Skip if /usr/lib, /usr/libexec or /usr/share/relink are on nfs mounted # filesystems, otherwise record which ones are mounted read-only. - for _d in /usr/{lib,libexec,share/relink}; do - _dkdev=$(df $_d | sed '1d;s/ .*//') - _mp=$(mount | grep "^$_dkdev") - [[ $_mp == *" type nfs "* ]] && return - if [[ $_mp == *" type ffs "*"read-only"* && - $_ro_list != *${_mp%% *}* ]]; then - _ro_list="$_ro_list ${_mp%% *}" + for _dkdev in $(df /usr/{lib,libexec} $_relink | + sed '1d;s/ .*//' | sort -u); do + _mp=$(mount -t ffs | grep "^$_dkdev") || return + if [[ $_mp == *read-only* ]]; then + _ro_list="$_ro_list ${_mp%% *}" fi done