ftpd: instead of wordy HELP, implement useful, and smaller, FEAT.
(HELP is still "supported" as an alias to FEAT) text data bss dec hex filename 807331 468 7856 815655 c7227 busybox_old 807246 468 7856 815570 c71d2 busybox_unstripped
This commit is contained in:
parent
edb0de4283
commit
1a82555108
@ -285,7 +285,7 @@ handle_stat(void)
|
|||||||
STR(FTP_STATOK)" Ok\r\n");
|
STR(FTP_STATOK)" Ok\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: implement FEAT. Example:
|
/* Examples of HELP and FEAT:
|
||||||
# nc -vvv ftp.kernel.org 21
|
# nc -vvv ftp.kernel.org 21
|
||||||
ftp.kernel.org (130.239.17.4:21) open
|
ftp.kernel.org (130.239.17.4:21) open
|
||||||
220 Welcome to ftp.kernel.org.
|
220 Welcome to ftp.kernel.org.
|
||||||
@ -309,16 +309,14 @@ HELP
|
|||||||
214 Help OK.
|
214 Help OK.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
handle_help(void)
|
handle_feat(unsigned status)
|
||||||
{
|
{
|
||||||
cmdio_write_raw(STR(FTP_HELP)"-Commands:\r\n"
|
cmdio_write(status, "-Features:");
|
||||||
" ALLO CDUP CWD EPSV HELP LIST\r\n"
|
cmdio_write_raw(" EPSV\r\n"
|
||||||
" MODE NLST NOOP PASS PASV PORT PWD QUIT\r\n"
|
" PASV\r\n"
|
||||||
" REST RETR SIZE STAT STRU SYST TYPE USER\r\n"
|
" REST STREAM\r\n"
|
||||||
#if ENABLE_FEATURE_FTP_WRITE
|
" SIZE\r\n");
|
||||||
" APPE DELE MKD RMD RNFR RNTO STOR STOU\r\n"
|
cmdio_write(status, " Ok");
|
||||||
#endif
|
|
||||||
STR(FTP_HELP)" Ok\r\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Download commands */
|
/* Download commands */
|
||||||
@ -904,7 +902,7 @@ cmdio_get_cmd_and_arg(void)
|
|||||||
cmd[len--] = '\0';
|
cmd[len--] = '\0';
|
||||||
|
|
||||||
if (G.verbose > 1)
|
if (G.verbose > 1)
|
||||||
bb_error_msg("%s", cmd);
|
verbose_log(cmd);
|
||||||
|
|
||||||
G.ftp_arg = strchr(cmd, ' ');
|
G.ftp_arg = strchr(cmd, ' ');
|
||||||
if (G.ftp_arg != NULL)
|
if (G.ftp_arg != NULL)
|
||||||
@ -927,6 +925,7 @@ enum {
|
|||||||
const_CWD = mk_const3('C', 'W', 'D'),
|
const_CWD = mk_const3('C', 'W', 'D'),
|
||||||
const_DELE = mk_const4('D', 'E', 'L', 'E'),
|
const_DELE = mk_const4('D', 'E', 'L', 'E'),
|
||||||
const_EPSV = mk_const4('E', 'P', 'S', 'V'),
|
const_EPSV = mk_const4('E', 'P', 'S', 'V'),
|
||||||
|
const_FEAT = mk_const4('F', 'E', 'A', 'T'),
|
||||||
const_HELP = mk_const4('H', 'E', 'L', 'P'),
|
const_HELP = mk_const4('H', 'E', 'L', 'P'),
|
||||||
const_LIST = mk_const4('L', 'I', 'S', 'T'),
|
const_LIST = mk_const4('L', 'I', 'S', 'T'),
|
||||||
const_MKD = mk_const3('M', 'K', 'D'),
|
const_MKD = mk_const3('M', 'K', 'D'),
|
||||||
@ -1126,8 +1125,9 @@ int ftpd_main(int argc, char **argv)
|
|||||||
handle_cwd();
|
handle_cwd();
|
||||||
else if (cmdval == const_CDUP) /* cd .. */
|
else if (cmdval == const_CDUP) /* cd .. */
|
||||||
handle_cdup();
|
handle_cdup();
|
||||||
else if (cmdval == const_HELP)
|
/* HELP is nearly useless, but we can reuse FEAT for it */
|
||||||
handle_help();
|
else if (cmdval == const_HELP || cmdval == const_FEAT)
|
||||||
|
handle_feat(cmdval == const_HELP ? STRNUM32(FTP_HELP) : STRNUM32(FTP_STATOK));
|
||||||
else if (cmdval == const_LIST) /* ls -l */
|
else if (cmdval == const_LIST) /* ls -l */
|
||||||
handle_list();
|
handle_list();
|
||||||
else if (cmdval == const_NLST) /* "name list", bare ls */
|
else if (cmdval == const_NLST) /* "name list", bare ls */
|
||||||
@ -1186,8 +1186,7 @@ int ftpd_main(int argc, char **argv)
|
|||||||
else {
|
else {
|
||||||
/* Which unsupported commands were seen in the wild?
|
/* Which unsupported commands were seen in the wild?
|
||||||
* (doesn't necessarily mean "we must support them")
|
* (doesn't necessarily mean "we must support them")
|
||||||
* lftp 3.6.3: FEAT - is it useful?
|
* lftp 3.6.3: MDTM - works fine without it anyway
|
||||||
* MDTM - works fine without it anyway
|
|
||||||
*/
|
*/
|
||||||
cmdio_write_raw(STR(FTP_BADCMD)" Unknown command\r\n");
|
cmdio_write_raw(STR(FTP_BADCMD)" Unknown command\r\n");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user