[comp.bugs.4bsd] Bug in ftp handling of .netrc file

mike@turing.UNM.EDU (Michael I. Bushnell) (06/09/88)

Subject: Ftp handles hostnames in the .netrc differently from rexec.
Index:	ucb/ftp/ftp.c 4.3BSD

Description & Repeat-By:
	Write a program which uses rexec.  Notice that hostnames are
canonicalized before being passed to ruserpass to be looked up in the
.netrc file.  Create a .netrc.  Ftp does not canonicalize hosts before
looking them up.  

Fix:
	Have ftp.c canonicalize the host name (if possible) before
sending the name to ruserpass.  Install the following patch to ftp.c:


*** /tmp/,RCSt1020320	Wed Jun  8 15:39:34 1988
--- /tmp/,RCSt2020320	Wed Jun  8 15:39:36 1988
***************
*** 149,158 ****
  {
  	char tmp[80];
  	char *user, *pass, *acct, *getlogin(), *mygetpass();
  	int n, aflag = 0;
  
  	user = pass = acct = 0;
! 	if (ruserpass(host, &user, &pass, &acct) < 0) {
  		disconnect();
  		code = -1;
  		return(0);
--- 149,160 ----
  {
  	char tmp[80];
  	char *user, *pass, *acct, *getlogin(), *mygetpass();
+ 	struct hostent *hp;
  	int n, aflag = 0;
  
+ 	hp = gethostbyname(host);
  	user = pass = acct = 0;
! 	if (ruserpass(hp ? hp->h_name : host, &user, &pass, &acct) < 0) {
  		disconnect();
  		code = -1;
  		return(0);
-- 
                N u m q u a m   G l o r i a   D e o 

			Michael I. Bushnell
			HASA - "A" division
			mike@turing.unm.edu
	    {ucbvax,gatech}!unmvax!turing.unm.edu!mike