summaryrefslogtreecommitdiff
path: root/distrib
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2008-03-09 00:42:09 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2008-03-09 00:42:09 +0000
commit4090c7c6338000ac314ee7bed04263e104e140ab (patch)
tree9dbecb27bd82fbd7e5c69e5e5509c30de3737919 /distrib
parent423e92ed0d2052823909d2bcc17bcfab41e69ac7 (diff)
Consolidate FTP option handling, fixing one missing set of options
and adding a new question during install to allow the setting of FTP's -k option in situations where intervening routers/firewalls are prematurely killing connections. Original idea and diff from espie@ ok espie@
Diffstat (limited to 'distrib')
-rw-r--r--distrib/miniroot/install.sub35
1 files changed, 20 insertions, 15 deletions
diff --git a/distrib/miniroot/install.sub b/distrib/miniroot/install.sub
index 26c8eed23bf..aae94987921 100644
--- a/distrib/miniroot/install.sub
+++ b/distrib/miniroot/install.sub
@@ -1,4 +1,4 @@
-# $OpenBSD: install.sub,v 1.426 2008/03/05 01:09:58 krw Exp $
+# $OpenBSD: install.sub,v 1.427 2008/03/09 00:42:08 krw Exp $
# $NetBSD: install.sub,v 1.5.2.8 1996/09/02 23:25:02 pk Exp $
#
# Copyright (c) 1997-2007 Todd Miller, Theo de Raadt, Ken Westerback
@@ -433,7 +433,7 @@ manual_net_cfg() {
# log in via ftp to host $1 as user $2 with password $3
# and return a list of all files in the directory $4 on stdout
ftp_list_files() {
- ftp ${_ftp_active} -V -n "$1" <<__EOT
+ ftp $FTPOPTS -n "$1" <<__EOT
user "$2" "$3"
cd "$4"
ls
@@ -944,9 +944,9 @@ __EOT
isin $_f $_get_sets || continue
echo "Getting $_f ..."
case $_f in
- *.tgz) ftp $_ftp_active -o - -V -m "$_src/$_f" | tar zxphf - -C /mnt
+ *.tgz) ftp $FTPOPTS -o - -m "$_src/$_f" | tar zxphf - -C /mnt
;;
- *) ftp $_ftp_active -o "/mnt/$_f" -V -m "$_src/$_f"
+ *) ftp $FTPOPTS -o "/mnt/$_f" -m "$_src/$_f"
;;
esac
if [ $? -ne 0 ]; then
@@ -1018,11 +1018,21 @@ ftp_error() {
return 1
}
+set_ftp_opt() {
+ local _q=$1 _opt=$2
+ ask_yn "Use $_q?" $(isin $_opt $FTPOPTS && echo "yes")
+
+ case $resp in
+ y) FTPOPTS=$(addel $_opt $FTPOPTS) ;;
+ n) FTPOPTS=$(rmel $_opt $FTPOPTS) ;;
+ esac
+}
+
# Get several parameters from the user, and xfer
# files from the server.
# $1 = url type (ftp or http)
# Note: _ftp_server_ip, _ftp_server_dir, _ftp_server_login,
-# and _ftp_active must be global.
+# and FTPOPTS must be global.
install_url() {
local _url_type=$1 _file_list _url_base _oifs _prompt _passwd
@@ -1037,7 +1047,7 @@ install_url() {
# ftp.openbsd.org == 129.128.5.191 and will remain at
# that address for the foreseeable future.
echo -n "Getting the list from 129.128.5.191 (ftp.openbsd.org)..."
- ftp $_ftp_active -V -a -o - \
+ ftp $FTPOPTS -a -o - \
ftp://129.128.5.191/$FTPDIR/ftplist 2>/tmp/ftplisterr \
| sed -ne "/^${_url_type}:\/\//s///p" >$SERVERLIST
if [[ -s $SERVERLIST ]]; then
@@ -1081,14 +1091,8 @@ install_url() {
# ask the user if it worth trying passive mode to the chosen server.
# Irrelevant if using a proxy.
if [[ $_url_type == ftp && -z $ftp_proxy ]]; then
- case $_ftp_active in
- -A) resp=no ;;
- *) resp=yes ;;
- esac
-
- unset _ftp_active
- ask_yn "Does the server support passive mode ftp?" $resp
- [[ $resp == n ]] && _ftp_active=-A
+ set_ftp_opt "active mode ftp" "-A"
+ set_ftp_opt "keepalive (NOOP) commands" "-k60"
fi
# Get server directory
@@ -1135,7 +1139,7 @@ install_url() {
else
# Assumes index file is "index.txt" for http (or proxy)
# We can't use index.html since the format is server-dependent
- _file_list=$(ftp -o - -V "$_url_base/index.txt" | sed 's/ //')
+ _file_list=$(ftp $FTPOPTS -o - "$_url_base/index.txt" | sed 's/ //')
fi
install_files "$_url_base" "$_file_list"
@@ -1621,6 +1625,7 @@ VERSION=43
VNAME="$(( $VERSION / 10 )).$(( $VERSION % 10 ))"
SETDIR="$VNAME/$ARCH"
FTPDIR="pub/OpenBSD/$VNAME"
+FTPOPTS="-V"
OBSD="OpenBSD/$ARCH $VNAME"
SERVERLIST=/tmp/serverlist