httpd,telnetd: make default port configurable
BusyBox on Termux can't use ports less than 1024 it's patched to change default port for httpd to 8080 and telnetd to 8023. https://github.com/termux/termux-packages/blob/master/packages/busybox/0011-networking-telnetd-default-port.patch https://github.com/termux/termux-packages/blob/master/packages/busybox/0010-networking-httpd-default-port.patch To avoid such patches we can make port configurable. function old new delta packed_usage 33920 33914 -6 Signed-off-by: Sergey Ponomarev <stokito@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
857800c655
commit
82c5eb8e46
@ -31,6 +31,9 @@
|
|||||||
# define ADJTIME_PATH "/etc/adjtime"
|
# define ADJTIME_PATH "/etc/adjtime"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define STR1(s) #s
|
||||||
|
#define STR(s) STR1(s)
|
||||||
|
|
||||||
INSERT
|
INSERT
|
||||||
|
|
||||||
#define busybox_notes_usage \
|
#define busybox_notes_usage \
|
||||||
|
@ -102,6 +102,11 @@
|
|||||||
//config: help
|
//config: help
|
||||||
//config: HTTP server.
|
//config: HTTP server.
|
||||||
//config:
|
//config:
|
||||||
|
//config:config FEATURE_HTTPD_PORT_DEFAULT
|
||||||
|
//config: int "Default port"
|
||||||
|
//config: default 80
|
||||||
|
//config: range 1 65535
|
||||||
|
//config:
|
||||||
//config:config FEATURE_HTTPD_RANGES
|
//config:config FEATURE_HTTPD_RANGES
|
||||||
//config: bool "Support 'Ranges:' header"
|
//config: bool "Support 'Ranges:' header"
|
||||||
//config: default y
|
//config: default y
|
||||||
@ -270,7 +275,7 @@
|
|||||||
//usage: "\n -i Inetd mode"
|
//usage: "\n -i Inetd mode"
|
||||||
//usage: "\n -f Don't daemonize"
|
//usage: "\n -f Don't daemonize"
|
||||||
//usage: "\n -v[v] Verbose"
|
//usage: "\n -v[v] Verbose"
|
||||||
//usage: "\n -p [IP:]PORT Bind to IP:PORT (default *:80)"
|
//usage: "\n -p [IP:]PORT Bind to IP:PORT (default *:"STR(CONFIG_FEATURE_HTTPD_PORT_DEFAULT)")"
|
||||||
//usage: IF_FEATURE_HTTPD_SETUID(
|
//usage: IF_FEATURE_HTTPD_SETUID(
|
||||||
//usage: "\n -u USER[:GRP] Set uid/gid after binding to port")
|
//usage: "\n -u USER[:GRP] Set uid/gid after binding to port")
|
||||||
//usage: IF_FEATURE_HTTPD_BASIC_AUTH(
|
//usage: IF_FEATURE_HTTPD_BASIC_AUTH(
|
||||||
@ -316,6 +321,9 @@
|
|||||||
|
|
||||||
#define HEADER_READ_TIMEOUT 60
|
#define HEADER_READ_TIMEOUT 60
|
||||||
|
|
||||||
|
#define STR1(s) #s
|
||||||
|
#define STR(s) STR1(s)
|
||||||
|
|
||||||
static const char DEFAULT_PATH_HTTPD_CONF[] ALIGN1 = "/etc";
|
static const char DEFAULT_PATH_HTTPD_CONF[] ALIGN1 = "/etc";
|
||||||
static const char HTTPD_CONF[] ALIGN1 = "httpd.conf";
|
static const char HTTPD_CONF[] ALIGN1 = "httpd.conf";
|
||||||
static const char HTTP_200[] ALIGN1 = "HTTP/1.1 200 OK\r\n";
|
static const char HTTP_200[] ALIGN1 = "HTTP/1.1 200 OK\r\n";
|
||||||
@ -542,7 +550,7 @@ enum {
|
|||||||
SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
|
SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
|
||||||
IF_FEATURE_HTTPD_BASIC_AUTH(g_realm = "Web Server Authentication";) \
|
IF_FEATURE_HTTPD_BASIC_AUTH(g_realm = "Web Server Authentication";) \
|
||||||
IF_FEATURE_HTTPD_RANGES(range_start = -1;) \
|
IF_FEATURE_HTTPD_RANGES(range_start = -1;) \
|
||||||
bind_addr_or_port = "80"; \
|
bind_addr_or_port = STR(CONFIG_FEATURE_HTTPD_PORT_DEFAULT); \
|
||||||
index_page = index_html; \
|
index_page = index_html; \
|
||||||
file_size = -1; \
|
file_size = -1; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
@ -68,6 +68,12 @@
|
|||||||
//config: help
|
//config: help
|
||||||
//config: Selecting this will make telnetd able to run standalone.
|
//config: Selecting this will make telnetd able to run standalone.
|
||||||
//config:
|
//config:
|
||||||
|
//config:config FEATURE_TELNETD_PORT_DEFAULT
|
||||||
|
//config: int "Default port"
|
||||||
|
//config: default 23
|
||||||
|
//config: range 1 65535
|
||||||
|
//config: depends on FEATURE_TELNETD_STANDALONE
|
||||||
|
//config:
|
||||||
//config:config FEATURE_TELNETD_INETD_WAIT
|
//config:config FEATURE_TELNETD_INETD_WAIT
|
||||||
//config: bool "Support -w SEC option (inetd wait mode)"
|
//config: bool "Support -w SEC option (inetd wait mode)"
|
||||||
//config: default y
|
//config: default y
|
||||||
@ -103,7 +109,7 @@
|
|||||||
//usage: "\n -K Close connection as soon as login exits"
|
//usage: "\n -K Close connection as soon as login exits"
|
||||||
//usage: "\n (normally wait until all programs close slave pty)"
|
//usage: "\n (normally wait until all programs close slave pty)"
|
||||||
//usage: IF_FEATURE_TELNETD_STANDALONE(
|
//usage: IF_FEATURE_TELNETD_STANDALONE(
|
||||||
//usage: "\n -p PORT Port to listen on"
|
//usage: "\n -p PORT Port to listen on. Default "STR(CONFIG_FEATURE_TELNETD_PORT_DEFAULT)
|
||||||
//usage: "\n -b ADDR[:PORT] Address to bind to"
|
//usage: "\n -b ADDR[:PORT] Address to bind to"
|
||||||
//usage: "\n -F Run in foreground"
|
//usage: "\n -F Run in foreground"
|
||||||
//usage: "\n -i Inetd mode"
|
//usage: "\n -i Inetd mode"
|
||||||
@ -708,7 +714,7 @@ int telnetd_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
} else {
|
} else {
|
||||||
master_fd = 0;
|
master_fd = 0;
|
||||||
if (!(opt & OPT_WAIT)) {
|
if (!(opt & OPT_WAIT)) {
|
||||||
unsigned portnbr = 23;
|
unsigned portnbr = CONFIG_FEATURE_TELNETD_PORT_DEFAULT;
|
||||||
if (opt & OPT_PORT)
|
if (opt & OPT_PORT)
|
||||||
portnbr = xatou16(opt_portnbr);
|
portnbr = xatou16(opt_portnbr);
|
||||||
master_fd = create_and_bind_stream_or_die(opt_bindaddr, portnbr);
|
master_fd = create_and_bind_stream_or_die(opt_bindaddr, portnbr);
|
||||||
|
Loading…
Reference in New Issue
Block a user