Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 30 Dec 1998 16:43:44 PST
From:      Craig Leres <leres@ee.lbl.gov>
To:        FreeBSD-gnats-submit@FreeBSD.ORG
Subject:   bin/9250: [PATCH] allow fetch to do ftp directory listings
Message-ID:  <199812310043.QAA03844@fun.ee.lbl.gov>

next in thread | raw e-mail | index | archive | help

>Number:         9250
>Category:       bin
>Synopsis:       [PATCH] allow fetch to do ftp directory listings
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:
>Keywords:
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Wed Dec 30 16:50:01 PST 1998
>Last-Modified:
>Originator:     Craig Leres
>Organization:
Lawrence Berkeley National Laboratory
>Release:        FreeBSD 3.0-RELEASE i386
>Environment:

>Description:

	Fetch cannot retreive a ftp directory listing; attempts to
	do so result in a ftp protocol error.

>How-To-Repeat:

	pig 62 % fetch -v ftp://ftp.ee.lbl.gov/
	Sending: USER anonymous
	ee.lbl.gov FTP server ready.
	Guest login ok, send ident as password.
	Sending: PASS leres@pig.ee.lbl.gov
	Guest login ok, access restrictions apply. Your mileage may vary.
	Sending: TYPE I
	Type set to I.
	Sending SIZE 
	'SIZE ': command not understood.
	Sending MDTM 
	'MDTM ': command not understood.
	fetch: : cannot get remote modification time
	Sending: PORT 131,243,1,91,18,188
	PORT command successful.
	Sending: RETR 
	'RETR ': command not understood.
	fetch: ftp://ftp.ee.lbl.gov/: FTP error:
	fetch: Syntax error, command unrecognized
	Sending: QUIT
	Goodbye.

>Fix:
	
	Context diffs to fetch/ftp.c and lib/libftpio.c are appended.
	This is mostly a matter of detecting that the filename is
	empty and doing a LIST instead of a RETR.

	(Note that when doing a directory listing, you should use
	the -o flag.)

RCS file: RCS/ftpio.c,v
retrieving revision 1.1
diff -c -r1.1 ftpio.c
*** /tmp/,RCSt1Wb3719	Wed Dec 30 16:35:42 1998
--- ftpio.c	Thu Dec 17 19:31:40 1998
***************
*** 258,264 ****
      if (ftpBinary(fp) != SUCCESS)
  	return NULL;
  
!     if (ftp_file_op(ftp, "RETR", file, &fp2, "r", seekto) == SUCCESS)
  	return fp2;
      return NULL;
  }
--- 258,265 ----
      if (ftpBinary(fp) != SUCCESS)
  	return NULL;
  
!     if (ftp_file_op(ftp, *file != '\0' ? "RETR" : "LIST", file,
! 	&fp2, "r", seekto) == SUCCESS)
  	return fp2;
      return NULL;
  }
***************
*** 800,806 ****
  		return i;
  	    }
  	}
! 	i = cmd(ftp, "%s %s", operation, file);
  	if (i < 0 || i > 299) {
  	    close(s);
  	    ftp->error = i;
--- 801,810 ----
  		return i;
  	    }
  	}
! 	if (*file != '\0')
! 		i = cmd(ftp, "%s %s", operation, file);
! 	else
! 		i = cmd(ftp, "%s", operation);
  	if (i < 0 || i > 299) {
  	    close(s);
  	    ftp->error = i;
***************
*** 846,852 ****
  	    else if (i != 350)
  		*seekto = (off_t)0;
  	}
! 	i = cmd(ftp, "%s %s", operation, file);
  	if (i < 0 || i > 299) {
  	    close(s);
  	    ftp->error = i;
--- 850,859 ----
  	    else if (i != 350)
  		*seekto = (off_t)0;
  	}
! 	if (*file != '\0')
! 		i = cmd(ftp, "%s %s", operation, file);
! 	else
! 		i = cmd(ftp, "%s", operation);
  	if (i < 0 || i > 299) {
  	    close(s);
  	    ftp->error = i;

RCS file: RCS/ftp.c,v
retrieving revision 1.1
diff -c -r1.1 ftp.c
*** /tmp/,RCSt1gg3685	Wed Dec 30 16:35:15 1998
--- ftp.c	Thu Dec 17 19:35:44 1998
***************
*** 382,392 ****
  		      (unsigned long)size);
  		return EX_DATAERR;
  	}
! 	modtime = ftpGetModtime(ftp, ftps->ftp_remote_file);
! 	if (modtime <= 0) {	/* xxx */
! 		warnx("%s: cannot get remote modification time", 
! 		      ftps->ftp_remote_path);
  		modtime = -1;
  	}
  	fs->fs_modtime = modtime;
  	seekloc = wehave = 0;
--- 382,396 ----
  		      (unsigned long)size);
  		return EX_DATAERR;
  	}
! 	if (*ftps->ftp_remote_file == '\0')
  		modtime = -1;
+ 	else {
+ 		modtime = ftpGetModtime(ftp, ftps->ftp_remote_file);
+ 		if (modtime <= 0) {	/* xxx */
+ 			warnx("%s: cannot get remote modification time", 
+ 			      ftps->ftp_remote_path);
+ 			modtime = -1;
+ 		}
  	}
  	fs->fs_modtime = modtime;
  	seekloc = wehave = 0;
>Audit-Trail:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message



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