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) \
86 #define mk_const4(a,b,c,d) (((a * 0x100 + b) * 0x100 + c) * 0x100 + d)
87 #define mk_const3(a,b,c) ((a * 0x100 + b) * 0x100 + c)
88 const_ALLO = mk_const4('A', 'L', 'L', 'O'),
89 const_APPE = mk_const4('A', 'P', 'P', 'E'),
90 const_CDUP = mk_const4('C', 'D', 'U', 'P'),
91 const_CWD = mk_const3('C', 'W', 'D'),
92 const_DELE = mk_const4('D', 'E', 'L', 'E'),
93 const_EPSV = mk_const4('E', 'P', 'S', 'V'),
94 const_HELP = mk_const4('H', 'E', 'L', 'P'),
95 const_LIST = mk_const4('L', 'I', 'S', 'T'),
96 const_MKD = mk_const3('M', 'K', 'D'),
97 const_MODE = mk_const4('M', 'O', 'D', 'E'),
98 const_NLST = mk_const4('N', 'L', 'S', 'T'),
99 const_NOOP = mk_const4('N', 'O', 'O', 'P'),
100 const_PASS = mk_const4('P', 'A', 'S', 'S'),
101 const_PASV = mk_const4('P', 'A', 'S', 'V'),
102 const_PORT = mk_const4('P', 'O', 'R', 'T'),
103 const_PWD = mk_const3('P', 'W', 'D'),
104 const_QUIT = mk_const4('Q', 'U', 'I', 'T'),
105 const_REST = mk_const4('R', 'E', 'S', 'T'),
106 const_RETR = mk_const4('R', 'E', 'T', 'R'),
107 const_RMD = mk_const3('R', 'M', 'D'),
108 const_RNFR = mk_const4('R', 'N', 'F', 'R'),
109 const_RNTO = mk_const4('R', 'N', 'T', 'O'),
110 const_SIZE = mk_const4('S', 'I', 'Z', 'E'),
111 const_STAT = mk_const4('S', 'T', 'A', 'T'),
112 const_STOR = mk_const4('S', 'T', 'O', 'R'),
113 const_STOU = mk_const4('S', 'T', 'O', 'U'),
114 const_STRU = mk_const4('S', 'T', 'R', 'U'),
115 const_SYST = mk_const4('S', 'Y', 'S', 'T'),
116 const_TYPE = mk_const4('T', 'Y', 'P', 'E'),
117 const_USER = mk_const4('U', 'S', 'E', 'R'),
121 char *p_control_line_buf;
122 len_and_sockaddr *local_addr;
123 len_and_sockaddr *port_addr;
129 #if ENABLE_FEATURE_FTP_WRITE
133 #define G (*(struct globals*)&bb_common_bufsiz1)
134 #define INIT_G() do { } while (0)
138 escape_text(const char *prepend, const char *str, unsigned escapee)
140 unsigned retlen, remainlen, chunklen;
144 append = (char)escapee;
147 remainlen = strlen(str);
148 retlen = strlen(prepend);
149 ret = xmalloc(retlen + remainlen * 2 + 1 + 1);
150 strcpy(ret, prepend);
153 found = strchrnul(str, escapee);
154 chunklen = found - str + 1;
156 /* Copy chunk up to and including escapee (or NUL) to ret */
157 memcpy(ret + retlen, str, chunklen);
160 if (*found == '\0') {
161 /* It wasn't escapee, it was NUL! */
162 ret[retlen - 1] = append; /* replace NUL */
163 ret[retlen] = '\0'; /* add NUL */
166 ret[retlen++] = escapee; /* duplicate escapee */
172 /* Returns strlen as a bonus */
174 replace_char(char *str, char from, char to)
186 cmdio_write(uint32_t status_str, const char *str)
197 /* FTP allegedly uses telnet protocol for command link.
198 * In telnet, 0xff is an escape char, and needs to be escaped: */
199 response = escape_text(u.buf, str, (0xff << 8) + '\r');
201 /* ?! does FTP send embedded LFs as NULs? wow */
202 len = replace_char(response, '\n', '\0');
204 response[len++] = '\n'; /* tack on trailing '\n' */
205 xwrite(STDOUT_FILENO, response, len);
210 cmdio_write_ok(int status)
212 fdprintf(STDOUT_FILENO, "%u Operation successful\r\n", status);
215 /* TODO: output strerr(errno) if errno != 0? */
217 cmdio_write_error(int status)
219 fdprintf(STDOUT_FILENO, "%u Error\r\n", status);
223 cmdio_write_raw(const char *p_text)
225 xwrite_str(STDOUT_FILENO, p_text);
228 /* Simple commands */
233 char *cwd, *response;
235 cwd = xrealloc_getcwd_or_warn(NULL);
239 /* We have to promote each " to "" */
240 response = escape_text(" \"", cwd, ('"' << 8) + '"');
242 cmdio_write(STRNUM32(FTP_PWDOK), response);
249 if (!G.ftp_arg || chdir(G.ftp_arg) != 0) {
250 cmdio_write_error(FTP_FILEFAIL);
253 cmdio_write_ok(FTP_CWDOK);
259 G.ftp_arg = (char*)"..";
266 cmdio_write_raw(STR(FTP_STATOK)"-FTP server status:\r\n"
268 STR(FTP_STATOK)" Ok\r\n");
274 cmdio_write_raw(STR(FTP_HELP)"-Commands:\r\n"
275 " ALLO CDUP CWD EPSV HELP LIST\r\n"
276 " MODE NLST NOOP PASS PASV PORT PWD QUIT\r\n"
277 " REST RETR SIZE STAT STRU SYST TYPE USER\r\n"
278 #if ENABLE_FEATURE_FTP_WRITE
279 " APPE DELE MKD RMD RNFR RNTO STOR STOU\r\n"
281 STR(FTP_HELP)" Ok\r\n");
284 /* Download commands */
287 ftpdataio_get_pasv_fd(void)
291 remote_fd = accept(G.pasv_listen_fd, NULL, 0);
294 cmdio_write_error(FTP_BADSENDCONN);
298 setsockopt(remote_fd, SOL_SOCKET, SO_KEEPALIVE, &const_int_1, sizeof(const_int_1));
305 return (G.port_addr != NULL);
311 return (G.pasv_listen_fd > STDOUT_FILENO);
315 get_remote_transfer_fd(const char *p_status_msg)
320 remote_fd = ftpdataio_get_pasv_fd();
322 remote_fd = xconnect_stream(G.port_addr);
327 cmdio_write(STRNUM32(FTP_DATACONN), p_status_msg);
332 data_transfer_checks_ok(void)
334 if (!pasv_active() && !port_active()) {
335 cmdio_write_raw(STR(FTP_BADSENDCONN)" Use PORT or PASV first\r\n");
343 port_pasv_cleanup(void)
347 if (G.pasv_listen_fd > STDOUT_FILENO)
348 close(G.pasv_listen_fd);
349 G.pasv_listen_fd = -1;
353 bind_for_passive_mode(void)
360 G.pasv_listen_fd = fd = xsocket(G.local_addr->u.sa.sa_family, SOCK_STREAM, 0);
361 setsockopt_reuseaddr(fd);
363 set_nport(G.local_addr, 0);
364 xbind(fd, &G.local_addr->u.sa, G.local_addr->len);
366 getsockname(fd, &G.local_addr->u.sa, &G.local_addr->len);
368 port = get_nport(&G.local_addr->u.sa);
377 char *addr, *response;
379 port = bind_for_passive_mode();
381 if (G.local_addr->u.sa.sa_family == AF_INET)
382 addr = xmalloc_sockaddr2dotted_noport(&G.local_addr->u.sa);
383 else /* seen this in the wild done by other ftp servers: */
384 addr = xstrdup("0.0.0.0");
385 replace_char(addr, '.', ',');
387 response = xasprintf(STR(FTP_PASVOK)" Entering Passive Mode (%s,%u,%u)\r\n",
388 addr, (int)(port >> 8), (int)(port & 255));
390 cmdio_write_raw(response);
400 port = bind_for_passive_mode();
401 response = xasprintf(STR(FTP_EPSVOK)" EPSV Ok (|||%u|)\r\n", port);
402 cmdio_write_raw(response);
410 char *raw, *port_part;
411 len_and_sockaddr *lsa = NULL;
418 * xatou16 will accept wrong input,
419 * xatou16 will exit instead of generating error to peer
422 port_part = strrchr(raw, ',');
423 if (port_part == NULL)
425 port = xatou16(&port_part[1]);
428 port_part = strrchr(raw, ',');
429 if (port_part == NULL)
431 port |= xatou16(&port_part[1]) << 8;
434 replace_char(raw, ',', '.');
435 lsa = xdotted2sockaddr(raw, port);
439 cmdio_write_error(FTP_BADCMD);
444 cmdio_write_ok(FTP_PORTOK);
450 /* When ftp_arg == NULL simply restart from beginning */
451 G.restart_pos = G.ftp_arg ? xatoi_u(G.ftp_arg) : 0;
452 cmdio_write_ok(FTP_RESTOK);
462 off_t offset = G.restart_pos;
467 if (!data_transfer_checks_ok())
468 return; /* data_transfer_checks_ok emitted error response */
470 /* O_NONBLOCK is useful if file happens to be a device node */
471 opened_file = G.ftp_arg ? open(G.ftp_arg, O_RDONLY | O_NONBLOCK) : -1;
472 if (opened_file < 0) {
473 cmdio_write_error(FTP_FILEFAIL);
477 if (fstat(opened_file, &statbuf) != 0 || !S_ISREG(statbuf.st_mode)) {
478 /* Note - pretend open failed */
479 cmdio_write_error(FTP_FILEFAIL);
483 /* Now deactive O_NONBLOCK, otherwise we have a problem on DMAPI filesystems
486 ndelay_off(opened_file);
488 /* Set the download offset (from REST) if any */
490 xlseek(opened_file, offset, SEEK_SET);
492 response = xasprintf(
493 " Opening BINARY mode data connection for %s (%"OFF_FMT"u bytes)",
494 G.ftp_arg, statbuf.st_size);
495 remote_fd = get_remote_transfer_fd(response);
498 goto port_pasv_cleanup_out;
500 trans_ret = bb_copyfd_eof(opened_file, remote_fd);
503 cmdio_write_error(FTP_BADSENDFILE);
505 cmdio_write_ok(FTP_TRANSFEROK);
507 port_pasv_cleanup_out:
517 popen_ls(const char *opt)
520 const char *argv[5] = { "ftpd", opt, NULL, G.ftp_arg, NULL };
521 struct fd_pair outfd;
524 cwd = xrealloc_getcwd_or_warn(NULL);
532 case -1: /* failure */
533 bb_perror_msg_and_die("vfork");
535 /* NB: close _first_, then move fds! */
537 xmove_fd(outfd.wr, STDOUT_FILENO);
539 /* xopen("/dev/null", O_RDONLY); - chroot may lack it! */
540 if (fchdir(G.proc_self_fd) == 0) {
541 close(G.proc_self_fd);
543 /* ftpd ls helper chdirs to argv[2],
544 * preventing peer from seeing /proc/self
546 execv("exe", (char**) argv);
557 handle_dir_common(int opts)
563 if (!(opts & 1) && !data_transfer_checks_ok())
564 return; /* data_transfer_checks_ok emitted error response */
566 ls_fd = popen_ls((opts & 2) ? "-l" : "-1");
567 ls_fp = fdopen(ls_fd, "r");
568 if (!ls_fp) /* never happens. paranoia */
569 bb_perror_msg_and_die("fdopen");
572 /* STAT <filename> */
573 cmdio_write_raw(STR(FTP_STATFILE_OK)"-Status follows:\r\n");
575 line = xmalloc_fgetline(ls_fp);
578 cmdio_write(0, line); /* hack: 0 results in no status at all */
581 cmdio_write_ok(FTP_STATFILE_OK);
583 /* LIST/NLST [<filename>] */
584 int remote_fd = get_remote_transfer_fd(" Here comes the directory listing");
585 if (remote_fd >= 0) {
587 line = xmalloc_fgetline(ls_fp);
590 xwrite_str(remote_fd, line);
591 xwrite(remote_fd, "\r\n", 2);
597 cmdio_write_ok(FTP_TRANSFEROK);
599 fclose(ls_fp); /* closes ls_fd too */
604 handle_dir_common(2);
609 handle_dir_common(0);
612 handle_stat_file(void)
614 handle_dir_common(3);
621 char buf[sizeof(STR(FTP_STATFILE_OK)" %"OFF_FMT"u\r\n") + sizeof(off_t)*3];
624 || stat(G.ftp_arg, &statbuf) != 0
625 || !S_ISREG(statbuf.st_mode)
627 cmdio_write_error(FTP_FILEFAIL);
630 sprintf(buf, STR(FTP_STATFILE_OK)" %"OFF_FMT"u\r\n", statbuf.st_size);
631 cmdio_write_raw(buf);
634 /* Upload commands */
636 #if ENABLE_FEATURE_FTP_WRITE
640 if (!G.ftp_arg || mkdir(G.ftp_arg, 0777) != 0) {
641 cmdio_write_error(FTP_FILEFAIL);
644 cmdio_write_ok(FTP_MKDIROK);
650 if (!G.ftp_arg || rmdir(G.ftp_arg) != 0) {
651 cmdio_write_error(FTP_FILEFAIL);
654 cmdio_write_ok(FTP_RMDIROK);
660 if (!G.ftp_arg || unlink(G.ftp_arg) != 0) {
661 cmdio_write_error(FTP_FILEFAIL);
664 cmdio_write_ok(FTP_DELEOK);
670 free(G.rnfr_filename);
671 G.rnfr_filename = xstrdup(G.ftp_arg);
672 cmdio_write_ok(FTP_RNFROK);
680 /* If we didn't get a RNFR, throw a wobbly */
681 if (G.rnfr_filename == NULL || G.ftp_arg == NULL) {
682 cmdio_write_raw(STR(FTP_NEEDRNFR)" RNFR required first\r\n");
686 retval = rename(G.rnfr_filename, G.ftp_arg);
687 free(G.rnfr_filename);
688 G.rnfr_filename = NULL;
691 cmdio_write_error(FTP_FILEFAIL);
694 cmdio_write_ok(FTP_RENAMEOK);
698 handle_upload_common(int is_append, int is_unique)
700 char *tempname = NULL;
706 offset = G.restart_pos;
709 if (!data_transfer_checks_ok())
714 tempname = xstrdup(" FILE: uniq.XXXXXX");
715 local_file_fd = mkstemp(tempname + 7);
716 } else if (G.ftp_arg) {
717 int flags = O_WRONLY | O_CREAT | O_TRUNC;
719 flags = O_WRONLY | O_CREAT | O_APPEND;
721 flags = O_WRONLY | O_CREAT;
722 local_file_fd = open(G.ftp_arg, flags, 0666);
724 if (local_file_fd < 0) {
725 cmdio_write_error(FTP_UPLOADFAIL);
729 /* TODO: paranoia: fstat it, refuse to do anything if it's not a regular file */
732 xlseek(local_file_fd, offset, SEEK_SET);
734 remote_fd = get_remote_transfer_fd(tempname ? tempname : " Ok to send data");
740 trans_ret = bb_copyfd_eof(remote_fd, local_file_fd);
744 cmdio_write_error(FTP_BADSENDFILE);
746 cmdio_write_ok(FTP_TRANSFEROK);
750 close(local_file_fd);
756 handle_upload_common(0, 0);
763 handle_upload_common(1, 0);
770 handle_upload_common(0, 1);
772 #endif /* ENABLE_FEATURE_FTP_WRITE */
775 cmdio_get_cmd_and_arg(void)
782 len = 8 * 1024; /* Paranoia. Peer may send 1 gigabyte long cmd... */
783 G.ftp_cmd = cmd = xmalloc_reads(STDIN_FILENO, NULL, &len);
787 len = strlen(cmd) - 1;
788 while (len >= 0 && cmd[len] == '\r') {
793 G.ftp_arg = strchr(cmd, ' ');
794 if (G.ftp_arg != NULL) {
800 cmdval = (cmdval << 8) + ((unsigned char)*cmd++ & (unsigned char)~0x20);
805 int ftpd_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
806 int ftpd_main(int argc, char **argv)
810 opts = getopt32(argv, "l1vS" USE_FEATURE_FTP_WRITE("w"));
812 if (opts & (OPT_l|OPT_1)) {
813 /* Our secret backdoor to ls */
815 argv[2] = (char*)"--";
816 return ls_main(argc, argv);
821 G.local_addr = get_sock_lsa(STDIN_FILENO);
823 /* This is confusing:
824 * bb_error_msg_and_die("stdin is not a socket");
827 /* Help text says that ftpd must be used as inetd service,
828 * which is by far the most usual cause of get_sock_lsa
833 logmode = LOGMODE_NONE;
835 /* LOG_NDELAY is needed since we may chroot later */
836 openlog(applet_name, LOG_PID | LOG_NDELAY, LOG_DAEMON);
837 logmode |= LOGMODE_SYSLOG;
840 G.proc_self_fd = xopen("/proc/self", O_RDONLY | O_DIRECTORY);
843 xchdir(argv[optind]);
847 //umask(077); - admin can set umask before starting us
849 /* Signals. We'll always take -EPIPE rather than a rude signal, thanks */
850 signal(SIGPIPE, SIG_IGN);
852 /* Set up options on the command socket (do we need these all? why?) */
853 setsockopt(STDIN_FILENO, IPPROTO_TCP, TCP_NODELAY, &const_int_1, sizeof(const_int_1));
854 setsockopt(STDIN_FILENO, SOL_SOCKET, SO_KEEPALIVE, &const_int_1, sizeof(const_int_1));
855 setsockopt(STDIN_FILENO, SOL_SOCKET, SO_OOBINLINE, &const_int_1, sizeof(const_int_1));
857 cmdio_write_ok(FTP_GREET);
859 #ifdef IF_WE_WANT_TO_REQUIRE_LOGIN
861 smallint user_was_specified = 0;
863 uint32_t cmdval = cmdio_get_cmd_and_arg();
865 if (cmdval == const_USER) {
866 if (G.ftp_arg == NULL || strcasecmp(G.ftp_arg, "anonymous") != 0)
867 cmdio_write_raw(STR(FTP_LOGINERR)" Server is anonymous only\r\n");
869 user_was_specified = 1;
870 cmdio_write_raw(STR(FTP_GIVEPWORD)" Please specify the password\r\n");
872 } else if (cmdval == const_PASS) {
873 if (user_was_specified)
875 cmdio_write_raw(STR(FTP_NEEDUSER)" Login with USER\r\n");
876 } else if (cmdval == const_QUIT) {
877 cmdio_write_ok(FTP_GOODBYE);
880 cmdio_write_raw(STR(FTP_LOGINERR)" Login with USER and PASS\r\n");
884 cmdio_write_ok(FTP_LOGINOK);
887 /* RFC-959 Section 5.1
888 * The following commands and options MUST be supported by every
889 * server-FTP and user-FTP, except in cases where the underlying
890 * file system or operating system does not allow or support
891 * a particular command.
892 * Type: ASCII Non-print, IMAGE, LOCAL 8
894 * Structure: File, Record*
895 * (Record structure is REQUIRED only for hosts whose file
896 * systems support record structure).
898 * USER, PASS, ACCT, [bbox: ACCT not supported]
903 * CWD, CDUP, RMD, MKD, PWD,
909 * "The argument field is a Telnet string identifying the user's account.
910 * The command is not necessarily related to the USER command, as some
911 * sites may require an account for login and others only for specific
912 * access, such as storing files. In the latter case the command may
913 * arrive at any time.
914 * There are reply codes to differentiate these cases for the automation:
915 * when account information is required for login, the response to
916 * a successful PASSword command is reply code 332. On the other hand,
917 * if account information is NOT required for login, the reply to
918 * a successful PASSword command is 230; and if the account information
919 * is needed for a command issued later in the dialogue, the server
920 * should return a 332 or 532 reply depending on whether it stores
921 * (pending receipt of the ACCounT command) or discards the command,
926 uint32_t cmdval = cmdio_get_cmd_and_arg();
928 if (cmdval == const_QUIT) {
929 cmdio_write_ok(FTP_GOODBYE);
932 else if (cmdval == const_USER)
933 cmdio_write_ok(FTP_GIVEPWORD);
934 else if (cmdval == const_PASS)
935 cmdio_write_ok(FTP_LOGINOK);
936 else if (cmdval == const_NOOP)
937 cmdio_write_ok(FTP_NOOPOK);
938 else if (cmdval == const_TYPE)
939 cmdio_write_ok(FTP_TYPEOK);
940 else if (cmdval == const_STRU)
941 cmdio_write_ok(FTP_STRUOK);
942 else if (cmdval == const_MODE)
943 cmdio_write_ok(FTP_MODEOK);
944 else if (cmdval == const_ALLO)
945 cmdio_write_ok(FTP_ALLOOK);
946 else if (cmdval == const_SYST)
947 cmdio_write_raw(STR(FTP_SYSTOK)" UNIX Type: L8\r\n");
948 else if (cmdval == const_PWD)
950 else if (cmdval == const_CWD)
952 else if (cmdval == const_CDUP) /* cd .. */
954 else if (cmdval == const_HELP)
956 else if (cmdval == const_LIST) /* ls -l */
958 else if (cmdval == const_NLST) /* "name list", bare ls */
960 else if (cmdval == const_SIZE)
962 else if (cmdval == const_STAT) {
963 if (G.ftp_arg == NULL)
968 else if (cmdval == const_PASV)
970 else if (cmdval == const_EPSV)
972 else if (cmdval == const_RETR)
974 else if (cmdval == const_PORT)
976 else if (cmdval == const_REST)
978 #if ENABLE_FEATURE_FTP_WRITE
979 else if (opts & OPT_w) {
980 if (cmdval == const_STOR)
982 else if (cmdval == const_MKD)
984 else if (cmdval == const_RMD)
986 else if (cmdval == const_DELE)
988 else if (cmdval == const_RNFR) /* "rename from" */
990 else if (cmdval == const_RNTO) /* "rename to" */
992 else if (cmdval == const_APPE)
994 else if (cmdval == const_STOU) /* "store unique" */
999 else if (cmdval == const_STOR
1000 || cmdval == const_MKD
1001 || cmdval == const_RMD
1002 || cmdval == const_DELE
1003 || cmdval == const_RNFR
1004 || cmdval == const_RNTO
1005 || cmdval == const_APPE
1006 || cmdval == const_STOU
1008 cmdio_write_raw(STR(FTP_NOPERM)" Permission denied\r\n");
1012 /* Which unsupported commands were seen in the wild?
1013 * (doesn't necessarily mean "we must support them")
1014 * lftp 3.6.3: FEAT - is it useful?
1015 * MDTM - works fine without it anyway
1017 cmdio_write_raw(STR(FTP_BADCMD)" Unknown command\r\n");