From b74e490629a75cb8c2cb798f0feadc2eb4dc5471 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sun, 15 Apr 2018 14:18:16 +0200 Subject: ar: stop using static data function old new delta static.ar_long_names 4 - -4 static.ar_long_name_size 4 - -4 get_header_ar 546 532 -14 ------------------------------------------------------------------------------ (add/remove: 0/2 grow/shrink: 0/1 up/down: 0/-22) Total: -22 bytes Signed-off-by: Denys Vlasenko --- include/bb_archive.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include') diff --git a/include/bb_archive.h b/include/bb_archive.h index b437f1920..0252488bf 100644 --- a/include/bb_archive.h +++ b/include/bb_archive.h @@ -116,6 +116,10 @@ typedef struct archive_handle_t { #if ENABLE_FEATURE_AR_CREATE const char *ar__name; struct archive_handle_t *ar__out; +# if ENABLE_FEATURE_AR_LONG_FILENAMES + char *ar__long_names; + unsigned ar__long_name_size; +# endif #endif } archive_handle_t; /* bits in ah_flags */ -- cgit v1.2.3-55-g6feb From 058a153b6970660f3c284ac259986ae87507df9a Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 16 Apr 2018 10:24:48 +0200 Subject: less: fix fallout from "use common routine to set raw termios" Testcase: (sleep 10; ls) | busybox less [...] ~ LICENSE ~ Makefile ~ Makefile.custom ~ Makefile.flags [...] less did not want this part: + /* dont convert NL to CR+NL on output */ + newterm->c_oflag &= ~(ONLCR); function old new delta get_termios_and_make_raw 108 115 +7 Signed-off-by: Denys Vlasenko --- include/libbb.h | 8 +++++--- libbb/xfuncs.c | 13 +++++++++---- miscutils/less.c | 2 +- 3 files changed, 15 insertions(+), 8 deletions(-) (limited to 'include') diff --git a/include/libbb.h b/include/libbb.h index c7bf33ef8..646c58bf2 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -1597,9 +1597,11 @@ int get_terminal_width_height(int fd, unsigned *width, unsigned *height) FAST_FU int get_terminal_width(int fd) FAST_FUNC; int tcsetattr_stdin_TCSANOW(const struct termios *tp) FAST_FUNC; -#define TERMIOS_CLEAR_ISIG (1 << 0) -#define TERMIOS_RAW_CRNL (1 << 1) -#define TERMIOS_RAW_INPUT (1 << 2) +#define TERMIOS_CLEAR_ISIG (1 << 0) +#define TERMIOS_RAW_CRNL_INPUT (1 << 1) +#define TERMIOS_RAW_CRNL_OUTPUT (1 << 2) +#define TERMIOS_RAW_CRNL (TERMIOS_RAW_CRNL_INPUT|TERMIOS_RAW_CRNL_OUTPUT) +#define TERMIOS_RAW_INPUT (1 << 3) int get_termios_and_make_raw(int fd, struct termios *newterm, struct termios *oldterm, int flags) FAST_FUNC; int set_termios_to_raw(int fd, struct termios *oldterm, int flags) FAST_FUNC; diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c index e8c027f17..b4d512bd6 100644 --- a/libbb/xfuncs.c +++ b/libbb/xfuncs.c @@ -330,7 +330,6 @@ int FAST_FUNC get_termios_and_make_raw(int fd, struct termios *newterm, struct t newterm->c_cc[VMIN] = 1; /* no timeout (reads block forever) */ newterm->c_cc[VTIME] = 0; - if (flags & TERMIOS_RAW_CRNL) { /* IXON, IXOFF, and IXANY: * IXOFF=1: sw flow control is enabled on input queue: * tty transmits a STOP char when input queue is close to full @@ -340,9 +339,12 @@ int FAST_FUNC get_termios_and_make_raw(int fd, struct termios *newterm, struct t * and resume sending if START is received, or if any char * is received and IXANY=1. */ + if (flags & TERMIOS_RAW_CRNL_INPUT) { /* IXON=0: XON/XOFF chars are treated as normal chars (why we do this?) */ /* dont convert CR to NL on input */ newterm->c_iflag &= ~(IXON | ICRNL); + } + if (flags & TERMIOS_RAW_CRNL_OUTPUT) { /* dont convert NL to CR+NL on output */ newterm->c_oflag &= ~(ONLCR); /* Maybe clear more c_oflag bits? Usually, only OPOST and ONLCR are set. @@ -363,9 +365,12 @@ int FAST_FUNC get_termios_and_make_raw(int fd, struct termios *newterm, struct t #ifndef IXANY # define IXANY 0 #endif - /* IXOFF=0: disable sending XON/XOFF if input buf is full */ - /* IXON=0: input XON/XOFF chars are not special */ - /* dont convert anything on input */ + /* IXOFF=0: disable sending XON/XOFF if input buf is full + * IXON=0: input XON/XOFF chars are not special + * BRKINT=0: dont send SIGINT on break + * IMAXBEL=0: dont echo BEL on input line too long + * INLCR,ICRNL,IUCLC: dont convert anything on input + */ newterm->c_iflag &= ~(IXOFF|IXON|IXANY|BRKINT|INLCR|ICRNL|IUCLC|IMAXBEL); } return r; diff --git a/miscutils/less.c b/miscutils/less.c index 6029b6809..938d9842f 100644 --- a/miscutils/less.c +++ b/miscutils/less.c @@ -1891,7 +1891,7 @@ int less_main(int argc, char **argv) G.kbd_fd_orig_flags = ndelay_on(tty_fd); kbd_fd = tty_fd; /* save in a global */ - get_termios_and_make_raw(tty_fd, &term_less, &term_orig, TERMIOS_RAW_CRNL); + get_termios_and_make_raw(tty_fd, &term_less, &term_orig, TERMIOS_RAW_CRNL_INPUT); IF_FEATURE_LESS_ASK_TERMINAL(G.winsize_err =) get_terminal_width_height(tty_fd, &width, &max_displayed_line); /* 20: two tabstops + 4 */ -- cgit v1.2.3-55-g6feb From 2aeb201c9751d4ee82978c623310e14b9e831b94 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 17 Apr 2018 12:43:54 +0200 Subject: libbb: new option FEATURE_ETC_SERVICES: if off, /etc/services reads often avoided In practice, "wget http://host.com/" always uses port 80. People explicitly set non-standard ports via options or parameters ("telnet 1.2.3.4 567" or "telnet 1.2.3.4 ftp") instead of modifying /etc/services. function old new delta telnet_main 1466 1464 -2 rdate_main 215 198 -17 fakeidentd_main 269 252 -17 parse_url 459 392 -67 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/4 up/down: 0/-103) Total: -103 bytes Signed-off-by: Denys Vlasenko --- include/libbb.h | 5 +++++ libbb/Config.src | 12 ++++++++++++ networking/isrv_identd.c | 2 +- networking/telnet.c | 3 ++- networking/wget.c | 8 ++++---- util-linux/rdate.c | 2 +- 6 files changed, 25 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/libbb.h b/include/libbb.h index 646c58bf2..a605c7f03 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -640,6 +640,11 @@ int setsockopt_bindtodevice(int fd, const char *iface) FAST_FUNC; int bb_getsockname(int sockfd, void *addr, socklen_t addrlen) FAST_FUNC; /* NB: returns port in host byte order */ unsigned bb_lookup_port(const char *port, const char *protocol, unsigned default_port) FAST_FUNC; +#if ENABLE_FEATURE_ETC_SERVICES +# define bb_lookup_std_port(portstr, protocol, portnum) bb_lookup_port(portstr, protocol, portnum) +#else +# define bb_lookup_std_port(portstr, protocol, portnum) (portnum) +#endif typedef struct len_and_sockaddr { socklen_t len; union { diff --git a/libbb/Config.src b/libbb/Config.src index fdf8bbb28..16e16480b 100644 --- a/libbb/Config.src +++ b/libbb/Config.src @@ -76,6 +76,18 @@ config FEATURE_ETC_NETWORKS a rarely used feature which allows you to use names instead of IP/mask pairs in route command. +config FEATURE_ETC_SERVICES + bool "Consult /etc/services even for well-known ports" + default n + help + Look up e.g. "telnet" and "http" in /etc/services file + instead of assuming ports 23 and 80. + This is almost never necessary (everybody uses standard ports), + and it makes sense to avoid reading this file. + If you disable this option, in the cases where port is explicitly + specified as a service name (e.g. "telnet HOST PORTNAME"), + it will still be looked up in /etc/services. + config FEATURE_EDITING bool "Command line editing" default y diff --git a/networking/isrv_identd.c b/networking/isrv_identd.c index 133d62a65..0c33dde4f 100644 --- a/networking/isrv_identd.c +++ b/networking/isrv_identd.c @@ -159,7 +159,7 @@ int fakeidentd_main(int argc UNUSED_PARAM, char **argv) fd = 0; if (!(opt & OPT_inetdwait)) { fd = create_and_bind_stream_or_die(bind_address, - bb_lookup_port("identd", "tcp", 113)); + bb_lookup_std_port("identd", "tcp", 113)); xlisten(fd, 5); } diff --git a/networking/telnet.c b/networking/telnet.c index 15d6a08d8..1e6be85bd 100644 --- a/networking/telnet.c +++ b/networking/telnet.c @@ -643,7 +643,8 @@ int telnet_main(int argc UNUSED_PARAM, char **argv) if (!*argv) bb_show_usage(); host = *argv++; - port = bb_lookup_port(*argv ? *argv++ : "telnet", "tcp", 23); + port = *argv ? bb_lookup_port(*argv++, "tcp", 23) + : bb_lookup_std_port("telnet", "tcp", 23); if (*argv) /* extra params?? */ bb_show_usage(); diff --git a/networking/wget.c b/networking/wget.c index 2650b5384..b6c76e9dc 100644 --- a/networking/wget.c +++ b/networking/wget.c @@ -505,23 +505,23 @@ static void parse_url(const char *src_url, struct host_info *h) *p = '\0'; h->host = p + 3; if (strcmp(url, P_FTP) == 0) { - h->port = bb_lookup_port(P_FTP, "tcp", 21); + h->port = bb_lookup_std_port(P_FTP, "tcp", 21); } else #if SSL_SUPPORTED # if ENABLE_FEATURE_WGET_HTTPS if (strcmp(url, P_FTPS) == 0) { - h->port = bb_lookup_port(P_FTPS, "tcp", 990); + h->port = bb_lookup_std_port(P_FTPS, "tcp", 990); h->protocol = P_FTPS; } else # endif if (strcmp(url, P_HTTPS) == 0) { - h->port = bb_lookup_port(P_HTTPS, "tcp", 443); + h->port = bb_lookup_std_port(P_HTTPS, "tcp", 443); h->protocol = P_HTTPS; } else #endif if (strcmp(url, P_HTTP) == 0) { http: - h->port = bb_lookup_port(P_HTTP, "tcp", 80); + h->port = bb_lookup_std_port(P_HTTP, "tcp", 80); h->protocol = P_HTTP; } else { *p = ':'; diff --git a/util-linux/rdate.c b/util-linux/rdate.c index f27294e25..5ec795208 100644 --- a/util-linux/rdate.c +++ b/util-linux/rdate.c @@ -45,7 +45,7 @@ static time_t askremotedate(const char *host) alarm(10); signal(SIGALRM, socket_timeout); - fd = create_and_connect_stream_or_die(host, bb_lookup_port("time", "tcp", 37)); + fd = create_and_connect_stream_or_die(host, bb_lookup_std_port("time", "tcp", 37)); if (safe_read(fd, &nett, 4) != 4) /* read time from server */ bb_error_msg_and_die("%s: %s", host, "short read"); -- cgit v1.2.3-55-g6feb