From vda.linux at googlemail.com Sun Jul 2 15:58:20 2023 From: vda.linux at googlemail.com (Denys Vlasenko) Date: Sun, 2 Jul 2023 17:58:20 +0200 Subject: [git commit] shell/math: do not accept $((36#@)) Message-ID: <20230702155842.D8EC7862FC@busybox.osuosl.org> commit: https://git.busybox.net/busybox/commit/?id=045924ed7d3c887cce1c6a22a0b4e0b692719154 branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master function old new delta parse_with_base 170 174 +4 arith_apply 996 991 -5 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 4/-5) Total: -1 bytes Signed-off-by: Denys Vlasenko --- shell/math.c | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/shell/math.c b/shell/math.c index beb89d140..b06d1ae3c 100644 --- a/shell/math.c +++ b/shell/math.c @@ -128,7 +128,8 @@ typedef unsigned char operator; * Consider * and / */ #define tok_decl(prec,id) (((id)<<5) | (prec)) -#define PREC(op) ((op) & 0x1F) +#define ID_SHIFT 5 +#define PREC(op) ((op) & 0x1f) #define PREC_LPAREN 0 #define TOK_LPAREN tok_decl(0,0) @@ -146,14 +147,16 @@ typedef unsigned char operator; #define TOK_AND_ASSIGN tok_decl(2,1) #define TOK_OR_ASSIGN tok_decl(2,2) #define TOK_XOR_ASSIGN tok_decl(2,3) -#define TOK_PLUS_ASSIGN tok_decl(2,4) -#define TOK_MINUS_ASSIGN tok_decl(2,5) +#define TOK_ADD_ASSIGN tok_decl(2,4) +#define TOK_SUB_ASSIGN tok_decl(2,5) #define TOK_LSHIFT_ASSIGN tok_decl(2,6) #define TOK_RSHIFT_ASSIGN tok_decl(2,7) #define PREC_ASSIGN2 3 #define TOK_MUL_ASSIGN tok_decl(3,0) -#define TOK_DIV_ASSIGN tok_decl(3,1) +/* "/" and "/=" ops have the same id bits */ +#define DIV_ID1 1 +#define TOK_DIV_ASSIGN tok_decl(3,DIV_ID1) #define TOK_REM_ASSIGN tok_decl(3,2) #define fix_assignment_prec(prec) do { prec -= (prec == 3); } while (0) @@ -198,7 +201,7 @@ typedef unsigned char operator; #define TOK_SUB tok_decl(13,1) #define TOK_MUL tok_decl(14,0) -#define TOK_DIV tok_decl(14,1) +#define TOK_DIV tok_decl(14,DIV_ID1) #define TOK_REM tok_decl(14,2) /* Exponent is right associative */ @@ -408,9 +411,9 @@ arith_apply(arith_state_t *math_state, operator op, var_or_num_t *numstack, var_ rez = (rez <= right_side_val); else if (op == TOK_MUL || op == TOK_MUL_ASSIGN) rez *= right_side_val; - else if (op == TOK_ADD || op == TOK_PLUS_ASSIGN) + else if (op == TOK_ADD || op == TOK_ADD_ASSIGN) rez += right_side_val; - else if (op == TOK_SUB || op == TOK_MINUS_ASSIGN) + else if (op == TOK_SUB || op == TOK_SUB_ASSIGN) rez -= right_side_val; else if (op == TOK_ASSIGN || op == TOK_COMMA) rez = right_side_val; @@ -439,11 +442,11 @@ arith_apply(arith_state_t *math_state, operator op, var_or_num_t *numstack, var_ * Make sure to at least not SEGV here: */ if (right_side_val == -1 - && rez << 1 == 0 /* MAX_NEGATIVE_INT or 0 */ + && (rez << 1) == 0 /* MAX_NEGATIVE_INT or 0 */ ) { right_side_val = 1; } - if (op == TOK_DIV || op == TOK_DIV_ASSIGN) + if (op & (DIV_ID1 << ID_SHIFT)) /* DIV or DIV_ASSIGN? */ rez /= right_side_val; else rez %= right_side_val; @@ -505,8 +508,8 @@ static const char op_tokens[] ALIGN1 = { '*','=', 0, TOK_MUL_ASSIGN, '/','=', 0, TOK_DIV_ASSIGN, '%','=', 0, TOK_REM_ASSIGN, - '+','=', 0, TOK_PLUS_ASSIGN, - '-','=', 0, TOK_MINUS_ASSIGN, + '+','=', 0, TOK_ADD_ASSIGN, + '-','=', 0, TOK_SUB_ASSIGN, '-','-', 0, TOK_POST_DEC, '^','=', 0, TOK_XOR_ASSIGN, '+','+', 0, TOK_POST_INC, @@ -542,12 +545,15 @@ static arith_t parse_with_base(const char *nptr, char **endptr, unsigned base) for (;;) { unsigned digit = (unsigned)*nptr - '0'; if (digit >= 10 /* not 0..9 */ - && digit <= 'z' - '0' /* needed to reject e.g. $((64#~)) */ + && digit <= 'z' - '0' /* reject e.g. $((64#~)) */ ) { - /* in bases up to 36, case does not matter for a-z */ + /* current char is one of :;<=>?@A..Z[\]^_`a..z */ + + /* in bases up to 36, case does not matter for a-z, + * map A..Z and a..z to 10..35: */ digit = (unsigned)(*nptr | 0x20) - ('a' - 10); if (base > 36 && *nptr <= '_') { - /* otherwise, A-Z,@,_ are 36-61,62,63 */ + /* base > 36: A-Z,@,_ are 36-61,62,63 */ if (*nptr == '_') digit = 63; else if (*nptr == '@') @@ -558,8 +564,8 @@ static arith_t parse_with_base(const char *nptr, char **endptr, unsigned base) break; /* error: one of [\]^ */ } //bb_error_msg("ch:'%c'%d digit:%u", *nptr, *nptr, digit); - //if (digit < 10) - example where we need this? - // break; + if (digit < 10) /* reject e.g. $((36#@)) */ + break; } if (digit >= base) break; From vda.linux at googlemail.com Sun Jul 2 17:32:12 2023 From: vda.linux at googlemail.com (Denys Vlasenko) Date: Sun, 2 Jul 2023 19:32:12 +0200 Subject: [git commit] shell/math: avoid $((3**999999999999999999)) to take years Message-ID: <20230702173312.5A0EB86346@busybox.osuosl.org> commit: https://git.busybox.net/busybox/commit/?id=cc9543fed1f916f62a63cfbe9eaefba3df8e22cb branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master function old new delta arith_apply 991 1030 +39 Signed-off-by: Denys Vlasenko --- shell/math.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/shell/math.c b/shell/math.c index b06d1ae3c..e90a38f05 100644 --- a/shell/math.c +++ b/shell/math.c @@ -155,7 +155,7 @@ typedef unsigned char operator; #define PREC_ASSIGN2 3 #define TOK_MUL_ASSIGN tok_decl(3,0) /* "/" and "/=" ops have the same id bits */ -#define DIV_ID1 1 +#define DIV_ID1 1 #define TOK_DIV_ASSIGN tok_decl(3,DIV_ID1) #define TOK_REM_ASSIGN tok_decl(3,2) @@ -422,8 +422,19 @@ arith_apply(arith_state_t *math_state, operator op, var_or_num_t *numstack, var_ if (right_side_val < 0) return "exponent less than 0"; c = 1; - while (--right_side_val >= 0) + while (right_side_val != 0) { + if ((right_side_val & 1) == 0) { + /* this if() block is not necessary for correctness, + * but otherwise echo $((3**999999999999999999)) + * takes a VERY LONG time + * (and it's not interruptible by ^C) + */ + rez *= rez; + right_side_val >>= 1; + } c *= rez; + right_side_val--; + } rez = c; } else /*if (op == TOK_DIV || op == TOK_DIV_ASSIGN @@ -550,7 +561,7 @@ static arith_t parse_with_base(const char *nptr, char **endptr, unsigned base) /* current char is one of :;<=>?@A..Z[\]^_`a..z */ /* in bases up to 36, case does not matter for a-z, - * map A..Z and a..z to 10..35: */ + * map @A..Z and `a..z to 9..35: */ digit = (unsigned)(*nptr | 0x20) - ('a' - 10); if (base > 36 && *nptr <= '_') { /* base > 36: A-Z,@,_ are 36-61,62,63 */ From vda.linux at googlemail.com Mon Jul 3 12:30:59 2023 From: vda.linux at googlemail.com (Denys Vlasenko) Date: Mon, 3 Jul 2023 14:30:59 +0200 Subject: [git commit] hush: quote values in "readonly" output Message-ID: <20230703123150.7D649863AE@busybox.osuosl.org> commit: https://git.busybox.net/busybox/commit/?id=e5692e2342c68092ee3d4d895ea847cf7d13fa57 branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master function old new delta builtin_readonly 61 107 +46 builtin_export 140 145 +5 .rodata 105321 105304 -17 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/1 up/down: 51/-17) Total: 34 bytes Signed-off-by: Denys Vlasenko --- shell/hush.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/shell/hush.c b/shell/hush.c index 426182924..ec4f3a2f2 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -11307,8 +11307,8 @@ static int FAST_FUNC builtin_export(char **argv) if (!p) /* wtf? take next variable */ continue; - /* export var= */ - printf("export %.*s", (int)(p - s) + 1, s); + /* "export VAR=" */ + printf("%s %.*s", "export", (int)(p - s) + 1, s); print_escaped(p + 1); putchar('\n'); # endif @@ -11352,8 +11352,15 @@ static int FAST_FUNC builtin_readonly(char **argv) struct variable *e; for (e = G.top_var; e; e = e->next) { if (e->flg_read_only) { -//TODO: quote value: readonly VAR='VAL' - printf("readonly %s\n", e->varstr); + const char *s = e->varstr; + const char *p = strchr(s, '='); + + if (!p) /* wtf? take next variable */ + continue; + /* "readonly VAR=" */ + printf("%s %.*s", "readonly", (int)(p - s) + 1, s); + print_escaped(p + 1); + putchar('\n'); } } return EXIT_SUCCESS; From bugzilla at busybox.net Tue Jul 4 09:38:30 2023 From: bugzilla at busybox.net (bugzilla at busybox.net) Date: Tue, 04 Jul 2023 09:38:30 +0000 Subject: [Bug 15679] New: wget with amazon.com fails with TLS handshake failure on Debian 12 Message-ID: https://bugs.busybox.net/show_bug.cgi?id=15679 Bug ID: 15679 Summary: wget with amazon.com fails with TLS handshake failure on Debian 12 Product: Busybox Version: unspecified Hardware: All OS: Linux Status: NEW Severity: blocker Priority: P5 Component: Networking Assignee: unassigned at busybox.net Reporter: pem3v78 at gmail.com CC: busybox-cvs at busybox.net Target Milestone: --- This is what I get on master, 1.36.0 and 1.36.1 versions: ./busybox wget https://amazon.com Connecting to amazon.com (54.239.28.85:443) wget: note: TLS certificate validation not implemented wget: TLS error from peer (alert code 40): handshake failure wget: error getting response: Connection reset by peer This happens for me only in Debian 12. The issue is wider because official busybox docker image was recently switch to Bookworm - https://github.com/docker-library/busybox/commit/41d9ed130671540340a1064689c9ea72d7b376fe. There are two possible fixes: 1) downgrade to older Debian distribution 2) revert commit with compiler optimization git revert -n 7fbfb2050f24a457a909ea6bcec85c49a21db83a After the revert, the above communication works without issues. I'm unable to find to root cause of this issue. Maybe the gcc is at fault here ? -- You are receiving this mail because: You are on the CC list for the bug. From bugzilla at busybox.net Tue Jul 4 09:39:27 2023 From: bugzilla at busybox.net (bugzilla at busybox.net) Date: Tue, 04 Jul 2023 09:39:27 +0000 Subject: [Bug 15679] wget with amazon.com fails with TLS handshake failure on Debian 12 In-Reply-To: References: Message-ID: https://bugs.busybox.net/show_bug.cgi?id=15679 --- Comment #1 from Michal P --- This happens when openssl is uninstalled and internal busybox tls implementation is used. -- You are receiving this mail because: You are on the CC list for the bug. From vda.linux at googlemail.com Tue Jul 4 12:38:25 2023 From: vda.linux at googlemail.com (Denys Vlasenko) Date: Tue, 4 Jul 2023 14:38:25 +0200 Subject: [git commit] ash: disable check for "good" function name, bash does not check this Message-ID: <20230704123859.6B487865FB@busybox.osuosl.org> commit: https://git.busybox.net/busybox/commit/?id=07a95cfcabb0706a22599b4440b495b6cfa8123e branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master function old new delta .rodata 105304 105261 -43 parse_command 1696 1633 -63 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-106) Total: -106 bytes Signed-off-by: Denys Vlasenko --- shell/ash.c | 17 +++++++++-------- shell/hush.c | 7 ++++++- shell/hush_test/hush-vars/readonly0.right | 4 ++-- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/shell/ash.c b/shell/ash.c index 96d2433d3..e91566994 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -12123,18 +12123,19 @@ simplecmd(void) if (args && app == &args->narg.next && !vars && !redir ) { - struct builtincmd *bcmd; - const char *name; +// struct builtincmd *bcmd; +// const char *name; /* We have a function */ if (IF_BASH_FUNCTION(!function_flag &&) readtoken() != TRP) raise_error_unexpected_syntax(TRP); - name = n->narg.text; - if (!goodname(name) - || ((bcmd = find_builtin(name)) && IS_BUILTIN_SPECIAL(bcmd)) - ) { - raise_error_syntax("bad function name"); - } +//bash allows functions named "123", "..", "return"! +// name = n->narg.text; +// if (!goodname(name) +// || ((bcmd = find_builtin(name)) && IS_BUILTIN_SPECIAL(bcmd)) +// ) { +// raise_error_syntax("bad function name"); +// } n->type = NDEFUN; checkkwd = CHKNL | CHKKWD | CHKALIAS; n->ndefun.text = n->narg.text; diff --git a/shell/hush.c b/shell/hush.c index ec4f3a2f2..1b7e546fa 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -4306,7 +4306,7 @@ static int done_word(struct parse_context *ctx) || endofname(command->argv[0])[0] != '\0' ) { /* bash says just "not a valid identifier" */ - syntax_error("bad variable name in for"); + syntax_error("bad for loop variable"); return 1; } /* Force FOR to have just one word (variable name) */ @@ -4683,6 +4683,11 @@ static int parse_group(struct parse_context *ctx, syntax_error_unexpected_ch(ch); return -1; } +//bash allows functions named "123", "..", "return"! +// if (endofname(command->argv[0])[0] != '\0') { +// syntax_error("bad function name"); +// return -1; +// } nommu_addchr(&ctx->as_string, ch); command->cmd_type = CMD_FUNCDEF; goto skip; diff --git a/shell/hush_test/hush-vars/readonly0.right b/shell/hush_test/hush-vars/readonly0.right index 8b750eb5f..7599698d2 100644 --- a/shell/hush_test/hush-vars/readonly0.right +++ b/shell/hush_test/hush-vars/readonly0.right @@ -1,5 +1,5 @@ -readonly a=A -readonly b=B +readonly a='A' +readonly b='B' Ok:0 hush: a=A: readonly variable From vda.linux at googlemail.com Sat Jul 8 15:57:42 2023 From: vda.linux at googlemail.com (Denys Vlasenko) Date: Sat, 8 Jul 2023 17:57:42 +0200 Subject: [git commit] hush: fix a compile failure Message-ID: <20230708155803.A2ABB8625D@busybox.osuosl.org> commit: https://git.busybox.net/busybox/commit/?id=e41e481fd5716fc9b2e2fdf2670d72c727ecb37f branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master Signed-off-by: Denys Vlasenko --- shell/hush.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/hush.c b/shell/hush.c index 1b7e546fa..2f55b92ea 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -11173,7 +11173,7 @@ static int FAST_FUNC builtin_umask(char **argv) } #endif -#if ENABLE_HUSH_EXPORT || ENABLE_HUSH_TRAP +#if ENABLE_HUSH_EXPORT || ENABLE_HUSH_READONLY || ENABLE_HUSH_SET || ENABLE_HUSH_TRAP static void print_escaped(const char *s) { //TODO? bash "set" does not quote variables which contain only alnums and "%+,-./:=@_~", From bugzilla at busybox.net Sun Jul 9 07:32:12 2023 From: bugzilla at busybox.net (bugzilla at busybox.net) Date: Sun, 09 Jul 2023 07:32:12 +0000 Subject: [Bug 15631] sleep command after '&' in a shell script has no effect In-Reply-To: References: Message-ID: https://bugs.busybox.net/show_bug.cgi?id=15631 --- Comment #2 from Tero Saarni --- This is the same bug as reported in https://bugs.busybox.net/show_bug.cgi?id=15619 -- You are receiving this mail because: You are on the CC list for the bug. From bugzilla at busybox.net Sun Jul 9 11:59:09 2023 From: bugzilla at busybox.net (bugzilla at busybox.net) Date: Sun, 09 Jul 2023 11:59:09 +0000 Subject: [Bug 15631] sleep command after '&' in a shell script has no effect In-Reply-To: References: Message-ID: https://bugs.busybox.net/show_bug.cgi?id=15631 Manhong changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |DUPLICATE Status|NEW |RESOLVED --- Comment #3 from Manhong --- *** This bug has been marked as a duplicate of bug 15619 *** -- You are receiving this mail because: You are on the CC list for the bug. From bugzilla at busybox.net Sun Jul 9 11:59:09 2023 From: bugzilla at busybox.net (bugzilla at busybox.net) Date: Sun, 09 Jul 2023 11:59:09 +0000 Subject: [Bug 15619] Odd beavor of loops with async sleep in 1.136 In-Reply-To: References: Message-ID: https://bugs.busybox.net/show_bug.cgi?id=15619 Manhong changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |manhongdai at gmail.com --- Comment #3 from Manhong --- *** Bug 15631 has been marked as a duplicate of this bug. *** -- You are receiving this mail because: You are on the CC list for the bug. From bugzilla at busybox.net Sun Jul 9 12:07:04 2023 From: bugzilla at busybox.net (bugzilla at busybox.net) Date: Sun, 09 Jul 2023 12:07:04 +0000 Subject: [Bug 15619] Odd beavor of loops with async sleep in 1.136 In-Reply-To: References: Message-ID: https://bugs.busybox.net/show_bug.cgi?id=15619 --- Comment #4 from Manhong --- I marked bug 15631 as a duplicate of this bug. Before this bug is fixed, we can add a pair of parenthesis as a workaround. The "bug.sh" below demonstrates that "sleep 10" doesn't sleep, while the "fix.sh" shows the workaround pi:~# ./bug.sh Sun Jul 9 12:05:09 UTC 2023 Sun Jul 9 12:05:09 UTC 2023 pi:~# ./fix.sh Sun Jul 9 12:05:12 UTC 2023 Sun Jul 9 12:05:22 UTC 2023 pi:~# cat bug.sh date & sleep 10 date pi:~# cat fix.sh ( date & ) sleep 10 date -- You are receiving this mail because: You are on the CC list for the bug. From bugzilla at busybox.net Sun Jul 9 15:33:36 2023 From: bugzilla at busybox.net (bugzilla at busybox.net) Date: Sun, 09 Jul 2023 15:33:36 +0000 Subject: [Bug 15688] New: less displays some unicode chars as { Message-ID: https://bugs.busybox.net/show_bug.cgi?id=15688 Bug ID: 15688 Summary: less displays some unicode chars as { Product: Busybox Version: unspecified Hardware: All OS: Linux Status: NEW Severity: normal Priority: P5 Component: Other Assignee: unassigned at busybox.net Reporter: yuri.kanivetsky at gmail.com CC: busybox-cvs at busybox.net Target Milestone: --- Example chars are: U+611B ? (e6 84 9b), U+529b ? (e5 8a 9b). What's common for them is they include 0x9b. As such I think they get replaced here: https://git.busybox.net/busybox/tree/miscutils/less.c?id=e41e481fd5716fc9b2e2fdf2670d72c727ecb37f#n885 Steps to reproduce: $ echo '??' | less Expected result: ?? Actual result: {{ I ran into it in a docker container (alpine:3.18, busybox-1.36.1), but I don't think it's docker-specific. Because e.g. cat works. -- You are receiving this mail because: You are on the CC list for the bug. From vda.linux at googlemail.com Sun Jul 9 18:26:23 2023 From: vda.linux at googlemail.com (Denys Vlasenko) Date: Sun, 9 Jul 2023 20:26:23 +0200 Subject: [git commit] libiproute: fix filtering ip6 route by table id Message-ID: <20230709184344.6900686982@busybox.osuosl.org> commit: https://git.busybox.net/busybox/commit/?id=6ce1dc2e91398145633ceaff7a6fecc786826277 branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master Otherwise - "ip -6 route show" shows routes from all tables - "ip -6 route show table 200" shows nothing function old new delta print_route 1962 1941 -21 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-21) Total: -21 bytes Signed-off-by: Yousong Zhou Signed-off-by: Denys Vlasenko --- networking/libiproute/iproute.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/networking/libiproute/iproute.c b/networking/libiproute/iproute.c index 5a972f8b2..cd77f642f 100644 --- a/networking/libiproute/iproute.c +++ b/networking/libiproute/iproute.c @@ -111,15 +111,7 @@ static int FAST_FUNC print_route(const struct sockaddr_nl *who UNUSED_PARAM, if (r->rtm_flags & RTM_F_CLONED) { return 0; } - if (G_filter.tb == RT_TABLE_LOCAL) { - if (r->rtm_type != RTN_LOCAL) { - return 0; - } - } else if (G_filter.tb == RT_TABLE_MAIN) { - if (r->rtm_type == RTN_LOCAL) { - return 0; - } - } else { + if (G_filter.tb != tid) { return 0; } } From vda.linux at googlemail.com Mon Jul 10 08:53:23 2023 From: vda.linux at googlemail.com (Denys Vlasenko) Date: Mon, 10 Jul 2023 10:53:23 +0200 Subject: [git commit] ash: disable sleep as builtin, closes 15619 Message-ID: <20230710085400.D3086863CD@busybox.osuosl.org> commit: https://git.busybox.net/busybox/commit/?id=5e0411a7fb510b9aecda0a850c76bdd62c50efa4 branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master Has a few annoying problems: * sleepcmd() -> sleep_main(), the parsing of bad arguments exits the shell. * sleep_for_duration() in sleep_main() has to be interruptible for ^C traps to work, which may be a problem for other users of sleep_for_duration(). * BUT, if sleep_for_duration() is interruptible, then SIGCHLD interrupts it as well (try "/bin/sleep 1 & sleep 10"). * sleep_main() must not allocate anything as ^C in ash longjmp's. (currently, allocations are only on error paths, in message printing). Signed-off-by: Denys Vlasenko --- include/libbb.h | 2 ++ shell/ash.c | 22 +++++++++++++++++----- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/include/libbb.h b/include/libbb.h index 18336da23..640fa3988 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -1513,6 +1513,8 @@ int hush_main(int argc, char** argv) IF_SHELL_HUSH(MAIN_EXTERNALLY_VISIBLE); /* If shell needs them, they exist even if not enabled as applets */ int echo_main(int argc, char** argv) IF_ECHO(MAIN_EXTERNALLY_VISIBLE); int sleep_main(int argc, char **argv) IF_SLEEP(MAIN_EXTERNALLY_VISIBLE); +/* See disabled "config ASH_SLEEP" in ash.c */ +#define ENABLE_ASH_SLEEP 0 int printf_main(int argc, char **argv) IF_PRINTF(MAIN_EXTERNALLY_VISIBLE); int test_main(int argc, char **argv) #if ENABLE_TEST || ENABLE_TEST1 || ENABLE_TEST2 diff --git a/shell/ash.c b/shell/ash.c index e91566994..e154cc6cc 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -134,11 +134,23 @@ //config: default y //config: depends on SHELL_ASH //config: -//config:config ASH_SLEEP -//config: bool "sleep builtin" -//config: default y -//config: depends on SHELL_ASH -//config: +// +////config:config ASH_SLEEP +////config: bool "sleep builtin" +////config: default y +////config: depends on SHELL_ASH +////config: +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +//Disabled for now. Has a few annoying problems: +// * sleepcmd() -> sleep_main(), the parsing of bad arguments exits the shell. +// * sleep_for_duration() in sleep_main() has to be interruptible for +// ^C traps to work, which may be a problem for other users +// of sleep_for_duration(). +// * BUT, if sleep_for_duration() is interruptible, then SIGCHLD interrupts it +// as well (try "/bin/sleep 1 & sleep 10"). +// * sleep_main() must not allocate anything as ^C in ash longjmp's. +// (currently, allocations are only on error paths, in message printing). +// //config:config ASH_HELP //config: bool "help builtin" //config: default y From bugzilla at busybox.net Mon Jul 10 08:54:04 2023 From: bugzilla at busybox.net (bugzilla at busybox.net) Date: Mon, 10 Jul 2023 08:54:04 +0000 Subject: [Bug 15619] Odd beavor of loops with async sleep in 1.136 In-Reply-To: References: Message-ID: https://bugs.busybox.net/show_bug.cgi?id=15619 Denys Vlasenko changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution|--- |FIXED --- Comment #5 from Denys Vlasenko --- I'm disabling sleep builtin in ash, with a comment describing problems. -- You are receiving this mail because: You are on the CC list for the bug. From vda.linux at googlemail.com Mon Jul 10 09:13:51 2023 From: vda.linux at googlemail.com (Denys Vlasenko) Date: Mon, 10 Jul 2023 11:13:51 +0200 Subject: [git commit] ash: remove "volatile" specifier from suppress_int Message-ID: <20230710091548.DA3658696C@busybox.osuosl.org> commit: https://git.busybox.net/busybox/commit/?id=ae351311da0d4e6642f746ae4a9c9a60f83e1e25 branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master function old new delta aliascmd 274 278 +4 signal_handler 81 80 -1 static.redirectsafe 144 141 -3 unwindlocalvars 219 215 -4 trapcmd 333 329 -4 setvar 164 160 -4 setpwd 167 163 -4 setinputfile 216 212 -4 setcmd 76 72 -4 readcmd 221 217 -4 raise_exception 26 22 -4 out2str 37 33 -4 out1str 32 28 -4 freejob 89 85 -4 forkchild 616 612 -4 fg_bgcmd 298 294 -4 expandarg 949 945 -4 evaltree 753 749 -4 evalsubshell 173 169 -4 evalpipe 346 342 -4 evalfun 408 404 -4 cdcmd 699 695 -4 ash_main 1240 1236 -4 __pgetc 589 585 -4 unaliascmd 152 147 -5 unalias 51 46 -5 umaskcmd 253 248 -5 stalloc 97 92 -5 shiftcmd 144 139 -5 setinputstring 73 68 -5 redirect 1068 1063 -5 recordregion 81 76 -5 pushstring 160 155 -5 popstring 120 115 -5 popstackmark 69 64 -5 popredir 123 118 -5 popfile 110 105 -5 out1fmt 45 40 -5 newline_and_flush 39 34 -5 ifsfree 66 61 -5 growstackblock 146 141 -5 freestrings 95 90 -5 fmtstr 59 54 -5 flush_stdout_stderr 23 18 -5 dowait 577 572 -5 delete_cmd_entry 52 47 -5 clearcmdentry 98 93 -5 ash_arith 79 74 -5 argstr 1404 1399 -5 evalcommand 1523 1515 -8 removerecordregions 219 209 -10 mklocal 284 274 -10 find_command 893 883 -10 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/52 up/down: 4/-251) Total: -247 bytes Signed-off-by: Denys Vlasenko --- shell/ash.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/shell/ash.c b/shell/ash.c index e154cc6cc..1764b43c9 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -424,7 +424,11 @@ struct globals_misc { struct jmploc *exception_handler; - volatile int suppress_int; /* counter */ + /*volatile*/ int suppress_int; /* counter */ + /* ^^^^^^^ removed "volatile" since gcc would turn suppress_int++ into ridiculouls + * 3-insn sequence otherwise. + * We don't change suppress_int asyncronously (in a signal handler), but we do read it async. + */ volatile /*sig_atomic_t*/ smallint pending_int; /* 1 = got SIGINT */ volatile /*sig_atomic_t*/ smallint got_sigchld; /* 1 = got SIGCHLD */ volatile /*sig_atomic_t*/ smallint pending_sig; /* last pending signal */ @@ -717,7 +721,8 @@ int_on(void) { barrier(); if (--suppress_int == 0 && pending_int) - raise_interrupt(); + raise_interrupt(); /* does not return */ + barrier(); } #if DEBUG_INTONOFF # define INT_ON do { \ @@ -733,7 +738,8 @@ force_int_on(void) barrier(); suppress_int = 0; if (pending_int) - raise_interrupt(); + raise_interrupt(); /* does not return */ + barrier(); } #define FORCE_INT_ON force_int_on() @@ -743,7 +749,8 @@ force_int_on(void) barrier(); \ suppress_int = (v); \ if (suppress_int == 0 && pending_int) \ - raise_interrupt(); \ + raise_interrupt(); /* does not return */ \ + barrier(); \ } while (0) From vda.linux at googlemail.com Mon Jul 10 10:02:34 2023 From: vda.linux at googlemail.com (Denys Vlasenko) Date: Mon, 10 Jul 2023 12:02:34 +0200 Subject: [git commit] ash: tweak comments, no code changes Message-ID: <20230710100256.38D2686A0C@busybox.osuosl.org> commit: https://git.busybox.net/busybox/commit/?id=a9047e09807f11bcd62f69c481ce19b2663f8862 branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master Signed-off-by: Denys Vlasenko --- shell/ash.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/shell/ash.c b/shell/ash.c index 1764b43c9..8bdeb44ae 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -425,9 +425,10 @@ struct globals_misc { struct jmploc *exception_handler; /*volatile*/ int suppress_int; /* counter */ - /* ^^^^^^^ removed "volatile" since gcc would turn suppress_int++ into ridiculouls - * 3-insn sequence otherwise. - * We don't change suppress_int asyncronously (in a signal handler), but we do read it async. + /* ^^^^^^^ removed "volatile" since on x86, gcc turns suppress_int++ + * into ridiculous 3-insn sequence otherwise. + * We don't change suppress_int asyncronously (in a signal handler), + * but we do read it async. */ volatile /*sig_atomic_t*/ smallint pending_int; /* 1 = got SIGINT */ volatile /*sig_atomic_t*/ smallint got_sigchld; /* 1 = got SIGCHLD */ @@ -9438,7 +9439,7 @@ evaltree(union node *n, int flags) } if (flags & EV_EXIT) { exexit: - raise_exception(EXEND); + raise_exception(EXEND); /* does not return */ } popstackmark(&smark); @@ -10466,7 +10467,7 @@ evalcommand(union node *cmd, int flags) /* We have a redirection error. */ if (spclbltin > 0) - raise_exception(EXERROR); + raise_exception(EXERROR); /* does not return */ goto out; } @@ -14571,7 +14572,7 @@ procargs(char **argv) optlist[i] = 2; if (options(&login_sh)) { /* it already printed err message */ - raise_exception(EXERROR); + raise_exception(EXERROR); /* does not return */ } xargv = argptr; xminusc = minusc; From bugzilla at busybox.net Tue Jul 11 01:47:11 2023 From: bugzilla at busybox.net (bugzilla at busybox.net) Date: Tue, 11 Jul 2023 01:47:11 +0000 Subject: [Bug 15691] New: ps -Z The displayed Context field is truncated. Message-ID: https://bugs.busybox.net/show_bug.cgi?id=15691 Bug ID: 15691 Summary: ps -Z The displayed Context field is truncated. Product: Busybox Version: 1.34.x Hardware: All OS: Linux Status: NEW Severity: normal Priority: P5 Component: Other Assignee: unassigned at busybox.net Reporter: renchunhui2 at huawei.com CC: busybox-cvs at busybox.net Target Milestone: --- In ps.c, the output length of the Context field is fixed to 32 characters. Consider increasing the width of this field? 736 len = printf("%5u %-32.32s %s ", 737 p->pid, 738 p->context ? p->context : "unknown", 739 p->state); If some process types are too long, the security attributes are truncated? PID CONTEXT STAT COMMAND 1370 system_u:system_r:os_busybox_t:s S /usr/sbin/rpc.mountd 1374 system_u:system_r:kernel_t:s0:c0 IW< [kworker/3:1H] 1411 system_u:system_r:os_busybox_t:s S {e3_daemon} /usr/local/UnifiedTest 1413 system_u:system_r:os_busybox_t:s S {e3_daemon} /usr/local/UnifiedTest 1419 system_u:system_r:os_busybox_t:s S sshd: /usr/sbin/sshd -D [listener] 1421 system_u:system_r:os_log_rsyslog S /usr/sbin/rsyslogd 1496 system_u:system_r:os_busybox_t:s S /bin/login -- 1497 system_u:system_r:os_busybox_t:s S -bash 1504 system_u:system_r:os_busybox_t:s R ps -Z 1505 system_u:system_r:os_busybox_t:s S tail -n 10 The complete information is as follows? PID CONTEXT STAT COMMAND 1370 system_u:system_r:os_busybox_t:s0:c0 S {rpc.mountd} /usr/ 1374 system_u:system_r:kernel_t:s0:c0 IW< [kworker/3:1H] 1411 system_u:system_r:os_busybox_t:s0:c0 S {e3_daemon} /usr/l 1413 system_u:system_r:os_busybox_t:s0:c0 S {e3_daemon} /usr/l 1419 system_u:system_r:os_busybox_t:s0:c0 S sshd: /usr/sbin/ss 1421 system_u:system_r:os_log_rsyslogd_t:s0:c0 S /usr/sbin/rsyslogd 1496 system_u:system_r:os_busybox_t:s0:c0 S /bin/login -- 1497 system_u:system_r:os_busybox_t:s0:c0 S -bash 1506 system_u:system_r:os_busybox_t:s0:c0 R ./ps -Z 1507 system_u:system_r:os_busybox_t:s0:c0 S tail -n 10 -- You are receiving this mail because: You are on the CC list for the bug. From vda.linux at googlemail.com Mon Jul 10 15:29:38 2023 From: vda.linux at googlemail.com (Denys Vlasenko) Date: Mon, 10 Jul 2023 17:29:38 +0200 Subject: [git commit] ntpd: fix a warning on 32-bit arch build Message-ID: <20230712101546.6FD4F86EA5@busybox.osuosl.org> commit: https://git.busybox.net/busybox/commit/?id=9fc5933b100694174071c7c4697c70095799bfd0 branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master Signed-off-by: Denys Vlasenko --- networking/ntpd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/networking/ntpd.c b/networking/ntpd.c index 93bd3189d..dcbdb8e60 100644 --- a/networking/ntpd.c +++ b/networking/ntpd.c @@ -1632,7 +1632,7 @@ update_local_clock(peer_t *p) if (adjtimex(&tmx) < 0) bb_simple_perror_msg_and_die("adjtimex"); bb_error_msg("p adjtimex freq:%ld offset:%+ld status:0x%x tc:%ld", - tmx.freq, tmx.offset, tmx.status, tmx.constant); + (long)tmx.freq, (long)tmx.offset, tmx.status, (long)tmx.constant); } memset(&tmx, 0, sizeof(tmx)); @@ -1747,7 +1747,7 @@ update_local_clock(peer_t *p) * Not sure why. Perhaps it is normal. */ VERB4 bb_error_msg("adjtimex:%d freq:%ld offset:%+ld status:0x%x", - rc, tmx.freq, tmx.offset, tmx.status); + rc, (long)tmx.freq, (long)tmx.offset, tmx.status); G.kernel_freq_drift = tmx.freq / 65536; VERB2 bb_error_msg("update from:%s offset:%+f delay:%f jitter:%f clock drift:%+.3fppm tc:%d", p->p_dotted, From vda.linux at googlemail.com Mon Jul 10 15:25:21 2023 From: vda.linux at googlemail.com (Denys Vlasenko) Date: Mon, 10 Jul 2023 17:25:21 +0200 Subject: [git commit] Update applet size estimates Message-ID: <20230712101546.5EA5C86EA2@busybox.osuosl.org> commit: https://git.busybox.net/busybox/commit/?id=5353df91cba7b397b9407701681708d0a1518df6 branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master Signed-off-by: Denys Vlasenko --- archival/bbunzip.c | 8 ++++---- archival/dpkg_deb.c | 2 +- archival/lzop.c | 2 +- console-tools/chvt.c | 2 +- console-tools/clear.c | 2 +- console-tools/deallocvt.c | 2 +- console-tools/dumpkmap.c | 2 +- console-tools/fgconsole.c | 2 +- console-tools/kbd_mode.c | 2 +- console-tools/loadfont.c | 2 +- console-tools/loadkmap.c | 2 +- console-tools/openvt.c | 2 +- console-tools/reset.c | 2 +- console-tools/resize.c | 2 +- console-tools/setconsole.c | 2 +- console-tools/setkeycodes.c | 2 +- console-tools/setlogcons.c | 2 +- console-tools/showkey.c | 2 +- coreutils/basename.c | 2 +- coreutils/cat.c | 2 +- coreutils/chroot.c | 2 +- coreutils/cksum.c | 4 ++-- coreutils/comm.c | 2 +- coreutils/cut.c | 2 +- coreutils/date.c | 2 +- coreutils/dd.c | 2 +- coreutils/df.c | 2 +- coreutils/dirname.c | 2 +- coreutils/dos2unix.c | 4 ++-- coreutils/du.c | 2 +- coreutils/echo.c | 2 +- coreutils/env.c | 2 +- coreutils/expand.c | 4 ++-- coreutils/expr.c | 2 +- coreutils/factor.c | 2 +- coreutils/false.c | 2 +- coreutils/fold.c | 2 +- coreutils/head.c | 2 +- coreutils/hostid.c | 2 +- coreutils/id.c | 4 ++-- coreutils/link.c | 2 +- coreutils/ln.c | 2 +- coreutils/logname.c | 2 +- coreutils/md5_sha1_sum.c | 10 +++++----- coreutils/mkdir.c | 2 +- coreutils/mkfifo.c | 2 +- coreutils/mknod.c | 2 +- coreutils/mktemp.c | 2 +- coreutils/nice.c | 2 +- coreutils/nl.c | 2 +- coreutils/nohup.c | 2 +- coreutils/nproc.c | 2 +- coreutils/paste.c | 2 +- coreutils/printenv.c | 2 +- coreutils/printf.c | 2 +- coreutils/pwd.c | 2 +- coreutils/readlink.c | 2 +- coreutils/realpath.c | 2 +- coreutils/rm.c | 2 +- coreutils/rmdir.c | 2 +- coreutils/seq.c | 2 +- coreutils/shred.c | 2 +- coreutils/shuf.c | 2 +- coreutils/sleep.c | 2 +- coreutils/sort.c | 2 +- coreutils/split.c | 2 +- coreutils/stty.c | 2 +- coreutils/sum.c | 2 +- coreutils/sync.c | 4 ++-- coreutils/tac.c | 2 +- coreutils/tail.c | 2 +- coreutils/tee.c | 2 +- coreutils/test.c | 2 +- coreutils/timeout.c | 2 +- coreutils/touch.c | 2 +- coreutils/tr.c | 2 +- coreutils/true.c | 2 +- coreutils/truncate.c | 2 +- coreutils/tsort.c | 2 +- coreutils/tty.c | 2 +- coreutils/uname.c | 4 ++-- coreutils/uniq.c | 2 +- coreutils/unlink.c | 2 +- coreutils/usleep.c | 2 +- coreutils/uudecode.c | 6 +++--- coreutils/uuencode.c | 2 +- coreutils/wc.c | 2 +- coreutils/who.c | 6 +++--- coreutils/whoami.c | 2 +- coreutils/yes.c | 2 +- debianutils/pipe_progress.c | 2 +- debianutils/run_parts.c | 2 +- debianutils/which.c | 2 +- e2fsprogs/chattr.c | 2 +- e2fsprogs/fsck.c | 2 +- e2fsprogs/lsattr.c | 2 +- editors/awk.c | 2 +- editors/cmp.c | 2 +- editors/ed.c | 2 +- editors/patch.c | 2 +- editors/patch_toybox.c | 2 +- editors/vi.c | 2 +- findutils/find.c | 2 +- findutils/grep.c | 6 +++--- findutils/xargs.c | 2 +- init/halt.c | 6 +++--- klibc-utils/resume.c | 2 +- klibc-utils/run-init.c | 2 +- loginutils/add-remove-shell.c | 4 ++-- loginutils/addgroup.c | 2 +- loginutils/chpasswd.c | 2 +- loginutils/cryptpw.c | 4 ++-- loginutils/deluser.c | 4 ++-- loginutils/getty.c | 2 +- loginutils/login.c | 2 +- loginutils/passwd.c | 2 +- loginutils/sulogin.c | 2 +- loginutils/vlock.c | 2 +- mailutils/makemime.c | 2 +- mailutils/popmaildir.c | 2 +- mailutils/reformime.c | 2 +- miscutils/adjtimex.c | 2 +- miscutils/ascii.c | 2 +- miscutils/bc.c | 4 ++-- miscutils/beep.c | 2 +- miscutils/chat.c | 2 +- miscutils/crond.c | 2 +- miscutils/devmem.c | 2 +- miscutils/hexedit.c | 2 +- miscutils/i2c_tools.c | 10 +++++----- miscutils/lsscsi.c | 2 +- miscutils/makedevs.c | 2 +- miscutils/microcom.c | 2 +- miscutils/mt.c | 2 +- miscutils/nandwrite.c | 4 ++-- miscutils/partprobe.c | 2 +- miscutils/raidautorun.c | 2 +- miscutils/readahead.c | 2 +- miscutils/runlevel.c | 2 +- miscutils/rx.c | 2 +- miscutils/seedrng.c | 2 +- miscutils/setfattr.c | 2 +- miscutils/setserial.c | 2 +- miscutils/strings.c | 2 +- miscutils/time.c | 2 +- miscutils/tree.c | 2 +- miscutils/ts.c | 2 +- miscutils/ttysize.c | 2 +- miscutils/ubi_tools.c | 12 ++++++------ miscutils/ubirename.c | 2 +- miscutils/volname.c | 2 +- miscutils/watchdog.c | 2 +- modutils/lsmod.c | 2 +- modutils/modprobe.c | 2 +- modutils/rmmod.c | 2 +- networking/arping.c | 2 +- networking/brctl.c | 2 +- networking/dnsd.c | 2 +- networking/ether-wake.c | 2 +- networking/ftpgetput.c | 4 ++-- networking/hostname.c | 4 ++-- networking/ifplugd.c | 2 +- networking/ip.c | 6 +++--- networking/ipcalc.c | 2 +- networking/isrv_identd.c | 2 +- networking/nameif.c | 2 +- networking/nbd-client.c | 2 +- networking/nslookup.c | 2 +- networking/ntpd.c | 2 +- networking/pscan.c | 2 +- networking/route.c | 2 +- networking/slattach.c | 2 +- networking/ssl_client.c | 2 +- networking/telnetd.c | 2 +- networking/traceroute.c | 2 +- networking/tunctl.c | 2 +- networking/udhcp/Config.src | 4 ++-- networking/vconfig.c | 2 +- networking/wget.c | 2 +- networking/whois.c | 2 +- networking/zcip.c | 2 +- printutils/lpd.c | 2 +- printutils/lpr.c | 4 ++-- procps/free.c | 2 +- procps/fuser.c | 2 +- procps/iostat.c | 2 +- procps/kill.c | 6 +++--- procps/lsof.c | 2 +- procps/mpstat.c | 2 +- procps/nmeter.c | 2 +- procps/pgrep.c | 4 ++-- procps/pidof.c | 2 +- procps/pmap.c | 2 +- procps/powertop.c | 2 +- procps/ps.c | 2 +- procps/pstree.c | 2 +- procps/pwdx.c | 2 +- procps/smemcap.c | 2 +- procps/sysctl.c | 2 +- procps/uptime.c | 2 +- procps/watch.c | 2 +- runit/chpst.c | 10 +++++----- runit/runsv.c | 2 +- runit/runsvdir.c | 2 +- runit/sv.c | 6 +++--- shell/ash.c | 2 +- shell/cttyhack.c | 2 +- shell/hush.c | 2 +- sysklogd/klogd.c | 2 +- sysklogd/logger.c | 2 +- sysklogd/logread.c | 2 +- sysklogd/syslogd.c | 2 +- util-linux/acpid.c | 2 +- util-linux/blkdiscard.c | 2 +- util-linux/blockdev.c | 2 +- util-linux/cal.c | 2 +- util-linux/chrt.c | 2 +- util-linux/dmesg.c | 2 +- util-linux/eject.c | 2 +- util-linux/fallocate.c | 2 +- util-linux/fatattr.c | 2 +- util-linux/fbset.c | 2 +- util-linux/fdformat.c | 2 +- util-linux/fdisk.c | 2 +- util-linux/findfs.c | 2 +- util-linux/flock.c | 2 +- util-linux/freeramdisk.c | 4 ++-- util-linux/fsfreeze.c | 2 +- util-linux/fstrim.c | 2 +- util-linux/getopt.c | 2 +- util-linux/hexdump.c | 4 ++-- util-linux/hexdump_xxd.c | 2 +- util-linux/hwclock.c | 2 +- util-linux/ionice.c | 2 +- util-linux/ipcrm.c | 2 +- util-linux/ipcs.c | 2 +- util-linux/last.c | 2 +- util-linux/losetup.c | 2 +- util-linux/lspci.c | 2 +- util-linux/lsusb.c | 2 +- util-linux/mdev.c | 2 +- util-linux/mesg.c | 2 +- util-linux/mkfs_vfat.c | 4 ++-- util-linux/mkswap.c | 2 +- util-linux/more.c | 2 +- util-linux/mount.c | 2 +- util-linux/mountpoint.c | 2 +- util-linux/nsenter.c | 2 +- util-linux/pivot_root.c | 2 +- util-linux/rdate.c | 2 +- util-linux/rdev.c | 2 +- util-linux/readprofile.c | 2 +- util-linux/renice.c | 2 +- util-linux/rev.c | 2 +- util-linux/rtcwake.c | 2 +- util-linux/script.c | 2 +- util-linux/scriptreplay.c | 2 +- util-linux/setarch.c | 6 +++--- util-linux/setpriv.c | 2 +- util-linux/setsid.c | 2 +- util-linux/switch_root.c | 2 +- util-linux/taskset.c | 2 +- util-linux/uevent.c | 2 +- util-linux/unshare.c | 2 +- util-linux/wall.c | 2 +- 265 files changed, 320 insertions(+), 320 deletions(-) Patch is too large, so refusing to show it From vda.linux at googlemail.com Mon Jul 10 15:27:26 2023 From: vda.linux at googlemail.com (Denys Vlasenko) Date: Mon, 10 Jul 2023 17:27:26 +0200 Subject: [git commit] i2ctransfer: fix build warning Message-ID: <20230712101546.6685886A06@busybox.osuosl.org> commit: https://git.busybox.net/busybox/commit/?id=69d33db445964727b053068cfaa4d417767f8960 branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master Signed-off-by: Denys Vlasenko --- miscutils/i2c_tools.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/miscutils/i2c_tools.c b/miscutils/i2c_tools.c index a70573ebe..5f41a72ec 100644 --- a/miscutils/i2c_tools.c +++ b/miscutils/i2c_tools.c @@ -107,6 +107,7 @@ static ALWAYS_INLINE void *itoptr(int i) return (void*)(intptr_t)i; } +#if ENABLE_I2CGET || ENABLE_I2CSET || ENABLE_I2CDUMP || ENABLE_I2CDETECT static int32_t i2c_smbus_access(int fd, char read_write, uint8_t cmd, int size, union i2c_smbus_data *data) { @@ -120,7 +121,6 @@ static int32_t i2c_smbus_access(int fd, char read_write, uint8_t cmd, return ioctl(fd, I2C_SMBUS, &args); } -#if ENABLE_I2CGET || ENABLE_I2CSET || ENABLE_I2CDUMP || ENABLE_I2CDETECT static int32_t i2c_smbus_read_byte(int fd) { union i2c_smbus_data data; From vda.linux at googlemail.com Wed Jul 12 14:27:49 2023 From: vda.linux at googlemail.com (Denys Vlasenko) Date: Wed, 12 Jul 2023 16:27:49 +0200 Subject: [git commit] hwclock: add get/set parameters option Message-ID: <20230712142848.1A1FF86EAC@busybox.osuosl.org> commit: https://git.busybox.net/busybox/commit/?id=d70256a5c719439cc6fab6a4571c1bb46178e4c7 branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master In kernel 5.16 special ioctls were introduced to get/set RTC parameters. Add option to get/set parameters into busybox version of hwclock. Implementation is similar to the one already used in linux-utils hwclock tool. Example of parameter get use: $ hwclock -g 2 The RTC parameter 0x2 is set to 0x2. $ hwclock --param-get bsm The RTC parameter 0x2 is set to 0x2. Example of parameter set use: $ hwclock -p 2=1 The RTC parameter 0x2 will be set to 0x1. $ hwclock -p bsm=2 The RTC parameter 0x2 will be set to 0x2. function old new delta hwclock_main 298 576 +278 .rodata 105231 105400 +169 packed_usage 34541 34576 +35 static.hwclock_longopts 60 84 +24 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 4/0 up/down: 506/0) Total: 506 bytes Signed-off-by: Andrej Picej Signed-off-by: Denys Vlasenko --- include/rtc_.h | 18 +++++++++++ util-linux/hwclock.c | 87 +++++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 100 insertions(+), 5 deletions(-) diff --git a/include/rtc_.h b/include/rtc_.h index 24ff5363f..782966090 100644 --- a/include/rtc_.h +++ b/include/rtc_.h @@ -46,6 +46,17 @@ struct linux_rtc_wkalrm { struct linux_rtc_time time; /* time the alarm is set to */ }; +struct rtc_param { + uint64_t param; + union { + uint64_t uvalue; + int64_t svalue; + uint64_t ptr; + }; + uint32_t index; + uint32_t __pad; +}; + /* * ioctl calls that are permitted to the /dev/rtc interface, if * any of the RTC drivers are enabled. @@ -71,12 +82,19 @@ struct linux_rtc_wkalrm { #define RTC_WKALM_SET _IOW('p', 0x0f, struct linux_rtc_wkalrm)/* Set wakeup alarm*/ #define RTC_WKALM_RD _IOR('p', 0x10, struct linux_rtc_wkalrm)/* Get wakeup alarm*/ +#define RTC_PARAM_GET _IOW('p', 0x13, struct rtc_param) /* Get parameter */ +#define RTC_PARAM_SET _IOW('p', 0x14, struct rtc_param) /* Set parameter */ + /* interrupt flags */ #define RTC_IRQF 0x80 /* any of the following is active */ #define RTC_PF 0x40 #define RTC_AF 0x20 #define RTC_UF 0x10 +#define RTC_PARAM_FEATURES 0 +#define RTC_PARAM_CORRECTION 1 +#define RTC_PARAM_BACKUP_SWITCH_MODE 2 + POP_SAVED_FUNCTION_VISIBILITY #endif diff --git a/util-linux/hwclock.c b/util-linux/hwclock.c index a0b7b52bd..d78bfe374 100644 --- a/util-linux/hwclock.c +++ b/util-linux/hwclock.c @@ -320,6 +320,70 @@ static void from_sys_clock(const char **pp_rtcname, int utc) close(rtc); } +static uint64_t resolve_rtc_param_alias(const char *alias) +{ + int n; + + BUILD_BUG_ON(RTC_PARAM_FEATURES != 0 + || RTC_PARAM_CORRECTION != 1 + || RTC_PARAM_BACKUP_SWITCH_MODE != 2 + ); + n = index_in_strings( + "features" "\0" + "correction" "\0" + "bsm" "\0" + , alias); + if (n >= 0) + return n; + return xstrtoull(alias, 0); +} + +static void get_rtc_param(const char **pp_rtcname, const char *rtc_param) +{ + int rtc; + struct rtc_param param; + + param.param = resolve_rtc_param_alias(rtc_param); + + rtc = rtc_xopen(pp_rtcname, O_RDONLY); + + xioctl(rtc, RTC_PARAM_GET, ¶m); + + printf("The RTC parameter 0x%llx is set to 0x%llx.\n", + (unsigned long long) param.param, (unsigned long long) param.uvalue); + + if (ENABLE_FEATURE_CLEAN_UP) + close(rtc); +} + +static void set_rtc_param(const char **pp_rtcname, char *rtc_param) +{ + int rtc; + struct rtc_param param; + char *eq; + + /* handle param name */ + eq = strchr(rtc_param, '='); + if (!eq) + bb_error_msg_and_die("expected ="); + *eq = '\0'; + param.param = resolve_rtc_param_alias(rtc_param); + *eq = '='; + + /* handle param value */ + param.uvalue = xstrtoull(eq + 1, 0); + + rtc = rtc_xopen(pp_rtcname, O_WRONLY); + + printf("The RTC parameter 0x%llx will be set to 0x%llx.\n", + (unsigned long long) param.param, (unsigned long long) param.uvalue); + + xioctl(rtc, RTC_PARAM_SET, ¶m); + + if (ENABLE_FEATURE_CLEAN_UP) + close(rtc); +} + // hwclock from util-linux 2.36.1 // hwclock [function] [option...] //Functions: @@ -346,10 +410,10 @@ static void from_sys_clock(const char **pp_rtcname, int utc) //usage:#define hwclock_trivial_usage //usage: IF_LONG_OPTS( -//usage: "[-swul] [--systz] [-f DEV]" +//usage: "[-swul] [--systz] [--param-get PARAM] [--param-set PARAM=VAL] [-f DEV]" //usage: ) //usage: IF_NOT_LONG_OPTS( -//usage: "[-swult] [-f DEV]" +//usage: "[-swult] [-g PARAM] [-p PARAM=VAL] [-f DEV]" //usage: ) //usage:#define hwclock_full_usage "\n\n" //usage: "Show or set hardware clock (RTC)\n" @@ -360,6 +424,8 @@ static void from_sys_clock(const char **pp_rtcname, int utc) //usage: IF_LONG_OPTS( //usage: "\n --systz Set in-kernel timezone, correct system time" //usage: "\n if RTC is kept in local time" +//usage: "\n --param-get PARAM Get RTC parameter" +//usage: "\n --param-set PARAM=VAL Set RTC parameter" //usage: ) //usage: "\n -f DEV Use specified device (e.g. /dev/rtc2)" //usage: "\n -u Assume RTC is kept in UTC" @@ -375,11 +441,14 @@ static void from_sys_clock(const char **pp_rtcname, int utc) #define HWCLOCK_OPT_SYSTOHC 0x10 #define HWCLOCK_OPT_SYSTZ 0x20 #define HWCLOCK_OPT_RTCFILE 0x40 +#define HWCLOCK_OPT_PARAM_GET 0x80 +#define HWCLOCK_OPT_PARAM_SET 0x100 int hwclock_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int hwclock_main(int argc UNUSED_PARAM, char **argv) { const char *rtcname = NULL; + char *param; unsigned opt; int utc; #if ENABLE_LONG_OPTS @@ -391,14 +460,18 @@ int hwclock_main(int argc UNUSED_PARAM, char **argv) "systohc\0" No_argument "w" "systz\0" No_argument "t" /* short opt is non-standard */ "rtc\0" Required_argument "f" + "param-get\0" Required_argument "g" /* short opt is non-standard */ + "param-set\0" Required_argument "p" /* short opt is non-standard */ ; #endif opt = getopt32long(argv, - "^""lurswtf:v" /* -v is accepted and ignored */ + "^""lurswtf:g:p:v" /* -v is accepted and ignored */ "\0" - "r--wst:w--rst:s--wrt:t--rsw:l--u:u--l", + "r--wstgp:w--rstgp:s--wrtgp:t--rswgp:g--rswtp:p--rswtg:l--u:u--l", hwclock_longopts, - &rtcname + &rtcname, + ¶m, + ¶m ); /* If -u or -l wasn't given, check if we are using utc */ @@ -413,6 +486,10 @@ int hwclock_main(int argc UNUSED_PARAM, char **argv) from_sys_clock(&rtcname, utc); else if (opt & HWCLOCK_OPT_SYSTZ) set_kernel_timezone_and_clock(utc, NULL); + else if (opt & HWCLOCK_OPT_PARAM_GET) + get_rtc_param(&rtcname, param); + else if (opt & HWCLOCK_OPT_PARAM_SET) + set_rtc_param(&rtcname, param); else /* default HWCLOCK_OPT_SHOW */ show_clock(&rtcname, utc); From bugzilla at busybox.net Thu Jul 13 13:48:22 2023 From: bugzilla at busybox.net (bugzilla at busybox.net) Date: Thu, 13 Jul 2023 13:48:22 +0000 Subject: [Bug 15694] New: ash built-in sleep behaves differently than external sleep when using traps (busybox 1.36.1) Message-ID: https://bugs.busybox.net/show_bug.cgi?id=15694 Bug ID: 15694 Summary: ash built-in sleep behaves differently than external sleep when using traps (busybox 1.36.1) Product: Busybox Version: unspecified Hardware: All OS: Linux Status: NEW Severity: normal Priority: P5 Component: Other Assignee: unassigned at busybox.net Reporter: karabaja4 at gmail.com CC: busybox-cvs at busybox.net Target Milestone: --- I noticed something strange during development. Consider this script: -------------------------------------- #!/bin/ash busybox sleep 11111 & _pid1="${!}" busybox sleep 22222 & _pid2="${!}" _trap() { echo "killing ${_pid1} ${_pid2}" kill -TERM "${_pid1}" "${_pid2}" echo "Goodbye" } trap '_trap' INT TERM QUIT HUP echo 'one' wait || true # press Ctrl-C here echo 'two' # works as expected, after wait exits the script waits here for 30s busybox sleep 30 echo 'three' -------------------------------------- This opens two external sleep processes and waits for SIGINT, then when the signal is received wait exits and "busybox sleep 30" is executed, and after 30 seconds "three" is printed. However when using builtin sleep, the script works a bit different. Replace "busybox sleep 30" with a builtin "sleep 30" Now, when pressing Ctrl-C, the script will just print "two" and "three" immediately, completely skipping the sleep command. Not sure why, but since built in sleep was just recently introduced I thought this could be a bug. I'm using busybox 1.36.1. Thanks, Igor -- You are receiving this mail because: You are on the CC list for the bug. From bugzilla at busybox.net Thu Jul 13 21:09:12 2023 From: bugzilla at busybox.net (bugzilla at busybox.net) Date: Thu, 13 Jul 2023 21:09:12 +0000 Subject: [Bug 15697] New: unzip: compressed symlink is not supported Message-ID: https://bugs.busybox.net/show_bug.cgi?id=15697 Bug ID: 15697 Summary: unzip: compressed symlink is not supported Product: Busybox Version: 1.35.x Hardware: All OS: Linux Status: NEW Severity: normal Priority: P5 Component: Other Assignee: unassigned at busybox.net Reporter: candrews at integralblue.com CC: busybox-cvs at busybox.net Target Milestone: --- The unzip binary provided by https://busybox.net/ does not suport compressed symlinks. Alpine previously had this problem and fixed it by with CFLAG "-DNO_LCHMOD", see https://gitlab.alpinelinux.org/alpine/aports/-/commit/3006365ef443c6c7d6432bd24ed65045341a4182 Can you please update the configuration used to generate the binaries available at busybox.net with this same solution? Reproduction steps: 1. curl https://busybox.net/downloads/binaries/1.35.0-x86_64-linux-musl/busybox_UNZIP -o unzip 2. chmod +x unzip 3. curl curl "https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.8.0.2856-linux.zip" -o sonar-scanner-cli-4.8.0.2856-linux.zip 4. ./unzip sonar-scanner-cli-4.8.0.2856-linux.zip Actual: Exits with status 1 and the error message: unzip: compressed symlink is not supported Expected: Exits with status 0 and no error message. -- You are receiving this mail because: You are on the CC list for the bug. From bugzilla at busybox.net Fri Jul 14 04:31:24 2023 From: bugzilla at busybox.net (bugzilla at busybox.net) Date: Fri, 14 Jul 2023 04:31:24 +0000 Subject: [Bug 15691] ps -Z The displayed Context field is truncated. In-Reply-To: References: Message-ID: https://bugs.busybox.net/show_bug.cgi?id=15691 chunren_r changed: What |Removed |Added ---------------------------------------------------------------------------- Version|1.34.x |unspecified -- You are receiving this mail because: You are on the CC list for the bug. From bugzilla at busybox.net Fri Jul 14 04:36:43 2023 From: bugzilla at busybox.net (bugzilla at busybox.net) Date: Fri, 14 Jul 2023 04:36:43 +0000 Subject: [Bug 15691] ps -Z The displayed Context field is truncated. In-Reply-To: References: Message-ID: https://bugs.busybox.net/show_bug.cgi?id=15691 chunren_r changed: What |Removed |Added ---------------------------------------------------------------------------- Version|unspecified |1.34.x -- You are receiving this mail because: You are on the CC list for the bug. From vda.linux at googlemail.com Fri Jul 14 14:37:24 2023 From: vda.linux at googlemail.com (Denys Vlasenko) Date: Fri, 14 Jul 2023 16:37:24 +0200 Subject: [git commit] hwclock: force LONG_OPTS, stop accepting non-compatible -t Message-ID: <20230714143812.1CB528709F@busybox.osuosl.org> commit: https://git.busybox.net/busybox/commit/?id=ab755f492599cf595d532f0f240a14c6e5caa435 branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master function old new delta hwclock_main 576 579 +3 .rodata 105404 105349 -55 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 3/-55) Total: -52 bytes Signed-off-by: Denys Vlasenko --- util-linux/hwclock.c | 83 ++++++++++++++++++++++++++-------------------------- 1 file changed, 42 insertions(+), 41 deletions(-) diff --git a/util-linux/hwclock.c b/util-linux/hwclock.c index d78bfe374..e6f0043d0 100644 --- a/util-linux/hwclock.c +++ b/util-linux/hwclock.c @@ -9,6 +9,7 @@ //config:config HWCLOCK //config: bool "hwclock (5.9 kb)" //config: default y +//config: select LONG_OPTS //config: help //config: The hwclock utility is used to read and set the hardware clock //config: on a system. This is primarily used to set the current time on @@ -409,89 +410,89 @@ static void set_rtc_param(const char **pp_rtcname, char *rtc_param) // -v, --verbose display more details //usage:#define hwclock_trivial_usage -//usage: IF_LONG_OPTS( -//usage: "[-swul] [--systz] [--param-get PARAM] [--param-set PARAM=VAL] [-f DEV]" -//usage: ) -//usage: IF_NOT_LONG_OPTS( -//usage: "[-swult] [-g PARAM] [-p PARAM=VAL] [-f DEV]" -//usage: ) +//usage: "[-ul] [-f DEV] [-s|-w|--systz|--param-get PARAM|--param-set PARAM=VAL]" //usage:#define hwclock_full_usage "\n\n" //usage: "Show or set hardware clock (RTC)\n" +//usage: "\n -f DEV Use this device (e.g. /dev/rtc2)" +//usage: "\n -u Assume RTC is kept in UTC" +//usage: "\n -l Assume RTC is kept in local time" +//usage: "\n (if neither is given, read from "ADJTIME_PATH")" ///////: "\n -r Show RTC time" ///////-r is default, don't bother showing it in help //usage: "\n -s Set system time from RTC" //usage: "\n -w Set RTC from system time" -//usage: IF_LONG_OPTS( //usage: "\n --systz Set in-kernel timezone, correct system time" //usage: "\n if RTC is kept in local time" //usage: "\n --param-get PARAM Get RTC parameter" //usage: "\n --param-set PARAM=VAL Set RTC parameter" -//usage: ) -//usage: "\n -f DEV Use specified device (e.g. /dev/rtc2)" -//usage: "\n -u Assume RTC is kept in UTC" -//usage: "\n -l Assume RTC is kept in local time" -//usage: "\n (if neither is given, read from "ADJTIME_PATH")" - -//TODO: get rid of incompatible -t alias to --systz? - -#define HWCLOCK_OPT_LOCALTIME 0x01 -#define HWCLOCK_OPT_UTC 0x02 -#define HWCLOCK_OPT_SHOW 0x04 -#define HWCLOCK_OPT_HCTOSYS 0x08 -#define HWCLOCK_OPT_SYSTOHC 0x10 -#define HWCLOCK_OPT_SYSTZ 0x20 -#define HWCLOCK_OPT_RTCFILE 0x40 -#define HWCLOCK_OPT_PARAM_GET 0x80 -#define HWCLOCK_OPT_PARAM_SET 0x100 int hwclock_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int hwclock_main(int argc UNUSED_PARAM, char **argv) { const char *rtcname = NULL; char *param; - unsigned opt; + unsigned opt, exclusive; int utc; -#if ENABLE_LONG_OPTS +#define OPT_LOCALTIME (1 << 0) +#define OPT_UTC (1 << 1) +#define OPT_RTCFILE (1 << 2) +#define OPT_SHOW (1 << 3) +#define OPT_HCTOSYS (1 << 4) +#define OPT_SYSTOHC (1 << 5) +#define OPT_PARAM_GET (1 << 6) +#define OPT_PARAM_SET (1 << 7) +//#define OPT_VERBOSE (1 << 8) UNUSED +#define OPT_SYSTZ (1 << 9) static const char hwclock_longopts[] ALIGN1 = "localtime\0" No_argument "l" "utc\0" No_argument "u" + "rtc\0" Required_argument "f" "show\0" No_argument "r" "hctosys\0" No_argument "s" "systohc\0" No_argument "w" - "systz\0" No_argument "t" /* short opt is non-standard */ - "rtc\0" Required_argument "f" - "param-get\0" Required_argument "g" /* short opt is non-standard */ - "param-set\0" Required_argument "p" /* short opt is non-standard */ + "param-get\0" Required_argument "\xfd" /* no short equivalent */ + "param-set\0" Required_argument "\xfe" /* no short equivalent */ + "systz\0" No_argument "\xff" /* no short equivalent */ ; -#endif opt = getopt32long(argv, - "^""lurswtf:g:p:v" /* -v is accepted and ignored */ + "^""luf:rsw\xfd:\xfe:v" /* -v is accepted and ignored */ "\0" - "r--wstgp:w--rstgp:s--wrtgp:t--rswgp:g--rswtp:p--rswtg:l--u:u--l", + "l--u:u--l", hwclock_longopts, &rtcname, ¶m, ¶m ); +#if 0 //DEBUG + bb_error_msg("opt:0x%x", opt); + if (opt & OPT_PARAM_GET) bb_error_msg("OPT_PARAM_GET %s", param); + if (opt & OPT_PARAM_SET) bb_error_msg("OPT_PARAM_SET %s", param); + if (opt & OPT_SYSTZ ) bb_error_msg("OPT_SYSTZ"); + return 0; +#endif + /* All options apart from -luf are exclusive, enforce */ + exclusive = opt >> 3; + if ((exclusive - 1) & exclusive) /* more than one bit set? */ + bb_show_usage(); /* If -u or -l wasn't given, check if we are using utc */ - if (opt & (HWCLOCK_OPT_UTC | HWCLOCK_OPT_LOCALTIME)) - utc = (opt & HWCLOCK_OPT_UTC); + if (opt & (OPT_UTC | OPT_LOCALTIME)) + utc = (opt & OPT_UTC); else utc = rtc_adjtime_is_utc(); - if (opt & HWCLOCK_OPT_HCTOSYS) + if (opt & OPT_HCTOSYS) to_sys_clock(&rtcname, utc); - else if (opt & HWCLOCK_OPT_SYSTOHC) + else if (opt & OPT_SYSTOHC) from_sys_clock(&rtcname, utc); - else if (opt & HWCLOCK_OPT_SYSTZ) + else if (opt & OPT_SYSTZ) set_kernel_timezone_and_clock(utc, NULL); - else if (opt & HWCLOCK_OPT_PARAM_GET) + else if (opt & OPT_PARAM_GET) get_rtc_param(&rtcname, param); - else if (opt & HWCLOCK_OPT_PARAM_SET) + else if (opt & OPT_PARAM_SET) set_rtc_param(&rtcname, param); else - /* default HWCLOCK_OPT_SHOW */ + /* default OPT_SHOW */ show_clock(&rtcname, utc); return 0; From vda.linux at googlemail.com Sun Jul 16 12:40:44 2023 From: vda.linux at googlemail.com (Denys Vlasenko) Date: Sun, 16 Jul 2023 14:40:44 +0200 Subject: [git commit] getfattr: new applet Message-ID: <20230716125235.3A294865FB@busybox.osuosl.org> commit: https://git.busybox.net/busybox/commit/?id=cf809e2f2dbf699035e4841e45070b947374a989 branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master function old new delta getfattr_main - 309 +309 print_attr - 115 +115 packed_usage 34576 34631 +55 .rodata 105349 105395 +46 lgetxattr - 41 +41 getxattr - 41 +41 llistxattr - 35 +35 listxattr - 35 +35 applet_names 2806 2815 +9 applet_main 1620 1624 +4 ------------------------------------------------------------------------------ (add/remove: 7/0 grow/shrink: 4/0 up/down: 690/0) Total: 690 bytes Signed-off-by: YU Jincheng Signed-off-by: Denys Vlasenko --- miscutils/getfattr.c | 131 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 131 insertions(+) diff --git a/miscutils/getfattr.c b/miscutils/getfattr.c new file mode 100644 index 000000000..59b6f6bca --- /dev/null +++ b/miscutils/getfattr.c @@ -0,0 +1,131 @@ +/* + * getfattr - get extended attributes of filesystem objects. + * + * Copyright (C) 2023 by LoveSy + * + * Licensed under GPLv2, see file LICENSE in this source tree. + */ +//config:config GETFATTR +//config: bool "getfattr (12.3 kb)" +//config: default y +//config: help +//config: Get extended attributes on files + +//applet:IF_GETFATTR(APPLET_NOEXEC(getfattr, getfattr, BB_DIR_USR_BIN, BB_SUID_DROP, getfattr)) + +//kbuild:lib-$(CONFIG_GETFATTR) += getfattr.o + +#include +#include +#include "libbb.h" + +//usage:#define getfattr_trivial_usage +//usage: "[-h] {-d|-n ATTR} FILE...\n" +//usage:#define getfattr_full_usage "\n\n" +//usage: "Get extended attributes" +//usage: "\n" +//usage: "\n -h Do not follow symlinks" +//usage: "\n -d Dump all attributes" +//usage: "\n -n ATTR Get attribute ATTR" + +enum { + OPT_h = (1 << 0), + OPT_d = (1 << 1), +}; + +static int print_attr(const char *file, const char *name, char **buf, size_t *bufsize) +{ + ssize_t len; + + if (*bufsize == 0) + goto grow; + again: + len = ((option_mask32 & OPT_h) ? lgetxattr: getxattr)(file, name, *buf, *bufsize); + if (len < 0) { + if (errno != ERANGE) + return len; + grow: + *bufsize = (*bufsize * 2) + 1024; + *buf = xrealloc(*buf, *bufsize); + goto again; + } + printf("%s=\"%.*s\"\n", name, len, *buf); + return 0; +} + +static ssize_t list_attr(const char *file, char **list, size_t *listsize) +{ + ssize_t len; + + if (*listsize == 0) + goto grow; + again: + len = ((option_mask32 & OPT_h) ? llistxattr : listxattr)(file, *list, *listsize); + if (len < 0) { + if (errno != ERANGE) + return len; + grow: + *listsize = (*listsize * 2) + 1024; + *list = xrealloc(*list, *listsize); + goto again; + } + return len; +} + +int getfattr_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; +int getfattr_main(int argc UNUSED_PARAM, char **argv) +{ + const char *name; + int status; + int opt; + char *buf = NULL; + size_t bufsize = 0; + char *list = NULL; + size_t listsize = 0; + + opt = getopt32(argv, "^" + "hdn:" + /* Min one arg; exactly one of -n or -d is required. */ + "\0" "-1:d:n:n--d:d--n" + , &name + ); + argv += optind; + status = EXIT_SUCCESS; + + do { + int r; + if (opt & OPT_d) { + ssize_t len = list_attr(*argv, &list, &listsize); + if (len > 0) { + char *key; + printf("# file: %s\n", *argv); + key = list; + while (len > 0) { + ssize_t keylen; + r = print_attr(*argv, key, &buf, &bufsize); + if (r) + goto err; + keylen = strlen(key) + 1; + key += keylen; + len -= keylen; + } + bb_putchar('\n'); + } + } else { + printf("# file: %s\n", *argv); + r = print_attr(*argv, name, &buf, &bufsize); + if (r) { + err: + bb_simple_perror_msg(*argv); + status = EXIT_FAILURE; + // continue; maybe? + } + bb_putchar('\n'); + } + } while (*++argv); + + if (ENABLE_FEATURE_CLEAN_UP) + free(buf); + + fflush_stdout_and_exit(status); +} From vda.linux at googlemail.com Mon Jul 17 07:36:17 2023 From: vda.linux at googlemail.com (Denys Vlasenko) Date: Mon, 17 Jul 2023 09:36:17 +0200 Subject: [git commit] getfattr: fix "getfattr NOTEXIST" - now prints error msg Message-ID: <20230717073716.34DC38711D@busybox.osuosl.org> commit: https://git.busybox.net/busybox/commit/?id=a6a102ec4c8d96fcfb968c88fbdae80f6142c7bf branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master function old new delta getfattr_main 309 307 -2 .rodata 105395 105391 -4 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-6) Total: -6 bytes Signed-off-by: Denys Vlasenko --- miscutils/getfattr.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/miscutils/getfattr.c b/miscutils/getfattr.c index 59b6f6bca..905aec65f 100644 --- a/miscutils/getfattr.c +++ b/miscutils/getfattr.c @@ -31,6 +31,7 @@ enum { OPT_h = (1 << 0), OPT_d = (1 << 1), + OPT_n = (1 << 2), }; static int print_attr(const char *file, const char *name, char **buf, size_t *bufsize) @@ -85,8 +86,9 @@ int getfattr_main(int argc UNUSED_PARAM, char **argv) opt = getopt32(argv, "^" "hdn:" - /* Min one arg; exactly one of -n or -d is required. */ - "\0" "-1:d:n:n--d:d--n" + /* Min one arg; -d and -n are exclusive */ + "\0" "-1:n--d:d--n" + //getfattr 2.5.1 does not enforce this: ":d:n" /* exactly one of -n or -d is required */ , &name ); argv += optind; @@ -94,8 +96,11 @@ int getfattr_main(int argc UNUSED_PARAM, char **argv) do { int r; - if (opt & OPT_d) { +//getfattr 2.5.1 with no -n/-d defaults to -d + if (!(opt & OPT_n)) { ssize_t len = list_attr(*argv, &list, &listsize); + if (len < 0) + goto err; if (len > 0) { char *key; printf("# file: %s\n", *argv); @@ -118,7 +123,7 @@ int getfattr_main(int argc UNUSED_PARAM, char **argv) err: bb_simple_perror_msg(*argv); status = EXIT_FAILURE; - // continue; maybe? + continue; } bb_putchar('\n'); } From vda.linux at googlemail.com Mon Jul 17 15:29:36 2023 From: vda.linux at googlemail.com (Denys Vlasenko) Date: Mon, 17 Jul 2023 17:29:36 +0200 Subject: [git commit] introduce and use exitcode_t Message-ID: <20230717152956.1608087358@busybox.osuosl.org> commit: https://git.busybox.net/busybox/commit/?id=c484846c4459affa769b84cbd0b586f2bbaec828 branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master function old new delta strings_main 422 420 -2 setfattr_main 175 173 -2 brctl_main 1548 1546 -2 makedevs_main 979 975 -4 rev_main 337 332 -5 getfattr_main 307 302 -5 cut_main 1201 1196 -5 cksum_main 398 393 -5 umount_main 573 565 -8 ln_main 516 508 -8 expand_main 660 652 -8 df_main 1068 1060 -8 renice_main 346 332 -14 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/13 up/down: 0/-76) Total: -76 bytes Signed-off-by: Denys Vlasenko --- coreutils/cksum.c | 2 +- coreutils/cut.c | 2 +- coreutils/dd.c | 2 +- coreutils/df.c | 2 +- coreutils/expand.c | 2 +- coreutils/fold.c | 2 +- coreutils/ln.c | 2 +- coreutils/touch.c | 2 +- include/libbb.h | 7 +++++++ miscutils/getfattr.c | 2 +- miscutils/makedevs.c | 2 +- miscutils/setfattr.c | 2 +- miscutils/strings.c | 3 ++- networking/brctl.c | 2 +- networking/tc.c | 5 ++--- util-linux/renice.c | 2 +- util-linux/rev.c | 2 +- util-linux/umount.c | 2 +- 18 files changed, 26 insertions(+), 19 deletions(-) diff --git a/coreutils/cksum.c b/coreutils/cksum.c index badc63a6a..1fb6ef2d0 100644 --- a/coreutils/cksum.c +++ b/coreutils/cksum.c @@ -39,7 +39,7 @@ int cksum_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int cksum_main(int argc UNUSED_PARAM, char **argv) { uint32_t *crc32_table = crc32_filltable(NULL, IS_CKSUM); - int exit_code = EXIT_SUCCESS; + exitcode_t exit_code = EXIT_SUCCESS; #if ENABLE_DESKTOP getopt32(argv, ""); /* cksum coreutils 6.9 compat */ diff --git a/coreutils/cut.c b/coreutils/cut.c index 25b16d1a8..d129f9b9d 100644 --- a/coreutils/cut.c +++ b/coreutils/cut.c @@ -311,7 +311,7 @@ int cut_main(int argc UNUSED_PARAM, char **argv) } { - int retval = EXIT_SUCCESS; + exitcode_t retval = EXIT_SUCCESS; if (!*argv) *--argv = (char *)"-"; diff --git a/coreutils/dd.c b/coreutils/dd.c index c032ebe1b..8bb782781 100644 --- a/coreutils/dd.c +++ b/coreutils/dd.c @@ -375,7 +375,7 @@ int dd_main(int argc UNUSED_PARAM, char **argv) OP_oflag_direct, #endif }; - smallint exitcode = EXIT_FAILURE; + exitcode_t exitcode = EXIT_FAILURE; int i; size_t ibs = 512; char *ibuf; diff --git a/coreutils/df.c b/coreutils/df.c index 76e9cefbf..03aa78148 100644 --- a/coreutils/df.c +++ b/coreutils/df.c @@ -113,7 +113,7 @@ int df_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int df_main(int argc UNUSED_PARAM, char **argv) { unsigned long df_disp_hr = 1024; - int status = EXIT_SUCCESS; + exitcode_t status = EXIT_SUCCESS; unsigned opt; FILE *mount_table; struct mntent *mount_entry; diff --git a/coreutils/expand.c b/coreutils/expand.c index 47693e144..c4db26055 100644 --- a/coreutils/expand.c +++ b/coreutils/expand.c @@ -192,7 +192,7 @@ int expand_main(int argc UNUSED_PARAM, char **argv) FILE *file; unsigned tab_size; unsigned opt; - int exit_status = EXIT_SUCCESS; + exitcode_t exit_status = EXIT_SUCCESS; init_unicode(); diff --git a/coreutils/fold.c b/coreutils/fold.c index 2839c8c68..8112fe911 100644 --- a/coreutils/fold.c +++ b/coreutils/fold.c @@ -77,7 +77,7 @@ int fold_main(int argc UNUSED_PARAM, char **argv) char *line_out = NULL; const char *w_opt = "80"; unsigned width; - smallint exitcode = EXIT_SUCCESS; + exitcode_t exitcode = EXIT_SUCCESS; init_unicode(); diff --git a/coreutils/ln.c b/coreutils/ln.c index 34eec398a..080ba142e 100644 --- a/coreutils/ln.c +++ b/coreutils/ln.c @@ -52,7 +52,7 @@ int ln_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int ln_main(int argc, char **argv) { - int status = EXIT_SUCCESS; + exitcode_t status = EXIT_SUCCESS; int opts; char *last; char *src_name; diff --git a/coreutils/touch.c b/coreutils/touch.c index 8fde70e12..ced596c89 100644 --- a/coreutils/touch.c +++ b/coreutils/touch.c @@ -77,7 +77,7 @@ int touch_main(int argc UNUSED_PARAM, char **argv) { int fd; int opts; - smalluint status = EXIT_SUCCESS; + exitcode_t status = EXIT_SUCCESS; #if ENABLE_FEATURE_TOUCH_SUSV3 char *reference_file; char *date_str; diff --git a/include/libbb.h b/include/libbb.h index 640fa3988..eb97a9880 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -1444,6 +1444,13 @@ void bb_verror_msg(const char *s, va_list p, const char *strerr) FAST_FUNC; void bb_die_memory_exhausted(void) NORETURN FAST_FUNC; void bb_logenv_override(void) FAST_FUNC; +/* x86 benefits from narrow exit code variables + * (because it has no widening MOV imm8,word32 insn, has to use MOV imm32,w + * for "exitcode = EXIT_FAILURE" and similar. The downside is that sometimes +* gcc widens the variable to int in various ugly suboptimal ways). + */ +typedef smalluint exitcode_t; + #if ENABLE_FEATURE_SYSLOG_INFO void bb_info_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2))) FAST_FUNC; void bb_simple_info_msg(const char *s) FAST_FUNC; diff --git a/miscutils/getfattr.c b/miscutils/getfattr.c index 905aec65f..cb42fdac0 100644 --- a/miscutils/getfattr.c +++ b/miscutils/getfattr.c @@ -77,7 +77,7 @@ int getfattr_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int getfattr_main(int argc UNUSED_PARAM, char **argv) { const char *name; - int status; + exitcode_t status; int opt; char *buf = NULL; size_t bufsize = 0; diff --git a/miscutils/makedevs.c b/miscutils/makedevs.c index 48be91875..999a3b976 100644 --- a/miscutils/makedevs.c +++ b/miscutils/makedevs.c @@ -181,7 +181,7 @@ int makedevs_main(int argc UNUSED_PARAM, char **argv) { parser_t *parser; char *line = (char *)"-"; - int ret = EXIT_SUCCESS; + exitcode_t ret = EXIT_SUCCESS; getopt32(argv, "^" "d:" "\0" "=1", &line); argv += optind; diff --git a/miscutils/setfattr.c b/miscutils/setfattr.c index 10d1840c9..b68bc9452 100644 --- a/miscutils/setfattr.c +++ b/miscutils/setfattr.c @@ -32,7 +32,7 @@ int setfattr_main(int argc UNUSED_PARAM, char **argv) { const char *name; const char *value = ""; - int status; + exitcode_t status; int opt; enum { OPT_h = (1 << 0), diff --git a/miscutils/strings.c b/miscutils/strings.c index 036df5c5d..bd1850cbb 100644 --- a/miscutils/strings.c +++ b/miscutils/strings.c @@ -40,7 +40,8 @@ int strings_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int strings_main(int argc UNUSED_PARAM, char **argv) { - int n, c, status = EXIT_SUCCESS; + int n, c; + exitcode_t status = EXIT_SUCCESS; unsigned count; off_t offset; FILE *file; diff --git a/networking/brctl.c b/networking/brctl.c index 7b0270b51..0f8dc2f7a 100644 --- a/networking/brctl.c +++ b/networking/brctl.c @@ -538,7 +538,7 @@ int brctl_main(int argc UNUSED_PARAM, char **argv) DIR *net; struct dirent *ent; int need_hdr = 1; - int exitcode = EXIT_SUCCESS; + exitcode_t exitcode = EXIT_SUCCESS; if (*argv) { /* "show BR1 BR2 BR3" */ diff --git a/networking/tc.c b/networking/tc.c index 43187f7ee..3a79fd2d9 100644 --- a/networking/tc.c +++ b/networking/tc.c @@ -502,7 +502,7 @@ int tc_main(int argc UNUSED_PARAM, char **argv) }; struct rtnl_handle rth; struct tcmsg msg; - int ret, obj, cmd, arg; + int obj, cmd, arg; char *dev = NULL; INIT_G(); @@ -510,7 +510,6 @@ int tc_main(int argc UNUSED_PARAM, char **argv) if (!*++argv) bb_show_usage(); xrtnl_open(&rth); - ret = EXIT_SUCCESS; obj = index_in_substrings(objects, *argv++); if (obj < 0) @@ -625,5 +624,5 @@ int tc_main(int argc UNUSED_PARAM, char **argv) if (ENABLE_FEATURE_CLEAN_UP) { rtnl_close(&rth); } - return ret; + return EXIT_SUCCESS; } diff --git a/util-linux/renice.c b/util-linux/renice.c index 53f197cce..f2737f29b 100644 --- a/util-linux/renice.c +++ b/util-linux/renice.c @@ -45,7 +45,7 @@ int renice_main(int argc UNUSED_PARAM, char **argv) { static const char Xetpriority_msg[] ALIGN1 = "%cetpriority"; - int retval = EXIT_SUCCESS; + exitcode_t retval = EXIT_SUCCESS; int which = PRIO_PROCESS; /* Default 'which' value. */ int use_relative = 0; int adjustment, new_priority; diff --git a/util-linux/rev.c b/util-linux/rev.c index 12df2b9ff..aad53722d 100644 --- a/util-linux/rev.c +++ b/util-linux/rev.c @@ -51,7 +51,7 @@ static void strrev(CHAR_T *s, int len) int rev_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int rev_main(int argc UNUSED_PARAM, char **argv) { - int retval; + exitcode_t retval; size_t bufsize; char *buf; diff --git a/util-linux/umount.c b/util-linux/umount.c index 23da32868..f5c97a034 100644 --- a/util-linux/umount.c +++ b/util-linux/umount.c @@ -97,7 +97,7 @@ int umount_main(int argc UNUSED_PARAM, char **argv) struct mntent me; FILE *fp; char *fstype = NULL; - int status = EXIT_SUCCESS; + exitcode_t status = EXIT_SUCCESS; unsigned opt; struct mtab_list { char *dir; From vda.linux at googlemail.com Tue Jul 18 14:41:12 2023 From: vda.linux at googlemail.com (Denys Vlasenko) Date: Tue, 18 Jul 2023 16:41:12 +0200 Subject: [git commit] libbb: rename source files, no code changes Message-ID: <20230718144939.051B9873BD@busybox.osuosl.org> commit: https://git.busybox.net/busybox/commit/?id=8f0845cad7bfc46939132b33f9cd0753b261b953 branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master Signed-off-by: Denys Vlasenko --- libbb/Kbuild.src | 10 +++++----- ...{hash_md5_sha_x86-32_shaNI.S => hash_sha1_hwaccel_x86-32.S} | 0 ...{hash_md5_sha_x86-64_shaNI.S => hash_sha1_hwaccel_x86-64.S} | 0 libbb/{hash_md5_sha_x86-64.S => hash_sha1_x86-64.S} | 2 +- libbb/{hash_md5_sha_x86-64.S.sh => hash_sha1_x86-64.S.sh} | 4 ++-- ..._md5_sha256_x86-32_shaNI.S => hash_sha256_hwaccel_x86-32.S} | 0 ..._md5_sha256_x86-64_shaNI.S => hash_sha256_hwaccel_x86-64.S} | 0 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/libbb/Kbuild.src b/libbb/Kbuild.src index 653025e56..c3b30003f 100644 --- a/libbb/Kbuild.src +++ b/libbb/Kbuild.src @@ -56,11 +56,11 @@ lib-y += login.o lib-y += make_directory.o lib-y += makedev.o lib-y += hash_md5_sha.o -lib-y += hash_md5_sha_x86-64.o -lib-y += hash_md5_sha_x86-64_shaNI.o -lib-y += hash_md5_sha_x86-32_shaNI.o -lib-y += hash_md5_sha256_x86-64_shaNI.o -lib-y += hash_md5_sha256_x86-32_shaNI.o +lib-y += hash_sha1_x86-64.o +lib-y += hash_sha1_hwaccel_x86-64.o +lib-y += hash_sha1_hwaccel_x86-32.o +lib-y += hash_sha256_hwaccel_x86-64.o +lib-y += hash_sha256_hwaccel_x86-32.o # Alternative (disabled) MD5 implementation #lib-y += hash_md5prime.o lib-y += messages.o diff --git a/libbb/hash_md5_sha_x86-32_shaNI.S b/libbb/hash_sha1_hwaccel_x86-32.S similarity index 100% rename from libbb/hash_md5_sha_x86-32_shaNI.S rename to libbb/hash_sha1_hwaccel_x86-32.S diff --git a/libbb/hash_md5_sha_x86-64_shaNI.S b/libbb/hash_sha1_hwaccel_x86-64.S similarity index 100% rename from libbb/hash_md5_sha_x86-64_shaNI.S rename to libbb/hash_sha1_hwaccel_x86-64.S diff --git a/libbb/hash_md5_sha_x86-64.S b/libbb/hash_sha1_x86-64.S similarity index 99% rename from libbb/hash_md5_sha_x86-64.S rename to libbb/hash_sha1_x86-64.S index 2cdd22015..b1968fff6 100644 --- a/libbb/hash_md5_sha_x86-64.S +++ b/libbb/hash_sha1_x86-64.S @@ -1,4 +1,4 @@ -### Generated by hash_md5_sha_x86-64.S.sh ### +### Generated by hash_sha1_x86-64.S.sh ### #if CONFIG_SHA1_SMALL == 0 && defined(__GNUC__) && defined(__x86_64__) #ifdef __linux__ diff --git a/libbb/hash_md5_sha_x86-64.S.sh b/libbb/hash_sha1_x86-64.S.sh similarity index 99% rename from libbb/hash_md5_sha_x86-64.S.sh rename to libbb/hash_sha1_x86-64.S.sh index 653fe4989..3fc125d51 100755 --- a/libbb/hash_md5_sha_x86-64.S.sh +++ b/libbb/hash_sha1_x86-64.S.sh @@ -4,7 +4,7 @@ # The reason is that the changes to generated code are difficult # to visualize by looking only at this script, it helps when the commit # also contains the diff of the generated file. -exec >hash_md5_sha_x86-64.S +exec >hash_sha1_x86-64.S # Based on http://arctic.org/~dean/crypto/sha1.html. # ("This SHA1 implementation is public domain.") @@ -124,7 +124,7 @@ INTERLEAVE() { # ...but pshufb is a SSSE3 insn. Can't use it. echo \ -"### Generated by hash_md5_sha_x86-64.S.sh ### +"### Generated by hash_sha1_x86-64.S.sh ### #if CONFIG_SHA1_SMALL == 0 && defined(__GNUC__) && defined(__x86_64__) #ifdef __linux__ diff --git a/libbb/hash_md5_sha256_x86-32_shaNI.S b/libbb/hash_sha256_hwaccel_x86-32.S similarity index 100% rename from libbb/hash_md5_sha256_x86-32_shaNI.S rename to libbb/hash_sha256_hwaccel_x86-32.S diff --git a/libbb/hash_md5_sha256_x86-64_shaNI.S b/libbb/hash_sha256_hwaccel_x86-64.S similarity index 100% rename from libbb/hash_md5_sha256_x86-64_shaNI.S rename to libbb/hash_sha256_hwaccel_x86-64.S From bugzilla at busybox.net Thu Jul 20 14:57:54 2023 From: bugzilla at busybox.net (bugzilla at busybox.net) Date: Thu, 20 Jul 2023 14:57:54 +0000 Subject: [Bug 15276] cut: transforms 0x00 to 0x0a In-Reply-To: References: Message-ID: https://bugs.busybox.net/show_bug.cgi?id=15276 --- Comment #1 from Eric Blake --- For what it's worth, POSIX says that cut is only required to operate on text files; a file with an embedded NUL byte is not a text file, so all bets are off on what behavior to expect: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/cut.html, INPUT FILES That said, gratuitous differences from other implementations are still worth patching. -- You are receiving this mail because: You are on the CC list for the bug.