summaryrefslogtreecommitdiffstats
path: root/usr.sbin/syspatch
diff options
context:
space:
mode:
authorajacoutot <ajacoutot@openbsd.org>2017-05-03 17:23:34 +0000
committerajacoutot <ajacoutot@openbsd.org>2017-05-03 17:23:34 +0000
commitb366f6d7169a67f7b0c8a0545a9643d2e27cca2a (patch)
tree1af49f6331b3e21e0ba250079d3c2b539ee11342 /usr.sbin/syspatch
parentspacing (in EXAMPLES code) (diff)
downloadwireguard-openbsd-b366f6d7169a67f7b0c8a0545a9643d2e27cca2a.tar.xz
wireguard-openbsd-b366f6d7169a67f7b0c8a0545a9643d2e27cca2a.zip
Output explicit error messages for:
- trying to install files mounted on a remote FS (diskless clients etc.) - read-only FS - not enough space on FS These were all properly catched before (syspatch would refuse to do anything) but the error message was a bit cryptic.
Diffstat (limited to 'usr.sbin/syspatch')
-rw-r--r--usr.sbin/syspatch/syspatch.sh15
1 files changed, 10 insertions, 5 deletions
diff --git a/usr.sbin/syspatch/syspatch.sh b/usr.sbin/syspatch/syspatch.sh
index 56fae099a2d..b48685520b4 100644
--- a/usr.sbin/syspatch/syspatch.sh
+++ b/usr.sbin/syspatch/syspatch.sh
@@ -1,6 +1,6 @@
#!/bin/ksh
#
-# $OpenBSD: syspatch.sh,v 1.96 2017/05/03 12:26:52 ajacoutot Exp $
+# $OpenBSD: syspatch.sh,v 1.97 2017/05/03 17:23:34 ajacoutot Exp $
#
# Copyright (c) 2016 Antoine Jacoutot <ajacoutot@openbsd.org>
#
@@ -69,7 +69,7 @@ apply_patch()
trap exit INT
}
-# quick-and-dirty size check:
+# quick-and-dirty filesystem status and size checks:
# - assume old files are about the same size as new ones
# - ignore new (nonexistent) files
# - compute total size of all files per fs, simpler and less margin for error
@@ -78,7 +78,7 @@ apply_patch()
# - /bsd.syspatchXX is not present (create_rollback will copy it from /bsd)
checkfs()
{
- local _d _df _dev _files="${@}" _sz
+ local _d _dev _df _files="${@}" _sz
[[ -n ${_files} ]]
if echo "${_files}" | grep -qw bsd; then
@@ -86,13 +86,18 @@ checkfs()
_files="bsd ${_files}"
fi
+ set +e # ignore errors due to:
+ # - nonexistent files (i.e. syspatch is installing new files)
+ # - broken interpolation due to bogus devices like remote filesystems
eval $(cd / &&
stat -qf "_dev=\"\${_dev} %Sd\" %Sd=\"\${%Sd:+\${%Sd}\+}%Uz\"" \
- ${_files}) || true # ignore nonexistent files
+ ${_files}) 2>/dev/null
+ set -e
+ [[ -z ${_dev} && -n ${_files} ]] && sp_err "Remote filesystem, aborting"
for _d in $(printf '%s\n' ${_dev} | sort -u); do
mount | grep -v read-only | grep -q "^/dev/${_d} " ||
- sp_err "Remote or read-only filesystem, aborting"
+ sp_err "Read-only filesystem, aborting"
_df=$(df -Pk | grep "^/dev/${_d} " | tr -s ' ' | cut -d ' ' -f4)
_sz=$(($((_d))/1024))
((_df > _sz)) || sp_err "No space left on ${_d}, aborting"