diff options
author | Toomas Soome <tsoome@me.com> | 2020-05-23 19:29:38 +0300 |
---|---|---|
committer | Toomas Soome <tsoome@me.com> | 2021-03-12 09:11:47 +0200 |
commit | 92163adad0f33b8ee626f71225670465b4718da2 (patch) | |
tree | bfcb5efdc458f2d9f89825dbe25dbbbaa8097a47 | |
parent | 835b861bfa01968a312484d1d7bd1798865ea383 (diff) | |
download | illumos-joyent-92163adad0f33b8ee626f71225670465b4718da2.tar.gz |
13532 ftp: multiply-defined symbols
Reviewed by: C Fraire <cfraire@me.com>
Reviewed by: Andy Fiddaman <andy@omniosce.org>
Approved by: Dan McDonald <danmcd@joyent.com>
-rw-r--r-- | usr/src/cmd/cmd-inet/usr.bin/ftp/ftp.c | 396 | ||||
-rw-r--r-- | usr/src/cmd/cmd-inet/usr.bin/ftp/ftp_var.h | 177 | ||||
-rw-r--r-- | usr/src/cmd/cmd-inet/usr.bin/ftp/main.c | 85 |
3 files changed, 364 insertions, 294 deletions
diff --git a/usr/src/cmd/cmd-inet/usr.bin/ftp/ftp.c b/usr/src/cmd/cmd-inet/usr.bin/ftp/ftp.c index f7007286a8..85674f1aba 100644 --- a/usr/src/cmd/cmd-inet/usr.bin/ftp/ftp.c +++ b/usr/src/cmd/cmd-inet/usr.bin/ftp/ftp.c @@ -25,7 +25,7 @@ */ /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ +/* All Rights Reserved */ /* * University Copyright- Copyright (c) 1982, 1986, 1988 @@ -43,7 +43,7 @@ /* * WRITE() returns: - * >0 no error + * >0 no error * -1 error, errorno is set * -2 security error (secure_write() only) */ @@ -55,10 +55,9 @@ static struct sockaddr_in6 data_addr; int data = -1; static int abrtflag = 0; static int ptflag = 0; -int connected; static jmp_buf sendabort; static jmp_buf recvabort; -static jmp_buf ptabort; +static jmp_buf ptabort; static int ptabflg; static boolean_t pasv_refused; boolean_t eport_supported = B_TRUE; @@ -376,7 +375,7 @@ login(char *host) } stop_timer(); (void) printf("Name (%s:%s): ", host, - (myname == NULL) ? "" : myname); + (myname == NULL) ? "" : myname); *tmp = '\0'; if (fgets(tmp, sizeof (tmp) - 1, stdin) != NULL) tmp[strlen(tmp) - 1] = '\0'; @@ -473,7 +472,7 @@ again: if (secure_command(command_buf) == 0) if (r == 533 && clevel == PROT_P) { (void) fprintf(stderr, "ENC command not supported at server; " - "retrying under MIC...\n"); + "retrying under MIC...\n"); clevel = PROT_S; goto again; } @@ -498,8 +497,8 @@ getreply(int expecteof) * 5yz: an error occurred, failure * 6yz: protected reply (is_base64 == TRUE) * 631 - base 64 encoded safe message - * 632 - base 64 encoded private message - * 633 - base 64 encoded confidential message + * 632 - base 64 encoded private message + * 633 - base 64 encoded confidential message * 'c' is a wide char type, for international char sets */ wint_t c; @@ -538,131 +537,137 @@ getreply(int expecteof) while ((c = ibuf[0] ? (wint_t)ibuf[i++] : fgetwc(ctrl_in)) != '\n') { - if (i >= FTPBUFSIZ) - break; - - if (c == IAC) { /* handle telnet commands */ - switch (c = fgetwc(ctrl_in)) { - case WILL: - case WONT: - c = fgetwc(ctrl_in); - (void) fprintf(ctrl_out, "%c%c%wc", IAC, - WONT, c); - (void) fflush(ctrl_out); - break; - case DO: - case DONT: - c = fgetwc(ctrl_in); - (void) fprintf(ctrl_out, "%c%c%wc", IAC, - DONT, c); - (void) fflush(ctrl_out); - break; - default: + if (i >= FTPBUFSIZ) break; + + if (c == IAC) { /* handle telnet commands */ + switch (c = fgetwc(ctrl_in)) { + case WILL: + case WONT: + c = fgetwc(ctrl_in); + (void) fprintf(ctrl_out, "%c%c%wc", IAC, + WONT, c); + (void) fflush(ctrl_out); + break; + case DO: + case DONT: + c = fgetwc(ctrl_in); + (void) fprintf(ctrl_out, "%c%c%wc", IAC, + DONT, c); + (void) fflush(ctrl_out); + break; + default: + break; + } + continue; } - continue; - } - dig++; - if (c == EOF) { - if (expecteof) { - (void) signal(SIGINT, oldintr); - code = 221; - return (0); + dig++; + if (c == EOF) { + if (expecteof) { + (void) signal(SIGINT, oldintr); + code = 221; + return (0); + } + lostpeer(0); + if (verbose) { + (void) printf( + "421 Service not available, remote" + " server has closed connection\n"); + } else { + (void) printf("Lost connection\n"); + } + (void) fflush(stdout); + code = 421; + return (4); } - lostpeer(0); - if (verbose) { - (void) printf( - "421 Service not available, remote" - " server has closed connection\n"); - } else - (void) printf("Lost connection\n"); - (void) fflush(stdout); - code = 421; - return (4); - } - if (n == 0) - n = c; - - if (n == '6') - is_base64 = 1; - - if ((auth_type != AUTHTYPE_NONE) && !ibuf[0] && - (is_base64 || continuation)) { - /* start storing chars in obuf */ - if (c != '\r' && dig > 4) - obuf[i++] = (char)c; - } else { + if (n == 0) + n = c; + + if (n == '6') + is_base64 = 1; + if ((auth_type != AUTHTYPE_NONE) && !ibuf[0] && - dig == 1 && verbose) - (void) printf("Unauthenticated reply received " - "from server:\n"); - if (reply_parse) - *reply_ptr++ = (char)c; - if (c != '\r' && (verbose > 0 || - (verbose > -1 && n == '5' && dig > 4))) { - if (proxflag && - (dig == 1 || dig == 5 && verbose == 0)) - (void) printf("%s:", hostname); - (void) putwchar(c); - } - } /* endif auth_type && !ibuf[0] ... */ + (is_base64 || continuation)) { + /* start storing chars in obuf */ + if (c != '\r' && dig > 4) + obuf[i++] = (char)c; + } else { + if ((auth_type != AUTHTYPE_NONE) && !ibuf[0] && + dig == 1 && verbose) + (void) printf("Unauthenticated reply " + "received from server:\n"); + if (reply_parse) + *reply_ptr++ = (char)c; + if (c != '\r' && (verbose > 0 || + (verbose > -1 && n == '5' && dig > 4))) { + if (proxflag && + (dig == 1 || dig == 5 && + verbose == 0)) + (void) printf("%s:", hostname); + (void) putwchar(c); + } + } /* endif auth_type && !ibuf[0] ... */ - if ((auth_type != AUTHTYPE_NONE) && !ibuf[0] && !is_base64) - continue; + if ((auth_type != AUTHTYPE_NONE) && !ibuf[0] && + !is_base64) + continue; + + /* we are still extracting the 3 digit code */ + if (dig < 4 && isascii(c) && isdigit(c)) + code = code * 10 + (c - '0'); + + /* starting passive mode */ + if (!pflag && code == 227) + pflag = 1; + + /* start to store characters, when dig > 4 */ + if (dig > 4 && pflag == 1 && isascii(c) && isdigit(c)) + pflag = 2; + if (pflag == 2) { + if (c != '\r' && c != ')') { + /* + * the mb array is to deal with + * the wchar_t + */ + char mb[MB_LEN_MAX]; + int avail; - /* we are still extracting the 3 digit code */ - if (dig < 4 && isascii(c) && isdigit(c)) - code = code * 10 + (c - '0'); - - /* starting passive mode */ - if (!pflag && code == 227) - pflag = 1; - - /* start to store characters, when dig > 4 */ - if (dig > 4 && pflag == 1 && isascii(c) && isdigit(c)) - pflag = 2; - if (pflag == 2) { - if (c != '\r' && c != ')') { - /* the mb array is to deal with the wchar_t */ - char mb[MB_LEN_MAX]; - int avail; - - /* - * space available in pasv[], accounting - * for trailing NULL - */ - avail = &pasv[sizeof (pasv)] - pt - 1; - - len = wctomb(mb, c); - if (len <= 0 && avail > 0) { - *pt++ = (unsigned char)c; - } else if (len > 0 && avail >= len) { - bcopy(mb, pt, (size_t)len); - pt += len; - } else { /* - * no room in pasv[]; - * close connection + * space available in pasv[], accounting + * for trailing NULL */ - (void) printf("\nReply too long - " - "closing connection\n"); - lostpeer(0); - (void) fflush(stdout); - (void) signal(SIGINT, oldintr); - return (4); + avail = &pasv[sizeof (pasv)] - pt - 1; + + len = wctomb(mb, c); + if (len <= 0 && avail > 0) { + *pt++ = (unsigned char)c; + } else if (len > 0 && avail >= len) { + bcopy(mb, pt, (size_t)len); + pt += len; + } else { + /* + * no room in pasv[]; + * close connection + */ + (void) printf("\nReply too long" + " - closing connection\n"); + lostpeer(0); + (void) fflush(stdout); + (void) signal(SIGINT, oldintr); + return (4); + } + } else { + *pt = '\0'; + pflag = 3; } - } else { - *pt = '\0'; - pflag = 3; + } /* endif pflag == 2 */ + if (dig == 4 && c == '-' && !is_base64) { + if (continuation) + code = 0; + continuation++; } - } /* endif pflag == 2 */ - if (dig == 4 && c == '-' && !is_base64) { - if (continuation) - code = 0; - continuation++; - } - if (cp < &reply_string[sizeof (reply_string) - 1]) - *cp++ = c; + if (cp < &reply_string[sizeof (reply_string) - 1]) + *cp++ = c; } /* end while */ @@ -672,15 +677,15 @@ getreply(int expecteof) ibuf[0] = obuf[i] = '\0'; if (code && is_base64) { - boolean_t again = 0; - n = decode_reply(ibuf, sizeof (ibuf), obuf, n, &again); - if (again) - continue; - } else - - if (verbose > 0 || verbose > -1 && n == '5') { - (void) putwchar(c); - (void) fflush(stdout); + boolean_t again = 0; + n = decode_reply(ibuf, sizeof (ibuf), obuf, n, &again); + if (again) + continue; + } else { + if (verbose > 0 || verbose > -1 && n == '5') { + (void) putwchar(c); + (void) fflush(stdout); + } } if (continuation && code != originalcode) { @@ -699,13 +704,14 @@ getreply(int expecteof) (*oldintr)(); if (reply_parse) { - *reply_ptr = '\0'; - if (reply_ptr = strstr(reply_buf, reply_parse)) { - reply_parse = reply_ptr + strlen(reply_parse); - if (reply_ptr = strpbrk(reply_parse, " \r")) - *reply_ptr = '\0'; - } else - reply_parse = reply_ptr; + *reply_ptr = '\0'; + if (reply_ptr = strstr(reply_buf, reply_parse)) { + reply_parse = reply_ptr + strlen(reply_parse); + if (reply_ptr = strpbrk(reply_parse, " \r")) + *reply_ptr = '\0'; + } else { + reply_parse = reply_ptr; + } } return (n - '0'); @@ -804,7 +810,7 @@ sendrequest(char *cmd, char *local, char *remote, int allowpipe) if (fstat(fileno(fin), &st) < 0 || (st.st_mode&S_IFMT) != S_IFREG) { (void) fprintf(stdout, - "%s: not a plain file.\n", local); + "%s: not a plain file.\n", local); (void) signal(SIGINT, oldintr); code = -1; (void) fclose(fin); @@ -834,7 +840,7 @@ sendrequest(char *cmd, char *local, char *remote, int allowpipe) return; } if (command("REST %lld", (longlong_t)restart_point) - != CONTINUE) { + != CONTINUE) { if (closefunc != NULL) (*closefunc)(fin); restart_point = 0; @@ -1275,8 +1281,8 @@ writeerr: perror(local); else (void) fprintf(stderr, - "%s: Unexpected end of file\n", - local); + "%s: Unexpected end of " + "file\n", local); goto abort; } if (c == '\n') @@ -1329,7 +1335,7 @@ endread: perror("netin"); } if ((fflush(fout) == EOF) || ferror(fout) || - (fsync(fileno(fout)) == -1)) { + (fsync(fileno(fout)) == -1)) { writer_ascii_err: errflg = 1; perror(local); @@ -1484,7 +1490,7 @@ initconn(void) perror("ftp: setsockopt (TCP_ABORT_THRESHOLD)"); if ((options & SO_DEBUG) && setsockopt(data, SOL_SOCKET, SO_DEBUG, (char *)&on, - sizeof (on)) < 0) + sizeof (on)) < 0) perror("setsockopt (ignored)"); /* * Use the system wide default send and receive buffer sizes @@ -1504,7 +1510,7 @@ initconn(void) if (ipv6rem == B_TRUE) { if (command("EPSV") != COMPLETE) { (void) fprintf(stderr, - "Passive mode refused. Try EPRT\n"); + "Passive mode refused. Try EPRT\n"); pasv_refused = B_TRUE; goto noport; } @@ -1541,7 +1547,7 @@ initconn(void) if (command("PASV") != COMPLETE) { (void) fprintf(stderr, - "Passive mode refused. Try PORT\n"); + "Passive mode refused. Try PORT\n"); pasv_refused = B_TRUE; goto noport; } @@ -1552,9 +1558,9 @@ initconn(void) * 227 Entering Passive Mode (h1,h2,h3,h4,p1,p2) */ if (sscanf(pasv, "%d,%d,%d,%d,%d,%d", - &a1, &a2, &a3, &a4, &p1, &p2) != 6) { + &a1, &a2, &a3, &a4, &p1, &p2) != 6) { (void) fprintf(stderr, - "Passive mode parsing failure.\n"); + "Passive mode parsing failure.\n"); goto bad; } /* @@ -1562,8 +1568,8 @@ initconn(void) * IPv4-mapped IPv6 address. */ a = (unsigned char *)&data_addr.sin6_addr + - sizeof (struct in6_addr) - - sizeof (struct in_addr); + sizeof (struct in6_addr) - + sizeof (struct in_addr); #define UC(b) ((b)&0xff) a[0] = UC(a1); a[1] = UC(a2); @@ -1661,18 +1667,19 @@ noport: hname, htons(data_addr.sin6_port)); if (result != COMPLETE) eport_supported = B_FALSE; - } + } } /* Try LPRT */ if (result != COMPLETE) { result = command( -"LPRT %d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", -6, 16, -UC(a[0]), UC(a[1]), UC(a[2]), UC(a[3]), -UC(a[4]), UC(a[5]), UC(a[6]), UC(a[7]), -UC(a[8]), UC(a[9]), UC(a[10]), UC(a[11]), -UC(a[12]), UC(a[13]), UC(a[14]), UC(a[15]), -2, UC(p[0]), UC(p[1])); + "LPRT %d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d," + "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", + 6, 16, + UC(a[0]), UC(a[1]), UC(a[2]), UC(a[3]), + UC(a[4]), UC(a[5]), UC(a[6]), UC(a[7]), + UC(a[8]), UC(a[9]), UC(a[10]), UC(a[11]), + UC(a[12]), UC(a[13]), UC(a[14]), UC(a[15]), + 2, UC(p[0]), UC(p[1])); } } @@ -1730,7 +1737,7 @@ ptransfer(char *direction, off_t bytes, hrtime_t t0, if (remote) (void) printf("remote: %s\n", remote); (void) printf("%lld bytes %s in %.2g seconds (%.2f Kbytes/s)\n", - (longlong_t)bytes, direction, s, bs / 1024.0); + (longlong_t)bytes, direction, s, bs / 1024.0); } /*ARGSUSED*/ @@ -2216,8 +2223,8 @@ gunique(char *local) while (!d) { if (++count == 100) { (void) printf( - "runique: can't find unique file name.\n"); - return ((char *)0); + "gunique: can't find unique file name.\n"); + return (NULL); } *cp++ = ext; *cp = '\0'; @@ -2290,34 +2297,34 @@ secure_command(char *cmd) in_buf.length = strlen(cmd) + 1; maj_stat = gss_context_time(&min_stat, gcontext, - &expire_time); + &expire_time); if (GSS_ERROR(maj_stat)) { user_gss_error(maj_stat, min_stat, - "gss context has expired"); + "gss context has expired"); fatal("Your gss credentials have expired. " - "Good-bye!"); + "Good-bye!"); } maj_stat = gss_seal(&min_stat, gcontext, - (clevel == PROT_P), /* private */ - GSS_C_QOP_DEFAULT, - &in_buf, &conf_state, - &out_buf); + (clevel == PROT_P), /* private */ + GSS_C_QOP_DEFAULT, + &in_buf, &conf_state, + &out_buf); if (maj_stat != GSS_S_COMPLETE) { /* generally need to deal */ user_gss_error(maj_stat, min_stat, - (clevel == PROT_P) ? - "gss_seal ENC didn't complete": - "gss_seal MIC didn't complete"); + (clevel == PROT_P) ? + "gss_seal ENC didn't complete": + "gss_seal MIC didn't complete"); } else if ((clevel == PROT_P) && !conf_state) { (void) fprintf(stderr, - "GSSAPI didn't encrypt message"); + "GSSAPI didn't encrypt message"); out = out_buf.value; } else { if (debug) - (void) fprintf(stderr, - "sealed (%s) %d bytes\n", - clevel == PROT_P ? "ENC" : "MIC", - out_buf.length); + (void) fprintf(stderr, + "sealed (%s) %d bytes\n", + clevel == PROT_P ? "ENC" : "MIC", + out_buf.length); out = out_buf.value; } @@ -2332,15 +2339,15 @@ secure_command(char *cmd) length = out_buf.length; if (auth_error = radix_encode(out, in, inlen, &length, 0)) { (void) fprintf(stderr, - "Couldn't base 64 encode command (%s)\n", - radix_error(auth_error)); + "Couldn't base 64 encode command (%s)\n", + radix_error(auth_error)); free(in); gss_release_buffer(&min_stat, &out_buf); return (0); } (void) fprintf(ctrl_out, "%s %s", - clevel == PROT_P ? "ENC" : "MIC", in); + clevel == PROT_P ? "ENC" : "MIC", in); free(in); gss_release_buffer(&min_stat, &out_buf); @@ -2407,11 +2414,8 @@ setpbsz(unsigned int size) * 5 if an error occurred */ static int -decode_reply(uchar_t *plain_buf, - int ilen, - uchar_t *b64_buf, - int retval, - boolean_t *again) +decode_reply(uchar_t *plain_buf, int ilen, uchar_t *b64_buf, int retval, + boolean_t *again) { int len; int safe = 0; @@ -2419,26 +2423,26 @@ decode_reply(uchar_t *plain_buf, *again = 0; if (!b64_buf[0]) /* if there is no string, no problem */ - return (retval); + return (retval); if ((auth_type == AUTHTYPE_NONE)) { - (void) printf("Cannot decode reply:\n%d %s\n", code, b64_buf); - return ('5'); + (void) printf("Cannot decode reply:\n%d %s\n", code, b64_buf); + return ('5'); } switch (code) { - case 631: /* 'safe' */ + case 631: /* 'safe' */ safe = 1; break; - case 632: /* 'private' */ + case 632: /* 'private' */ break; - case 633: /* 'confidential' */ + case 633: /* 'confidential' */ break; - default: + default: (void) printf("Unknown reply: %d %s\n", code, b64_buf); return ('5'); } @@ -2448,7 +2452,7 @@ decode_reply(uchar_t *plain_buf, if (auth_error) { (void) printf("Can't base 64 decode reply %d (%s)\n\"%s\"\n", - code, radix_error(auth_error), b64_buf); + code, radix_error(auth_error), b64_buf); return ('5'); } @@ -2461,10 +2465,10 @@ decode_reply(uchar_t *plain_buf, /* decrypt/verify the message */ maj_stat = gss_unseal(&min_stat, gcontext, - &xmit_buf, &msg_buf, &conf_state, NULL); + &xmit_buf, &msg_buf, &conf_state, NULL); if (maj_stat != GSS_S_COMPLETE) { user_gss_error(maj_stat, min_stat, - "failed unsealing reply"); + "failed unsealing reply"); return ('5'); } if (msg_buf.length < ilen - 2 - 1) { @@ -2474,7 +2478,7 @@ decode_reply(uchar_t *plain_buf, *again = 1; } else { user_gss_error(maj_stat, min_stat, - "reply was too long"); + "reply was too long"); return ('5'); } } /* end if GSSAPI */ diff --git a/usr/src/cmd/cmd-inet/usr.bin/ftp/ftp_var.h b/usr/src/cmd/cmd-inet/usr.bin/ftp/ftp_var.h index 000166db3d..0533305669 100644 --- a/usr/src/cmd/cmd-inet/usr.bin/ftp/ftp_var.h +++ b/usr/src/cmd/cmd-inet/usr.bin/ftp/ftp_var.h @@ -24,7 +24,7 @@ */ /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ +/* All Rights Reserved */ /* * University Copyright- Copyright (c) 1982, 1986, 1988 @@ -39,8 +39,6 @@ #ifndef _FTP_VAR_H #define _FTP_VAR_H -#pragma ident "%Z%%M% %I% %E% SMI" - #ifdef __cplusplus extern "C" { #endif @@ -92,90 +90,87 @@ extern "C" { /* * FTP global variables. */ -#ifndef EXTERN -#define EXTERN extern -#endif #define DEFAULTFTPFILE "/etc/default/ftp" /* * Options and other state info. */ -EXTERN int trace; /* trace packets exchanged */ -EXTERN int hash; /* print # for each buffer transferred */ -EXTERN int sendport; /* use PORT cmd for each data connection */ -EXTERN int verbose; /* print messages coming back from server */ -EXTERN int connected; /* connected to server */ -EXTERN int fromatty; /* input is from a terminal */ -EXTERN int interactive; /* interactively prompt on m* cmds */ -EXTERN int debug; /* debugging level */ -EXTERN int bell; /* ring bell on cmd completion */ -EXTERN int doglob; /* glob local file names */ -EXTERN int autologin; /* establish user account on connection */ -EXTERN int proxy; /* proxy server connection active */ -EXTERN int proxflag; /* proxy connection exists */ -EXTERN int sunique; /* store files on server with unique name */ -EXTERN int runique; /* store local files with unique name */ -EXTERN int mcase; /* map upper to lower case for mget names */ -EXTERN int ntflag; /* use ntin ntout tables for name translation */ -EXTERN int mapflag; /* use mapin mapout templates on file names */ -EXTERN int code; /* return/reply code for ftp command */ -EXTERN int crflag; /* if 1, strip car. rets. on ascii gets */ -EXTERN char pasv[64]; /* passive port for proxy data connection */ -EXTERN char *altarg; /* argv[1] with no shell-like preprocessing */ -EXTERN char ntin[17]; /* input translation table */ -EXTERN char ntout[17]; /* output translation table */ -EXTERN char mapin[MAXPATHLEN]; /* input map template */ -EXTERN char mapout[MAXPATHLEN]; /* output map template */ -EXTERN char typename[32]; /* name of file transfer type */ -EXTERN int type; /* file transfer type */ -EXTERN char structname[32]; /* name of file transfer structure */ -EXTERN int stru; /* file transfer structure */ -EXTERN char formname[32]; /* name of file transfer format */ -EXTERN int form; /* file transfer format */ -EXTERN char modename[32]; /* name of file transfer mode */ -EXTERN int mode; /* file transfer mode */ -EXTERN char bytename[32]; /* local byte size in ascii */ -EXTERN int bytesize; /* local byte size in binary */ -EXTERN int passivemode; /* passive transfer mode toggle */ -EXTERN off_t restart_point; /* transfer restart offset */ -EXTERN int tcpwindowsize; /* TCP window size for the data connection */ - -EXTERN boolean_t ls_invokes_NLST; /* behaviour of 'ls' */ -EXTERN char *hostname; /* name of host connected to */ -EXTERN char *home; -EXTERN char *globerr; - -EXTERN struct sockaddr_in6 myctladdr; /* for channel bindings */ -EXTERN struct sockaddr_in6 remctladdr; /* for channel bindings */ - -EXTERN int clevel; /* command channel protection level */ -EXTERN int dlevel; /* data channel protection level */ - -EXTERN int autoauth; /* do authentication on connect */ -EXTERN int auth_type; /* authentication type */ -EXTERN int auth_error; /* one error code for all auth types */ -EXTERN int autoencrypt; /* do encryption on connect */ -EXTERN int fflag; /* forward credentials */ -EXTERN boolean_t goteof; - -EXTERN int skipsyst; /* enable automatic sending of SYST command */ - -EXTERN uchar_t *ucbuf; /* clear text buffer */ +extern int trace; /* trace packets exchanged */ +extern int hash; /* print # for each buffer transferred */ +extern int sendport; /* use PORT cmd for each data connection */ +extern int verbose; /* print messages coming back from server */ +extern int connected; /* connected to server */ +extern int fromatty; /* input is from a terminal */ +extern int interactive; /* interactively prompt on m* cmds */ +extern int debug; /* debugging level */ +extern int bell; /* ring bell on cmd completion */ +extern int doglob; /* glob local file names */ +extern int autologin; /* establish user account on connection */ +extern int proxy; /* proxy server connection active */ +extern int proxflag; /* proxy connection exists */ +extern int sunique; /* store files on server with unique name */ +extern int runique; /* store local files with unique name */ +extern int mcase; /* map upper to lower case for mget names */ +extern int ntflag; /* use ntin ntout tables for name translation */ +extern int mapflag; /* use mapin mapout templates on file names */ +extern int code; /* return/reply code for ftp command */ +extern int crflag; /* if 1, strip car. rets. on ascii gets */ +extern char pasv[64]; /* passive port for proxy data connection */ +extern char *altarg; /* argv[1] with no shell-like preprocessing */ +extern char ntin[17]; /* input translation table */ +extern char ntout[17]; /* output translation table */ +extern char mapin[MAXPATHLEN]; /* input map template */ +extern char mapout[MAXPATHLEN]; /* output map template */ +extern char typename[32]; /* name of file transfer type */ +extern int type; /* file transfer type */ +extern char structname[32]; /* name of file transfer structure */ +extern int stru; /* file transfer structure */ +extern char formname[32]; /* name of file transfer format */ +extern int form; /* file transfer format */ +extern char modename[32]; /* name of file transfer mode */ +extern int mode; /* file transfer mode */ +extern char bytename[32]; /* local byte size in ascii */ +extern int bytesize; /* local byte size in binary */ +extern int passivemode; /* passive transfer mode toggle */ +extern off_t restart_point; /* transfer restart offset */ +extern int tcpwindowsize; /* TCP window size for the data connection */ + +extern boolean_t ls_invokes_NLST; /* behaviour of 'ls' */ +extern char *hostname; /* name of host connected to */ +extern char *home; +extern char *globerr; + +extern struct sockaddr_in6 myctladdr; /* for channel bindings */ +extern struct sockaddr_in6 remctladdr; /* for channel bindings */ + +extern int clevel; /* command channel protection level */ +extern int dlevel; /* data channel protection level */ + +extern int autoauth; /* do authentication on connect */ +extern int auth_type; /* authentication type */ +extern int auth_error; /* one error code for all auth types */ +extern int autoencrypt; /* do encryption on connect */ +extern int fflag; /* forward credentials */ +extern boolean_t goteof; + +extern int skipsyst; /* enable automatic sending of SYST command */ + +extern uchar_t *ucbuf; /* clear text buffer */ #define MECH_SZ 40 #define FTP_DEF_MECH "kerberos_v5" -EXTERN char mechstr[MECH_SZ]; /* mechanism type */ +extern char mechstr[MECH_SZ]; /* mechanism type */ -EXTERN gss_OID mechoid; /* corresponding mechanism oid type */ -EXTERN gss_ctx_id_t gcontext; /* gss security context */ +extern gss_OID mechoid; /* corresponding mechanism oid type */ +extern gss_ctx_id_t gcontext; /* gss security context */ #define FTPBUFSIZ BUFSIZ*16 #define HASHSIZ BUFSIZ*8 -EXTERN char *buf; /* buffer for binary sends and gets */ +extern char *buf; /* buffer for binary sends and gets */ -EXTERN jmp_buf toplevel; /* non-local goto stuff for cmd scanner */ +extern jmp_buf toplevel; /* non-local goto stuff for cmd scanner */ /* * BUFSIZE includes @@ -192,25 +187,25 @@ EXTERN jmp_buf toplevel; /* non-local goto stuff for cmd scanner */ #define MAXCMDLEN 10 /* The length of longest command in cmdtab[] */ #define BUFSIZE ((MAXPATHLEN)*2+MAXCMDLEN+4) -EXTERN char line[BUFSIZE]; /* input line buffer */ -EXTERN char *stringbase; /* current scan point in line buffer */ -EXTERN char argbuf[BUFSIZE]; /* argument storage buffer */ -EXTERN char *argbase; /* current storage point in arg buffer */ -EXTERN int margc; /* count of arguments on input line */ -EXTERN char **margv; /* args parsed from input line */ -EXTERN int cpend; /* flag: if != 0, then pending server reply */ -EXTERN int mflag; /* flag: if != 0, then active multi command */ -EXTERN FILE *tmp_nlst; /* tmp file; holds NLST results for mget, etc */ +extern char line[BUFSIZE]; /* input line buffer */ +extern char *stringbase; /* current scan point in line buffer */ +extern char argbuf[BUFSIZE]; /* argument storage buffer */ +extern char *argbase; /* current storage point in arg buffer */ +extern int margc; /* count of arguments on input line */ +extern char **margv; /* args parsed from input line */ +extern int cpend; /* flag: if != 0, then pending server reply */ +extern int mflag; /* flag: if != 0, then active multi command */ +extern FILE *tmp_nlst; /* tmp file; holds NLST results for mget, etc */ -EXTERN char *reply_parse; /* for parsing replies to the ADAT command */ -EXTERN char reply_buf[FTPBUFSIZ]; -EXTERN char *reply_ptr; +extern char *reply_parse; /* for parsing replies to the ADAT command */ +extern char reply_buf[FTPBUFSIZ]; +extern char *reply_ptr; -EXTERN int options; /* used during socket creation */ +extern int options; /* used during socket creation */ -EXTERN int timeout; /* connection timeout */ -EXTERN int timeoutms; /* connection timeout in msec */ -EXTERN jmp_buf timeralarm; /* to recover from global timeout */ +extern int timeout; /* connection timeout */ +extern int timeoutms; /* connection timeout in msec */ +extern jmp_buf timeralarm; /* to recover from global timeout */ /* @@ -231,9 +226,9 @@ struct macel { char *mac_end; /* end of macro in macbuf */ }; -EXTERN int macnum; /* number of defined macros */ -EXTERN struct macel macros[16]; -EXTERN char macbuf[4096]; +extern int macnum; /* number of defined macros */ +extern struct macel macros[16]; +extern char macbuf[4096]; extern void macdef(int argc, char *argv[]); extern void doproxy(int argc, char *argv[]); diff --git a/usr/src/cmd/cmd-inet/usr.bin/ftp/main.c b/usr/src/cmd/cmd-inet/usr.bin/ftp/main.c index e787a45087..09a0782a50 100644 --- a/usr/src/cmd/cmd-inet/usr.bin/ftp/main.c +++ b/usr/src/cmd/cmd-inet/usr.bin/ftp/main.c @@ -24,7 +24,7 @@ */ /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ +/* All Rights Reserved */ /* * University Copyright- Copyright (c) 1982, 1986, 1988 @@ -36,15 +36,86 @@ * contributors. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * FTP User Program -- Command Interface. */ -#define EXTERN #include "ftp_var.h" #include <deflt.h> /* macros that make using libcmd easier */ +int trace; +int hash; +int sendport; +int verbose; +int connected; +int fromatty; +int interactive; +int debug; +int bell; +int doglob; +int autologin; +int proxy; +int proxflag; +int sunique; +int runique; +int mcase; +int ntflag; +int mapflag; +int code; +int crflag; +char pasv[64]; +char *altarg; +char ntin[17]; +char ntout[17]; +char mapin[MAXPATHLEN]; +char mapout[MAXPATHLEN]; +char typename[32]; +int type; +char structname[32]; +int stru; +char formname[32]; +int form; +char modename[32]; +int mode; +char bytename[32]; +int bytesize; +int passivemode; +off_t restart_point; +int tcpwindowsize; +boolean_t ls_invokes_NLST; +char *hostname; +char *home; +char *globerr; +struct sockaddr_in6 myctladdr; +struct sockaddr_in6 remctladdr; +int clevel; +int dlevel; +int autoauth; +int auth_error; +int autoencrypt; +int fflag; +boolean_t goteof; +int skipsyst; +char mechstr[MECH_SZ]; +char *buf; +jmp_buf toplevel; +char line[BUFSIZE]; +char *stringbase; +char argbuf[BUFSIZE]; +char *argbase; +int margc; +char **margv; +int cpend; +int mflag; +char reply_buf[FTPBUFSIZ]; +char *reply_ptr; +int options; +int timeout; +int timeoutms; +jmp_buf timeralarm; +int macnum; +struct macel macros[16]; +char macbuf[4096]; + static void usage(void); static void timeout_sig(int sig); static void cmdscanner(int top); @@ -132,7 +203,7 @@ main(int argc, char *argv[]) case 'T': if (!isdigit(*optarg)) { (void) fprintf(stderr, - "ftp: bad timeout: \"%s\"\n", optarg); + "ftp: bad timeout: \"%s\"\n", optarg); break; } timeout = atoi(optarg); @@ -627,7 +698,7 @@ help(int argc, char *argv[]) extern int NCMDS; (void) printf( - "Commands may be abbreviated. Commands are:\n\n"); + "Commands may be abbreviated. Commands are:\n\n"); for (c = cmdtab; c < &cmdtab[NCMDS]; c++) { int len = strlen(c->c_name); @@ -673,7 +744,7 @@ help(int argc, char *argv[]) (void) printf("?Invalid help command %s\n", arg); else (void) printf("%-*s\t%s\n", HELPINDENT, - c->c_name, c->c_help); + c->c_name, c->c_help); } } |