1 /* vi: set sw=4 ts=4: */
3 * Simple FTP daemon, based on vsftpd 2.0.7 (written by Chris Evans)
5 * Author: Adam Tkac <vonsch@gmail.com>
7 * Licensed under GPLv2, see file LICENSE in this tarball for details.
9 * Only subset of FTP protocol is implemented but vast majority of clients
10 * should not have any problem. You have to run this daemon via inetd.
13 * -w - enable FTP write commands
15 * TODO: implement "421 Timeout" thingy (alarm(60) while waiting for a cmd).
20 #include <netinet/tcp.h>
22 #define FTP_DATACONN 150
23 #define FTP_NOOPOK 200
24 #define FTP_TYPEOK 200
25 #define FTP_PORTOK 200
26 #define FTP_STRUOK 200
27 #define FTP_MODEOK 200
28 #define FTP_ALLOOK 202
29 #define FTP_STATOK 211
30 #define FTP_STATFILE_OK 213
32 #define FTP_SYSTOK 215
34 #define FTP_GOODBYE 221
35 #define FTP_TRANSFEROK 226
36 #define FTP_PASVOK 227
37 /*#define FTP_EPRTOK 228*/
38 #define FTP_EPSVOK 229
39 #define FTP_LOGINOK 230
41 #define FTP_RMDIROK 250
42 #define FTP_DELEOK 250
43 #define FTP_RENAMEOK 250
45 #define FTP_MKDIROK 257
46 #define FTP_GIVEPWORD 331
47 #define FTP_RESTOK 350
48 #define FTP_RNFROK 350
49 #define FTP_BADSENDCONN 425
50 #define FTP_BADSENDNET 426
51 #define FTP_BADSENDFILE 451
52 #define FTP_BADCMD 500
53 #define FTP_COMMANDNOTIMPL 502
54 #define FTP_NEEDUSER 503
55 #define FTP_NEEDRNFR 503
56 #define FTP_BADSTRU 504
57 #define FTP_BADMODE 504
58 #define FTP_LOGINERR 530
59 #define FTP_FILEFAIL 550
60 #define FTP_NOPERM 550
61 #define FTP_UPLOADFAIL 553
64 #define STR(s) STR1(s)
66 /* Convert a constant to 3-digit string, packed into uint32_t */
68 /* Shift for Nth decimal digit */
69 SHIFT0 = 16 * BB_LITTLE_ENDIAN + 8 * BB_BIG_ENDIAN,
70 SHIFT1 = 8 * BB_LITTLE_ENDIAN + 16 * BB_BIG_ENDIAN,
71 SHIFT2 = 0 * BB_LITTLE_ENDIAN + 24 * BB_BIG_ENDIAN,
73 #define STRNUM32(s) (uint32_t)(0 \
74 | (('0' + ((s) / 1 % 10)) << SHIFT0) \
75 | (('0' + ((s) / 10 % 10)) << SHIFT1) \
76 | (('0' + ((s) / 100 % 10)) << SHIFT2) \
85 #define mk_const4(a,b,c,d) (((a * 0x100 + b) * 0x100 + c) * 0x100 + d)
86 #define mk_const3(a,b,c) ((a * 0x100 + b) * 0x100 + c)
87 const_ALLO = mk_const4('A', 'L', 'L', 'O'),
88 const_APPE = mk_const4('A', 'P', 'P', 'E'),
89 const_CDUP = mk_const4('C', 'D', 'U', 'P'),
90 const_CWD = mk_const3('C', 'W', 'D'),
91 const_DELE = mk_const4('D', 'E', 'L', 'E'),
92 const_EPSV = mk_const4('E', 'P', 'S', 'V'),
93 const_HELP = mk_const4('H', 'E', 'L', 'P'),
94 const_LIST = mk_const4('L', 'I', 'S', 'T'),
95 const_MKD = mk_const3('M', 'K', 'D'),
96 const_MODE = mk_const4('M', 'O', 'D', 'E'),
97 const_NLST = mk_const4('N', 'L', 'S', 'T'),
98 const_NOOP = mk_const4('N', 'O', 'O', 'P'),
99 const_PASS = mk_const4('P', 'A', 'S', 'S'),
100 const_PASV = mk_const4('P', 'A', 'S', 'V'),
101 const_PORT = mk_const4('P', 'O', 'R', 'T'),
102 const_PWD = mk_const3('P', 'W', 'D'),
103 const_QUIT = mk_const4('Q', 'U', 'I', 'T'),
104 const_REST = mk_const4('R', 'E', 'S', 'T'),
105 const_RETR = mk_const4('R', 'E', 'T', 'R'),
106 const_RMD = mk_const3('R', 'M', 'D'),
107 const_RNFR = mk_const4('R', 'N', 'F', 'R'),
108 const_RNTO = mk_const4('R', 'N', 'T', 'O'),
109 const_SIZE = mk_const4('S', 'I', 'Z', 'E'),
110 const_STAT = mk_const4('S', 'T', 'A', 'T'),
111 const_STOR = mk_const4('S', 'T', 'O', 'R'),
112 const_STOU = mk_const4('S', 'T', 'O', 'U'),
113 const_STRU = mk_const4('S', 'T', 'R', 'U'),
114 const_SYST = mk_const4('S', 'Y', 'S', 'T'),
115 const_TYPE = mk_const4('T', 'Y', 'P', 'E'),
116 const_USER = mk_const4('U', 'S', 'E', 'R'),
120 char *p_control_line_buf;
121 len_and_sockaddr *local_addr;
122 len_and_sockaddr *port_addr;
128 #if ENABLE_FEATURE_FTP_WRITE
132 #define G (*(struct globals*)&bb_common_bufsiz1)
133 #define INIT_G() do { } while (0)
137 escape_text(const char *prepend, const char *str, unsigned escapee)
139 unsigned retlen, remainlen, chunklen;
143 append = (char)escapee;
146 remainlen = strlen(str);
147 retlen = strlen(prepend);
148 ret = xmalloc(retlen + remainlen * 2 + 1 + 1);
149 strcpy(ret, prepend);
152 found = strchrnul(str, escapee);
153 chunklen = found - str + 1;
155 /* Copy chunk up to and including escapee (or NUL) to ret */
156 memcpy(ret + retlen, str, chunklen);
159 if (*found == '\0') {
160 /* It wasn't escapee, it was NUL! */
161 ret[retlen - 1] = append; /* replace NUL */
162 ret[retlen] = '\0'; /* add NUL */
165 ret[retlen++] = escapee; /* duplicate escapee */
171 /* Returns strlen as a bonus */
173 replace_char(char *str, char from, char to)
185 cmdio_write(uint32_t status_str, const char *str)
196 /* FTP allegedly uses telnet protocol for command link.
197 * In telnet, 0xff is an escape char, and needs to be escaped: */
198 response = escape_text(u.buf, str, (0xff << 8) + '\r');
200 /* ?! does FTP send embedded LFs as NULs? wow */
201 len = replace_char(response, '\n', '\0');
203 response[len++] = '\n'; /* tack on trailing '\n' */
204 xwrite(STDOUT_FILENO, response, len);
209 cmdio_write_ok(int status)
211 fdprintf(STDOUT_FILENO, "%u Operation successful\r\n", status);
214 /* TODO: output strerr(errno) if errno != 0? */
216 cmdio_write_error(int status)
218 fdprintf(STDOUT_FILENO, "%u Error\r\n", status);
222 cmdio_write_raw(const char *p_text)
224 xwrite_str(STDOUT_FILENO, p_text);
227 /* Simple commands */
232 char *cwd, *response;
234 cwd = xrealloc_getcwd_or_warn(NULL);
238 /* We have to promote each " to "" */
239 response = escape_text(" \"", cwd, ('"' << 8) + '"');
241 cmdio_write(STRNUM32(FTP_PWDOK), response);
248 if (!G.ftp_arg || chdir(G.ftp_arg) != 0) {
249 cmdio_write_error(FTP_FILEFAIL);
252 cmdio_write_ok(FTP_CWDOK);
258 G.ftp_arg = (char*)"..";
265 cmdio_write_raw(STR(FTP_STATOK)"-FTP server status:\r\n"
267 STR(FTP_STATOK)" Ok\r\n");
273 cmdio_write_raw(STR(FTP_HELP)"-Commands:\r\n"
274 " ALLO CDUP CWD EPSV HELP LIST\r\n"
275 " MODE NLST NOOP PASS PASV PORT PWD QUIT\r\n"
276 " REST RETR SIZE STAT STRU SYST TYPE USER\r\n"
277 #if ENABLE_FEATURE_FTP_WRITE
278 " APPE DELE MKD RMD RNFR RNTO STOR STOU\r\n"
280 STR(FTP_HELP)" Ok\r\n");
283 /* Download commands */
286 ftpdataio_get_pasv_fd(void)
290 remote_fd = accept(G.pasv_listen_fd, NULL, 0);
293 cmdio_write_error(FTP_BADSENDCONN);
297 setsockopt(remote_fd, SOL_SOCKET, SO_KEEPALIVE, &const_int_1, sizeof(const_int_1));
304 return (G.port_addr != NULL);
310 return (G.pasv_listen_fd > STDOUT_FILENO);
314 get_remote_transfer_fd(const char *p_status_msg)
319 remote_fd = ftpdataio_get_pasv_fd();
321 remote_fd = xconnect_stream(G.port_addr);
326 cmdio_write(STRNUM32(FTP_DATACONN), p_status_msg);
331 data_transfer_checks_ok(void)
333 if (!pasv_active() && !port_active()) {
334 cmdio_write_raw(STR(FTP_BADSENDCONN)" Use PORT or PASV first\r\n");
342 port_pasv_cleanup(void)
346 if (G.pasv_listen_fd > STDOUT_FILENO)
347 close(G.pasv_listen_fd);
348 G.pasv_listen_fd = -1;
352 bind_for_passive_mode(void)
359 G.pasv_listen_fd = fd = xsocket(G.local_addr->u.sa.sa_family, SOCK_STREAM, 0);
360 setsockopt_reuseaddr(fd);
362 set_nport(G.local_addr, 0);
363 xbind(fd, &G.local_addr->u.sa, G.local_addr->len);
365 getsockname(fd, &G.local_addr->u.sa, &G.local_addr->len);
367 port = get_nport(&G.local_addr->u.sa);
376 char *addr, *response;
378 port = bind_for_passive_mode();
380 if (G.local_addr->u.sa.sa_family == AF_INET)
381 addr = xmalloc_sockaddr2dotted_noport(&G.local_addr->u.sa);
382 else /* seen this in the wild done by other ftp servers: */
383 addr = xstrdup("0.0.0.0");
384 replace_char(addr, '.', ',');
386 response = xasprintf(STR(FTP_PASVOK)" Entering Passive Mode (%s,%u,%u)\r\n",
387 addr, (int)(port >> 8), (int)(port & 255));
389 cmdio_write_raw(response);
399 port = bind_for_passive_mode();
400 response = xasprintf(STR(FTP_EPSVOK)" EPSV Ok (|||%u|)\r\n", port);
401 cmdio_write_raw(response);
409 char *raw, *port_part;
410 len_and_sockaddr *lsa = NULL;
417 * xatou16 will accept wrong input,
418 * xatou16 will exit instead of generating error to peer
421 port_part = strrchr(raw, ',');
422 if (port_part == NULL)
424 port = xatou16(&port_part[1]);
427 port_part = strrchr(raw, ',');
428 if (port_part == NULL)
430 port |= xatou16(&port_part[1]) << 8;
433 replace_char(raw, ',', '.');
434 lsa = xdotted2sockaddr(raw, port);
438 cmdio_write_error(FTP_BADCMD);
443 cmdio_write_ok(FTP_PORTOK);
449 /* When ftp_arg == NULL simply restart from beginning */
450 G.restart_pos = G.ftp_arg ? xatoi_u(G.ftp_arg) : 0;
451 cmdio_write_ok(FTP_RESTOK);
461 off_t offset = G.restart_pos;
466 if (!data_transfer_checks_ok())
467 return; /* data_transfer_checks_ok emitted error response */
469 /* O_NONBLOCK is useful if file happens to be a device node */
470 opened_file = G.ftp_arg ? open(G.ftp_arg, O_RDONLY | O_NONBLOCK) : -1;
471 if (opened_file < 0) {
472 cmdio_write_error(FTP_FILEFAIL);
476 if (fstat(opened_file, &statbuf) != 0 || !S_ISREG(statbuf.st_mode)) {
477 /* Note - pretend open failed */
478 cmdio_write_error(FTP_FILEFAIL);
482 /* Now deactive O_NONBLOCK, otherwise we have a problem on DMAPI filesystems
485 ndelay_off(opened_file);
487 /* Set the download offset (from REST) if any */
489 xlseek(opened_file, offset, SEEK_SET);
491 response = xasprintf(
492 " Opening BINARY mode data connection for %s (%"OFF_FMT"u bytes)",
493 G.ftp_arg, statbuf.st_size);
494 remote_fd = get_remote_transfer_fd(response);
497 goto port_pasv_cleanup_out;
499 trans_ret = bb_copyfd_eof(opened_file, remote_fd);
502 cmdio_write_error(FTP_BADSENDFILE);
504 cmdio_write_ok(FTP_TRANSFEROK);
506 port_pasv_cleanup_out:
516 popen_ls(const char *opt)
519 const char *argv[5] = { "ftpd", opt, NULL, G.ftp_arg, NULL };
520 struct fd_pair outfd;
523 cwd = xrealloc_getcwd_or_warn(NULL);
531 case -1: /* failure */
532 bb_perror_msg_and_die("vfork");
534 /* NB: close _first_, then move fds! */
536 xmove_fd(outfd.wr, STDOUT_FILENO);
538 /* xopen("/dev/null", O_RDONLY); - chroot may lack it! */
539 if (fchdir(G.proc_self_fd) == 0) {
540 close(G.proc_self_fd);
542 /* ftpd ls helper chdirs to argv[2],
543 * preventing peer from seeing /proc/self
545 execv("exe", (char**) argv);
556 handle_dir_common(int opts)
562 if (!(opts & 1) && !data_transfer_checks_ok())
563 return; /* data_transfer_checks_ok emitted error response */
565 ls_fd = popen_ls((opts & 2) ? "-l" : "-1");
566 ls_fp = fdopen(ls_fd, "r");
567 if (!ls_fp) /* never happens. paranoia */
568 bb_perror_msg_and_die("fdopen");
571 /* STAT <filename> */
572 cmdio_write_raw(STR(FTP_STATFILE_OK)"-Status follows:\r\n");
574 line = xmalloc_fgetline(ls_fp);
577 cmdio_write(0, line); /* hack: 0 results in no status at all */
580 cmdio_write_ok(FTP_STATFILE_OK);
582 /* LIST/NLST [<filename>] */
583 int remote_fd = get_remote_transfer_fd(" Here comes the directory listing");
584 if (remote_fd >= 0) {
586 line = xmalloc_fgetline(ls_fp);
589 xwrite_str(remote_fd, line);
590 xwrite(remote_fd, "\r\n", 2);
596 cmdio_write_ok(FTP_TRANSFEROK);
598 fclose(ls_fp); /* closes ls_fd too */
603 handle_dir_common(2);
608 handle_dir_common(0);
611 handle_stat_file(void)
613 handle_dir_common(3);
620 char buf[sizeof(STR(FTP_STATFILE_OK)" %"OFF_FMT"u\r\n") + sizeof(off_t)*3];
623 || stat(G.ftp_arg, &statbuf) != 0
624 || !S_ISREG(statbuf.st_mode)
626 cmdio_write_error(FTP_FILEFAIL);
629 sprintf(buf, STR(FTP_STATFILE_OK)" %"OFF_FMT"u\r\n", statbuf.st_size);
630 cmdio_write_raw(buf);
633 /* Upload commands */
635 #if ENABLE_FEATURE_FTP_WRITE
639 if (!G.ftp_arg || mkdir(G.ftp_arg, 0777) != 0) {
640 cmdio_write_error(FTP_FILEFAIL);
643 cmdio_write_ok(FTP_MKDIROK);
649 if (!G.ftp_arg || rmdir(G.ftp_arg) != 0) {
650 cmdio_write_error(FTP_FILEFAIL);
653 cmdio_write_ok(FTP_RMDIROK);
659 if (!G.ftp_arg || unlink(G.ftp_arg) != 0) {
660 cmdio_write_error(FTP_FILEFAIL);
663 cmdio_write_ok(FTP_DELEOK);
669 free(G.rnfr_filename);
670 G.rnfr_filename = xstrdup(G.ftp_arg);
671 cmdio_write_ok(FTP_RNFROK);
679 /* If we didn't get a RNFR, throw a wobbly */
680 if (G.rnfr_filename == NULL || G.ftp_arg == NULL) {
681 cmdio_write_raw(STR(FTP_NEEDRNFR)" RNFR required first\r\n");
685 retval = rename(G.rnfr_filename, G.ftp_arg);
686 free(G.rnfr_filename);
687 G.rnfr_filename = NULL;
690 cmdio_write_error(FTP_FILEFAIL);
693 cmdio_write_ok(FTP_RENAMEOK);
697 handle_upload_common(int is_append, int is_unique)
699 char *tempname = NULL;
705 offset = G.restart_pos;
708 if (!data_transfer_checks_ok())
713 tempname = xstrdup(" FILE: uniq.XXXXXX");
714 local_file_fd = mkstemp(tempname + 7);
715 } else if (G.ftp_arg) {
716 int flags = O_WRONLY | O_CREAT | O_TRUNC;
718 flags = O_WRONLY | O_CREAT | O_APPEND;
720 flags = O_WRONLY | O_CREAT;
721 local_file_fd = open(G.ftp_arg, flags, 0666);
723 if (local_file_fd < 0) {
724 cmdio_write_error(FTP_UPLOADFAIL);
728 /* TODO: paranoia: fstat it, refuse to do anything if it's not a regular file */
731 xlseek(local_file_fd, offset, SEEK_SET);
733 remote_fd = get_remote_transfer_fd(tempname ? tempname : " Ok to send data");
739 trans_ret = bb_copyfd_eof(remote_fd, local_file_fd);
743 cmdio_write_error(FTP_BADSENDFILE);
745 cmdio_write_ok(FTP_TRANSFEROK);
749 close(local_file_fd);
755 handle_upload_common(0, 0);
762 handle_upload_common(1, 0);
769 handle_upload_common(0, 1);
771 #endif /* ENABLE_FEATURE_FTP_WRITE */
774 cmdio_get_cmd_and_arg(void)
781 len = 8 * 1024; /* Paranoia. Peer may send 1 gigabyte long cmd... */
782 G.ftp_cmd = cmd = xmalloc_reads(STDIN_FILENO, NULL, &len);
786 len = strlen(cmd) - 1;
787 while (len >= 0 && cmd[len] == '\r') {
792 G.ftp_arg = strchr(cmd, ' ');
793 if (G.ftp_arg != NULL) {
799 cmdval = (cmdval << 8) + ((unsigned char)*cmd++ & (unsigned char)~0x20);
804 int ftpd_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
805 int ftpd_main(int argc, char **argv)
809 opts = getopt32(argv, "l1v" USE_FEATURE_FTP_WRITE("w"));
811 if (opts & (OPT_l|OPT_1)) {
812 /* Our secret backdoor to ls */
814 argv[2] = (char*)"--";
815 return ls_main(argc, argv);
820 G.local_addr = get_sock_lsa(STDIN_FILENO);
822 /* This is confusing:
823 * bb_error_msg_and_die("stdin is not a socket");
826 /* Help text says that ftpd must be used as inetd service,
827 * which is by far the most usual cause of get_sock_lsa
831 /* LOG_NDELAY is needed since we may chroot later */
832 openlog(applet_name, LOG_PID | LOG_NDELAY, LOG_DAEMON);
833 logmode |= LOGMODE_SYSLOG;
835 logmode = LOGMODE_SYSLOG;
837 G.proc_self_fd = xopen("/proc/self", O_RDONLY | O_DIRECTORY);
840 xchdir(argv[optind]);
844 //umask(077); - admin can set umask before starting us
846 /* Signals. We'll always take -EPIPE rather than a rude signal, thanks */
847 signal(SIGPIPE, SIG_IGN);
849 /* Set up options on the command socket (do we need these all? why?) */
850 setsockopt(STDIN_FILENO, IPPROTO_TCP, TCP_NODELAY, &const_int_1, sizeof(const_int_1));
851 setsockopt(STDIN_FILENO, SOL_SOCKET, SO_KEEPALIVE, &const_int_1, sizeof(const_int_1));
852 setsockopt(STDIN_FILENO, SOL_SOCKET, SO_OOBINLINE, &const_int_1, sizeof(const_int_1));
854 cmdio_write_ok(FTP_GREET);
856 #ifdef IF_WE_WANT_TO_REQUIRE_LOGIN
858 smallint user_was_specified = 0;
860 uint32_t cmdval = cmdio_get_cmd_and_arg();
862 if (cmdval == const_USER) {
863 if (G.ftp_arg == NULL || strcasecmp(G.ftp_arg, "anonymous") != 0)
864 cmdio_write_raw(STR(FTP_LOGINERR)" Server is anonymous only\r\n");
866 user_was_specified = 1;
867 cmdio_write_raw(STR(FTP_GIVEPWORD)" Please specify the password\r\n");
869 } else if (cmdval == const_PASS) {
870 if (user_was_specified)
872 cmdio_write_raw(STR(FTP_NEEDUSER)" Login with USER\r\n");
873 } else if (cmdval == const_QUIT) {
874 cmdio_write_ok(FTP_GOODBYE);
877 cmdio_write_raw(STR(FTP_LOGINERR)" Login with USER and PASS\r\n");
881 cmdio_write_ok(FTP_LOGINOK);
884 /* RFC-959 Section 5.1
885 * The following commands and options MUST be supported by every
886 * server-FTP and user-FTP, except in cases where the underlying
887 * file system or operating system does not allow or support
888 * a particular command.
889 * Type: ASCII Non-print, IMAGE, LOCAL 8
891 * Structure: File, Record*
892 * (Record structure is REQUIRED only for hosts whose file
893 * systems support record structure).
895 * USER, PASS, ACCT, [bbox: ACCT not supported]
900 * CWD, CDUP, RMD, MKD, PWD,
906 * "The argument field is a Telnet string identifying the user's account.
907 * The command is not necessarily related to the USER command, as some
908 * sites may require an account for login and others only for specific
909 * access, such as storing files. In the latter case the command may
910 * arrive at any time.
911 * There are reply codes to differentiate these cases for the automation:
912 * when account information is required for login, the response to
913 * a successful PASSword command is reply code 332. On the other hand,
914 * if account information is NOT required for login, the reply to
915 * a successful PASSword command is 230; and if the account information
916 * is needed for a command issued later in the dialogue, the server
917 * should return a 332 or 532 reply depending on whether it stores
918 * (pending receipt of the ACCounT command) or discards the command,
923 uint32_t cmdval = cmdio_get_cmd_and_arg();
925 if (cmdval == const_QUIT) {
926 cmdio_write_ok(FTP_GOODBYE);
929 else if (cmdval == const_USER)
930 cmdio_write_ok(FTP_GIVEPWORD);
931 else if (cmdval == const_PASS)
932 cmdio_write_ok(FTP_LOGINOK);
933 else if (cmdval == const_NOOP)
934 cmdio_write_ok(FTP_NOOPOK);
935 else if (cmdval == const_TYPE)
936 cmdio_write_ok(FTP_TYPEOK);
937 else if (cmdval == const_STRU)
938 cmdio_write_ok(FTP_STRUOK);
939 else if (cmdval == const_MODE)
940 cmdio_write_ok(FTP_MODEOK);
941 else if (cmdval == const_ALLO)
942 cmdio_write_ok(FTP_ALLOOK);
943 else if (cmdval == const_SYST)
944 cmdio_write_raw(STR(FTP_SYSTOK)" UNIX Type: L8\r\n");
945 else if (cmdval == const_PWD)
947 else if (cmdval == const_CWD)
949 else if (cmdval == const_CDUP) /* cd .. */
951 else if (cmdval == const_HELP)
953 else if (cmdval == const_LIST) /* ls -l */
955 else if (cmdval == const_NLST) /* "name list", bare ls */
957 else if (cmdval == const_SIZE)
959 else if (cmdval == const_STAT) {
960 if (G.ftp_arg == NULL)
965 else if (cmdval == const_PASV)
967 else if (cmdval == const_EPSV)
969 else if (cmdval == const_RETR)
971 else if (cmdval == const_PORT)
973 else if (cmdval == const_REST)
975 #if ENABLE_FEATURE_FTP_WRITE
976 else if (opts & OPT_w) {
977 if (cmdval == const_STOR)
979 else if (cmdval == const_MKD)
981 else if (cmdval == const_RMD)
983 else if (cmdval == const_DELE)
985 else if (cmdval == const_RNFR) /* "rename from" */
987 else if (cmdval == const_RNTO) /* "rename to" */
989 else if (cmdval == const_APPE)
991 else if (cmdval == const_STOU) /* "store unique" */
996 else if (cmdval == const_STOR
997 || cmdval == const_MKD
998 || cmdval == const_RMD
999 || cmdval == const_DELE
1000 || cmdval == const_RNFR
1001 || cmdval == const_RNTO
1002 || cmdval == const_APPE
1003 || cmdval == const_STOU
1005 cmdio_write_raw(STR(FTP_NOPERM)" Permission denied\r\n");
1009 /* Which unsupported commands were seen in the wild?
1010 * (doesn't necessarily mean "we must support them")
1011 * lftp 3.6.3: FEAT - is it useful?
1012 * MDTM - works fine without it anyway
1014 cmdio_write_raw(STR(FTP_BADCMD)" Unknown command\r\n");