//usage: "[OPTIONS] HOST [PORT]"
//usage:#define tftp_full_usage "\n\n"
//usage: "Transfer a file from/to tftp server\n"
-//usage: "\nOptions:"
//usage: "\n -l FILE Local FILE"
//usage: "\n -r FILE Remote FILE"
//usage: IF_FEATURE_TFTP_GET(
//usage: "\n"
//usage: "tftpd should be used as an inetd service.\n"
//usage: "tftpd's line for inetd.conf:\n"
-//usage: " 69 dgram udp nowait root tftpd tftpd /files/to/serve\n"
+//usage: " 69 dgram udp nowait root tftpd tftpd -l /files/to/serve\n"
//usage: "It also can be ran from udpsvd:\n"
//usage: " udpsvd -vE 0.0.0.0 69 tftpd /files/to/serve\n"
-//usage: "\nOptions:"
//usage: "\n -r Prohibit upload"
//usage: "\n -c Allow file creation via upload"
//usage: "\n -u Access files as USER"
+//usage: "\n -l Log to syslog (inetd mode requires this)"
#include "libbb.h"
+#include <syslog.h>
#if ENABLE_FEATURE_TFTP_GET || ENABLE_FEATURE_TFTP_PUT
TFTPD_OPT_r = (1 << 8) * ENABLE_TFTPD,
TFTPD_OPT_c = (1 << 9) * ENABLE_TFTPD,
TFTPD_OPT_u = (1 << 10) * ENABLE_TFTPD,
+ TFTPD_OPT_l = (1 << 11) * ENABLE_TFTPD,
};
#if ENABLE_FEATURE_TFTP_GET && !ENABLE_FEATURE_TFTP_PUT
peer_lsa->len = our_lsa->len;
/* Shifting to not collide with TFTP_OPTs */
- opt = option_mask32 = TFTPD_OPT | (getopt32(argv, "rcu:", &user_opt) << 8);
+ opt = option_mask32 = TFTPD_OPT | (getopt32(argv, "rcu:l", &user_opt) << 8);
argv += optind;
- if (argv[0])
- xchdir(argv[0]);
+ if (opt & TFTPD_OPT_l) {
+ openlog(applet_name, LOG_PID, LOG_DAEMON);
+ logmode = LOGMODE_SYSLOG;
+ }
+ if (argv[0]) {
+ xchroot(argv[0]);
+ }
result = recv_from_to(STDIN_FILENO, block_buf, sizeof(block_buf),
0 /* flags */,
goto err;
}
mode = local_file + strlen(local_file) + 1;
- if (mode >= block_buf + result || strcmp(mode, "octet") != 0) {
+ /* RFC 1350 says mode string is case independent */
+ if (mode >= block_buf + result || strcasecmp(mode, "octet") != 0) {
goto err;
}
# if ENABLE_FEATURE_TFTP_BLOCKSIZE