diff options
author | ajacoutot <ajacoutot@openbsd.org> | 2019-05-05 10:34:01 +0000 |
---|---|---|
committer | ajacoutot <ajacoutot@openbsd.org> | 2019-05-05 10:34:01 +0000 |
commit | 7f3597a0e5ea0b10e5130afef0c253a58e676224 (patch) | |
tree | 97ec0dec3445d6c08dd097fed699208db8d977a3 /usr.sbin/syspatch | |
parent | Initialise variable. (diff) | |
download | wireguard-openbsd-7f3597a0e5ea0b10e5130afef0c253a58e676224.tar.xz wireguard-openbsd-7f3597a0e5ea0b10e5130afef0c253a58e676224.zip |
For "unpriv -f file", chown file back to root once the command finishes,
like install.sub and sysupgrade(8) do.
Diffstat (limited to 'usr.sbin/syspatch')
-rw-r--r-- | usr.sbin/syspatch/syspatch.sh | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/usr.sbin/syspatch/syspatch.sh b/usr.sbin/syspatch/syspatch.sh index 1089ef5cbd2..06234bbbc59 100644 --- a/usr.sbin/syspatch/syspatch.sh +++ b/usr.sbin/syspatch/syspatch.sh @@ -1,6 +1,6 @@ #!/bin/ksh # -# $OpenBSD: syspatch.sh,v 1.147 2019/05/05 10:24:00 ajacoutot Exp $ +# $OpenBSD: syspatch.sh,v 1.148 2019/05/05 10:34:01 ajacoutot Exp $ # # Copyright (c) 2016, 2017 Antoine Jacoutot <ajacoutot@openbsd.org> # @@ -243,7 +243,7 @@ trap_handler() unpriv() { - local _file=$2 _user=_syspatch + local _file=$2 _rc=0 _user=_syspatch if [[ $1 == -f && -n ${_file} ]]; then >${_file} @@ -253,7 +253,11 @@ unpriv() fi (($# >= 1)) - eval su -s /bin/sh ${_user} -c "'$@'" + eval su -s /bin/sh ${_user} -c "'$@'" || _rc=$? + + [[ -n ${_file} ]] && chown root "${_file}" + + return ${_rc} } # only run on release (not -current nor -stable) |