diff options
author | dteske <dteske@FreeBSD.org> | 2013-07-04 20:12:12 +0000 |
---|---|---|
committer | dteske <dteske@FreeBSD.org> | 2013-07-04 20:12:12 +0000 |
commit | d22cbd9996dd8eeb66460e624d65b8abd94f8c4e (patch) | |
tree | ed5346e9e8f574fef1a7c5c9b6c87afd2fff418f /usr.sbin/bsdconfig/share/media/ftp.subr | |
parent | eeea14c75af862477741d779b12b307abdd49fbc (diff) | |
download | FreeBSD-src-d22cbd9996dd8eeb66460e624d65b8abd94f8c4e.zip FreeBSD-src-d22cbd9996dd8eeb66460e624d65b8abd94f8c4e.tar.gz |
Implement $probe_only for the media access modules. sysinstall(8) was
allowed to ignore the probe_only argument of its member functions solely
because in the C language, the file accessor methods open and return a file
descriptor and reading of the data is optional. In shell, the file accessor
methods return data on stdout and that data should not be ignored (large
files could block execution).
So, we must adhere to the probe_only flags and in some cases (in the case of
FTP, for example) change the `get' strategy to simply test existence and
return an appropriate status.
This was required because the up-coming package management stuff makes heavy
use of the probe_only argument to try different package suffixes. Every
media access module must implement $probe_only for the `get' accessor.
Diffstat (limited to 'usr.sbin/bsdconfig/share/media/ftp.subr')
-rw-r--r-- | usr.sbin/bsdconfig/share/media/ftp.subr | 15 |
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 |