Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 1 Oct 1997 12:50:01 -0700 (PDT)
From:      Bill Fenner <fenner@parc.xerox.com>
To:        freebsd-bugs
Subject:   Re: bin/4670: /usr/bin/fetch fails to ftp a file ncftp can 
Message-ID:  <199710011950.MAA03603@hub.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/4670; it has been noted by GNATS.

From: Bill Fenner <fenner@parc.xerox.com>
To: Garrett Wollman <wollman@khavrinen.lcs.mit.edu>
Cc: freebsd-gnats-submit@freebsd.org
Subject: Re: bin/4670: /usr/bin/fetch fails to ftp a file ncftp can 
Date: Wed, 1 Oct 1997 12:41:51 PDT

 However, if fetch followed the RFC1738 definition of ftp: URL's, then it
 would be able to fetch this particular URL.
 
 Sending: USER anonymous
 FTP.FU-Berlin.DE ready, please login as user "ftp".
 Anonymous login ok, send your e-mail address as password.
 Sending: PASS fenner@ampere.freebsd.org
 
 Welcome at Freie Universitaet Berlin, Germany.
 
 Anonymous login ok, for special commands see the README.
 Sending: TYPE I
 Type set to I.
 Sending: CWD pub
 CWD command successful.
 Sending: CWD unix
 CWD command successful.
 Sending: CWD mail
 CWD command successful.
 Sending: CWD mutt
 CWD command successful.
 Sending: CWD mutt-pgp
 This is the Mutt version with PGP support.  I always try to upload the
 latest version here.  This is either the illegally exported version from
   ftp://ftp.teuto.de/pub/user/lmb
 or my adaption of the PGP parts to a newer Mutt version.  This is an
 inofficial Mutt version.
                                 leitner@math.fu-berlin.de
 
 CWD command successful.
 Sending SIZE mutt-0.84e-0.84.diff.gz
 13751
 Sending MDTM mutt-0.84e-0.84.diff.gz
 19970917125011
 Sending: PORT 204,216,27,20,4,19
 PORT command successful.
 Sending: RETR mutt-0.84e-0.84.diff.gz
 Opening BINARY mode data connection for mutt-0.84e-0.84.diff.gz (13751 bytes).
 Receiving mutt-0.84e-0.84.diff.gz (13751 bytes)Sending: QUIT
 Transfer complete.
 
 
 The following diff causes fetch to interpret FTP URL's as RFC1738
 defines.
 
   Bill
 
 Index: ftp.c
 ===================================================================
 RCS file: /home/ncvs/src/usr.bin/fetch/ftp.c,v
 retrieving revision 1.7
 diff -u -r1.7 ftp.c
 --- ftp.c	1997/05/31 14:45:41	1.7
 +++ ftp.c	1997/10/01 19:33:41
 @@ -293,6 +293,7 @@
  	off_t seekloc, wehave;
  	time_t modtime;
  	size_t readresult, writeresult;
 +	char *p, *q, *path;
  
  	ftp = ftpLogin(ftps->ftp_hostname, 
  		       (char *)(ftps->ftp_user ? ftps->ftp_user : "anonymous"),
 @@ -306,8 +307,19 @@
  	}
  	ftpBinary(ftp);
  	ftpPassive(ftp, fs->fs_passive_mode);
 -	size = ftpGetSize(ftp, ftps->ftp_remote_file);
 -	modtime = ftpGetModtime(ftp, ftps->ftp_remote_file);
 +	p = path = safe_strdup(ftps->ftp_remote_file);
 +	while ((q = strchr(p, '/')) != 0) {
 +		*q++ = '\0';
 +		if ((status = ftpChdir(ftp, p)) != 0) {
 +			warnx("%s: %s: %s", ftps->ftp_hostname,
 +				p, ftpErrString(status));
 +			free(path);
 +			return EX_IOERR;
 +		}
 +		p = q;
 +	}
 +	size = ftpGetSize(ftp, p);
 +	modtime = ftpGetModtime(ftp, p);
  	if (modtime <= 0) {	/* xxx */
  		warnx("%s: cannot get remote modification time", 
  		      ftps->ftp_remote_file);
 @@ -334,6 +346,7 @@
  		if (fs->fs_mirror && stab.st_size == size
  		    && modtime <= stab.st_mtime) {
  			fclose(ftp);
 +			free(path);
  			return 0;
  		}
  		if (fs->fs_restart) {
 @@ -342,7 +355,8 @@
  		}
  	}
  
 -	remote = ftpGet(ftp, ftps->ftp_remote_file, &seekloc);
 +	remote = ftpGet(ftp, p, &seekloc);
 +	free(path);
  	if (remote == 0) {
  		if (ftpErrno(ftp)) {
  			warnx("ftp://%s/%s: FTP error:",



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199710011950.MAA03603>