earle@SUN.COM (Greg Earle) (07/14/89)
The latest documentation for the 4BSD `ftp' client program that I have lists the following, in the description of the .netrc file: account string Supply an additional account password. If this token is present, the auto-login process will supply the specified string if the remote server requires an addi- tional account password, or the auto-login process will initiate an ACCT command if it does not. The last half of this appears to be true, but the first half is not. When one attempts to use this, one is always prompted for the `Account:' string, no matter whether the `account [ string ]' is in the .netrc file or not. An example, talking to a Univac system that requires an account: myhost% cat ~/.netrc machine univac login me password noseeum account 12345 myhost% ftp -v -t -d univac Connected to univac. 220-File server ready for new user. 220 Enter USER user-id. ---> USER me 331 User-id received; Enter PASS password. ---> PASS noseeum 332 enter ACCT account[,project]. Account: ^C myhost% I found the following code chunk in /usr/src/ucb/ftp/ftp.c's login() function, for every version of ftp.c I could find - SunOS 4.0.3, 4.3BSD-tahoe, and Rick Adams' post-Tahoe ftp on uunet.UU.NET: myhost% sccs what uunet_ftp/ftp.c bsd-tahoe_ftp/ftp.c /usr/src/ucb/ftp/ftp.c uunet_ftp/ftp.c: ftp.c 5.28 (Berkeley) 4/20/89 bsd-tahoe_ftp/ftp.c: ftp.c 5.24.1.3 (Berkeley) 3/1/89 /usr/src/ucb/ftp/ftp.c: ftp.c 1.1 89/05/19 SMI; from 5.14 (Berkeley) 5/22/86 [ code chunk ] ... n = command("USER %s", user); if (n == CONTINUE) { if (pass == NULL) pass = getpass("Password:"); n = command("PASS %s", pass); } if (n == CONTINUE) { aflag++; acct = getpass("Account:"); n = command("ACCT %s", acct); } if (n != COMPLETE) { fprintf(stderr, "Login failed.\n"); return (0); } if (!aflag && acct != NULL) (void) command("ACCT %s", acct); ... In other words, the code checks to see if the PASS has been loaded from the .netrc, and if so, it sends it on. However, in the case of ACCT, it doesn't check to see if it has been pre-loaded, and asks for it no matter what. This seems so obvious that I thought I'd ask first before assuming it's a bug. Am I missing something? Is there some reason for this?? i.e., why is the code acct = getpass("Account:"); and not if (acct == NULL) acct = getpass("Account:"); just like it is for the sending of the password??? I have a customer who would like to use his .netrc file in conjunction with a shell `here is' document to automate retrieval of files from this Univac, and we're stuck by this. As you can see from the script, the Univac machine demands the account at login time; so we can't just remove the `account 12345' from .netrc and manually send it from the `here is' document (as part of the standard input) once logged on. Thanks, - Greg Earle earle@Sun.COM