summaryrefslogtreecommitdiff
path: root/distrib/miniroot/install.sub
diff options
context:
space:
mode:
authorAlexander Hall <halex@cvs.openbsd.org>2010-04-04 22:29:09 +0000
committerAlexander Hall <halex@cvs.openbsd.org>2010-04-04 22:29:09 +0000
commitcb146c4e1e0343ccf994ef3be07d0ccf965c2972 (patch)
treeaeb80cc92f86ff6ac866cb6662557b9c24456cd5 /distrib/miniroot/install.sub
parent8314ae9c3d54ab1c468a138989389646f93881a2 (diff)
If the system time is off by more than 120 seconds from the TIME=nnn
supplied from ftplist.cgi, ask if the user wants to set it accordingly. Idea from deraadt@, feedback from sthen@, guenther@ ok deraadt@, krw@ (slightly different version)
Diffstat (limited to 'distrib/miniroot/install.sub')
-rw-r--r--distrib/miniroot/install.sub30
1 files changed, 24 insertions, 6 deletions
diff --git a/distrib/miniroot/install.sub b/distrib/miniroot/install.sub
index f877b6f31a3..a9c268c1759 100644
--- a/distrib/miniroot/install.sub
+++ b/distrib/miniroot/install.sub
@@ -1,4 +1,4 @@
-# $OpenBSD: install.sub,v 1.600 2010/03/09 23:34:09 deraadt Exp $
+# $OpenBSD: install.sub,v 1.601 2010/04/04 22:29:08 halex Exp $
# $NetBSD: install.sub,v 1.5.2.8 1996/09/02 23:25:02 pk Exp $
#
# Copyright (c) 1997-2009 Todd Miller, Theo de Raadt, Ken Westerback
@@ -1148,15 +1148,23 @@ startftplist() {
# If no networks are configured, we do not need the ftplist file
(( nifs < 1 )) && return
- # ftp.openbsd.org == 129.128.5.191 and will remain at
- # that address for the foreseeable future.
- ftp $FTPOPTS -a -o - "http://129.128.5.191/cgi-bin/ftplist.cgi?path=$FTPSETDIR" \
- 2>/tmp/ftplisterr > $SERVERLISTALL & ftppid=$!
+ # Make sure the ftp subshell gets its own process group
+ set -m
+ (
+ # ftp.openbsd.org == 129.128.5.191 and will remain at
+ # that address for the foreseeable future.
+ ftp $FTPOPTS -a -o - "http://129.128.5.191/cgi-bin/ftplist.cgi?path=$FTPSETDIR" \
+ 2>/tmp/ftplisterr > $SERVERLISTALL
+
+ # Remember finish time for adjusting the received timestamp
+ echo -n $SECONDS >$SERVERLISTSEC
+ ) & ftppid=$!
+ set +m
# If the ftp process takes more than 12 seconds, kill it
# XXX We are relying on the pid space not randomly biting us --
# XXX ftp could terminate early, and the pid could be reused
- (sleep 12; kill -INT $ftppid >/dev/null 2>&1) &
+ (sleep 12; kill -INT -$ftppid >/dev/null 2>&1) &
}
# Wait for the ftp process to finish, or be killed after the timeout
@@ -1173,6 +1181,15 @@ waitftplist() {
[[ -n $_dot ]] && echo # XXX
}
+# If possible, print the timestamp received from the ftplist.cgi output,
+# adjusted with the time elapsed since it was received
+ftp_time() {
+ local _ftplist_sec=$(cat $SERVERLISTSEC 2>&-)
+ local _time=$(sed '/^TIME=\([0-9]*\)$/!d;s//\1/;q' $SERVERLISTALL 2>&-)
+ [[ -n $_ftplist_sec && -n $_time ]] &&
+ echo $((_time + SECONDS - _ftplist_sec))
+}
+
# Get several parameters from the user, and xfer
# files from the server.
# $1 = url type (ftp or http)
@@ -1857,6 +1874,7 @@ SETDIR="$VNAME/$ARCH"
FTPDIR="pub/OpenBSD/$VNAME"
FTPOPTS="-V"
SERVERLISTALL=/tmp/serverlistall
+SERVERLISTSEC=/tmp/serverlistsec
SERVERLIST=/tmp/serverlist
# Do not limit ourselves during installs or upgrades.