summaryrefslogtreecommitdiffstats
path: root/usr.sbin/bsdconfig/share/media/ftp.subr
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/bsdconfig/share/media/ftp.subr')
-rw-r--r--usr.sbin/bsdconfig/share/media/ftp.subr15
1 files changed, 13 insertions, 2 deletions
diff --git a/usr.sbin/bsdconfig/share/media/ftp.subr b/usr.sbin/bsdconfig/share/media/ftp.subr
index c2c7e6a..fb96b91 100644
--- a/usr.sbin/bsdconfig/share/media/ftp.subr
+++ b/usr.sbin/bsdconfig/share/media/ftp.subr
@@ -792,8 +792,8 @@ f_media_init_ftp()
#
# Returns data from $file on an FTP server using ftp(1). Please note that
# $device is unused but must be present (even if null). Information is instead
-# gathered from the environment. $probe_only is currently unused by this media
-# type.
+# gathered from the environment. If $probe_only is present and non-NULL,
+# returns success if $file exists.
#
# Variables from variable.subr used to configure the connection are as follows
# (all of which are configured by f_media_set_ftp above):
@@ -900,6 +900,17 @@ f_media_get_ftp()
f_dprintf "sending ftp request for: %s" "ftp://$host$port/$dir/$file"
+ if [ "$probe_only" ]; then
+ local url="ftp://$userpass$host$port/$dir/$file"
+ [ "$use_anon" ] && url="ftp://$host$port/$dir/$file"
+ if ! size=$( fetch -s "$url" 2>&1 ) || ! f_isinteger "$size"
+ then
+ f_dprintf "request failed! size response=[%s]" "$size"
+ return $FAILURE
+ fi
+ return $SUCCESS
+ fi
+
eval FTPMODE=\"\$mode\" ${use_anon:+FTPANONPASS=\"\$pass\"} \
ftp -V ${use_anon:+-a} -o - \
\"ftp://\$userpass\$host\$port/\$dir/\$file\" 2> /dev/null
OpenPOWER on IntegriCloud