diff options
-rw-r--r-- | distrib/miniroot/install.sub | 21 | ||||
-rw-r--r-- | usr.sbin/sysupgrade/sysupgrade.sh | 38 |
2 files changed, 29 insertions, 30 deletions
diff --git a/distrib/miniroot/install.sub b/distrib/miniroot/install.sub index 5683cf79a27..328f7b03407 100644 --- a/distrib/miniroot/install.sub +++ b/distrib/miniroot/install.sub @@ -1,5 +1,5 @@ #!/bin/ksh -# $OpenBSD: install.sub,v 1.1134 2019/05/13 23:18:22 naddy Exp $ +# $OpenBSD: install.sub,v 1.1135 2019/05/14 14:27:49 ajacoutot Exp $ # # Copyright (c) 1997-2015 Todd Miller, Theo de Raadt, Ken Westerback # Copyright (c) 2015, Robert Peichaer <rpe@openbsd.org> @@ -68,7 +68,7 @@ err_exit() { # Show usage of the installer script and exit. usage() { - err_exit "usage: ${0##*/} [-ax] [-f filename] [-m install | upgrade]" + err_exit "usage: ${0##*/} [-a] [-f filename] [-m install | upgrade]" } # Wait for the ftp(1) process started in start_cgiinfo() to end and extract @@ -2881,6 +2881,12 @@ do_autoinstall() { # Email autoinstall protocol to root on next boot. prep_root_mail /tmp/ai/ai.log "$(hostname) $AI_MODE log" + if $UU; then + cat <<__EOT >>/mnt/etc/rc.firsttime +[[ ! -e /home/_sysupgrade/keep ]] && rm -f /home/_sysupgrade/* +__EOT + fi + exec reboot } @@ -3195,7 +3201,7 @@ do_upgrade() { umount /mnt || { echo "Can't umount $ROOTDEV!"; exit; } mount_fs - rm -f /mnt/bsd.upgrade /mnt/auto_upgrade.conf + rm -f /mnt/bsd.upgrade # Feed the random pool some entropy before we read from it. feed_random @@ -3222,9 +3228,8 @@ check_unattendedupgrade() { if [[ -n $_d ]]; then make_dev $_d if mount -t ffs -r /dev/${_d}a /mnt; then - [[ -f /mnt/bsd.upgrade && -f /mnt/auto_upgrade.conf ]] + ls /mnt/bsd.upgrade _rc=$? - ((_rc == 0)) && cp /mnt/auto_upgrade.conf / umount -f /mnt fi rm -f /dev/{r,}$_d? @@ -3384,6 +3389,12 @@ elif $UU; then # trigger watchdog (sleep 1800 && reboot) & + cat <<__EOT > /auto_upgrade.conf +Location of sets = disk +Pathname to the sets = /home/_sysupgrade/ +Set name(s) = done +Directory does not contain SHA256.sig. Continue without verification = yes +__EOT get_responsefile do_autoinstall elif [[ -z $AI_RESPFILE ]]; then diff --git a/usr.sbin/sysupgrade/sysupgrade.sh b/usr.sbin/sysupgrade/sysupgrade.sh index 6b16d494fb8..3f8a7f92e19 100644 --- a/usr.sbin/sysupgrade/sysupgrade.sh +++ b/usr.sbin/sysupgrade/sysupgrade.sh @@ -1,6 +1,6 @@ #!/bin/ksh # -# $OpenBSD: sysupgrade.sh,v 1.20 2019/05/13 02:25:16 ajacoutot Exp $ +# $OpenBSD: sysupgrade.sh,v 1.21 2019/05/14 14:27:49 ajacoutot Exp $ # # Copyright (c) 1997-2015 Todd Miller, Theo de Raadt, Ken Westerback # Copyright (c) 2015 Robert Peichaer <rpe@openbsd.org> @@ -24,6 +24,7 @@ set -e umask 0022 ARCH=$(uname -m) +SETSDIR=/home/_sysupgrade ug_err() { @@ -56,17 +57,6 @@ unpriv() return ${_rc} } -# df(1) is run twice to sort our prefered FS list first -get_prefetcharea() { - { df -kl /{tmp,home,usr{/local,}}; df -kl ;} | - while read a a a a m m; do - [[ $m == /@(tmp|home|usr/@(src,obj,xobj))@(|/*) ]] && - ((a > 524288)) && echo $m && break - [[ $m == @(|/*) ]] && - ((a > 524288 * 4)) && echo $m && break - done -} - # Remove all occurrences of first argument from list formed by the remaining # arguments. rmel() { @@ -128,20 +118,16 @@ else URL=${MIRROR}/${NEXT_VERSION}/${ARCH}/ fi -SETSDIR=$(mktemp -d -p $(get_prefetcharea) .sysupgrade.XXXXXXXXXX) - -if [[ -n ${SETSDIR} ]]; then - install -d -o 0 -g 0 -m 0755 ${SETSDIR} - cat <<-__EOT >/auto_upgrade.conf - Location of sets = disk - Pathname to the sets = ${SETSDIR} - Set name(s) = done - Directory does not contain SHA256.sig. Continue without verification = yes - __EOT - ${KEEP} || echo "rm -rf -- \"${SETSDIR}\"" >>/etc/rc.firsttime - +if [[ -e ${SETSDIR} ]]; then + eval $(stat -s ${SETSDIR}) + [[ $st_uid -eq 0 ]] || + ug_err "${SETSDIR} needs to be owned by root:wheel" + [[ $st_gid -eq 0 ]] || + ug_err "${SETSDIR} needs to be owned by root:wheel" + [[ $st_mode -eq 040755 ]] || + ug_err "${SETSDIR} is not a directory with permissions 0755" else - ug_err "Not enough space to fetch sets" + mkdir -p ${SETSDIR} fi cd ${SETSDIR} @@ -194,6 +180,8 @@ if [[ -n ${DL} ]]; then unpriv cksum -qC SHA256 ${DL} fi +${KEEP} && > keep + cp bsd.rd /nbsd.upgrade ln -f /nbsd.upgrade /bsd.upgrade rm /nbsd.upgrade |