version 1.42, 2006/04/25 05:45:20 |
version 1.43, 2006/05/16 23:43:16 |
|
|
int |
int |
ftp_login(const char *host, char *user, char *pass) |
ftp_login(const char *host, char *user, char *pass) |
{ |
{ |
char tmp[80], *acct = NULL, hostname[MAXHOSTNAMELEN]; |
char tmp[80], *acctname = NULL, host_name[MAXHOSTNAMELEN]; |
char anonpass[MAXLOGNAME + 1 + MAXHOSTNAMELEN]; /* "user@hostname" */ |
char anonpass[MAXLOGNAME + 1 + MAXHOSTNAMELEN]; /* "user@hostname" */ |
int n, aflag = 0, retry = 0; |
int n, aflag = 0, retry = 0; |
struct passwd *pw; |
struct passwd *pw; |
|
|
if (user == NULL) { |
if (user == NULL) { |
if (ruserpass(host, &user, &pass, &acct) < 0) { |
if (ruserpass(host, &user, &pass, &acctname) < 0) { |
code = -1; |
code = -1; |
return (0); |
return (0); |
} |
} |
|
|
*/ |
*/ |
if ((user == NULL || pass == NULL) && anonftp) { |
if ((user == NULL || pass == NULL) && anonftp) { |
memset(anonpass, 0, sizeof(anonpass)); |
memset(anonpass, 0, sizeof(anonpass)); |
memset(hostname, 0, sizeof(hostname)); |
memset(host_name, 0, sizeof(host_name)); |
|
|
/* |
/* |
* Set up anonymous login password. |
* Set up anonymous login password. |
|
|
else |
else |
user = pw->pw_name; |
user = pw->pw_name; |
} |
} |
gethostname(hostname, sizeof(hostname)); |
gethostname(host_name, sizeof(host_name)); |
#ifndef DONT_CHEAT_ANONPASS |
#ifndef DONT_CHEAT_ANONPASS |
/* |
/* |
* Every anonymous FTP server I've encountered |
* Every anonymous FTP server I've encountered |
|
|
} |
} |
if (n == CONTINUE) { |
if (n == CONTINUE) { |
aflag++; |
aflag++; |
if (acct == NULL) |
if (acctname == NULL) |
acct = getpass("Account:"); |
acctname = getpass("Account:"); |
n = command("ACCT %s", acct); |
n = command("ACCT %s", acctname); |
} |
} |
if ((n != COMPLETE) || |
if ((n != COMPLETE) || |
(!aflag && acct != NULL && command("ACCT %s", acct) != COMPLETE)) { |
(!aflag && acctname != NULL && command("ACCT %s", acctname) != COMPLETE)) { |
warnx("Login failed."); |
warnx("Login failed."); |
if (retry || !anonftp) |
if (retry || !anonftp) |
return (0); |
return (0); |
|
|
char * |
char * |
remglob(char *argv[], int doswitch, char **errbuf) |
remglob(char *argv[], int doswitch, char **errbuf) |
{ |
{ |
char temp[MAXPATHLEN], *cp, *mode; |
char temp[MAXPATHLEN], *cp, *lmode; |
static char buf[MAXPATHLEN], **args; |
static char buf[MAXPATHLEN], **args; |
static FILE *ftemp = NULL; |
static FILE *ftemp = NULL; |
int oldverbose, oldhash, fd; |
int oldverbose, oldhash, fd; |
|
|
hash = 0; |
hash = 0; |
if (doswitch) |
if (doswitch) |
pswitch(!proxy); |
pswitch(!proxy); |
for (mode = "w"; *++argv != NULL; mode = "a") |
for (lmode = "w"; *++argv != NULL; lmode = "a") |
recvrequest("NLST", temp, *argv, mode, 0, 0); |
recvrequest("NLST", temp, *argv, lmode, 0, 0); |
if ((code / 100) != COMPLETE) { |
if ((code / 100) != COMPLETE) { |
if (errbuf != NULL) |
if (errbuf != NULL) |
*errbuf = reply_string; |
*errbuf = reply_string; |
|
|
int |
int |
confirm(const char *cmd, const char *file) |
confirm(const char *cmd, const char *file) |
{ |
{ |
char line[BUFSIZ]; |
char str[BUFSIZ]; |
|
|
if (!interactive || confirmrest) |
if (!interactive || confirmrest) |
return (1); |
return (1); |
top: |
top: |
fprintf(ttyout, "%s %s? ", cmd, file); |
fprintf(ttyout, "%s %s? ", cmd, file); |
(void)fflush(ttyout); |
(void)fflush(ttyout); |
if (fgets(line, sizeof(line), stdin) == NULL) |
if (fgets(str, sizeof(str), stdin) == NULL) |
return (0); |
return (0); |
switch (tolower(*line)) { |
switch (tolower(*str)) { |
case 'n': |
case 'n': |
return (0); |
return (0); |
case 'p': |
case 'p': |