From dev at vitlabuda.cz Sun Jan 1 16:23:40 2023 From: dev at vitlabuda.cz (=?UTF-8?q?V=C3=ADt=20Labuda?=) Date: Sun, 1 Jan 2023 17:23:40 +0100 Subject: [PATCH] ping: explicitly set ICMP code to zero Message-ID: <20230101162340.26842-1-dev@vitlabuda.cz> The 'code' field in ICMPv4 and ICMPv6 echo messages didn't use to be explicitly set to zero, which resulted in malformed ping packets (with incorrect code) being generated in case a custom payload pattern was set using the '-p' command line option. --- networking/ping.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/networking/ping.c b/networking/ping.c index 9805695a1..1c387353f 100644 --- a/networking/ping.c +++ b/networking/ping.c @@ -563,7 +563,7 @@ static void sendping4(int junk UNUSED_PARAM) memset(pkt, G.pattern, datalen + ICMP_MINLEN + 4); pkt->icmp_type = ICMP_ECHO; - /*pkt->icmp_code = 0;*/ + pkt->icmp_code = 0; pkt->icmp_cksum = 0; /* cksum is calculated with this field set to 0 */ pkt->icmp_seq = htons(G.ntransmitted); /* don't ++ here, it can be a macro */ pkt->icmp_id = myid; @@ -586,7 +586,7 @@ static void sendping6(int junk UNUSED_PARAM) memset(pkt, G.pattern, datalen + sizeof(struct icmp6_hdr) + 4); pkt->icmp6_type = ICMP6_ECHO_REQUEST; - /*pkt->icmp6_code = 0;*/ + pkt->icmp6_code = 0; /*pkt->icmp6_cksum = 0;*/ pkt->icmp6_seq = htons(G.ntransmitted); /* don't ++ here, it can be a macro */ pkt->icmp6_id = myid; -- 2.38.1 From ravitripathi.1310 at gmail.com Mon Jan 2 11:48:53 2023 From: ravitripathi.1310 at gmail.com (Ravi Tripathi) Date: Mon, 2 Jan 2023 17:18:53 +0530 Subject: Query regarding busybox Message-ID: Hello Team Can you please help me with a query regarding busybox. Query: My embedded project is currently using busybox version 1.29.3. And for creating a performance optimization tool I need few utilities like tar with option --use-compress-program=LZ4 df -B pgrep (full version) chrt lz4 Among these 5 utilities, lz4 and chrt are available in v1.29.3 but df and tar does not have required option. pgrep is not available. Could you tell me which version could i refer for having all utilities? Regards *Ravi Tripathi* *8884609031* *wa.me/91 **8884609031* -------------- next part -------------- An HTML attachment was scrubbed... URL: From yetanothergeek at gmail.com Mon Jan 2 12:39:30 2023 From: yetanothergeek at gmail.com (Jeff Pohlmeyer) Date: Mon, 2 Jan 2023 06:39:30 -0600 Subject: Query regarding busybox In-Reply-To: References: Message-ID: On Mon, Jan 2, 2023 at 5:50 AM Ravi Tripathi wrote: > My embedded project is currently using busybox version 1.29.3. > And for creating a performance optimization tool I need few utilities like > > tar with option --use-compress-program=LZ4 > df -B > pgrep (full version) > chrt > lz4 > Could you tell me which version could i refer for having all utilities? The latest busybox tar has options for --lzma and -a (autodetect), but you could just use a pipe for other cases. It also has an lzma applet and support for df -B Not sure what features you need from pgrep, but the current busybox help shows these options: -l Show command name too -a Show command line too -f Match against entire command line -n Show the newest process only -o Show the oldest process only -v Negate the match -x Match whole name (not substring) -s Match session ID (0 for current) -P Match parent process ID (There is also a "pidof" applet which might be useful) -- Jeff From lists at kaiser.cx Thu Jan 5 11:12:29 2023 From: lists at kaiser.cx (Martin Kaiser) Date: Thu, 5 Jan 2023 12:12:29 +0100 Subject: git tag for 1.36 Message-ID: <20230105111229.of654fyxur26kcqb@viti.kaiser.cx> Hi Denys, I've just seen that you released busybox 1.36. Would you mind creating a 1_36_0 tag in the repository? This would make it easier for me to import the new version. Thanks & best regards, Martin From vda.linux at googlemail.com Thu Jan 5 15:24:46 2023 From: vda.linux at googlemail.com (Denys Vlasenko) Date: Thu, 5 Jan 2023 16:24:46 +0100 Subject: [PATCH] ed: don't use memcpy with overlapping memory regions In-Reply-To: <31SAK73EXP4VU.3IXCK0OYH8096@8pit.net> References: <20220208192930.15089-1-soeren@soeren-tempel.net> <21PHGKH89PGCJ.3P3652PG9R9MG@8pit.net> <34KG665IX3UJS.3FW56Z09RA3AK@8pit.net> <31SAK73EXP4VU.3IXCK0OYH8096@8pit.net> Message-ID: Applied, thank you On Thu, Dec 22, 2022 at 3:30 PM S?ren Tempel wrote: > > PING. > > Any love for good old ed(1)? > > S?ren Tempel wrote: > > Pinging again as this is still unfixed and the proposed fix is rather trivial. > > > > S?ren Tempel wrote: > > > Ping. > > > > > > soeren at soeren-tempel.net wrote: > > > > From: S?ren Tempel > > > > > > > > The memcpy invocations in the subCommand function, modified by this > > > > commit, previously used memcpy with overlapping memory regions. This is > > > > undefined behavior. On Alpine Linux, it causes BusyBox ed to crash since > > > > we compile BusyBox with -D_FORTIFY_SOURCE=2 and our fortify-headers > > > > implementation catches this source of undefined behavior [0]. The issue > > > > can only be triggered if the replacement string is the same size or > > > > shorter than the old string. > > > > > > > > Looking at the code, it seems to me that a memmove(3) is what was > > > > actually intended here, this commit modifies the code accordingly. > > > > > > > > [0]: https://gitlab.alpinelinux.org/alpine/aports/-/issues/13504 > > > > --- > > > > editors/ed.c | 2 +- > > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > > > diff --git a/editors/ed.c b/editors/ed.c > > > > index 209ce9942..4a84f7433 100644 > > > > --- a/editors/ed.c > > > > +++ b/editors/ed.c > > > > @@ -720,7 +720,7 @@ static void subCommand(const char *cmd, int num1, int num2) > > > > if (deltaLen <= 0) { > > > > memcpy(&lp->data[offset], newStr, newLen); > > > > if (deltaLen) { > > > > - memcpy(&lp->data[offset + newLen], > > > > + memmove(&lp->data[offset + newLen], > > > > &lp->data[offset + oldLen], > > > > lp->len - offset - oldLen); > > > > > > > > _______________________________________________ > > > > busybox mailing list > > > > busybox at busybox.net > > > > http://lists.busybox.net/mailman/listinfo/busybox > > > _______________________________________________ > > > busybox mailing list > > > busybox at busybox.net > > > http://lists.busybox.net/mailman/listinfo/busybox > > _______________________________________________ > > busybox mailing list > > busybox at busybox.net > > http://lists.busybox.net/mailman/listinfo/busybox > _______________________________________________ > busybox mailing list > busybox at busybox.net > http://lists.busybox.net/mailman/listinfo/busybox From xoneca at gmail.com Thu Jan 5 16:50:31 2023 From: xoneca at gmail.com (Xabier Oneca -- xOneca) Date: Thu, 5 Jan 2023 17:50:31 +0100 Subject: git tag for 1.36 In-Reply-To: <20230105111229.of654fyxur26kcqb@viti.kaiser.cx> References: <20230105111229.of654fyxur26kcqb@viti.kaiser.cx> Message-ID: Hi, Would you mind creating a 1_36_0 tag in the repository? This would make > it easier for me to import the new version. > Yeah, it seems he forgot to push the tag.. XD It has just "backported" a commit in the 1.36 branch already.. :/ Cheers, Xabier Oneca_,,_ -------------- next part -------------- An HTML attachment was scrubbed... URL: From edre at google.com Thu Jan 5 17:05:56 2023 From: edre at google.com (Eric Roshan-Eisner) Date: Thu, 5 Jan 2023 09:05:56 -0800 Subject: [PATCH] tsort: avoid use-after-free Message-ID: <20230105170556.2352620-1-edre@google.com> The old code freed nodes inline after processing them. This works fine unless the input has cycles, in which case future iterations will try to decrement in_count for the freed nodes. The new code defers freeing all nodes until the processing is done. --- coreutils/tsort.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/coreutils/tsort.c b/coreutils/tsort.c index dedb65b15..15c8ecbf2 100644 --- a/coreutils/tsort.c +++ b/coreutils/tsort.c @@ -101,6 +101,8 @@ int tsort_main(int argc UNUSED_PARAM, char **argv) ssize_t len; struct node *a; int cycles; + unsigned i; + unsigned remaining; INIT_G(); @@ -152,16 +154,17 @@ int tsort_main(int argc UNUSED_PARAM, char **argv) * - if any nodes are left, they form cycles. */ cycles = 0; - while (G.nodes_len) { + remaining = G.nodes_len; + + while (remaining) { struct node *n; - unsigned i; /* Search for first node with no incoming edges */ - for (i = 0; i < G.nodes_len; i++) { + for (i = 0; i < remaining; i++) { if (!G.nodes[i]->in_count) break; } - if (i == G.nodes_len) { + if (i == remaining) { /* Must be a cycle; arbitraily break it at node 0 */ cycles++; i = 0; @@ -170,17 +173,22 @@ int tsort_main(int argc UNUSED_PARAM, char **argv) #endif } - /* Remove the node (need no longer maintain sort) */ + /* Swap the node to the back (need no longer maintain sort) */ n = G.nodes[i]; - G.nodes[i] = G.nodes[--G.nodes_len]; + G.nodes[i] = G.nodes[--remaining]; + G.nodes[remaining] = n; /* And remove its outgoing edges */ for (i = 0; i < n->out_count; i++) n->out[i]->in_count--; - free(n->out); puts(n->name); - free(n); + } + + /* Free all nodes */ + for (i = 0; i < G.nodes_len; i++) { + free(G.nodes[i]->out); + free(G.nodes[i]); } free(G.nodes); -- 2.39.0.314.g84b9a713c41-goog From asmadeus at codewreck.org Thu Jan 5 17:45:35 2023 From: asmadeus at codewreck.org (Dominique Martinet) Date: Fri, 6 Jan 2023 02:45:35 +0900 Subject: [PATCH v2] sed: check errors writing file with sed -i In-Reply-To: <20221116101859.33414-1-asmadeus@codewreck.org> References: <20221116101859.33414-1-asmadeus@codewreck.org> Message-ID: Hi Denys, Dominique Martinet wrote on Wed, Nov 16, 2022 at 07:18:59PM +0900: > From: Dominique Martinet > > sed would currently not error if write failed when modifying a file. I noticed this never got applied and isn't part of the 1.36 release, should I resend this? Thanks -- Dominique From soeren at soeren-tempel.net Thu Jan 5 20:39:09 2023 From: soeren at soeren-tempel.net (=?UTF-8?Q?S=C3=B6ren?= Tempel) Date: Thu, 05 Jan 2023 21:39:09 +0100 Subject: BusyBox 1.36.0 regression: Segfaults on i386 musl libc Message-ID: <23OF6NG55ND97.34V21YCK0QJEJ@8pit.net> Hi, I am the maintainer of the BusyBox package for Alpine Linux. While upgrading that package from 1.35.0 to 1.36.0 I noticed a segfault on Alpine x86, on all other architectures BusyBox 1.36.0 builds fine and passes the tests. On x86 though it segfaults with any command-line argument, for example: $ make defconfig $ make $ gdb --args ./busybox_unstripped (gdb) run Starting program: /home/buildozer/aports/main/busybox/src/build-dynamic/busybox_unstripped Program received signal SIGSEGV, Segmentation fault. 0xf7fc24e0 in do_relocs (dso=dso at entry=0xf7ffca20 , rel=0x565578e4, rel_size=8712, stride=2) at ldso/dynlink.c:471 471 ldso/dynlink.c: No such file or directory. (gdb) bt #0 0xf7fc24e0 in do_relocs (dso=dso at entry=0xf7ffca20 , rel=0x565578e4, rel_size=8712, stride=2) at ldso/dynlink.c:471 #1 0xf7fc263f in reloc_all (p=p at entry=0xf7ffca20 ) at ldso/dynlink.c:1375 #2 0xf7fc473e in __dls3 (sp=0xffffdcf0, auxv=0xffffdd3c) at ldso/dynlink.c:1974 #3 0xf7fc3eab in __dls2 (base=, sp=) at ldso/dynlink.c:1719 #4 0xf7fc19c9 in _dlstart () from /lib/ld-musl-i386.so.1 Looking at the backtrace, it seems that it segfaults in musl's dynamic loader. Since BusyBox 1.35.0 worked fine on x86 I bisected this and it turns out that this is a regression introduced in commit a96ccbefe417aaac6a2ce59c788e01fc0f83902f [1]. If I disable SHA/MD5 hardware acceleration then BusyBox 1.36.0 builds fine and passes all tests on Alpine Linux x86. Any idea what particular part of the referenced commit might be causing this? Greetings, S?ren [1]: https://git.busybox.net/busybox/commit/?id=a96ccbefe417aaac6a2ce59c788e01fc0f83902f From ncopa at alpinelinux.org Fri Jan 6 09:34:15 2023 From: ncopa at alpinelinux.org (Natanael Copa) Date: Fri, 6 Jan 2023 10:34:15 +0100 Subject: BusyBox 1.36.0 regression: Segfaults on i386 musl libc In-Reply-To: <23OF6NG55ND97.34V21YCK0QJEJ@8pit.net> References: <23OF6NG55ND97.34V21YCK0QJEJ@8pit.net> Message-ID: <20230106103415.7eec7ac8@ncopa-desktop.lan> On Thu, 05 Jan 2023 21:39:09 +0100 S?ren Tempel wrote: > Hi, > > I am the maintainer of the BusyBox package for Alpine Linux. While > upgrading that package from 1.35.0 to 1.36.0 I noticed a segfault > on Alpine x86, on all other architectures BusyBox 1.36.0 builds > fine and passes the tests. On x86 though it segfaults with any > command-line argument, for example: > > $ make defconfig > $ make > $ gdb --args ./busybox_unstripped > (gdb) run > Starting program: /home/buildozer/aports/main/busybox/src/build-dynamic/busybox_unstripped > > Program received signal SIGSEGV, Segmentation fault. > 0xf7fc24e0 in do_relocs (dso=dso at entry=0xf7ffca20 , rel=0x565578e4, rel_size=8712, stride=2) at ldso/dynlink.c:471 > 471 ldso/dynlink.c: No such file or directory. > (gdb) bt > #0 0xf7fc24e0 in do_relocs (dso=dso at entry=0xf7ffca20 , rel=0x565578e4, rel_size=8712, stride=2) at ldso/dynlink.c:471 > #1 0xf7fc263f in reloc_all (p=p at entry=0xf7ffca20 ) at ldso/dynlink.c:1375 > #2 0xf7fc473e in __dls3 (sp=0xffffdcf0, auxv=0xffffdd3c) at ldso/dynlink.c:1974 > #3 0xf7fc3eab in __dls2 (base=, sp=) at ldso/dynlink.c:1719 > #4 0xf7fc19c9 in _dlstart () from /lib/ld-musl-i386.so.1 > > Looking at the backtrace, it seems that it segfaults in musl's dynamic > loader. Since BusyBox 1.35.0 worked fine on x86 I bisected this and it > turns out that this is a regression introduced in commit > a96ccbefe417aaac6a2ce59c788e01fc0f83902f [1]. If I disable SHA/MD5 > hardware acceleration then BusyBox 1.36.0 builds fine and passes all > tests on Alpine Linux x86. > > Any idea what particular part of the referenced commit might be causing this? I believe this happens due to ebx is clobbered which is needed for position independent code (PIC) on 32 bit x86. I also wonder if the asm needs to be volatile. Try something like this: diff --git a/libbb/hash_md5_sha.c b/libbb/hash_md5_sha.c index 880ffab01..d2351d3e6 100644 --- a/libbb/hash_md5_sha.c +++ b/libbb/hash_md5_sha.c @@ -17,8 +17,11 @@ # if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) static void cpuid(unsigned *eax, unsigned *ebx, unsigned *ecx, unsigned *edx) { - asm ("cpuid" - : "=a"(*eax), "=b"(*ebx), "=c"(*ecx), "=d"(*edx) + asm volatile ( + "mov %%ebx, %%esi;" /* save %ebx PIC register */ + "cpuid;" + "xchg %%ebx, %%esi;" + : "=a"(*eax), "=S"(*ebx), "=c"(*ecx), "=d"(*edx) : "0"(*eax), "1"(*ebx), "2"(*ecx), "3"(*edx) ); } > > Greetings, > S?ren > > [1]: > https://git.busybox.net/busybox/commit/?id=a96ccbefe417aaac6a2ce59c788e01fc0f83902f > _______________________________________________ busybox mailing list > busybox at busybox.net > http://lists.busybox.net/mailman/listinfo/busybox From dxdt at dev.snart.me Fri Jan 6 19:50:36 2023 From: dxdt at dev.snart.me (David Timber) Date: Sat, 7 Jan 2023 03:50:36 +0800 Subject: BusyBox and IPv6 Message-ID: G'day, Using BusyBox for few years, I've noticed that BusyBox is nowhere near IPv6 ready out of the box. To give you guys some context, here's what I've found so far. ifupdown applet only implements these methods(ifupdown.c:535): static const struct method_t methods6[] ALIGN_PTR = { # if ENABLE_FEATURE_IFUPDOWN_IP ?? ?{ "v4tunnel" , v4tunnel_up???? , v4tunnel_down?? , }, # endif ?? ?{ "static"?? , static_up6????? , static_down6??? , }, ?? ?{ "manual"?? , manual_up_down6 , manual_up_down6 , }, ?? ?{ "loopback" , loopback_up6??? , loopback_down6? , }, }; Currently, there's not much can be done for IPv6 using /etc/network/interfaces. At first, I tried to use udhcpc6 since udhcpc is the default implementation BusyBox uses. I've found that there's been some progress, but I doubt there's anyone actually using this. The default script shipped with Buildroot has a bug where it deletes IPv4 default routes when executed for IPv6 leases. The following shell function seems to have been written for interop with an external NDP implementation that's only responsible for setting IPv6 default routes. wait_for_ipv6_default_route() { ?? ?printf "Waiting for IPv6 default route to appear" ?? ?while [ $IF_WAIT_DELAY -gt 0 ]; do ?? ???? if [ -z "$(ip -6 route list | grep default)" ]; then ?? ???? ??? printf "\n" ?? ???? ??? return ?? ???? fi ?? ???? sleep 1 ?? ???? printf "." ?? ???? : $((IF_WAIT_DELAY -= 1)) ?? ?done ?? ?printf " timeout!\n" } This function does not make sense at all when only udhcpc6 is used - the script will always wait because there's no one from BusyBox family that sets default IPv6 routes! If anything, RA is not handled by BusyBox at all. I think involving more than one implementation to configure IPv6 is a bad idea anyways. I wonder what the other program was(that the functions awaits). And there's this rant of a frustrated dev: https://git.busybox.net/busybox/tree/docs/ifupdown_design.txt So, my questions being: how do people usually enable IPv6 on their embedded systems? Do they just go on using packages like dhclient and odhcp6c? Is there a motion to make BusyBox's own DHCPv6 and RA implementation? It seems like handling network stack is too much for BusyBox. References(some of these are ancient): http://lists.busybox.net/pipermail/buildroot/2019-May/553084.html http://lists.busybox.net/pipermail/buildroot/2021-February/302702.html https://udhcp.busybox.net/README.udhcpc https://udhcp.busybox.net/ https://github.com/openwrt/odhcp6c From steffen at sdaoden.eu Fri Jan 6 20:07:45 2023 From: steffen at sdaoden.eu (Steffen Nurpmeso) Date: Fri, 06 Jan 2023 21:07:45 +0100 Subject: BusyBox 1.36.0 regression: Segfaults on i386 musl libc In-Reply-To: <20230106103415.7eec7ac8@ncopa-desktop.lan> References: <23OF6NG55ND97.34V21YCK0QJEJ@8pit.net> <20230106103415.7eec7ac8@ncopa-desktop.lan> Message-ID: <20230106200745.YEwGD%steffen@sdaoden.eu> Natanael Copa wrote in <20230106103415.7eec7ac8 at ncopa-desktop.lan>: |On Thu, 05 Jan 2023 21:39:09 +0100 |S?ren Tempel wrote: ... |> Looking at the backtrace, it seems that it segfaults in musl's dynamic |> loader. Since BusyBox 1.35.0 worked fine on x86 I bisected this and it |> turns out that this is a regression introduced in commit |> a96ccbefe417aaac6a2ce59c788e01fc0f83902f [1]. If I disable SHA/MD5 |> hardware acceleration then BusyBox 1.36.0 builds fine and passes all |> tests on Alpine Linux x86. ... |I believe this happens due to ebx is clobbered which is needed for |position independent code (PIC) on 32 bit x86. | |I also wonder if the asm needs to be volatile. | |Try something like this: | |diff --git a/libbb/hash_md5_sha.c b/libbb/hash_md5_sha.c |index 880ffab01..d2351d3e6 100644 |--- a/libbb/hash_md5_sha.c |+++ b/libbb/hash_md5_sha.c |@@ -17,8 +17,11 @@ | # if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) | static void cpuid(unsigned *eax, unsigned *ebx, unsigned *ecx, unsigned \ | *edx) | { |- asm ("cpuid" |- : "=a"(*eax), "=b"(*ebx), "=c"(*ecx), "=d"(*edx) |+ asm volatile ( |+ "mov %%ebx, %%esi;" /* save %ebx PIC register */ |+ "cpuid;" |+ "xchg %%ebx, %%esi;" |+ : "=a"(*eax), "=S"(*ebx), "=c"(*ecx), "=d"(*edx) |: "0"(*eax), "1"(*ebx), "2"(*ecx), "3"(*edx) | ); Shouldn't it be enough to place "%ebx" in the "third operand"? The following surely worked twenty years ago: asm volatile( "cpuid" : "=&a"(i), "=&d"(nedx) : "0"(0x80000001) : "%ebx", "%ecx" ); --steffen | |Der Kragenbaer, The moon bear, |der holt sich munter he cheerfully and one by one |einen nach dem anderen runter wa.ks himself off |(By Robert Gernhardt) From soeren at soeren-tempel.net Sat Jan 7 12:01:59 2023 From: soeren at soeren-tempel.net (=?UTF-8?Q?S=C3=B6ren?= Tempel) Date: Sat, 07 Jan 2023 13:01:59 +0100 Subject: BusyBox 1.36.0 regression: Segfaults on i386 musl libc In-Reply-To: <20230106103415.7eec7ac8@ncopa-desktop.lan> References: <23OF6NG55ND97.34V21YCK0QJEJ@8pit.net> <20230106103415.7eec7ac8@ncopa-desktop.lan> Message-ID: <2F4MCGE05XQJH.2GZEOO3O0Q0DP@8pit.net> Hello, Natanael Copa wrote: > diff --git a/libbb/hash_md5_sha.c b/libbb/hash_md5_sha.c > index 880ffab01..d2351d3e6 100644 > --- a/libbb/hash_md5_sha.c > +++ b/libbb/hash_md5_sha.c > @@ -17,8 +17,11 @@ > # if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) > static void cpuid(unsigned *eax, unsigned *ebx, unsigned *ecx, unsigned *edx) > { > - asm ("cpuid" > - : "=a"(*eax), "=b"(*ebx), "=c"(*ecx), "=d"(*edx) > + asm volatile ( > + "mov %%ebx, %%esi;" /* save %ebx PIC register */ > + "cpuid;" > + "xchg %%ebx, %%esi;" > + : "=a"(*eax), "=S"(*ebx), "=c"(*ecx), "=d"(*edx) > : "0"(*eax), "1"(*ebx), "2"(*ecx), "3"(*edx) > ); > } Unfortunately, this does not fix the segfault. Since the segfault occurs in musl's dynamic loader I also don't think that this code is reached/executed. Instead, this seems to be a problem with the symbols of the provided assembly file. I am currently debugging this on a96ccbefe417aaac6a2ce59c788e01fc0f83902f. If I remove the PSHUFFLE_BYTE_FLIP_MASK definition (and the instruction using it) in hash_md5_sha256_x86-32_shaNI.S from the checkout for this commit then the segfault doesn't occur. So this does definitely seem to be a problem with the hash_md5_sha256_x86-32_shaNI.S assembly file... Greetings, S?ren From stokito at gmail.com Sat Jan 7 12:35:56 2023 From: stokito at gmail.com (stokito) Date: Sat, 7 Jan 2023 14:35:56 +0200 Subject: [PATCH 1/2] wget: Use HEAD for --spider In-Reply-To: <20220508171354.56073-1-stokito@gmail.com> References: <20220508171354.56073-1-stokito@gmail.com> Message-ID: <5ffbda34-7795-eb50-2f60-e3a33dd074be@gmail.com> Hi, Last year I sent a set of patches for wget to send HTTP methods other that just GET and POST. This will make the wget to be used instead of curl for basic REST API usage. Could you please take a look, that would be great. http://lists.busybox.net/pipermail/busybox/2022-May/089712.html Regards, Sergey From soeren at soeren-tempel.net Sun Jan 8 19:22:31 2023 From: soeren at soeren-tempel.net (=?UTF-8?Q?S=C3=B6ren?= Tempel) Date: Sun, 08 Jan 2023 20:22:31 +0100 Subject: BusyBox 1.36.0 regression: Segfaults on i386 musl libc In-Reply-To: <2F4MCGE05XQJH.2GZEOO3O0Q0DP@8pit.net> References: <23OF6NG55ND97.34V21YCK0QJEJ@8pit.net> <20230106103415.7eec7ac8@ncopa-desktop.lan> <2F4MCGE05XQJH.2GZEOO3O0Q0DP@8pit.net> Message-ID: <3B90H6Q18EJGG.3818B9FB1N688@8pit.net> Investigated this further. The problem is a text relocation created by the hash_md5_sha256_x86-32_shaNI.S file. When compiling BusyBox with LDFLAGS=-Wl,-z,text one is warned about the following relocation by gcc: /usr/lib/gcc/i586-alpine-linux-musl/12.2.1/../../../../i586-alpine-linux-musl/bin/ld: libbb/lib.a(hash_md5_sha_x86-32_shaNI.o): warning: relocation in read-only section `.text.sha1_process_block64_shaNI' /usr/lib/gcc/i586-alpine-linux-musl/12.2.1/../../../../i586-alpine-linux-musl/bin/ld: read-only segment has dynamic relocations The Linux Kernel, from which the assembly was copied, does addressing relative to the %pic register to avoid this relocation it seems [1]: movdqa PSHUFFLE_BYTE_FLIP_MASK(%rip), SHUF_MASK However, the %rip register is AFAIK not available for i386 and since I am personally not an x86 wizard I have no idea how to best rewrite this code in a way that it doesn't require dynamic relocations. [1]: https://github.com/torvalds/linux/blob/94a855111ed9106971ca2617c5d075269e6aefde/arch/x86/crypto/sha1_ni_asm.S#L112 S?ren Tempel wrote: > Hello, > > Natanael Copa wrote: > > diff --git a/libbb/hash_md5_sha.c b/libbb/hash_md5_sha.c > > index 880ffab01..d2351d3e6 100644 > > --- a/libbb/hash_md5_sha.c > > +++ b/libbb/hash_md5_sha.c > > @@ -17,8 +17,11 @@ > > # if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) > > static void cpuid(unsigned *eax, unsigned *ebx, unsigned *ecx, unsigned *edx) > > { > > - asm ("cpuid" > > - : "=a"(*eax), "=b"(*ebx), "=c"(*ecx), "=d"(*edx) > > + asm volatile ( > > + "mov %%ebx, %%esi;" /* save %ebx PIC register */ > > + "cpuid;" > > + "xchg %%ebx, %%esi;" > > + : "=a"(*eax), "=S"(*ebx), "=c"(*ecx), "=d"(*edx) > > : "0"(*eax), "1"(*ebx), "2"(*ecx), "3"(*edx) > > ); > > } > > Unfortunately, this does not fix the segfault. Since the segfault occurs > in musl's dynamic loader I also don't think that this code is > reached/executed. Instead, this seems to be a problem with the symbols > of the provided assembly file. > > I am currently debugging this on a96ccbefe417aaac6a2ce59c788e01fc0f83902f. > If I remove the PSHUFFLE_BYTE_FLIP_MASK definition (and the instruction > using it) in hash_md5_sha256_x86-32_shaNI.S from the checkout for this > commit then the segfault doesn't occur. So this does definitely seem to > be a problem with the hash_md5_sha256_x86-32_shaNI.S assembly file... > > Greetings, > S?ren > _______________________________________________ > busybox mailing list > busybox at busybox.net > http://lists.busybox.net/mailman/listinfo/busybox From ncopa at alpinelinux.org Tue Jan 10 12:11:12 2023 From: ncopa at alpinelinux.org (Natanael Copa) Date: Tue, 10 Jan 2023 13:11:12 +0100 Subject: BusyBox 1.36.0 regression: Segfaults on i386 musl libc In-Reply-To: <3B90H6Q18EJGG.3818B9FB1N688@8pit.net> References: <23OF6NG55ND97.34V21YCK0QJEJ@8pit.net> <20230106103415.7eec7ac8@ncopa-desktop.lan> <2F4MCGE05XQJH.2GZEOO3O0Q0DP@8pit.net> <3B90H6Q18EJGG.3818B9FB1N688@8pit.net> Message-ID: <20230110131112.4d6022cc@ncopa-desktop> On Sun, 08 Jan 2023 20:22:31 +0100 S?ren Tempel wrote: > Investigated this further. The problem is a text relocation created by > the hash_md5_sha256_x86-32_shaNI.S file. When compiling BusyBox with > LDFLAGS=-Wl,-z,text one is warned about the following relocation by gcc: > > /usr/lib/gcc/i586-alpine-linux-musl/12.2.1/../../../../i586-alpine-linux-musl/bin/ld: libbb/lib.a(hash_md5_sha_x86-32_shaNI.o): warning: relocation in read-only section `.text.sha1_process_block64_shaNI' > /usr/lib/gcc/i586-alpine-linux-musl/12.2.1/../../../../i586-alpine-linux-musl/bin/ld: read-only segment has dynamic relocations > Also scanelf confirms that there are textrels in 3 places: $ scanelf --textrels busybox_unstripped TYPE TEXTRELS FILE busybox_unstripped: (memory/data?) [r_offset=0x816E] r_type=8 in (optimized out: previous sha256_process_block64_shaNI) [closest_prev_sym=0x8158] busybox_unstripped: (memory/data?) [r_offset=0x8173] r_type=8 in (optimized out: previous sha256_process_block64_shaNI) [closest_prev_sym=0x8158] busybox_unstripped: (memory/data?) [r_offset=0x8415] r_type=8 in (optimized out: previous sha1_process_block64_shaNI) [closest_prev_sym=0x8400] ET_DYN busybox_unstripped > The Linux Kernel, from which the assembly was copied, does addressing > relative to the %pic register to avoid this relocation it seems [1]: > > movdqa PSHUFFLE_BYTE_FLIP_MASK(%rip), SHUF_MASK > > However, the %rip register is AFAIK not available for i386 and since I > am personally not an x86 wizard I have no idea how to best rewrite this > code in a way that it doesn't require dynamic relocations. For sha1 we can (ab)use the stack for the PSHUFFLE_BYTE_FLIP_MASK data when we do position independent code (PIC): diff --git a/libbb/hash_md5_sha_x86-32_shaNI.S b/libbb/hash_md5_sha_x86-32_shaNI.S index 7455a29f0..4c3d1ea88 100644 --- a/libbb/hash_md5_sha_x86-32_shaNI.S +++ b/libbb/hash_md5_sha_x86-32_shaNI.S @@ -49,7 +49,16 @@ sha1_process_block64_shaNI: pinsrd $3, 76+4*4(%eax), E0 # load to uppermost 32-bit word shuf128_32 $0x1B, ABCD, ABCD # DCBA -> ABCD +#ifdef __PIC__ + pushl 0x0c0d0e0f + pushl 0x08090a0b + pushl 0x04050607 + pushl 0x00010203 + mova128 (%esp), %xmm7 + addl 16, %esp +#else mova128 PSHUFFLE_BYTE_FLIP_MASK, %xmm7 +#endif movu128 0*16(%eax), MSG0 pshufb %xmm7, MSG0 @@ -225,10 +234,11 @@ sha1_process_block64_shaNI: ret .size sha1_process_block64_shaNI, .-sha1_process_block64_shaNI - +#ifndef __PIC__ .section .rodata.cst16.PSHUFFLE_BYTE_FLIP_MASK, "aM", @progbits, 16 .balign 16 PSHUFFLE_BYTE_FLIP_MASK: .octa 0x000102030405060708090a0b0c0d0e0f +#endif #endif But for the $K256 data we'd need use the global offset table. Not sure exactly how to do that. > > [1]: https://github.com/torvalds/linux/blob/94a855111ed9106971ca2617c5d075269e6aefde/arch/x86/crypto/sha1_ni_asm.S#L112 > > S?ren Tempel wrote: > > Hello, > > > > Natanael Copa wrote: > > > diff --git a/libbb/hash_md5_sha.c b/libbb/hash_md5_sha.c > > > index 880ffab01..d2351d3e6 100644 > > > --- a/libbb/hash_md5_sha.c > > > +++ b/libbb/hash_md5_sha.c > > > @@ -17,8 +17,11 @@ > > > # if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) > > > static void cpuid(unsigned *eax, unsigned *ebx, unsigned *ecx, unsigned *edx) > > > { > > > - asm ("cpuid" > > > - : "=a"(*eax), "=b"(*ebx), "=c"(*ecx), "=d"(*edx) > > > + asm volatile ( > > > + "mov %%ebx, %%esi;" /* save %ebx PIC register */ > > > + "cpuid;" > > > + "xchg %%ebx, %%esi;" > > > + : "=a"(*eax), "=S"(*ebx), "=c"(*ecx), "=d"(*edx) > > > : "0"(*eax), "1"(*ebx), "2"(*ecx), "3"(*edx) > > > ); > > > } > > > > Unfortunately, this does not fix the segfault. Since the segfault occurs > > in musl's dynamic loader I also don't think that this code is > > reached/executed. Instead, this seems to be a problem with the symbols > > of the provided assembly file. > > > > I am currently debugging this on a96ccbefe417aaac6a2ce59c788e01fc0f83902f. > > If I remove the PSHUFFLE_BYTE_FLIP_MASK definition (and the instruction > > using it) in hash_md5_sha256_x86-32_shaNI.S from the checkout for this > > commit then the segfault doesn't occur. So this does definitely seem to > > be a problem with the hash_md5_sha256_x86-32_shaNI.S assembly file... > > > > Greetings, > > S?ren > > _______________________________________________ > > busybox mailing list > > busybox at busybox.net > > http://lists.busybox.net/mailman/listinfo/busybox From steffen at sdaoden.eu Tue Jan 10 19:03:24 2023 From: steffen at sdaoden.eu (Steffen Nurpmeso) Date: Tue, 10 Jan 2023 20:03:24 +0100 Subject: BusyBox 1.36.0 regression: Segfaults on i386 musl libc In-Reply-To: <20230110131112.4d6022cc@ncopa-desktop> References: <23OF6NG55ND97.34V21YCK0QJEJ@8pit.net> <20230106103415.7eec7ac8@ncopa-desktop.lan> <2F4MCGE05XQJH.2GZEOO3O0Q0DP@8pit.net> <3B90H6Q18EJGG.3818B9FB1N688@8pit.net> <20230110131112.4d6022cc@ncopa-desktop> Message-ID: <20230110190324.HRSux%steffen@sdaoden.eu> So i am really, really sorry to be here once again. (And without really looking) Natanael Copa wrote in <20230110131112.4d6022cc at ncopa-desktop>: |On Sun, 08 Jan 2023 20:22:31 +0100 |S?ren Tempel wrote: |> Investigated this further. The problem is a text relocation created by |> the hash_md5_sha256_x86-32_shaNI.S file. When compiling BusyBox with |> LDFLAGS=-Wl,-z,text one is warned about the following relocation by gcc: ... |But for the $K256 data we'd need use the global offset table. Not sure \ |exactly how to do that. Twenty years ago i head (this x86 not x86-64, say) #if SF_PIC .extern G(_GLOBAL_OFFSET_TABLE_) # define GET_GOT() \ pushl %ebx;\ call 1f;\ 1: popl %ebx;\ addl $G(_GLOBAL_OFFSET_TABLE_)+(.-1b), %ebx # define UNGET_GOT() \ popl %ebx # define GOT @GOT(%ebx) // external sym ('s ptr; leal + deref) # define GOTOFF @GOTOFF(%ebx) // local sym (leal) # define PLT @PLT // function # define PIC_INJ(X) X # define PICSO(OFF) OFF+4 // PIC-STACK-OFFSET #else // SF_PIC # define GET_GOT() # define UNGET_GOT() # define GOT # define GOTOFF # define PLT # define PIC_INJ(X) # define PICSO(OFF) OFF #endif // !SF_PIC Which then could be used like .if SF_PIC ;\ leal L(THELOCALSYM)GOTOFF, %eax;\ .else ; \ pushl $L(THELOCALSYM);\ .endif ;\ Function arguments loading from stack via movl __PICSO(4)(%esp), %edi I have not done that since about 2006 though. But should work, no? I was never so smart like the guys that did this IBT thing. --steffen | |Der Kragenbaer, The moon bear, |der holt sich munter he cheerfully and one by one |einen nach dem anderen runter wa.ks himself off |(By Robert Gernhardt) From erkska.dev at gmail.com Thu Jan 12 13:26:21 2023 From: erkska.dev at gmail.com (erkska dev) Date: Thu, 12 Jan 2023 15:26:21 +0200 Subject: Busybox su leaves EUID unchanged Message-ID: Hello. Environment: aarch64 embedded device, Linux 5.4.70, Busybox v1.33.0 # cat /etc/passwd root:!:0:0::/:/bin/sh userx:!:203:203::/:/bin/sh # id uid=0(root) gid=0(root) # su userx # id uid=203(userx) gid=203(userx) euid=0(root) Is this expected behaviour? From source I can see it does setuid() which should also modify euid. If not then what could be the issue? Thanks! -------------- next part -------------- An HTML attachment was scrubbed... URL: From ska-dietlibc at skarnet.org Thu Jan 12 17:48:24 2023 From: ska-dietlibc at skarnet.org (Laurent Bercot) Date: Thu, 12 Jan 2023 17:48:24 +0000 Subject: Busybox su leaves EUID unchanged In-Reply-To: References: Message-ID: ># su userx ># id >uid=203(userx) gid=203(userx) euid=0(root) > >Is this expected behaviour? From source I can see it does setuid() >which should also modify euid. If not then what could be the issue? As is often the case, the best debug tool here is strace :) What does "strace su userx id" say? -- Laurent From soeren at soeren-tempel.net Thu Jan 12 18:05:49 2023 From: soeren at soeren-tempel.net (=?UTF-8?Q?S=C3=B6ren?= Tempel) Date: Thu, 12 Jan 2023 19:05:49 +0100 Subject: [PATCH] umount: Implement -O option to unmount by mount options In-Reply-To: <20220619145223.11321-1-soeren@soeren-tempel.net> References: <20220619145223.11321-1-soeren@soeren-tempel.net> Message-ID: <2UUGHLYZS9L38.3I46X0XCDIJKQ@8pit.net> PING. This would be very helpful for us at Alpine since OpenRC uses this option to unmount all network file systems and there isn't any other clean way of achieving this. soeren at soeren-tempel.net wrote: > From: S?ren Tempel > > This commit adds a primitive implementation of the umount -O option, as > provided by util-linux's mount(8) implementation, to BusyBox. Similar to > -t, the option is intended to be used in conjunction with -a thereby > allowing users to filter which file systems are unmounted by mount > options. Multiple options can be specified with -O, all of which need to > match. Each option can be prefixed with `no` to indicate that no action > should be taken for a mount point with this mount option. > > At Alpine, this feature is often requested by users as the OpenRC > netmount service uses `umount -a -O _netdev` to amount all network > file systems [1] [2]. > > Discussion: > > * There is some minor code duplication between fsopt_matches and > fstype_matches. Adding some sort of utility function to resolve > this may allow for a further decrease in text segment size. > * The semantics of -O are not well described in the util-linux > mount(8) man page. Please review this carefully to ensure that the > implementation proposed here is semantically equivalent to the one > provided by util-linux. > > [1]: https://gitlab.alpinelinux.org/alpine/aports/-/issues/9923 > [2]: https://gitlab.alpinelinux.org/alpine/aports/-/issues/13789 > > Signed-off-by: S?ren Tempel > --- > I haven't tested this extensively yet. Feedback is most welcome. > > include/libbb.h | 1 + > libbb/Kbuild.src | 1 + > libbb/match_fsopts.c | 59 ++++++++++++++++++++++++++++++++++++++++++++ > util-linux/umount.c | 10 +++++--- > 4 files changed, 68 insertions(+), 3 deletions(-) > create mode 100644 libbb/match_fsopts.c > > diff --git a/include/libbb.h b/include/libbb.h > index 6aeec249d..1a203861e 100644 > --- a/include/libbb.h > +++ b/include/libbb.h > @@ -1585,6 +1585,7 @@ const struct hwtype *get_hwntype(int type) FAST_FUNC; > > > extern int fstype_matches(const char *fstype, const char *comma_list) FAST_FUNC; > +extern int fsopts_matches(const char *opts_list, const char *reqopts_list) FAST_FUNC; > #ifdef HAVE_MNTENT_H > extern struct mntent *find_mount_point(const char *name, int subdir_too) FAST_FUNC; > #endif > diff --git a/libbb/Kbuild.src b/libbb/Kbuild.src > index 653025e56..4bb8260b9 100644 > --- a/libbb/Kbuild.src > +++ b/libbb/Kbuild.src > @@ -120,6 +120,7 @@ lib-y += xrealloc_vector.o > > lib-$(CONFIG_MOUNT) += match_fstype.o > lib-$(CONFIG_UMOUNT) += match_fstype.o > +lib-$(CONFIG_UMOUNT) += match_fsopts.o > > lib-$(CONFIG_FEATURE_UTMP) += utmp.o > > diff --git a/libbb/match_fsopts.c b/libbb/match_fsopts.c > new file mode 100644 > index 000000000..fff236c7a > --- /dev/null > +++ b/libbb/match_fsopts.c > @@ -0,0 +1,59 @@ > +/* vi: set sw=4 ts=4: */ > +/* > + * Match fsopts for use in mount unmount -O. > + * > + * Returns 1 for a match, otherwise 0. > + * > + * Licensed under GPLv2 or later, see file LICENSE in this source tree. > + */ > + > +#include "libbb.h" > + > +static int FAST_FUNC fsopt_matches(const char *opts_list, const char *opt, size_t optlen) > +{ > + int match = 1; > + > + if (optlen > 2 && opt[0] == 'n' && opt[1] == '0') { > + match--; > + opt += 2; optlen -= 2; > + } > + > + while (1) { > + if (strncmp(opts_list, opt, optlen) == 0) { > + const char *after_opt = opts_list + optlen; > + if (*after_opt == '\0' || *after_opt == ',') > + return match; > + } > + > + opts_list = strchr(opts_list, ','); > + if (!opts_list) > + break; > + opts_list++; > + } > + > + return !match; > +} > + > +int FAST_FUNC fsopts_matches(const char *opts_list, const char *reqopts_list) > +{ > + if (!reqopts_list) > + return 1; /* no options requested, match anything */ > + > + while (1) { > + size_t len; > + const char *comma = strchr(reqopts_list, ','); > + if (!comma) > + len = strlen(reqopts_list); > + else > + len = comma - reqopts_list; > + > + if (len && !fsopt_matches(opts_list, reqopts_list, len)) > + return 0; > + > + if (!comma) > + break; > + reqopts_list = ++comma; > + } > + > + return 1; > +} > diff --git a/util-linux/umount.c b/util-linux/umount.c > index 23da32868..7a54cafb0 100644 > --- a/util-linux/umount.c > +++ b/util-linux/umount.c > @@ -41,7 +41,7 @@ > //kbuild:lib-$(CONFIG_UMOUNT) += umount.o > > //usage:#define umount_trivial_usage > -//usage: "[-rlf"IF_FEATURE_MTAB_SUPPORT("m")IF_FEATURE_MOUNT_LOOP("d")IF_FEATURE_UMOUNT_ALL("a")"] [-t FSTYPE] FILESYSTEM|DIRECTORY" > +//usage: "[-rlf"IF_FEATURE_MTAB_SUPPORT("m")IF_FEATURE_MOUNT_LOOP("d")IF_FEATURE_UMOUNT_ALL("a")"] [-t FSTYPE] [-O FSOPT] FILESYSTEM|DIRECTORY" > //usage:#define umount_full_usage "\n\n" > //usage: "Unmount filesystems\n" > //usage: IF_FEATURE_UMOUNT_ALL( > @@ -57,6 +57,7 @@ > //usage: "\n -d Free loop device if it has been used" > //usage: ) > //usage: "\n -t FSTYPE[,...] Unmount only these filesystem type(s)" > +//usage: "\n -O FSOPT[,...] Unmount only filesystem mounted with the given options" > //usage: > //usage:#define umount_example_usage > //usage: "$ umount /dev/hdc1\n" > @@ -82,7 +83,7 @@ static struct mntent *getmntent_r(FILE* stream, struct mntent* result, > #endif > > /* ignored: -c -v -i */ > -#define OPTION_STRING "fldnrat:" "cvi" > +#define OPTION_STRING "fldnrat:O:" "cvi" > #define OPT_FORCE (1 << 0) // Same as MNT_FORCE > #define OPT_LAZY (1 << 1) // Same as MNT_DETACH > #define OPT_FREELOOP (1 << 2) > @@ -96,6 +97,7 @@ int umount_main(int argc UNUSED_PARAM, char **argv) > int doForce; > struct mntent me; > FILE *fp; > + char *opts = NULL; > char *fstype = NULL; > int status = EXIT_SUCCESS; > unsigned opt; > @@ -105,7 +107,7 @@ int umount_main(int argc UNUSED_PARAM, char **argv) > struct mtab_list *next; > } *mtl, *m; > > - opt = getopt32(argv, OPTION_STRING, &fstype); > + opt = getopt32(argv, OPTION_STRING, &fstype, &opts); > //argc -= optind; > argv += optind; > > @@ -133,6 +135,8 @@ int umount_main(int argc UNUSED_PARAM, char **argv) > /* Match fstype (fstype==NULL matches always) */ > if (!fstype_matches(me.mnt_type, fstype)) > continue; > + if (!fsopts_matches(me.mnt_opts, opts)) > + continue; > m = xzalloc(sizeof(*m)); > m->next = mtl; > m->device = xstrdup(me.mnt_fsname); > _______________________________________________ > busybox mailing list > busybox at busybox.net > http://lists.busybox.net/mailman/listinfo/busybox From bryan at aetheros.com Thu Jan 12 23:17:44 2023 From: bryan at aetheros.com (Bryan Green) Date: Thu, 12 Jan 2023 15:17:44 -0800 Subject: patch command doesn't respect "\ No newline at end of file" Message-ID: The busybox version of the patch command is not handling patches correctly which end with "\ No newline at end of file". If the patch is from a file with a newline to one without, the patch command "succeeds" but does not remove the newline. If the patch is from a file without a newline to one with a newline, the patch command fails with a "Hunk ... FAILED" error. I'm using busybox v1.23.2, but I don't see any source code changes since then that would affect this behavior. Here is a log to show how I reproduced the issue. # echo -n line > nonewline /data # hexdump -Cv nonewline 00000000 6c 69 6e 65 |line| 00000004 # echo line > withnewline # hexdump -Cv withnewline 00000000 6c 69 6e 65 0a |line.| 00000005 # diff withnewline nonewline > rmnewline.patch # cat rmnewline.patch --- withnewline +++ nonewline @@ -1 +1 @@ -line +line \ No newline at end of file # cp withnewline withnewline.tmp # patch withnewline.tmp rmnewline.patch patching file withnewline.tmp # hexdump -Cv withnewline.tmp 00000000 6c 69 6e 65 0a |line.| 00000005 /data # diff nonewline withnewline > addnewline.patch /data # cat addnewline.patch --- nonewline +++ withnewline @@ -1 +1 @@ -line \ No newline at end of file +line /data # cp nonewline nonewline.tmp /data # patch nonewline.tmp addnewline.patch patching file nonewline.tmp Hunk 1 FAILED 1/1. -line -------------- next part -------------- An HTML attachment was scrubbed... URL: From peron.clem at gmail.com Fri Jan 13 09:48:42 2023 From: peron.clem at gmail.com (=?UTF-8?q?Cl=C3=A9ment=20P=C3=A9ron?=) Date: Fri, 13 Jan 2023 10:48:42 +0100 Subject: [PATCH][RFC] udhcp: add option to set CoS priority Message-ID: <20230113094842.214119-1-peron.clem@gmail.com> Some ISP, like the French ISP Orange uses DHCP messages with a CoS Priority of 6 otherwise they are not processed. Add an option to allow setting this property. Signed-off-by: Cl?ment P?ron --- networking/udhcp/Config.src | 8 ++++++++ networking/udhcp/d6_dhcpc.c | 6 ++++++ networking/udhcp/d6_packet.c | 14 ++++++++++++++ networking/udhcp/dhcpc.c | 12 +++++++++++- networking/udhcp/dhcpc.h | 2 ++ networking/udhcp/packet.c | 16 ++++++++++++++++ 6 files changed, 57 insertions(+), 1 deletion(-) diff --git a/networking/udhcp/Config.src b/networking/udhcp/Config.src index 7ba7f48fc..49d5d7ef1 100644 --- a/networking/udhcp/Config.src +++ b/networking/udhcp/Config.src @@ -137,6 +137,14 @@ config UDHCP_DEBUG Bigger values result in bigger code. Levels above 1 are very verbose and useful for debugging only. +config FEATURE_UDHCPC_COS + bool "Enable '-y priority' option for udhcpc" + default n + depends on UDHCPC || UDHCPC6 + help + At the cost of ~300 bytes, enables -y priority option. + This feature is typically not needed. + config UDHCPC_SLACK_FOR_BUGGY_SERVERS int "DHCP options slack buffer size" default 80 diff --git a/networking/udhcp/d6_dhcpc.c b/networking/udhcp/d6_dhcpc.c index cdd06188e..675914432 100644 --- a/networking/udhcp/d6_dhcpc.c +++ b/networking/udhcp/d6_dhcpc.c @@ -129,6 +129,7 @@ static const char udhcpc6_longopts[] ALIGN1 = ) /// IF_FEATURE_UDHCPC_ARPING("arping\0" No_argument "a") IF_FEATURE_UDHCP_PORT("client-port\0" Required_argument "P") + IF_FEATURE_UDHCPC_COS("cos\0" Required_argument "y") ; #endif /* Must match getopt32 option string order */ @@ -1153,6 +1154,9 @@ static void client_background(void) ////usage: IF_FEATURE_UDHCPC_ARPING( ////usage: "\n -a Use arping to validate offered address" ////usage: ) +//usage: IF_FEATURE_UDHCPC_COS( +//usage: "\n -y PRIORITY CoS value 0 .. 7, default 0" +//usage: ) //usage: "\n -l Send 'information request' instead of 'solicit'" //usage: "\n (used for servers which do not assign IPv6 addresses)" //usage: "\n -r IPv6 Request this address ('no' to not request any IP)" @@ -1214,6 +1218,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv) USE_FOR_MMU("b") ///IF_FEATURE_UDHCPC_ARPING("a") IF_FEATURE_UDHCP_PORT("P:") + IF_FEATURE_UDHCPC_COS("y:+") "v" "\0" IF_UDHCP_VERBOSE("vv") /* -v is a counter */ , udhcpc6_longopts @@ -1223,6 +1228,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv) , &list_O , &list_x IF_FEATURE_UDHCP_PORT(, &str_P) + IF_FEATURE_UDHCPC_COS(, &sk_prio) IF_UDHCP_VERBOSE(, &dhcp_verbose) ); requested_ipv6 = NULL; diff --git a/networking/udhcp/d6_packet.c b/networking/udhcp/d6_packet.c index 142de9b43..425037ada 100644 --- a/networking/udhcp/d6_packet.c +++ b/networking/udhcp/d6_packet.c @@ -68,6 +68,13 @@ int FAST_FUNC d6_send_raw_packet_from_client_data_ifindex( goto ret_msg; } + IF_FEATURE_UDHCPC_COS( + if (sk_prio) { + if (setsockopt_int(fd, SOL_SOCKET, SO_PRIORITY, sk_prio)) { + log1s("raw: SO_PRIORITY setsockopt() failed"); + } + }) + memset(&dest_sll, 0, sizeof(dest_sll)); memset(&packet, 0, offsetof(struct ip6_udp_d6_packet, data)); packet.data = *d6_pkt; /* struct copy */ @@ -153,6 +160,13 @@ int FAST_FUNC d6_send_kernel_packet_from_client_data_ifindex( } setsockopt_reuseaddr(fd); + IF_FEATURE_UDHCPC_COS( + if (sk_prio) { + if (setsockopt_int(fd, SOL_SOCKET, SO_PRIORITY, sk_prio)) { + log1s("raw: SO_PRIORITY setsockopt() failed"); + } + }) + memset(&sa, 0, sizeof(sa)); sa.sin6_family = AF_INET6; sa.sin6_port = htons(source_port); diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c index c757fb37c..7ff5ffde8 100644 --- a/networking/udhcp/dhcpc.c +++ b/networking/udhcp/dhcpc.c @@ -1085,6 +1085,13 @@ static int udhcp_raw_socket(int ifindex) } #endif +IF_FEATURE_UDHCPC_COS( + if (sk_prio) { + if (setsockopt_int(fd, SOL_SOCKET, SO_PRIORITY, sk_prio)) { + log1s("raw: SO_PRIORITY setsockopt() failed"); + } + }) + if (setsockopt_1(fd, SOL_PACKET, PACKET_AUXDATA) != 0) { if (errno != ENOPROTOOPT) log1s("can't set PACKET_AUXDATA on raw socket"); @@ -1162,7 +1169,7 @@ static void client_background(void) //usage:#endif //usage:#define udhcpc_trivial_usage //usage: "[-fbq"IF_UDHCP_VERBOSE("v")"RB]"IF_FEATURE_UDHCPC_ARPING(" [-a[MSEC]]")" [-t N] [-T SEC] [-A SEC|-n]\n" -//usage: " [-i IFACE]"IF_FEATURE_UDHCP_PORT(" [-P PORT]")" [-s PROG] [-p PIDFILE]\n" +//usage: " [-i IFACE]"IF_FEATURE_UDHCP_PORT(" [-P PORT]")" "IF_FEATURE_UDHCPC_COS(" [-y PRIORITY]")" [-s PROG] [-p PIDFILE]\n" //usage: " [-oC] [-r IP] [-V VENDOR] [-F NAME] [-x OPT:VAL]... [-O OPT]..." //usage:#define udhcpc_full_usage "\n" //usage: "\n -i IFACE Interface to use (default "CONFIG_UDHCPC_DEFAULT_INTERFACE")" @@ -1186,6 +1193,9 @@ static void client_background(void) //usage: IF_FEATURE_UDHCPC_ARPING( //usage: "\n -a[MSEC] Validate offered address with ARP ping" //usage: ) +//usage: IF_FEATURE_UDHCPC_COS( +//usage: "\n -y PRIORITY CoS value 0 .. 7, default 0" +//usage: ) //usage: "\n -r IP Request this IP address" //usage: "\n -o Don't request any options (unless -O is given)" //usage: "\n -O OPT Request option OPT from server (cumulative)" diff --git a/networking/udhcp/dhcpc.h b/networking/udhcp/dhcpc.h index 19b054b32..c033eb13f 100644 --- a/networking/udhcp/dhcpc.h +++ b/networking/udhcp/dhcpc.h @@ -7,6 +7,8 @@ PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN +IF_FEATURE_UDHCPC_COS(extern int sk_prio;) + struct client_data_t { uint8_t client_mac[6]; /* Our mac address */ IF_FEATURE_UDHCP_PORT(uint16_t port;) diff --git a/networking/udhcp/packet.c b/networking/udhcp/packet.c index 529978189..0babf451f 100644 --- a/networking/udhcp/packet.c +++ b/networking/udhcp/packet.c @@ -12,6 +12,8 @@ #include #include +IF_FEATURE_UDHCPC_COS(int sk_prio;) + #if ENABLE_UDHCPC || ENABLE_UDHCPD void FAST_FUNC udhcp_init_header(struct dhcp_packet *packet, char type) { @@ -121,6 +123,13 @@ int FAST_FUNC udhcp_send_raw_packet(struct dhcp_packet *dhcp_pkt, goto ret_msg; } + IF_FEATURE_UDHCPC_COS( + if (sk_prio) { + if (setsockopt_int(fd, SOL_SOCKET, SO_PRIORITY, sk_prio)) { + log1s("raw: SO_PRIORITY setsockopt() failed"); + } + }) + memset(&dest_sll, 0, sizeof(dest_sll)); memset(&packet, 0, offsetof(struct ip_udp_dhcp_packet, data)); packet.data = *dhcp_pkt; /* struct copy */ @@ -207,6 +216,13 @@ int FAST_FUNC udhcp_send_kernel_packet(struct dhcp_packet *dhcp_pkt, } setsockopt_reuseaddr(fd); + IF_FEATURE_UDHCPC_COS( + if (sk_prio) { + if (setsockopt_int(fd, SOL_SOCKET, SO_PRIORITY, sk_prio)) { + log1s("raw: SO_PRIORITY setsockopt() failed"); + } + }) + /* If interface carrier goes down, unless we * bind socket to a particular netdev, the packet * can go out through another interface, eg. via -- 2.34.1 From peron.clem at gmail.com Fri Jan 13 09:55:26 2023 From: peron.clem at gmail.com (=?UTF-8?B?Q2zDqW1lbnQgUMOpcm9u?=) Date: Fri, 13 Jan 2023 10:55:26 +0100 Subject: [PATCH][RFC] udhcp: add option to set CoS priority In-Reply-To: <20230113094842.214119-1-peron.clem@gmail.com> References: <20230113094842.214119-1-peron.clem@gmail.com> Message-ID: Hi, On Fri, 13 Jan 2023 at 10:48, Cl?ment P?ron wrote: > > Some ISP, like the French ISP Orange uses DHCP messages with > a CoS Priority of 6 otherwise they are not processed. > > Add an option to allow setting this property. Please note, that I get this information from this blog post https://www.lafois.com/tag/udhcp/ I'm still testing this patch and I'm unsure if we need to set the priority for all the sockets. I recovered a patch from Ubiquiti GPL archive where only udhcp_send_raw_packet() set the priority and not udhcp_send_kernel_packet(). I'm not sure which one is correct. Thanks for your help, BR, Clement > > Signed-off-by: Cl?ment P?ron > --- > networking/udhcp/Config.src | 8 ++++++++ > networking/udhcp/d6_dhcpc.c | 6 ++++++ > networking/udhcp/d6_packet.c | 14 ++++++++++++++ > networking/udhcp/dhcpc.c | 12 +++++++++++- > networking/udhcp/dhcpc.h | 2 ++ > networking/udhcp/packet.c | 16 ++++++++++++++++ > 6 files changed, 57 insertions(+), 1 deletion(-) > > diff --git a/networking/udhcp/Config.src b/networking/udhcp/Config.src > index 7ba7f48fc..49d5d7ef1 100644 > --- a/networking/udhcp/Config.src > +++ b/networking/udhcp/Config.src > @@ -137,6 +137,14 @@ config UDHCP_DEBUG > Bigger values result in bigger code. Levels above 1 > are very verbose and useful for debugging only. > > +config FEATURE_UDHCPC_COS > + bool "Enable '-y priority' option for udhcpc" > + default n > + depends on UDHCPC || UDHCPC6 > + help > + At the cost of ~300 bytes, enables -y priority option. > + This feature is typically not needed. > + > config UDHCPC_SLACK_FOR_BUGGY_SERVERS > int "DHCP options slack buffer size" > default 80 > diff --git a/networking/udhcp/d6_dhcpc.c b/networking/udhcp/d6_dhcpc.c > index cdd06188e..675914432 100644 > --- a/networking/udhcp/d6_dhcpc.c > +++ b/networking/udhcp/d6_dhcpc.c > @@ -129,6 +129,7 @@ static const char udhcpc6_longopts[] ALIGN1 = > ) > /// IF_FEATURE_UDHCPC_ARPING("arping\0" No_argument "a") > IF_FEATURE_UDHCP_PORT("client-port\0" Required_argument "P") > + IF_FEATURE_UDHCPC_COS("cos\0" Required_argument "y") > ; > #endif > /* Must match getopt32 option string order */ > @@ -1153,6 +1154,9 @@ static void client_background(void) > ////usage: IF_FEATURE_UDHCPC_ARPING( > ////usage: "\n -a Use arping to validate offered address" > ////usage: ) > +//usage: IF_FEATURE_UDHCPC_COS( > +//usage: "\n -y PRIORITY CoS value 0 .. 7, default 0" > +//usage: ) > //usage: "\n -l Send 'information request' instead of 'solicit'" > //usage: "\n (used for servers which do not assign IPv6 addresses)" > //usage: "\n -r IPv6 Request this address ('no' to not request any IP)" > @@ -1214,6 +1218,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv) > USE_FOR_MMU("b") > ///IF_FEATURE_UDHCPC_ARPING("a") > IF_FEATURE_UDHCP_PORT("P:") > + IF_FEATURE_UDHCPC_COS("y:+") > "v" > "\0" IF_UDHCP_VERBOSE("vv") /* -v is a counter */ > , udhcpc6_longopts > @@ -1223,6 +1228,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv) > , &list_O > , &list_x > IF_FEATURE_UDHCP_PORT(, &str_P) > + IF_FEATURE_UDHCPC_COS(, &sk_prio) > IF_UDHCP_VERBOSE(, &dhcp_verbose) > ); > requested_ipv6 = NULL; > diff --git a/networking/udhcp/d6_packet.c b/networking/udhcp/d6_packet.c > index 142de9b43..425037ada 100644 > --- a/networking/udhcp/d6_packet.c > +++ b/networking/udhcp/d6_packet.c > @@ -68,6 +68,13 @@ int FAST_FUNC d6_send_raw_packet_from_client_data_ifindex( > goto ret_msg; > } > > + IF_FEATURE_UDHCPC_COS( > + if (sk_prio) { > + if (setsockopt_int(fd, SOL_SOCKET, SO_PRIORITY, sk_prio)) { > + log1s("raw: SO_PRIORITY setsockopt() failed"); > + } > + }) > + > memset(&dest_sll, 0, sizeof(dest_sll)); > memset(&packet, 0, offsetof(struct ip6_udp_d6_packet, data)); > packet.data = *d6_pkt; /* struct copy */ > @@ -153,6 +160,13 @@ int FAST_FUNC d6_send_kernel_packet_from_client_data_ifindex( > } > setsockopt_reuseaddr(fd); > > + IF_FEATURE_UDHCPC_COS( > + if (sk_prio) { > + if (setsockopt_int(fd, SOL_SOCKET, SO_PRIORITY, sk_prio)) { > + log1s("raw: SO_PRIORITY setsockopt() failed"); > + } > + }) > + > memset(&sa, 0, sizeof(sa)); > sa.sin6_family = AF_INET6; > sa.sin6_port = htons(source_port); > diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c > index c757fb37c..7ff5ffde8 100644 > --- a/networking/udhcp/dhcpc.c > +++ b/networking/udhcp/dhcpc.c > @@ -1085,6 +1085,13 @@ static int udhcp_raw_socket(int ifindex) > } > #endif > > +IF_FEATURE_UDHCPC_COS( > + if (sk_prio) { > + if (setsockopt_int(fd, SOL_SOCKET, SO_PRIORITY, sk_prio)) { > + log1s("raw: SO_PRIORITY setsockopt() failed"); > + } > + }) > + > if (setsockopt_1(fd, SOL_PACKET, PACKET_AUXDATA) != 0) { > if (errno != ENOPROTOOPT) > log1s("can't set PACKET_AUXDATA on raw socket"); > @@ -1162,7 +1169,7 @@ static void client_background(void) > //usage:#endif > //usage:#define udhcpc_trivial_usage > //usage: "[-fbq"IF_UDHCP_VERBOSE("v")"RB]"IF_FEATURE_UDHCPC_ARPING(" [-a[MSEC]]")" [-t N] [-T SEC] [-A SEC|-n]\n" > -//usage: " [-i IFACE]"IF_FEATURE_UDHCP_PORT(" [-P PORT]")" [-s PROG] [-p PIDFILE]\n" > +//usage: " [-i IFACE]"IF_FEATURE_UDHCP_PORT(" [-P PORT]")" "IF_FEATURE_UDHCPC_COS(" [-y PRIORITY]")" [-s PROG] [-p PIDFILE]\n" > //usage: " [-oC] [-r IP] [-V VENDOR] [-F NAME] [-x OPT:VAL]... [-O OPT]..." > //usage:#define udhcpc_full_usage "\n" > //usage: "\n -i IFACE Interface to use (default "CONFIG_UDHCPC_DEFAULT_INTERFACE")" > @@ -1186,6 +1193,9 @@ static void client_background(void) > //usage: IF_FEATURE_UDHCPC_ARPING( > //usage: "\n -a[MSEC] Validate offered address with ARP ping" > //usage: ) > +//usage: IF_FEATURE_UDHCPC_COS( > +//usage: "\n -y PRIORITY CoS value 0 .. 7, default 0" > +//usage: ) > //usage: "\n -r IP Request this IP address" > //usage: "\n -o Don't request any options (unless -O is given)" > //usage: "\n -O OPT Request option OPT from server (cumulative)" > diff --git a/networking/udhcp/dhcpc.h b/networking/udhcp/dhcpc.h > index 19b054b32..c033eb13f 100644 > --- a/networking/udhcp/dhcpc.h > +++ b/networking/udhcp/dhcpc.h > @@ -7,6 +7,8 @@ > > PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN > > +IF_FEATURE_UDHCPC_COS(extern int sk_prio;) > + > struct client_data_t { > uint8_t client_mac[6]; /* Our mac address */ > IF_FEATURE_UDHCP_PORT(uint16_t port;) > diff --git a/networking/udhcp/packet.c b/networking/udhcp/packet.c > index 529978189..0babf451f 100644 > --- a/networking/udhcp/packet.c > +++ b/networking/udhcp/packet.c > @@ -12,6 +12,8 @@ > #include > #include > > +IF_FEATURE_UDHCPC_COS(int sk_prio;) > + > #if ENABLE_UDHCPC || ENABLE_UDHCPD > void FAST_FUNC udhcp_init_header(struct dhcp_packet *packet, char type) > { > @@ -121,6 +123,13 @@ int FAST_FUNC udhcp_send_raw_packet(struct dhcp_packet *dhcp_pkt, > goto ret_msg; > } > > + IF_FEATURE_UDHCPC_COS( > + if (sk_prio) { > + if (setsockopt_int(fd, SOL_SOCKET, SO_PRIORITY, sk_prio)) { > + log1s("raw: SO_PRIORITY setsockopt() failed"); > + } > + }) > + > memset(&dest_sll, 0, sizeof(dest_sll)); > memset(&packet, 0, offsetof(struct ip_udp_dhcp_packet, data)); > packet.data = *dhcp_pkt; /* struct copy */ > @@ -207,6 +216,13 @@ int FAST_FUNC udhcp_send_kernel_packet(struct dhcp_packet *dhcp_pkt, > } > setsockopt_reuseaddr(fd); > > + IF_FEATURE_UDHCPC_COS( > + if (sk_prio) { > + if (setsockopt_int(fd, SOL_SOCKET, SO_PRIORITY, sk_prio)) { > + log1s("raw: SO_PRIORITY setsockopt() failed"); > + } > + }) > + > /* If interface carrier goes down, unless we > * bind socket to a particular netdev, the packet > * can go out through another interface, eg. via > -- > 2.34.1 > From peron.clem at gmail.com Fri Jan 13 14:02:44 2023 From: peron.clem at gmail.com (=?UTF-8?q?Cl=C3=A9ment=20P=C3=A9ron?=) Date: Fri, 13 Jan 2023 15:02:44 +0100 Subject: [PATCH] udhcp: use the define instead of value + comment Message-ID: <20230113140244.295636-1-peron.clem@gmail.com> All the DHCP value are already properly defines but instead of using them we recopy the value and add a comment. Let's directly add the define when we can. Signed-off-by: Cl?ment P?ron --- networking/udhcp/common.c | 90 +++++++++++++++++++-------------------- networking/udhcp/common.h | 73 +++++++++++++++---------------- 2 files changed, 82 insertions(+), 81 deletions(-) diff --git a/networking/udhcp/common.c b/networking/udhcp/common.c index ae818db05..2ab31c472 100644 --- a/networking/udhcp/common.c +++ b/networking/udhcp/common.c @@ -21,57 +21,57 @@ const uint8_t MAC_BCAST_ADDR[6] ALIGN2 = { */ const struct dhcp_optflag dhcp_optflags[] ALIGN2 = { /* flags code */ - { OPTION_IP | OPTION_REQ, 0x01 }, /* DHCP_SUBNET */ - { OPTION_S32 , 0x02 }, /* DHCP_TIME_OFFSET */ - { OPTION_IP | OPTION_LIST | OPTION_REQ, 0x03 }, /* DHCP_ROUTER */ -// { OPTION_IP | OPTION_LIST , 0x04 }, /* DHCP_TIME_SERVER */ -// { OPTION_IP | OPTION_LIST , 0x05 }, /* DHCP_NAME_SERVER */ - { OPTION_IP | OPTION_LIST | OPTION_REQ, 0x06 }, /* DHCP_DNS_SERVER */ -// { OPTION_IP | OPTION_LIST , 0x07 }, /* DHCP_LOG_SERVER */ -// { OPTION_IP | OPTION_LIST , 0x08 }, /* DHCP_COOKIE_SERVER */ - { OPTION_IP | OPTION_LIST , 0x09 }, /* DHCP_LPR_SERVER */ - { OPTION_STRING_HOST | OPTION_REQ, 0x0c }, /* DHCP_HOST_NAME */ - { OPTION_U16 , 0x0d }, /* DHCP_BOOT_SIZE */ - { OPTION_STRING_HOST | OPTION_REQ, 0x0f }, /* DHCP_DOMAIN_NAME */ - { OPTION_IP , 0x10 }, /* DHCP_SWAP_SERVER */ - { OPTION_STRING , 0x11 }, /* DHCP_ROOT_PATH */ - { OPTION_U8 , 0x17 }, /* DHCP_IP_TTL */ - { OPTION_U16 , 0x1a }, /* DHCP_MTU */ + { OPTION_IP | OPTION_REQ, DHCP_SUBNET }, + { OPTION_S32 , DHCP_TIME_OFFSET }, + { OPTION_IP | OPTION_LIST | OPTION_REQ, DHCP_ROUTER }, +// { OPTION_IP | OPTION_LIST , DHCP_TIME_SERVER }, +// { OPTION_IP | OPTION_LIST , DHCP_NAME_SERVER }, + { OPTION_IP | OPTION_LIST | OPTION_REQ, DHCP_DNS_SERVER }, +// { OPTION_IP | OPTION_LIST , DHCP_LOG_SERVER }, +// { OPTION_IP | OPTION_LIST , DHCP_COOKIE_SERVER }, + { OPTION_IP | OPTION_LIST , DHCP_LPR_SERVER }, + { OPTION_STRING_HOST | OPTION_REQ, DHCP_HOST_NAME }, + { OPTION_U16 , DHCP_BOOT_SIZE }, + { OPTION_STRING_HOST | OPTION_REQ, DHCP_DOMAIN_NAME }, + { OPTION_IP , DHCP_SWAP_SERVER }, + { OPTION_STRING , DHCP_ROOT_PATH }, + { OPTION_U8 , DHCP_IP_TTL }, + { OPTION_U16 , DHCP_MTU }, //TODO: why do we request DHCP_BROADCAST? Can't we assume that //in the unlikely case it is different from typical N.N.255.255, //server would let us know anyway? - { OPTION_IP | OPTION_REQ, 0x1c }, /* DHCP_BROADCAST */ - { OPTION_IP_PAIR | OPTION_LIST , 0x21 }, /* DHCP_ROUTES */ - { OPTION_STRING_HOST , 0x28 }, /* DHCP_NIS_DOMAIN */ - { OPTION_IP | OPTION_LIST , 0x29 }, /* DHCP_NIS_SERVER */ - { OPTION_IP | OPTION_LIST | OPTION_REQ, 0x2a }, /* DHCP_NTP_SERVER */ - { OPTION_IP | OPTION_LIST , 0x2c }, /* DHCP_WINS_SERVER */ - { OPTION_U32 , 0x33 }, /* DHCP_LEASE_TIME */ - { OPTION_IP , 0x36 }, /* DHCP_SERVER_ID */ - { OPTION_STRING , 0x38 }, /* DHCP_ERR_MESSAGE */ - { OPTION_STRING , 0x3c }, /* DHCP_VENDOR */ + { OPTION_IP | OPTION_REQ, DHCP_BROADCAST }, + { OPTION_IP_PAIR | OPTION_LIST , DHCP_ROUTES }, + { OPTION_STRING_HOST , DHCP_NIS_DOMAIN }, + { OPTION_IP | OPTION_LIST , DHCP_NIS_SERVER }, + { OPTION_IP | OPTION_LIST | OPTION_REQ, DHCP_NTP_SERVER }, + { OPTION_IP | OPTION_LIST , DHCP_WINS_SERVER }, + { OPTION_U32 , DHCP_LEASE_TIME }, + { OPTION_IP , DHCP_SERVER_ID }, + { OPTION_STRING , DHCP_ERR_MESSAGE }, + { OPTION_STRING , DHCP_VENDOR }, //TODO: must be combined with 'sname' and 'file' handling: - { OPTION_STRING_HOST , 0x42 }, /* DHCP_TFTP_SERVER_NAME */ - { OPTION_STRING , 0x43 }, /* DHCP_BOOT_FILE */ + { OPTION_STRING_HOST , DHCP_TFTP_SERVER_NAME }, + { OPTION_STRING , DHCP_BOOT_FILE }, //TODO: not a string, but a set of LASCII strings: -// { OPTION_STRING , 0x4D }, /* DHCP_USER_CLASS */ - { OPTION_STRING , 0x64 }, /* DHCP_PCODE */ - { OPTION_STRING , 0x65 }, /* DHCP_TCODE */ +// { OPTION_STRING , DHCP_USER_CLASS }, + { OPTION_STRING , DHCP_PCODE }, + { OPTION_STRING , DHCP_TCODE }, #if ENABLE_FEATURE_UDHCP_RFC3397 - { OPTION_DNS_STRING | OPTION_LIST , 0x77 }, /* DHCP_DOMAIN_SEARCH */ - { OPTION_SIP_SERVERS , 0x78 }, /* DHCP_SIP_SERVERS */ + { OPTION_DNS_STRING | OPTION_LIST , DHCP_DOMAIN_SEARCH }, + { OPTION_SIP_SERVERS , DHCP_SIP_SERVERS }, #endif - { OPTION_STATIC_ROUTES | OPTION_LIST , 0x79 }, /* DHCP_STATIC_ROUTES */ + { OPTION_STATIC_ROUTES | OPTION_LIST , DHCP_STATIC_ROUTES }, #if ENABLE_FEATURE_UDHCP_8021Q - { OPTION_U16 , 0x84 }, /* DHCP_VLAN_ID */ - { OPTION_U8 , 0x85 }, /* DHCP_VLAN_PRIORITY */ + { OPTION_U16 , DHCP_VLAN_ID }, + { OPTION_U8 , DHCP_VLAN_PRIORITY }, #endif - { OPTION_STRING , 0xd1 }, /* DHCP_PXE_CONF_FILE */ - { OPTION_STRING , 0xd2 }, /* DHCP_PXE_PATH_PREFIX */ - { OPTION_U32 , 0xd3 }, /* DHCP_REBOOT_TIME */ - { OPTION_6RD , 0xd4 }, /* DHCP_6RD */ - { OPTION_STATIC_ROUTES | OPTION_LIST , 0xf9 }, /* DHCP_MS_STATIC_ROUTES */ - { OPTION_STRING , 0xfc }, /* DHCP_WPAD */ + { OPTION_STRING , DHCP_PXE_CONF_FILE }, + { OPTION_STRING , DHCP_PXE_PATH_PREFIX }, + { OPTION_U32 , DHCP_REBOOT_TIME }, + { OPTION_6RD , DHCP_6RD }, + { OPTION_STATIC_ROUTES | OPTION_LIST , DHCP_MS_STATIC_ROUTES }, + { OPTION_STRING , DHCP_WPAD }, /* Options below have no match in dhcp_option_strings[], * are not passed to dhcpc scripts, and cannot be specified @@ -80,9 +80,9 @@ const struct dhcp_optflag dhcp_optflags[] ALIGN2 = { * to correctly encode options into packets. */ - { OPTION_IP , 0x32 }, /* DHCP_REQUESTED_IP */ - { OPTION_U8 , 0x35 }, /* DHCP_MESSAGE_TYPE */ - { OPTION_U16 , 0x39 }, /* DHCP_MAX_SIZE */ + { OPTION_IP , DHCP_REQUESTED_IP }, + { OPTION_U8 , DHCP_MESSAGE_TYPE }, + { OPTION_U16 , DHCP_MAX_SIZE }, //looks like these opts will work just fine even without these defs: // /* not really a string: */ // { OPTION_STRING , 0x3d }, /* DHCP_CLIENT_ID */ diff --git a/networking/udhcp/common.h b/networking/udhcp/common.h index 49a0b593d..e4db6307a 100644 --- a/networking/udhcp/common.h +++ b/networking/udhcp/common.h @@ -134,56 +134,57 @@ struct dhcp_scan_state { */ #define DHCP_PADDING 0x00 #define DHCP_SUBNET 0x01 -//#define DHCP_TIME_OFFSET 0x02 /* (localtime - UTC_time) in seconds. signed */ -//#define DHCP_ROUTER 0x03 -//#define DHCP_TIME_SERVER 0x04 /* RFC 868 time server (32-bit, 0 = 1.1.1900) */ -//#define DHCP_NAME_SERVER 0x05 /* IEN 116 _really_ ancient kind of NS */ -//#define DHCP_DNS_SERVER 0x06 -//#define DHCP_LOG_SERVER 0x07 /* port 704 UDP log (not syslog) */ -//#define DHCP_COOKIE_SERVER 0x08 /* "quote of the day" server */ -//#define DHCP_LPR_SERVER 0x09 +#define DHCP_TIME_OFFSET 0x02 /* (localtime - UTC_time) in seconds. signed */ +#define DHCP_ROUTER 0x03 +#define DHCP_TIME_SERVER 0x04 /* RFC 868 time server (32-bit, 0 = 1.1.1900) */ +#define DHCP_NAME_SERVER 0x05 /* IEN 116 _really_ ancient kind of NS */ +#define DHCP_DNS_SERVER 0x06 +#define DHCP_LOG_SERVER 0x07 /* port 704 UDP log (not syslog) */ +#define DHCP_COOKIE_SERVER 0x08 /* "quote of the day" server */ +#define DHCP_LPR_SERVER 0x09 #define DHCP_HOST_NAME 0x0c /* 12: either client informs server or server gives name to client */ -//#define DHCP_BOOT_SIZE 0x0d -//#define DHCP_DOMAIN_NAME 0x0f /* 15: server gives domain suffix */ -//#define DHCP_SWAP_SERVER 0x10 -//#define DHCP_ROOT_PATH 0x11 -//#define DHCP_IP_TTL 0x17 -//#define DHCP_MTU 0x1a -//#define DHCP_BROADCAST 0x1c -//#define DHCP_ROUTES 0x21 -//#define DHCP_NIS_DOMAIN 0x28 -//#define DHCP_NIS_SERVER 0x29 -//#define DHCP_NTP_SERVER 0x2a -//#define DHCP_WINS_SERVER 0x2c +#define DHCP_BOOT_SIZE 0x0d +#define DHCP_DOMAIN_NAME 0x0f /* 15: server gives domain suffix */ +#define DHCP_SWAP_SERVER 0x10 +#define DHCP_ROOT_PATH 0x11 +#define DHCP_IP_TTL 0x17 +#define DHCP_MTU 0x1a +#define DHCP_BROADCAST 0x1c +#define DHCP_ROUTES 0x21 +#define DHCP_NIS_DOMAIN 0x28 +#define DHCP_NIS_SERVER 0x29 +#define DHCP_NTP_SERVER 0x2a +#define DHCP_WINS_SERVER 0x2c #define DHCP_REQUESTED_IP 0x32 /* 50: sent by client if specific IP is wanted */ #define DHCP_LEASE_TIME 0x33 /* 51: 32bit big-endian */ #define DHCP_OPTION_OVERLOAD 0x34 /* 52: 1 byte */ #define DHCP_MESSAGE_TYPE 0x35 /* 53: 1 byte */ #define DHCP_SERVER_ID 0x36 /* 54: server's IP */ #define DHCP_PARAM_REQ 0x37 /* 55: list of options client wants */ -//#define DHCP_ERR_MESSAGE 0x38 /* 56: error message when sending NAK etc */ +#define DHCP_ERR_MESSAGE 0x38 /* 56: error message when sending NAK etc */ #define DHCP_MAX_SIZE 0x39 /* 57: 16bit big-endian */ // 0x3a /* 58: from server: renew time, 32bit big-endian */ // 0x3b /* 59: from server: rebind time, 32bit big-endian */ #define DHCP_VENDOR 0x3c /* 60: client's vendor (a string) */ #define DHCP_CLIENT_ID 0x3d /* 61: by default client's MAC addr, but may be arbitrarily long */ -//#define DHCP_TFTP_SERVER_NAME 0x42 /* 66: same as 'sname' field */ -//#define DHCP_BOOT_FILE 0x43 /* 67: same as 'file' field */ -//#define DHCP_USER_CLASS 0x4d /* 77: RFC 3004. set of LASCII strings. "I am a printer" etc */ +#define DHCP_TFTP_SERVER_NAME 0x42 /* 66: same as 'sname' field */ +#define DHCP_BOOT_FILE 0x43 /* 67: same as 'file' field */ +#define DHCP_USER_CLASS 0x4d /* 77: RFC 3004. set of LASCII strings. "I am a printer" etc */ // 0x50 /* 80: rapid commit ("I'm ok with getting immediate ACK, not just OFFER"), 0 bytes */ #define DHCP_FQDN 0x51 /* 81: client asks to update DNS to map its FQDN to its new IP */ -//#define DHCP_PCODE 0x64 /* 100: RFC 4833. IEEE 1003.1 TZ string */ -//#define DHCP_TCODE 0x65 /* 101: RFC 4833. Reference to the TZ database string */ -//#define DHCP_DOMAIN_SEARCH 0x77 /* 119: RFC 3397. set of ASCIZ string, DNS-style compressed */ -//#define DHCP_SIP_SERVERS 0x78 /* 120: RFC 3361. flag byte, then: 0: domain names, 1: IP addrs */ -//#define DHCP_STATIC_ROUTES 0x79 /* 121: RFC 3442. (mask,ip,router) tuples */ -//#define DHCP_VLAN_ID 0x84 /* 132: 802.1P VLAN ID */ -//#define DHCP_VLAN_PRIORITY 0x85 /* 133: 802.1Q VLAN priority */ -//#define DHCP_PXE_CONF_FILE 0xd1 /* 209: RFC 5071 Configuration file */ -//#define DHCP_PXE_PATH_PREFIX 0xd2 /* 210: RFC 5071 Path prefix */ -//#define DHCP_REBOOT_TIME 0xd3 /* 211: RFC 5071 Reboot time */ -//#define DHCP_MS_STATIC_ROUTES 0xf9 /* 249: Microsoft's pre-RFC 3442 code for 0x79? */ -//#define DHCP_WPAD 0xfc /* 252: MSIE's Web Proxy Autodiscovery Protocol */ +#define DHCP_PCODE 0x64 /* 100: RFC 4833. IEEE 1003.1 TZ string */ +#define DHCP_TCODE 0x65 /* 101: RFC 4833. Reference to the TZ database string */ +#define DHCP_DOMAIN_SEARCH 0x77 /* 119: RFC 3397. set of ASCIZ string, DNS-style compressed */ +#define DHCP_SIP_SERVERS 0x78 /* 120: RFC 3361. flag byte, then: 0: domain names, 1: IP addrs */ +#define DHCP_STATIC_ROUTES 0x79 /* 121: RFC 3442. (mask,ip,router) tuples */ +#define DHCP_VLAN_ID 0x84 /* 132: 802.1P VLAN ID */ +#define DHCP_VLAN_PRIORITY 0x85 /* 133: 802.1Q VLAN priority */ +#define DHCP_PXE_CONF_FILE 0xd1 /* 209: RFC 5071 Configuration file */ +#define DHCP_PXE_PATH_PREFIX 0xd2 /* 210: RFC 5071 Path prefix */ +#define DHCP_REBOOT_TIME 0xd3 /* 211: RFC 5071 Reboot time */ +#define DHCP_6RD 0xd4 /* 212: RFC 5969 IPv6 Rapid Deployment on IPv4 Infrastructures*/ +#define DHCP_MS_STATIC_ROUTES 0xf9 /* 249: Microsoft's pre-RFC 3442 code for 0x79? */ +#define DHCP_WPAD 0xfc /* 252: MSIE's Web Proxy Autodiscovery Protocol */ #define DHCP_END 0xff /* 255: */ /* Offsets in option byte sequence */ -- 2.34.1 From rep.dot.nop at gmail.com Fri Jan 13 20:08:46 2023 From: rep.dot.nop at gmail.com (Bernhard Reutner-Fischer) Date: Fri, 13 Jan 2023 21:08:46 +0100 Subject: [PATCH][RFC] udhcp: add option to set CoS priority In-Reply-To: References: <20230113094842.214119-1-peron.clem@gmail.com> Message-ID: <20230113210846.3551d0cd@nbbrfq> On Fri, 13 Jan 2023 10:55:26 +0100 Cl?ment P?ron wrote: > Hi, > > > On Fri, 13 Jan 2023 at 10:48, Cl?ment P?ron wrote: > > > > Some ISP, like the French ISP Orange uses DHCP messages with > > a CoS Priority of 6 otherwise they are not processed. > > > > Add an option to allow setting this property. > > Please note, that I get this information from this blog post > https://www.lafois.com/tag/udhcp/ > > I'm still testing this patch and I'm unsure if we need to set the > priority for all the sockets. > > I recovered a patch from Ubiquiti GPL archive where only > > udhcp_send_raw_packet() set the priority and not udhcp_send_kernel_packet(). > > I'm not sure which one is correct. I admit that i did not look, so cannot comment. > > Thanks for your help, > BR, > Clement > > diff --git a/networking/udhcp/d6_packet.c b/networking/udhcp/d6_packet.c > > index 142de9b43..425037ada 100644 > > --- a/networking/udhcp/d6_packet.c > > +++ b/networking/udhcp/d6_packet.c > > @@ -68,6 +68,13 @@ int FAST_FUNC d6_send_raw_packet_from_client_data_ifindex( > > goto ret_msg; > > } > > > > + IF_FEATURE_UDHCPC_COS( > > + if (sk_prio) { > > + if (setsockopt_int(fd, SOL_SOCKET, SO_PRIORITY, sk_prio)) { setsockopt_SOL_SOCKET_int() ? > > + log1s("raw: SO_PRIORITY setsockopt() failed"); > > + } Maybe add a common helper to udhcp like setsockopt_priority(sk_prio) that does setsockopt_SOL_SOCKET_int() || log1s() since you seem to do that more than once? > > +//usage: IF_FEATURE_UDHCPC_COS( > > +//usage: "\n -y PRIORITY CoS value 0 .. 7, default 0" I don't see that you would cap the value to 7 anywhere, do you? The manpage seems to imply that 0..6 can be used by unprivileged users, higher values require CAP_NET_ADMIN which is fine per se; I assume the kernel does enough sanity-checking so we can attempt to pass whatever the user said. thanks, From peron.clem at gmail.com Sun Jan 15 14:27:18 2023 From: peron.clem at gmail.com (=?UTF-8?B?Q2zDqW1lbnQgUMOpcm9u?=) Date: Sun, 15 Jan 2023 15:27:18 +0100 Subject: [PATCH][RFC] udhcp: add option to set CoS priority In-Reply-To: <20230113210846.3551d0cd@nbbrfq> References: <20230113094842.214119-1-peron.clem@gmail.com> <20230113210846.3551d0cd@nbbrfq> Message-ID: Hi Bernhard, On Fri, 13 Jan 2023 at 21:08, Bernhard Reutner-Fischer wrote: > > On Fri, 13 Jan 2023 10:55:26 +0100 > Cl?ment P?ron wrote: > > > Hi, > > > > > > On Fri, 13 Jan 2023 at 10:48, Cl?ment P?ron wrote: > > > > > > Some ISP, like the French ISP Orange uses DHCP messages with > > > a CoS Priority of 6 otherwise they are not processed. > > > > > > Add an option to allow setting this property. > > > > Please note, that I get this information from this blog post > > https://www.lafois.com/tag/udhcp/ > > > > I'm still testing this patch and I'm unsure if we need to set the > > priority for all the sockets. > > > > I recovered a patch from Ubiquiti GPL archive where only > > > > udhcp_send_raw_packet() set the priority and not udhcp_send_kernel_packet(). > > > > I'm not sure which one is correct. > > I admit that i did not look, so cannot comment. > > > > > Thanks for your help, > > BR, > > Clement > > > > diff --git a/networking/udhcp/d6_packet.c b/networking/udhcp/d6_packet.c > > > index 142de9b43..425037ada 100644 > > > --- a/networking/udhcp/d6_packet.c > > > +++ b/networking/udhcp/d6_packet.c > > > @@ -68,6 +68,13 @@ int FAST_FUNC d6_send_raw_packet_from_client_data_ifindex( > > > goto ret_msg; > > > } > > > > > > + IF_FEATURE_UDHCPC_COS( > > > + if (sk_prio) { > > > + if (setsockopt_int(fd, SOL_SOCKET, SO_PRIORITY, sk_prio)) { > > setsockopt_SOL_SOCKET_int() ? > > > > + log1s("raw: SO_PRIORITY setsockopt() failed"); > > > + } > > Maybe add a common helper to udhcp like > setsockopt_priority(sk_prio) that does > setsockopt_SOL_SOCKET_int() || log1s() Good point, I will send a v2 with a helper function in common.c void udhcp_socket_prio(int fd); Also I will move the global int sk_prio; in common.c and declare it in common.h which is more logic than packet.c > since you seem to do that more than once? > > > > +//usage: IF_FEATURE_UDHCPC_COS( > > > +//usage: "\n -y PRIORITY CoS value 0 .. 7, default 0" > > I don't see that you would cap the value to 7 anywhere, do you? > The manpage seems to imply that 0..6 can be used by unprivileged users, > higher values require CAP_NET_ADMIN which is fine per se; I assume the > kernel does enough sanity-checking so we can attempt to pass whatever > the user said. > thanks, Agree will remove this in the usage documentation. Thanks for your review! From peron.clem at gmail.com Mon Jan 16 10:11:14 2023 From: peron.clem at gmail.com (=?UTF-8?q?Cl=C3=A9ment=20P=C3=A9ron?=) Date: Mon, 16 Jan 2023 11:11:14 +0100 Subject: [PATCH v2] udhcp: add option to set CoS priority Message-ID: <20230116101114.52097-1-peron.clem@gmail.com> Some ISP, like the French ISP Orange uses DHCP messages with a CoS Priority of 6 otherwise they are not processed. Add an option to allow setting this property. Signed-off-by: Cl?ment P?ron --- Changes since v1: - Use setsockopt_SOL_SOCKET_int() - Introduce an helper udhcp_socket_prio() - Move sk_prio in common.c networking/udhcp/Config.src | 8 ++++++++ networking/udhcp/common.c | 15 +++++++++++++++ networking/udhcp/common.h | 3 +++ networking/udhcp/d6_dhcpc.c | 8 +++++++- networking/udhcp/d6_packet.c | 4 ++++ networking/udhcp/dhcpc.c | 10 +++++++++- networking/udhcp/packet.c | 4 ++++ 7 files changed, 50 insertions(+), 2 deletions(-) diff --git a/networking/udhcp/Config.src b/networking/udhcp/Config.src index 7ba7f48fc..49d5d7ef1 100644 --- a/networking/udhcp/Config.src +++ b/networking/udhcp/Config.src @@ -137,6 +137,14 @@ config UDHCP_DEBUG Bigger values result in bigger code. Levels above 1 are very verbose and useful for debugging only. +config FEATURE_UDHCPC_COS + bool "Enable '-y priority' option for udhcpc" + default n + depends on UDHCPC || UDHCPC6 + help + At the cost of ~300 bytes, enables -y priority option. + This feature is typically not needed. + config UDHCPC_SLACK_FOR_BUGGY_SERVERS int "DHCP options slack buffer size" default 80 diff --git a/networking/udhcp/common.c b/networking/udhcp/common.c index ae818db05..d5ef54f0e 100644 --- a/networking/udhcp/common.c +++ b/networking/udhcp/common.c @@ -10,6 +10,8 @@ unsigned dhcp_verbose; #endif +IF_FEATURE_UDHCPC_COS(int sk_prio;) + const uint8_t MAC_BCAST_ADDR[6] ALIGN2 = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; @@ -733,3 +735,16 @@ int FAST_FUNC sprint_nip6(char *dest, /*const char *pre,*/ const uint8_t *ip) hexstrbuf + 7 * 4 ); } + +#if defined CONFIG_FEATURE_UDHCPC_COS +void FAST_FUNC udhcp_socket_prio(int fd) +{ + if (!sk_prio) + return; + + log2("setting prio: %d", sk_prio); + if (setsockopt_SOL_SOCKET_int(fd, SO_PRIORITY, sk_prio)) { + bb_simple_error_msg("SO_PRIORITY setsockopt() failed"); + } +} +#endif diff --git a/networking/udhcp/common.h b/networking/udhcp/common.h index 49a0b593d..4b276fe79 100644 --- a/networking/udhcp/common.h +++ b/networking/udhcp/common.h @@ -386,6 +386,9 @@ int arpping(uint32_t test_nip, /* note: ip is a pointer to an IPv6 in network order, possibly misaliged */ int sprint_nip6(char *dest, /*const char *pre,*/ const uint8_t *ip) FAST_FUNC; +IF_FEATURE_UDHCPC_COS(extern int sk_prio;) +IF_FEATURE_UDHCPC_COS(void udhcp_socket_prio(int fd) FAST_FUNC;) + POP_SAVED_FUNCTION_VISIBILITY #endif diff --git a/networking/udhcp/d6_dhcpc.c b/networking/udhcp/d6_dhcpc.c index cdd06188e..59bdd34b3 100644 --- a/networking/udhcp/d6_dhcpc.c +++ b/networking/udhcp/d6_dhcpc.c @@ -129,6 +129,7 @@ static const char udhcpc6_longopts[] ALIGN1 = ) /// IF_FEATURE_UDHCPC_ARPING("arping\0" No_argument "a") IF_FEATURE_UDHCP_PORT("client-port\0" Required_argument "P") + IF_FEATURE_UDHCPC_COS("cos\0" Required_argument "y") ; #endif /* Must match getopt32 option string order */ @@ -1130,7 +1131,7 @@ static void client_background(void) //usage:#endif //usage:#define udhcpc6_trivial_usage //usage: "[-fbq"IF_UDHCP_VERBOSE("v")"R] [-t N] [-T SEC] [-A SEC|-n] [-i IFACE] [-s PROG]\n" -//usage: " [-p PIDFILE]"IF_FEATURE_UDHCP_PORT(" [-P PORT]")" [-ldo] [-r IPv6] [-x OPT:VAL]... [-O OPT]..." +//usage: " [-p PIDFILE]"IF_FEATURE_UDHCP_PORT(" [-P PORT]")""IF_FEATURE_UDHCPC_COS(" [-y PRIORITY]")" [-ldo] [-r IPv6] [-x OPT:VAL]... [-O OPT]..." //usage:#define udhcpc6_full_usage "\n" //usage: "\n -i IFACE Interface to use (default "CONFIG_UDHCPC_DEFAULT_INTERFACE")" //usage: "\n -p FILE Create pidfile" @@ -1153,6 +1154,9 @@ static void client_background(void) ////usage: IF_FEATURE_UDHCPC_ARPING( ////usage: "\n -a Use arping to validate offered address" ////usage: ) +//usage: IF_FEATURE_UDHCPC_COS( +//usage: "\n -y PRIORITY CoS value, default 0" +//usage: ) //usage: "\n -l Send 'information request' instead of 'solicit'" //usage: "\n (used for servers which do not assign IPv6 addresses)" //usage: "\n -r IPv6 Request this address ('no' to not request any IP)" @@ -1214,6 +1218,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv) USE_FOR_MMU("b") ///IF_FEATURE_UDHCPC_ARPING("a") IF_FEATURE_UDHCP_PORT("P:") + IF_FEATURE_UDHCPC_COS("y:+") "v" "\0" IF_UDHCP_VERBOSE("vv") /* -v is a counter */ , udhcpc6_longopts @@ -1223,6 +1228,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv) , &list_O , &list_x IF_FEATURE_UDHCP_PORT(, &str_P) + IF_FEATURE_UDHCPC_COS(, &sk_prio) IF_UDHCP_VERBOSE(, &dhcp_verbose) ); requested_ipv6 = NULL; diff --git a/networking/udhcp/d6_packet.c b/networking/udhcp/d6_packet.c index 142de9b43..424120c2c 100644 --- a/networking/udhcp/d6_packet.c +++ b/networking/udhcp/d6_packet.c @@ -68,6 +68,8 @@ int FAST_FUNC d6_send_raw_packet_from_client_data_ifindex( goto ret_msg; } + IF_FEATURE_UDHCPC_COS(udhcp_socket_prio(fd);) + memset(&dest_sll, 0, sizeof(dest_sll)); memset(&packet, 0, offsetof(struct ip6_udp_d6_packet, data)); packet.data = *d6_pkt; /* struct copy */ @@ -153,6 +155,8 @@ int FAST_FUNC d6_send_kernel_packet_from_client_data_ifindex( } setsockopt_reuseaddr(fd); + IF_FEATURE_UDHCPC_COS(udhcp_socket_prio(fd);) + memset(&sa, 0, sizeof(sa)); sa.sin6_family = AF_INET6; sa.sin6_port = htons(source_port); diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c index c757fb37c..60ae8ad70 100644 --- a/networking/udhcp/dhcpc.c +++ b/networking/udhcp/dhcpc.c @@ -77,6 +77,7 @@ static const char udhcpc_longopts[] ALIGN1 = "broadcast\0" No_argument "B" IF_FEATURE_UDHCPC_ARPING("arping\0" Optional_argument "a") IF_FEATURE_UDHCP_PORT("client-port\0" Required_argument "P") + IF_FEATURE_UDHCPC_COS("cos\0" Required_argument "y") ; #endif /* Must match getopt32 option string order */ @@ -1085,6 +1086,8 @@ static int udhcp_raw_socket(int ifindex) } #endif + IF_FEATURE_UDHCPC_COS(udhcp_socket_prio(fd);) + if (setsockopt_1(fd, SOL_PACKET, PACKET_AUXDATA) != 0) { if (errno != ENOPROTOOPT) log1s("can't set PACKET_AUXDATA on raw socket"); @@ -1162,7 +1165,7 @@ static void client_background(void) //usage:#endif //usage:#define udhcpc_trivial_usage //usage: "[-fbq"IF_UDHCP_VERBOSE("v")"RB]"IF_FEATURE_UDHCPC_ARPING(" [-a[MSEC]]")" [-t N] [-T SEC] [-A SEC|-n]\n" -//usage: " [-i IFACE]"IF_FEATURE_UDHCP_PORT(" [-P PORT]")" [-s PROG] [-p PIDFILE]\n" +//usage: " [-i IFACE]"IF_FEATURE_UDHCP_PORT(" [-P PORT]")""IF_FEATURE_UDHCPC_COS(" [-y PRIORITY]")" [-s PROG] [-p PIDFILE]\n" //usage: " [-oC] [-r IP] [-V VENDOR] [-F NAME] [-x OPT:VAL]... [-O OPT]..." //usage:#define udhcpc_full_usage "\n" //usage: "\n -i IFACE Interface to use (default "CONFIG_UDHCPC_DEFAULT_INTERFACE")" @@ -1186,6 +1189,9 @@ static void client_background(void) //usage: IF_FEATURE_UDHCPC_ARPING( //usage: "\n -a[MSEC] Validate offered address with ARP ping" //usage: ) +//usage: IF_FEATURE_UDHCPC_COS( +//usage: "\n -y PRIORITY CoS value, default 0" +//usage: ) //usage: "\n -r IP Request this IP address" //usage: "\n -o Don't request any options (unless -O is given)" //usage: "\n -O OPT Request option OPT from server (cumulative)" @@ -1248,6 +1254,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv) USE_FOR_MMU("b") IF_FEATURE_UDHCPC_ARPING("a::") IF_FEATURE_UDHCP_PORT("P:") + IF_FEATURE_UDHCPC_COS("y:+") "v" "\0" IF_UDHCP_VERBOSE("vv") /* -v is a counter */ , udhcpc_longopts @@ -1260,6 +1267,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv) , &list_x IF_FEATURE_UDHCPC_ARPING(, &str_a) IF_FEATURE_UDHCP_PORT(, &str_P) + IF_FEATURE_UDHCPC_COS(, &sk_prio) IF_UDHCP_VERBOSE(, &dhcp_verbose) ); if (opt & OPT_F) { diff --git a/networking/udhcp/packet.c b/networking/udhcp/packet.c index 529978189..9aaa51de9 100644 --- a/networking/udhcp/packet.c +++ b/networking/udhcp/packet.c @@ -121,6 +121,8 @@ int FAST_FUNC udhcp_send_raw_packet(struct dhcp_packet *dhcp_pkt, goto ret_msg; } + IF_FEATURE_UDHCPC_COS(udhcp_socket_prio(fd);) + memset(&dest_sll, 0, sizeof(dest_sll)); memset(&packet, 0, offsetof(struct ip_udp_dhcp_packet, data)); packet.data = *dhcp_pkt; /* struct copy */ @@ -207,6 +209,8 @@ int FAST_FUNC udhcp_send_kernel_packet(struct dhcp_packet *dhcp_pkt, } setsockopt_reuseaddr(fd); + IF_FEATURE_UDHCPC_COS(udhcp_socket_prio(fd);) + /* If interface carrier goes down, unless we * bind socket to a particular netdev, the packet * can go out through another interface, eg. via -- 2.34.1 From bluca at debian.org Mon Jan 16 15:11:10 2023 From: bluca at debian.org (Luca Boccassi) Date: Mon, 16 Jan 2023 15:11:10 +0000 Subject: [PATCH v2] udhcpc: add support for sending DHCPINFORM packets In-Reply-To: References: <20220830213443.1922500-1-luca.boccassi@gmail.com> <20220830214151.1923924-1-bluca@debian.org> <530912df10d28daa536b94d7b6efa814c4e41200.camel@debian.org> Message-ID: On Wed, 2 Nov 2022 at 12:05, Luca Boccassi wrote: > > On Thu, 22 Sept 2022 at 13:31, Luca Boccassi wrote: > > > > On Tue, 2022-08-30 at 22:41 +0100, bluca at debian.org wrote: > > > From: Luca Boccassi > > > > > > It is useful for applications to be able to query DHCP options > > > without renewing IP address. Instead of a full DHCP handshake, > > > using -I will cause a single DHCPINFORM packet to be sent, and > > > the server response (including DHCP options received) to be > > > printed and terminate. No configuration will be changed. > > > > > > This is useful for clients that want to query additional information > > > from a server, that might not be normally processed, like custom > > > server options. Also useful for checking specific options via -O. > > > > > > As per RFC 2131, allow targeting the already-known DHCP server via > > > unicast instead of broadcast, via new -e option. > > > > > > Tested by running isc-dhcp-server with the following configuration: > > > > > > option domain-name "example.org"; > > > option domain-name-servers 1.1.1.1, 8.8.8.8; > > > subnet 192.168.11.0 netmask 255.255.255.0 { > > > range 192.168.11.1 192.168.11.100; > > > authoritative; > > > option default-url "default.url"; > > > } > > > > > > $ busybox udhcpc -I -i host0 -O 114 -r 192.168.11.1 > > > udhcpc: started, v1.36.0.git > > > udhcpc: broadcasting inform for 192.168.11.1, server 0.0.0.0 > > > udhcpc: lease of 0.0.0.0 obtained from 0.0.0.0, lease time 3600 (default) > > > udhcpc: option: opt53=0x05 > > > udhcpc: option: serverid=192.168.11.101 > > > udhcpc: option: subnet=255.255.255.0 > > > udhcpc: option: dns=1.1.1.1 8.8.8.8 > > > udhcpc: option: domain=example.org > > > udhcpc: option: opt114=0x64656661756c742e75726c > > > > > > $ busybox udhcpc -e 192.168.11.101 -I -i host0 -O 114 -r 192.168.11.1 > > > udhcpc: started, v1.36.0.git > > > udhcpc: unicasting inform for 192.168.11.1, server 192.168.11.101 > > > udhcpc: lease of 0.0.0.0 obtained from 192.168.11.101, lease time 3600 (default) > > > udhcpc: option: opt53=0x05 > > > udhcpc: option: serverid=192.168.11.101 > > > udhcpc: option: subnet=255.255.255.0 > > > udhcpc: option: dns=1.1.1.1 8.8.8.8 > > > udhcpc: option: domain=example.org > > > udhcpc: option: opt114=0x64656661756c742e75726c > > > > > > Co-authored-by: Sinan Kaya > > > Signed-off-by: Luca Boccassi > > > --- > > > v2: updated commit message and comments > > > applied all review comments > > > print received DHCP options and exit > > > > > > networking/udhcp/dhcpc.c | 116 ++++++++++++++++++++++++++++++++++----- > > > 1 file changed, 103 insertions(+), 13 deletions(-) > > > > Hello Denys, > > > > Any chance for a second review? Thank you! > > Hello, > > One more ping for a re-review. Thank you! Hello and happy new year, One more ping, if you have time would love a review of v2. Thanks! Kind regards, Luca Boccassi From vakevk at gmail.com Tue Jan 17 11:29:12 2023 From: vakevk at gmail.com (vakevk at gmail.com) Date: Tue, 17 Jan 2023 12:29:12 +0100 Subject: The busybox website is unbearably slow Message-ID: <29ff1ca4-a40d-0785-2cfe-cf9165348655@gmail.com> The busybox website (https://busybox.net) is slow. It often takes more than 10 seconds for pages to load and sometimes they time out altogether. This makes it frustrating to learn more about the project. Most of the website is static content which should be fast to serve. From vakevk at gmail.com Tue Jan 17 13:10:48 2023 From: vakevk at gmail.com (Valentin) Date: Tue, 17 Jan 2023 14:10:48 +0100 Subject: [PATCH] adduser: Make home directory not world readable Message-ID: <20230117131048.227359-1-vakevk@gmail.com> adduser sets the mode of the newly created home directory to u+rwx g+rx o+rx (755). This allows every user on the system to read the directory. This commit changes the mode to not give other users any permissions (750). This is a better default. Home directories are likely to contain sensitive information, which you expect to not be world readable. If you really want your home directory to be world readable you can manually chmod it afterwards. On the other hand, if the default is world readable, then inaction exposes sensitive information. This can happen by accident when you are not aware what mode adduser sets. I could not find any reasoning for the current behavior. 755 has been used since the commit that created adduser.c in 2002. Neither the commit nor the file today contain an explanation. --- loginutils/adduser.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/loginutils/adduser.c b/loginutils/adduser.c index d3c795afa..218fe1371 100644 --- a/loginutils/adduser.c +++ b/loginutils/adduser.c @@ -278,9 +278,9 @@ int adduser_main(int argc UNUSED_PARAM, char **argv) umask(0); if (!(opts & OPT_DONT_MAKE_HOME)) { /* set the owner and group so it is owned by the new user, - * then fix up the permissions to 2755. Can't do it before + * then fix up the permissions to 2750. Can't do it before * since chown will clear the setgid bit */ - int mkdir_err = mkdir(pw.pw_dir, 0755); + int mkdir_err = mkdir(pw.pw_dir, 0750); if (mkdir_err == 0) { /* New home. Copy /etc/skel to it */ const char *args[] = { @@ -299,7 +299,7 @@ int adduser_main(int argc UNUSED_PARAM, char **argv) } if ((mkdir_err != 0 && errno != EEXIST) || chown(pw.pw_dir, pw.pw_uid, pw.pw_gid) != 0 - || chmod(pw.pw_dir, 02755) != 0 /* set setgid bit on homedir */ + || chmod(pw.pw_dir, 02750) != 0 /* set setgid bit on homedir */ ) { bb_simple_perror_msg(pw.pw_dir); } -- 2.39.0 From farmatito at tiscali.it Tue Jan 17 13:24:13 2023 From: farmatito at tiscali.it (tito) Date: Tue, 17 Jan 2023 14:24:13 +0100 Subject: [PATCH] adduser: Make home directory not world readable In-Reply-To: <20230117131048.227359-1-vakevk@gmail.com> References: <20230117131048.227359-1-vakevk@gmail.com> Message-ID: <20230117142413.189e2cd3@devuan> On Tue, 17 Jan 2023 14:10:48 +0100 Valentin wrote: > adduser sets the mode of the newly created home directory to > u+rwx g+rx o+rx (755). This allows every user on the system to read the > directory. > > This commit changes the mode to not give other users any permissions > (750). > > This is a better default. Home directories are likely to contain > sensitive information, which you expect to not be world readable. If > you really want your home directory to be world readable you can > manually chmod it afterwards. > > On the other hand, if the default is world readable, then inaction > exposes sensitive information. This can happen by accident when you are > not aware what mode adduser sets. > > I could not find any reasoning for the current behavior. 755 has been > used since the commit that created adduser.c in 2002. Neither the commit > nor the file today contain an explanation. > --- > loginutils/adduser.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/loginutils/adduser.c b/loginutils/adduser.c > index d3c795afa..218fe1371 100644 > --- a/loginutils/adduser.c > +++ b/loginutils/adduser.c > @@ -278,9 +278,9 @@ int adduser_main(int argc UNUSED_PARAM, char **argv) > umask(0); > if (!(opts & OPT_DONT_MAKE_HOME)) { > /* set the owner and group so it is owned by the new user, > - * then fix up the permissions to 2755. Can't do it before > + * then fix up the permissions to 2750. Can't do it before > * since chown will clear the setgid bit */ > - int mkdir_err = mkdir(pw.pw_dir, 0755); > + int mkdir_err = mkdir(pw.pw_dir, 0750); > if (mkdir_err == 0) { > /* New home. Copy /etc/skel to it */ > const char *args[] = { > @@ -299,7 +299,7 @@ int adduser_main(int argc UNUSED_PARAM, char **argv) > } > if ((mkdir_err != 0 && errno != EEXIST) > || chown(pw.pw_dir, pw.pw_uid, pw.pw_gid) != 0 > - || chmod(pw.pw_dir, 02755) != 0 /* set setgid bit on homedir */ > + || chmod(pw.pw_dir, 02750) != 0 /* set setgid bit on homedir */ > ) { > bb_simple_perror_msg(pw.pw_dir); > } Hi, this is the default in debian as could be seen in /etc/adduser.conf: # If DIR_MODE is set, directories will be created with the specified # mode. Otherwise the default mode 0755 will be used. DIR_MODE=0755 so busybox uses the default. This could be made a config option with 755 as default or if we want to be more on the security side 750. Ciao, Tito From mikes at guam.net Tue Jan 17 13:14:29 2023 From: mikes at guam.net (Michael D. Setzer II) Date: Tue, 17 Jan 2023 23:14:29 +1000 Subject: The busybox website is unbearably slow In-Reply-To: <29ff1ca4-a40d-0785-2cfe-cf9165348655@gmail.com> References: <29ff1ca4-a40d-0785-2cfe-cf9165348655@gmail.com> Message-ID: <63C69F35.18117.A52D390@mikes.guam.net> On 17 Jan 2023 at 12:29, vakevk at gmail.com wrote: Date sent: Tue, 17 Jan 2023 12:29:12 +0100 To: busybox at busybox.net From: vakevk at gmail.com Subject: The busybox website is unbearably slow > The busybox website (https://busybox.net) is slow. It often takes more > than 10 seconds for pages to load and sometimes they time out > altogether. This makes it frustrating to learn more about the project. > Most of the website is static content which should be fast to serve. > Not sure site is even actually up. Checked it with https://www.isitdownrightnow.com/busybox.net.html It reports Busybox.net is DOWN for everyone. Traceroute to site stops getting returns at 13 eugn-oh-pe-01.net.linkoregon.org (207.98.127.250) 205.137 ms 211.491 ms 209.707 ms 14 eugn-oh-pe-02.net.linkoregon.org (207.98.126.15) 206.603 ms 207.768 ms 202.427 ms 15 corv-kerr-pe-02.net.linkoregon.org (207.98.126.89) 212.435 ms 215.497 ms 215.886 ms 16 corv-kerr-pe-01.net.linkoregon.org (207.98.127.242) 208.928 ms 202.506 ms 202.070 ms Think that is under a university of oregon? Looks like when page does come up, it is something pulling from a cache?? Strange that pinging the ip seems to work? 64 bytes from 140.211.167.122: icmp_seq=1 ttl=52 time=208 ms whois shows the domain expiring today?? Domain Name: BUSYBOX.NET Registry Domain ID: 10276015_DOMAIN_NET-VRSN Registrar WHOIS Server: whois.godaddy.com Registrar URL: https://www.godaddy.com Updated Date: 2022-01-18T00:03:45Z Creation Date: 1999-09-16T08:59:14Z Registrar Registration Expiration Date: 2023-01-17T23:59:59Z Registrar: GoDaddy.com, LLC So don't know if it something with network or routing. Found emails of 3 maintainers, and sent info, but no reply. Whois doesn't show stuff. So don't have a clue. Got the latest update from Jan 3rd 2023.. > _______________________________________________ > busybox mailing list > busybox at busybox.net > http://lists.busybox.net/mailman/listinfo/busybox +------------------------------------------------------------+ Michael D. Setzer II - Computer Science Instructor (Retired) mailto:mikes at guam.net mailto:msetzerii at gmail.com Guam - Where America's Day Begins G4L Disk Imaging Project maintainer http://sourceforge.net/projects/g4l/ +------------------------------------------------------------+ -------------- next part -------------- An HTML attachment was scrubbed... URL: From vakevk at gmail.com Tue Jan 17 15:19:38 2023 From: vakevk at gmail.com (Valentin) Date: Tue, 17 Jan 2023 16:19:38 +0100 Subject: [PATCH] adduser: Make home directory not world readable In-Reply-To: <20230117142413.189e2cd3@devuan> References: <20230117142413.189e2cd3@devuan> Message-ID: <20ebf22f-c434-67b7-ce15-2baea2dde1e3@gmail.com> > this is the default in debian Thank you for explaining the historical context. Is this *just* the historical context or do you mean that busybox *should* follow debian? If it is the latter, would busybox change the default if debian did so first? > This could be made a config option Do you mean a config option in a config file or a command line argument? adduser currently does not parse any config file and I do not want to make that part of this change. Adding a command line argument for the mode is a smaller change but even that I would rather not make part of this change. From farmatito at tiscali.it Tue Jan 17 15:30:13 2023 From: farmatito at tiscali.it (tito) Date: Tue, 17 Jan 2023 16:30:13 +0100 Subject: [PATCH] adduser: Make home directory not world readable In-Reply-To: <20ebf22f-c434-67b7-ce15-2baea2dde1e3@gmail.com> References: <20230117142413.189e2cd3@devuan> <20ebf22f-c434-67b7-ce15-2baea2dde1e3@gmail.com> Message-ID: <20230117163013.1f830ce5@devuan> On Tue, 17 Jan 2023 16:19:38 +0100 Valentin wrote: > > this is the default in debian > > Thank you for explaining the historical context. Is this *just* the > historical context or do you mean that busybox *should* follow debian? > If it is the latter, would busybox change the default if debian did so > first? > > > This could be made a config option > > Do you mean a config option in a config file or a command line argument? > adduser currently does not parse any config file and I do not want to > make that part of this change. Adding a command line argument for the > mode is a smaller change but even that I would rather not make part of > this change. Hi, thought about a config option in the busybox build system with 755 as default value that could be modified at build time. It will still be a hardcoded value. Don't know if the maintainer likes this solution, let's see if there is some reaction. Ciao, Tito > _______________________________________________ > busybox mailing list > busybox at busybox.net > http://lists.busybox.net/mailman/listinfo/busybox From vda.linux at googlemail.com Tue Jan 17 15:47:43 2023 From: vda.linux at googlemail.com (Denys Vlasenko) Date: Tue, 17 Jan 2023 16:47:43 +0100 Subject: [PATCH v2] ntpd: make NTP client and server Y2036/2038-ready In-Reply-To: <20220916130636.628472-1-mlichvar@redhat.com> References: <20220916130636.628472-1-mlichvar@redhat.com> Message-ID: Apologies for a very late reply. On Fri, Sep 16, 2022 at 3:07 PM Miroslav Lichvar wrote: > The 32-bit integer part of the NTP timestamp overflows in year 2036, > which starts the second NTP era. > + /* Shift timestamps before 1970 to the second NTP era (2036-2106) */ > + if (lfp.int_partl < OFFSET_1900_1970) > + ret += (double)UINT_MAX + 1.0; Shouldn't this be 0xffffffff instead of UINT_MAX? What you are doing here is treating 0...OFFSET_1900_1970 as if there is a carry bit in int_partl, right? And int_partl is not unit_t. It's uint32_t. Thus you need to add (1<<32). From vda.linux at googlemail.com Tue Jan 17 16:00:50 2023 From: vda.linux at googlemail.com (Denys Vlasenko) Date: Tue, 17 Jan 2023 17:00:50 +0100 Subject: [PATCH v2] ntpd: make NTP client and server Y2036/2038-ready In-Reply-To: References: <20220916130636.628472-1-mlichvar@redhat.com> Message-ID: On Tue, Jan 17, 2023 at 4:47 PM Denys Vlasenko wrote: > Apologies for a very late reply. > > On Fri, Sep 16, 2022 at 3:07 PM Miroslav Lichvar wrote: > > The 32-bit integer part of the NTP timestamp overflows in year 2036, > > which starts the second NTP era. > > > + /* Shift timestamps before 1970 to the second NTP era (2036-2106) */ > > + if (lfp.int_partl < OFFSET_1900_1970) > > + ret += (double)UINT_MAX + 1.0; > > Shouldn't this be 0xffffffff instead of UINT_MAX? > > What you are doing here is treating 0...OFFSET_1900_1970 > as if there is a carry bit in int_partl, right? > And int_partl is not unit_t. It's uint32_t. Thus you need to add > (1<<32). Speaking of this... these are bugs, no? ret = (double)lfp.int_partl + ((double)lfp.fractionl / UINT_MAX); ... ret = (double)sfp.int_parts + ((double)sfp.fractions / USHRT_MAX); because fractionl of 0xffffffff is not 1 second (as the above code thinks), it is less than that: 0xffffffff / (1<<32) seconds From xoneca at gmail.com Tue Jan 17 19:21:48 2023 From: xoneca at gmail.com (Xabier Oneca -- xOneca) Date: Tue, 17 Jan 2023 20:21:48 +0100 Subject: The busybox website is unbearably slow In-Reply-To: <29ff1ca4-a40d-0785-2cfe-cf9165348655@gmail.com> References: <29ff1ca4-a40d-0785-2cfe-cf9165348655@gmail.com> Message-ID: Hi, The busybox website (https://busybox.net) is slow. It often takes more > than 10 seconds for pages to load and sometimes they time out > altogether. > Yes, I see the same in git.busybox.net since a while back. I thought it was my browser's fault (because it sticks in "performing TLS handshake"), but now tried with wget and it connects and waits too. Cheers, Xabier Oneca_,,_ -------------- next part -------------- An HTML attachment was scrubbed... URL: From steffen at sdaoden.eu Tue Jan 17 20:23:33 2023 From: steffen at sdaoden.eu (Steffen Nurpmeso) Date: Tue, 17 Jan 2023 21:23:33 +0100 Subject: ash: redirection bug (temporary file reuse, race condition??) In-Reply-To: <20230117185938.U5TC3%steffen@sdaoden.eu> References: <20230117185938.U5TC3%steffen@sdaoden.eu> Message-ID: <20230117202333.P9GNd%steffen@sdaoden.eu> Hello.. Steffen Nurpmeso wrote in <20230117185938.U5TC3%steffen at sdaoden.eu>: ... | #?0|kent:tmp$ ./t2.sh | inner shell has: 18587 18587 | outer shell has: 18587 18587 | x is 18587, job is 18588: 18588 18587 | #?0|kent:tmp$ ./t2.sh | inner shell has: 18621 18621 | outer shell has: 18621 18621 | x is 18621, job is 18622: PID PGID ... Forget about this please, bash shows the same problems, but i still have not understood why. (Has nothing to do with monitor mode.) --steffen | |Der Kragenbaer, The moon bear, |der holt sich munter he cheerfully and one by one |einen nach dem anderen runter wa.ks himself off |(By Robert Gernhardt) From steffen at sdaoden.eu Tue Jan 17 20:27:31 2023 From: steffen at sdaoden.eu (Steffen Nurpmeso) Date: Tue, 17 Jan 2023 21:27:31 +0100 Subject: ash: support "set -m" monitor mode even when not interactive Message-ID: <20230117202731.6q006%steffen@sdaoden.eu> Hello. This came up on the dash list, and so i took over Jilles Tjoelker's FreeBSD commit from 2014 to busybox ash. Note i have no idea of what i am doing, but from testing it seems to work; i have simply taken it over, which is a cleanup really. (This is on top of my arithmetic patch but it should not really interfere, .. in case linenumber shifts are seen.) Ciao! --steffen | |Der Kragenbaer, The moon bear, |der holt sich munter he cheerfully and one by one |einen nach dem anderen runter wa.ks himself off |(By Robert Gernhardt) -------------- next part -------------- A non-text attachment was scrubbed... Name: ash_monitor_non_imode.patch Type: text/x-diff Size: 6018 bytes Desc: not available URL: From steffen at sdaoden.eu Tue Jan 17 18:59:38 2023 From: steffen at sdaoden.eu (Steffen Nurpmeso) Date: Tue, 17 Jan 2023 19:59:38 +0100 Subject: ash: redirection bug (temporary file reuse, race condition??) Message-ID: <20230117185938.U5TC3%steffen@sdaoden.eu> Hello. Imagine this file: #!/sbin/busybox.static ash #set -m ( echo >&2 "inner shell has: $(ps -o pid,pgid $$ | tail -n1)" ) & echo >&2 "outer shell has: $(ps -o pid,pgid $$ | tail -n1)" echo >&2 "x is $$, job is $!: $(ps -o pid,pgid $! | tail -n1)" If in a t2.sh and run it generates this output: #?0|kent:tmp$ ./t2.sh outer shell has: 18192 18192 inner shell has: 18192 18192 x is 18192, job is 18193: 18193 18192 #?0|kent:tmp$ ./t2.sh inner shell has: 18563 18563 outer shell has: 18563 18563 x is 18563, job is 18564: PID PGID #?0|kent:tmp$ ./t2.sh inner shell has: 18575 18575 outer shell has: 18575 18575 x is 18575, job is 18576: 18576 18575 #?0|kent:tmp$ ./t2.sh inner shell has: 18587 18587 outer shell has: 18587 18587 x is 18587, job is 18588: 18588 18587 #?0|kent:tmp$ ./t2.sh inner shell has: 18621 18621 outer shell has: 18621 18621 x is 18621, job is 18622: PID PGID #?0|kent:tmp$ ./t2.sh inner shell has: 18633 18633 outer shell has: 18633 18633 x is 18633, job is 18634: PID PGID This with and without my $(()) stack B-(. (On the other hand it must be said that i first thought this, because my last busybox, from November 8th, generates output like ?0|kent:tmp$ ./t2.sh inner shell has: PID PGID outer shell has: PID PGID x is 6640, job is 6641: PID PGID #?0|kent:tmp$ ./t2.sh inner shell has: PID PGID outer shell has: PID PGID x is , job is 6792: 6792 6791 ie, it is totally borked. Maybe the miscompilation commit hmm.) Enabling -m'onitor mode makes it less weird. But this is a different story and shall be narrated another time. ("Neverending story", badly translated.) --steffen | |Der Kragenbaer, The moon bear, |der holt sich munter he cheerfully and one by one |einen nach dem anderen runter wa.ks himself off |(By Robert Gernhardt) From steffen at sdaoden.eu Tue Jan 17 20:31:38 2023 From: steffen at sdaoden.eu (Steffen Nurpmeso) Date: Tue, 17 Jan 2023 21:31:38 +0100 Subject: ash: redirection bug (temporary file reuse, race condition??) In-Reply-To: <20230117202333.P9GNd%steffen@sdaoden.eu> References: <20230117185938.U5TC3%steffen@sdaoden.eu> <20230117202333.P9GNd%steffen@sdaoden.eu> Message-ID: <20230117203138.vIPVO%steffen@sdaoden.eu> Steffen Nurpmeso wrote in <20230117202333.P9GNd%steffen at sdaoden.eu>: ... |Forget about this please, bash shows the same problems, but |i still have not understood why. |(Has nothing to do with monitor mode.) Signal cums and causes childs to think they can go. Likely. Sorry for the noise. --steffen | |Der Kragenbaer, The moon bear, |der holt sich munter he cheerfully and one by one |einen nach dem anderen runter wa.ks himself off |(By Robert Gernhardt) From mikes at guam.net Tue Jan 17 21:29:22 2023 From: mikes at guam.net (Michael D. Setzer II) Date: Wed, 18 Jan 2023 07:29:22 +1000 Subject: whois busybox.net seems to show it is about to expire?? Message-ID: <63C71332.18552.1A43088@mikes.guam.net> whois busybox.net [Querying whois.verisign-grs.com] [Redirected to whois.godaddy.com] [Querying whois.godaddy.com] [whois.godaddy.com] Domain Name: BUSYBOX.NET Registry Domain ID: 10276015_DOMAIN_NET-VRSN Registrar WHOIS Server: whois.godaddy.com Registrar URL: https://www.godaddy.com Updated Date: 2022-01-18T00:03:45Z Creation Date: 1999-09-16T08:59:14Z Registrar Registration Expiration Date: 2023-01-17T23:59:59Z Registrar: GoDaddy.com, LLC Registrar IANA ID: 146 Registrar Abuse Contact Email: abuse at godaddy.com Registrar Abuse Contact Phone: +1.4806242505 Domain Status: clientTransferProhibited https://icann.org/epp#clientTransferProhibited Domain Status: clientUpdateProhibited https://icann.org/epp#clientUpdateProhibited Domain Status: clientRenewProhibited https://icann.org/epp#clientRenewProhibited Domain Status: clientDeleteProhibited https://icann.org/epp#clientDeleteProhibited Registry Registrant ID: Not Available From Registry Registrant Name: Registration Private Registrant Organization: Domains By Proxy, LLC Registrant Street: DomainsByProxy.com Registrant Street: 2155 E Warner Rd Registrant City: Tempe Registrant State/Province: Arizona Registrant Postal Code: 85284 Registrant Country: US Registrant Phone: +1.4806242599 Registrant Phone Ext: Registrant Fax: +1.4806242598 Registrant Fax Ext: Registrant Email: Select Contact Domain Holder link at https://www.godaddy.com/whois/results.aspx?domain=BUSYBOX.NET Registry Admin ID: Not Available From Registry Admin Name: Registration Private Admin Organization: Domains By Proxy, LLC Admin Street: DomainsByProxy.com Admin Street: 2155 E Warner Rd Admin City: Tempe Admin State/Province: Arizona Admin Postal Code: 85284 Admin Country: US Admin Phone: +1.4806242599 Admin Phone Ext: Admin Fax: +1.4806242598 Admin Fax Ext: Admin Email: Select Contact Domain Holder link at https://www.godaddy.com/whois/results.aspx?domain=BUSYBOX.NET Registry Tech ID: Not Available From Registry Tech Name: Registration Private Tech Organization: Domains By Proxy, LLC Tech Street: DomainsByProxy.com Tech Street: 2155 E Warner Rd Tech City: Tempe Tech State/Province: Arizona Tech Postal Code: 85284 Tech Country: US Tech Phone: +1.4806242599 Tech Phone Ext: Tech Fax: +1.4806242598 Tech Fax Ext: Tech Email: Select Contact Domain Holder link at https://www.godaddy.com/whois/results.aspx?domain=BUSYBOX.NET Name Server: NS1.AUTH.OSUOSL.ORG Name Server: NS2.AUTH.OSUOSL.ORG Name Server: NS3.AUTH.OSUOSL.ORG DNSSEC: unsigned URL of the ICANN WHOIS Data Problem Reporting System: http://wdprs.internic.net/ >>> Last update of WHOIS database: 2023-01-17T21:25:22Z <<< For more information on Whois status codes, please visit https://icann.org/epp TERMS OF USE: The data contained in this registrar's Whois database, while believed by the registrar to be reliable, is provided "as is" with no guarantee or warranties regarding its accuracy. This information is provided for the sole purpose of assisting you in obtaining information about domain name registration records. Any use of this data for any other purpose is expressly forbidden without the prior written permission of this registrar. By submitting an inquiry, you agree to these terms and limitations of warranty. In particular, you agree not to use this data to allow, enable, or otherwise support the dissemination or collection of this data, in part or in its entirety, for any purpose, such as transmission by e-mail, telephone, postal mail, facsimile or other means of mass unsolicited, commercial advertising or solicitations of any kind, including spam. You further agree not to use this data to enable high volume, automated or robotic electronic processes designed to collect or compile this data for any purpose, including mining this data for your own personal or commercial purposes. Failure to comply with these terms may result in termination of access to the Whois database. These terms may be subject to modification at any time without notice. +------------------------------------------------------------+ Michael D. Setzer II - Computer Science Instructor (Retired) mailto:mikes at guam.net mailto:msetzerii at gmail.com Guam - Where America's Day Begins G4L Disk Imaging Project maintainer http://sourceforge.net/projects/g4l/ +------------------------------------------------------------+ From mlichvar at redhat.com Wed Jan 18 08:36:26 2023 From: mlichvar at redhat.com (Miroslav Lichvar) Date: Wed, 18 Jan 2023 09:36:26 +0100 Subject: [PATCH v2] ntpd: make NTP client and server Y2036/2038-ready In-Reply-To: References: <20220916130636.628472-1-mlichvar@redhat.com> Message-ID: On Tue, Jan 17, 2023 at 05:00:50PM +0100, Denys Vlasenko wrote: > > On Fri, Sep 16, 2022 at 3:07 PM Miroslav Lichvar wrote: > > > The 32-bit integer part of the NTP timestamp overflows in year 2036, > > > which starts the second NTP era. > > > > > + /* Shift timestamps before 1970 to the second NTP era (2036-2106) */ > > > + if (lfp.int_partl < OFFSET_1900_1970) > > > + ret += (double)UINT_MAX + 1.0; > > > > Shouldn't this be 0xffffffff instead of UINT_MAX? > > > > What you are doing here is treating 0...OFFSET_1900_1970 > > as if there is a carry bit in int_partl, right? > > And int_partl is not unit_t. It's uint32_t. Thus you need to add > > (1<<32). Right, that was the intention, but I didn't realize it needs to work on systems where int is not 32-bit. Thanks for fixing it. > Speaking of this... these are bugs, no? Yes. > ret = (double)lfp.int_partl + ((double)lfp.fractionl / UINT_MAX); In this case it probably didn't matter as the values are too large to contain the lowest bits of the fraction in the double format. > ... > ret = (double)sfp.int_parts + ((double)sfp.fractions / USHRT_MAX); -- Miroslav Lichvar From ncopa at alpinelinux.org Wed Jan 18 12:03:43 2023 From: ncopa at alpinelinux.org (Natanael Copa) Date: Wed, 18 Jan 2023 13:03:43 +0100 Subject: sha_ni detection for sha hwaccel is broken Message-ID: <20230118130343.5b4a1e00@ncopa-desktop.lan> Hi, We have an issue where busybox sha1sum and/or sha256sum is broken when HWACCEL is enabled. This has been observed on github runners only so far. I cloned busybox repo and added github runner that build only sha1sum and sha256sum with hwaccel enabled. I added debug printf statements to see if shaNI was enabled or not. What happened was that sometimes shaNI is enabled, and sometimes it is not. You have example of this here: https://github.com/ncopa/busybox/actions/runs/3948518291/jobs/6758600595 As you see, when sha256sum runs, shaNI is -1, but later, using the same binary shaNI becomes 11 and ends up with illegal instruction. Something is off, but I'm not sure what. Disabling hwaccel makes it all go away. I have not been able to reproduce this on my i9. It has only been observed on github runners so far. -nc From peter at korsgaard.com Wed Jan 18 16:45:00 2023 From: peter at korsgaard.com (Peter Korsgaard) Date: Wed, 18 Jan 2023 17:45:00 +0100 Subject: The busybox website is unbearably slow In-Reply-To: (Xabier Oneca's message of "Tue, 17 Jan 2023 20:21:48 +0100") References: <29ff1ca4-a40d-0785-2cfe-cf9165348655@gmail.com> Message-ID: <87wn5jdc6r.fsf@dell.be.48ers.dk> >>>>> "Xabier" == Xabier Oneca <-- xOneca > writes: Hi, > Yes, I see the same in git.busybox.net since a while back. I thought it was > my browser's fault (because it sticks in "performing TLS handshake"), but > now tried with wget and it connects and waits too. I've restarted Apache on the VM, which seems to have improved things somewhat. -- Bye, Peter Korsgaard From farmatito at tiscali.it Wed Jan 18 19:39:27 2023 From: farmatito at tiscali.it (tito) Date: Wed, 18 Jan 2023 20:39:27 +0100 Subject: The busybox website is unbearably slow In-Reply-To: <87wn5jdc6r.fsf@dell.be.48ers.dk> References: <29ff1ca4-a40d-0785-2cfe-cf9165348655@gmail.com> <87wn5jdc6r.fsf@dell.be.48ers.dk> Message-ID: <20230118203927.0ca8e716@devuan> On Wed, 18 Jan 2023 17:45:00 +0100 Peter Korsgaard wrote: > >>>>> "Xabier" == Xabier Oneca <-- xOneca > writes: > > Hi, > > > Yes, I see the same in git.busybox.net since a while back. I thought it was > > my browser's fault (because it sticks in "performing TLS handshake"), but > > now tried with wget and it connects and waits too. > > I've restarted Apache on the VM, which seems to have improved things > somewhat. > Hi, not really improved: The connection has timed out An error occurred during a connection to busybox.net. Ciao, Tito From xoneca at gmail.com Wed Jan 18 19:51:11 2023 From: xoneca at gmail.com (Xabier Oneca -- xOneca) Date: Wed, 18 Jan 2023 20:51:11 +0100 Subject: The busybox website is unbearably slow In-Reply-To: <20230118203927.0ca8e716@devuan> References: <29ff1ca4-a40d-0785-2cfe-cf9165348655@gmail.com> <87wn5jdc6r.fsf@dell.be.48ers.dk> <20230118203927.0ca8e716@devuan> Message-ID: Hi, On 18 jan 2023, 20:40, tito () wrote: > On Wed, 18 Jan 2023 17:45:00 +0100 > Peter Korsgaard wrote: > > > >>>>> "Xabier" == Xabier Oneca <-- xOneca > writes: > > > > Hi, > > > > > Yes, I see the same in git.busybox.net since a while back. I thought > it was > > > my browser's fault (because it sticks in "performing TLS handshake"), > but > > > now tried with wget and it connects and waits too. > > > > I've restarted Apache on the VM, which seems to have improved things > > somewhat. > > > > Hi, > not really improved: > > The connection has timed out > > An error occurred during a connection to busybox.net. > Thank you Peter, but still not improved... :/ Trying HTTP is veeery laggy, and HTTPS just hangs on TLS handshake... $ curl --verbose https://busybox.net/ * Trying 140.211.167.122:443... * Connected to busybox.net (140.211.167.122) port 443 (#0) * ALPN: offers h2 * ALPN: offers http/1.1 * TLSv1.3 (OUT), TLS handshake, Client hello (1): HTH, Xabier Oneca_,,_ -------------- next part -------------- An HTML attachment was scrubbed... URL: From fido_max at inbox.ru Wed Jan 18 19:59:07 2023 From: fido_max at inbox.ru (Maxim Kochetkov) Date: Wed, 18 Jan 2023 22:59:07 +0300 Subject: The busybox website is unbearably slow In-Reply-To: References: <29ff1ca4-a40d-0785-2cfe-cf9165348655@gmail.com> <87wn5jdc6r.fsf@dell.be.48ers.dk> <20230118203927.0ca8e716@devuan> Message-ID: On 18.01.2023 22:51, Xabier Oneca -- xOneca wrote: > Thank you Peter, but still not improved... :/ > > Trying HTTP is veeery laggy, and HTTPS just hangs on TLS handshake... > > $ curl --verbose https://busybox.net/ > * ? Trying 140.211.167.122:443... > * Connected to busybox.net (140.211.167.122) port > 443 (#0) > * ALPN: offers h2 > * ALPN: offers http/1.1 > * TLSv1.3 (OUT), TLS handshake, Client hello (1): > The same for buildroot: $ curl --verbose https://git.buildroot.net/ * Trying 140.211.167.122:443... * Connected to git.buildroot.net (140.211.167.122) port 443 (#0) * ALPN: offers h2 * ALPN: offers http/1.1 * CAfile: /etc/ssl/certs/ca-certificates.crt * CApath: /etc/ssl/certs * TLSv1.0 (OUT), TLS header, Certificate Status (22): * TLSv1.3 (OUT), TLS handshake, Client hello (1): And busybox: curl --verbose https://busybox.net/ * Trying 140.211.167.122:443... * Connected to busybox.net (140.211.167.122) port 443 (#0) * ALPN: offers h2 * ALPN: offers http/1.1 * CAfile: /etc/ssl/certs/ca-certificates.crt * CApath: /etc/ssl/certs * TLSv1.0 (OUT), TLS header, Certificate Status (22): * TLSv1.3 (OUT), TLS handshake, Client hello (1): From peter at korsgaard.com Wed Jan 18 20:19:36 2023 From: peter at korsgaard.com (Peter Korsgaard) Date: Wed, 18 Jan 2023 21:19:36 +0100 Subject: The busybox website is unbearably slow In-Reply-To: (Maxim Kochetkov's message of "Wed, 18 Jan 2023 22:59:07 +0300") References: <29ff1ca4-a40d-0785-2cfe-cf9165348655@gmail.com> <87wn5jdc6r.fsf@dell.be.48ers.dk> <20230118203927.0ca8e716@devuan> Message-ID: <87sfg7d293.fsf@dell.be.48ers.dk> >>>>> "Maxim" == Maxim Kochetkov writes: > On 18.01.2023 22:51, Xabier Oneca -- xOneca wrote: >> Thank you Peter, but still not improved... :/ >> Trying HTTP is veeery laggy, and HTTPS just hangs on TLS >> handshake... >> $ curl --verbose https://busybox.net/ >> * ? Trying 140.211.167.122:443... >> * Connected to busybox.net (140.211.167.122) >> port 443 (#0) >> * ALPN: offers h2 >> * ALPN: offers http/1.1 >> * TLSv1.3 (OUT), TLS handshake, Client hello (1): >> > The same for buildroot: > $ curl --verbose https://git.buildroot.net/ > * Trying 140.211.167.122:443... > curl --verbose https://busybox.net/ > * Trying 140.211.167.122:443... Yes, it is the same machine. -- Bye, Peter Korsgaard From mikes at guam.net Thu Jan 19 00:57:40 2023 From: mikes at guam.net (Michael D. Setzer II) Date: Thu, 19 Jan 2023 10:57:40 +1000 Subject: The busybox website is unbearably slow In-Reply-To: <87sfg7d293.fsf@dell.be.48ers.dk> References: <29ff1ca4-a40d-0785-2cfe-cf9165348655@gmail.com>, (Maxim Kochetkov's message of "Wed, 18 Jan 2023 22:59:07 +0300"), <87sfg7d293.fsf@dell.be.48ers.dk> Message-ID: <63C89584.18493.789396B@mikes.guam.net> Don't know if this has any info. I had downloaded whole site with wget2 the other day, and that seemed to have no problem, but was seein occassional timeouts just going to page. Do note that isitdown is now showing site as up, but another isitup.org is showing it as down? Also, find that traceroute busybox.net doesn't reach site, but traceroute -I busybox.net does? Redid download of https://busybox.net/index.html to see what it shows with the -dv option. It doesn't seem to show and error, but seems there are some lines that show if isn't finding what it wants. wget2 https://busybox.net/index.html [0] Downloading 'https://busybox.net/index.html' ... Saving 'index.html' HTTP response 200 OK [https://busybox.net/index.html] [root at setzconote ~]# man wget2 [root at setzconote ~]# wget2 -dv https://busybox.net/index.html 19.104900.019 Local URI encoding = 'UTF-8' 19.104900.019 Input URI encoding = 'UTF-8' 19.104900.019 Fetched HSTS data from '/root/.local/share/wget/.wget-hsts' 19.104900.019 Fetched HPKP data from '/root/.local/share/wget/.wget-hpkp' 19.104900.019 Fetched OCSP hosts from '/root/.local/share/wget/.wget-ocsp_hosts' 19.104900.019 Fetched OCSP fingerprints from '/root/.local/share/wget/.wget-ocsp' 19.104900.019 set_exit_status(0) 19.104900.020 *url = 19.104900.020 *3 https://busybox.net/index.html 19.104900.020 local filename = 'index.html' 19.104900.020 host_add_job: job fname index.html 19.104900.020 host_add_job: 0x55991eb5f4d0 https://busybox.net/index.html 19.104900.020 host_add_job: qsize 1 host-qsize=1 19.104900.020 queue_size: qsize=1 19.104900.020 queue_size: qsize=1 19.104900.020 queue_size: qsize=1 19.104900.020 [0] action=1 pending=0 host=0x0 19.104900.020 dequeue job https://busybox.net/index.html 19.104900.020 resolving busybox.net:443... 19.104900.023 has 140.211.167.122:443 19.104900.023 trying 140.211.167.122:443... 19.104900.023 GnuTLS init 19.104900.238 GnuTLS system certificate store is empty 19.104900.238 Certificates loaded: 349 19.104900.239 GnuTLS init done 19.104900.239 TLS False Start requested 19.104900.239 ALPN offering h2 19.104900.239 ALPN offering http/1.1 19.104900.467 host has no pubkey pinnings stored in hpkp db 19.104900.467 host has no pubkey pinnings stored in hpkp db 19.104900.468 host has no pubkey pinnings stored in hpkp db 19.104900.468 host has no pubkey pinnings stored in hpkp db 19.104900.469 Cannot find URL from issuer: The requested data were not available. 19.104900.469 Cannot contact OCSP server 19.104900.469 check_ocsp_response() returned -1 19.104900.469 WARNING: OCSP response not available or ignored 19.104900.469 host has no pubkey pinnings stored in hpkp db 19.104900.469 host has no pubkey pinnings stored in hpkp db 19.104900.470 Cannot find issuer: The requested data were not available. 19.104900.471 TLS False Start: off 19.104900.471 ALPN: Server accepted protocol 'http/1.1' ---- Certificate info [0]: Valid since: Sat 19 Nov 2022 01:23:49 PM ChST Expires: Fri 17 Feb 2023 01:23:48 PM ChST Fingerprint: 2d2a317aa3027ca9c0eedfa2fa22f299 Serial number: 2d2a317aa3027ca9c0eedfa2fa22f299 Public key: RSA, Medium (2048 bits) Version: #3 DN: CN=busybox.net Issuer's DN: C=US,O=Let's Encrypt,CN=R3 Issuer's OID: 2.5.4.6 Issuer's UID: 2.5.4.6 Certificate info [1]: Valid since: Fri 04 Sep 2020 10:00:00 AM ChST Expires: Tue 16 Sep 2025 02:00:00 AM ChST Fingerprint: e829e65d7c4307d6fbc13c179e037a36 Serial number: e829e65d7c4307d6fbc13c179e037a36 Public key: RSA, Medium (2048 bits) Version: #3 DN: C=US,O=Let's Encrypt,CN=R3 Issuer's DN: C=US,O=Internet Security Research Group,CN=ISRG Root X1 Issuer's OID: 2.5.4.6 Issuer's UID: 2.5.4.6 Certificate info [2]: Valid since: Thu 21 Jan 2021 05:14:03 AM ChST Expires: Tue 01 Oct 2024 04:14:03 AM ChST Fingerprint: c1e1ff07f9f688498274d1a18053eabf Serial number: c1e1ff07f9f688498274d1a18053eabf Public key: RSA, High (4096 bits) Version: #3 DN: C=US,O=Internet Security Research Group,CN=ISRG Root X1 Issuer's DN: O=Digital Signature Trust Co.,CN=DST Root CA X3 Issuer's OID: 2.5.4.10 Issuer's UID: 2.5.4.10 ---- Ephemeral ECDH using curve X25519 Key Exchange: ECDHE-RSA Protocol: TLS1.3 Certificate Type: X.509 Cipher: AES-256-GCM MAC: AEAD ---- 19.104900.472 Handshake completed 19.104900.472 established connection busybox.net [0] Downloading 'https://busybox.net/index.html' ... 19.104900.472 cookie_create_request_header for host=busybox.net path=index.html 19.104900.472 # sent 228 bytes: GET /index.html HTTP/1.1 Host: busybox.net Accept-Encoding: gzip, deflate, bzip2, xz, lzma, br, zstd Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 User-Agent: wget2/2.0.0 Connection: keep-alive 19.104900.472 [0] action=2 pending=1 host=0x55991eb5f450 19.104900.472 ### req 0x7fb5e4088580 pending requests = 1 19.104900.683 # got header 322 bytes: HTTP/1.1 200 OK Date: Thu, 19 Jan 2023 00:49:00 GMT Server: Apache Strict-Transport-Security: max-age=63072000 Accept-Ranges: bytes X-Content-Type-Options: nosniff X-Frame-Options: DENY X-XSS-Protection: 1 Keep-Alive: timeout=15, max=100 Connection: Keep-Alive Transfer-Encoding: chunked Content-Type: text/html Saving 'index.html.1' 19.104900.684 blacklist set filename: index.html -> index.html.1 19.104900.684 method 1 0 0: 19.104900.684 need at least 211837 more bytes 19.104901.506 chunk completed HTTP response 200 OK [https://busybox.net/index.html] 19.104901.506 keep_alive=1 19.104901.506 update HSTS busybox.net:443 (maxage=63072000, includeSubDomains=0) 19.104901.506 _host_remove_job: 0x55991eb5f4d0 19.104901.506 host_remove_job: qsize=0 host->qsize=0 19.104901.506 [0] action=1 pending=0 host=0x55991eb5f450 19.104901.506 closing connection 19.104901.506 [0] action=1 pending=0 host=0x0 19.104901.506 main: wake up 19.104901.506 main: done 19.104901.507 Successfully updated '/root/.local/share/wget/.wget-hsts'. 19.104901.507 Saved 1 HSTS entry into '/root/.local/share/wget/.wget-hsts' 19.104901.507 Successfully updated '/root/.local/share/wget/.wget-ocsp_hosts'. 19.104901.507 Saved OCSP hosts to '/root/.local/share/wget/.wget-ocsp_hosts' 19.104901.507 Successfully updated '/root/.local/share/wget/.wget-ocsp'. 19.104901.507 Saved OCSP fingerprints to '/root/.local/share/wget/.wget-ocsp' 19.104901.507 blacklist https://busybox.net/index.html On 18 Jan 2023 at 21:19, Peter Korsgaard wrote: From: Peter Korsgaard To: Maxim Kochetkov Subject: Re: The busybox website is unbearably slow Date sent: Wed, 18 Jan 2023 21:19:36 +0100 Copies to: busybox at busybox.net > >>>>> "Maxim" == Maxim Kochetkov writes: > > > On 18.01.2023 22:51, Xabier Oneca -- xOneca wrote: > >> Thank you Peter, but still not improved... :/ > >> Trying HTTP is veeery laggy, and HTTPS just hangs on TLS > >> handshake... > >> $ curl --verbose https://busybox.net/ > >> * ? Trying 140.211.167.122:443... > >> * Connected to busybox.net (140.211.167.122) > >> port 443 (#0) > >> * ALPN: offers h2 > >> * ALPN: offers http/1.1 > >> * TLSv1.3 (OUT), TLS handshake, Client hello (1): > >> > > The same for buildroot: > > > $ curl --verbose https://git.buildroot.net/ > > * Trying 140.211.167.122:443... > > curl --verbose https://busybox.net/ > > * Trying 140.211.167.122:443... > > Yes, it is the same machine. > > -- > Bye, Peter Korsgaard > _______________________________________________ > busybox mailing list > busybox at busybox.net > http://lists.busybox.net/mailman/listinfo/busybox +------------------------------------------------------------+ Michael D. Setzer II - Computer Science Instructor (Retired) mailto:mikes at guam.net mailto:msetzerii at gmail.com Guam - Where America's Day Begins G4L Disk Imaging Project maintainer http://sourceforge.net/projects/g4l/ +------------------------------------------------------------+ From farmatito at tiscali.it Thu Jan 19 06:56:52 2023 From: farmatito at tiscali.it (tito) Date: Thu, 19 Jan 2023 07:56:52 +0100 Subject: The busybox website is unbearably slow In-Reply-To: <63C89584.18493.789396B@mikes.guam.net> References: <29ff1ca4-a40d-0785-2cfe-cf9165348655@gmail.com> <87sfg7d293.fsf@dell.be.48ers.dk> <63C89584.18493.789396B@mikes.guam.net> Message-ID: <20230119075652.08193196@devuan> On Thu, 19 Jan 2023 10:57:40 +1000 "Michael D. Setzer II" wrote: > Don't know if this has any info. I had downloaded whole > site with wget2 the other day, and that seemed to have > no problem, but was seein occassional timeouts just > going to page. > > Do note that isitdown is now showing site as up, but > another isitup.org is showing it as down? > > Also, find that traceroute busybox.net doesn't reach site, > but traceroute -I busybox.net does? > > Redid download of https://busybox.net/index.html to see > what it shows with the -dv option. It doesn't seem to > show and error, but seems there are some lines that > show if isn't finding what it wants. > > wget2 https://busybox.net/index.html > [0] Downloading 'https://busybox.net/index.html' ... > Saving 'index.html' > HTTP response 200 OK [https://busybox.net/index.html] > [root at setzconote ~]# man wget2 > [root at setzconote ~]# wget2 -dv https://busybox.net/index.html > 19.104900.019 Local URI encoding = 'UTF-8' > 19.104900.019 Input URI encoding = 'UTF-8' > 19.104900.019 Fetched HSTS data from '/root/.local/share/wget/.wget-hsts' > 19.104900.019 Fetched HPKP data from '/root/.local/share/wget/.wget-hpkp' > 19.104900.019 Fetched OCSP hosts from > '/root/.local/share/wget/.wget-ocsp_hosts' > 19.104900.019 Fetched OCSP fingerprints from > '/root/.local/share/wget/.wget-ocsp' > 19.104900.019 set_exit_status(0) > 19.104900.020 *url = > 19.104900.020 *3 https://busybox.net/index.html > 19.104900.020 local filename = 'index.html' > 19.104900.020 host_add_job: job fname index.html > 19.104900.020 host_add_job: 0x55991eb5f4d0 https://busybox.net/index.html > 19.104900.020 host_add_job: qsize 1 host-qsize=1 > 19.104900.020 queue_size: qsize=1 > 19.104900.020 queue_size: qsize=1 > 19.104900.020 queue_size: qsize=1 > 19.104900.020 [0] action=1 pending=0 host=0x0 > 19.104900.020 dequeue job https://busybox.net/index.html > 19.104900.020 resolving busybox.net:443... > 19.104900.023 has 140.211.167.122:443 > 19.104900.023 trying 140.211.167.122:443... > 19.104900.023 GnuTLS init > 19.104900.238 GnuTLS system certificate store is empty > 19.104900.238 Certificates loaded: 349 > 19.104900.239 GnuTLS init done > 19.104900.239 TLS False Start requested > 19.104900.239 ALPN offering h2 > 19.104900.239 ALPN offering http/1.1 > 19.104900.467 host has no pubkey pinnings stored in hpkp db > 19.104900.467 host has no pubkey pinnings stored in hpkp db > 19.104900.468 host has no pubkey pinnings stored in hpkp db > 19.104900.468 host has no pubkey pinnings stored in hpkp db > 19.104900.469 Cannot find URL from issuer: The requested data were not > available. > 19.104900.469 Cannot contact OCSP server > 19.104900.469 check_ocsp_response() returned -1 > 19.104900.469 WARNING: OCSP response not available or ignored > 19.104900.469 host has no pubkey pinnings stored in hpkp db > 19.104900.469 host has no pubkey pinnings stored in hpkp db > 19.104900.470 Cannot find issuer: The requested data were not available. > 19.104900.471 TLS False Start: off > 19.104900.471 ALPN: Server accepted protocol 'http/1.1' > ---- > Certificate info [0]: > Valid since: Sat 19 Nov 2022 01:23:49 PM ChST > Expires: Fri 17 Feb 2023 01:23:48 PM ChST > Fingerprint: 2d2a317aa3027ca9c0eedfa2fa22f299 > Serial number: 2d2a317aa3027ca9c0eedfa2fa22f299 > Public key: RSA, Medium (2048 bits) > Version: #3 > DN: CN=busybox.net > Issuer's DN: C=US,O=Let's Encrypt,CN=R3 > Issuer's OID: 2.5.4.6 > Issuer's UID: 2.5.4.6 > Certificate info [1]: > Valid since: Fri 04 Sep 2020 10:00:00 AM ChST > Expires: Tue 16 Sep 2025 02:00:00 AM ChST > Fingerprint: e829e65d7c4307d6fbc13c179e037a36 > Serial number: e829e65d7c4307d6fbc13c179e037a36 > Public key: RSA, Medium (2048 bits) > Version: #3 > DN: C=US,O=Let's Encrypt,CN=R3 > Issuer's DN: C=US,O=Internet Security Research Group,CN=ISRG Root X1 > Issuer's OID: 2.5.4.6 > Issuer's UID: 2.5.4.6 > Certificate info [2]: > Valid since: Thu 21 Jan 2021 05:14:03 AM ChST > Expires: Tue 01 Oct 2024 04:14:03 AM ChST > Fingerprint: c1e1ff07f9f688498274d1a18053eabf > Serial number: c1e1ff07f9f688498274d1a18053eabf > Public key: RSA, High (4096 bits) > Version: #3 > DN: C=US,O=Internet Security Research Group,CN=ISRG Root X1 > Issuer's DN: O=Digital Signature Trust Co.,CN=DST Root CA X3 > Issuer's OID: 2.5.4.10 > Issuer's UID: 2.5.4.10 > ---- > Ephemeral ECDH using curve X25519 > Key Exchange: ECDHE-RSA > Protocol: TLS1.3 > Certificate Type: X.509 > Cipher: AES-256-GCM > MAC: AEAD > ---- > 19.104900.472 Handshake completed > 19.104900.472 established connection busybox.net > [0] Downloading 'https://busybox.net/index.html' ... > 19.104900.472 cookie_create_request_header for host=busybox.net > path=index.html > 19.104900.472 # sent 228 bytes: > GET /index.html HTTP/1.1 > Host: busybox.net > Accept-Encoding: gzip, deflate, bzip2, xz, lzma, br, zstd > Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 > User-Agent: wget2/2.0.0 > Connection: keep-alive > > 19.104900.472 [0] action=2 pending=1 host=0x55991eb5f450 > 19.104900.472 ### req 0x7fb5e4088580 pending requests = 1 > 19.104900.683 # got header 322 bytes: > HTTP/1.1 200 OK > Date: Thu, 19 Jan 2023 00:49:00 GMT > Server: Apache > Strict-Transport-Security: max-age=63072000 > Accept-Ranges: bytes > X-Content-Type-Options: nosniff > X-Frame-Options: DENY > X-XSS-Protection: 1 > Keep-Alive: timeout=15, max=100 > Connection: Keep-Alive > Transfer-Encoding: chunked > Content-Type: text/html > > Saving 'index.html.1' > 19.104900.684 blacklist set filename: index.html -> index.html.1 > 19.104900.684 method 1 0 0: > 19.104900.684 need at least 211837 more bytes > 19.104901.506 chunk completed > HTTP response 200 OK [https://busybox.net/index.html] > 19.104901.506 keep_alive=1 > 19.104901.506 update HSTS busybox.net:443 (maxage=63072000, > includeSubDomains=0) > 19.104901.506 _host_remove_job: 0x55991eb5f4d0 > 19.104901.506 host_remove_job: qsize=0 host->qsize=0 > 19.104901.506 [0] action=1 pending=0 host=0x55991eb5f450 > 19.104901.506 closing connection > 19.104901.506 [0] action=1 pending=0 host=0x0 > 19.104901.506 main: wake up > 19.104901.506 main: done > 19.104901.507 Successfully updated '/root/.local/share/wget/.wget-hsts'. > 19.104901.507 Saved 1 HSTS entry into '/root/.local/share/wget/.wget-hsts' > 19.104901.507 Successfully updated '/root/.local/share/wget/.wget-ocsp_hosts'. > 19.104901.507 Saved OCSP hosts to '/root/.local/share/wget/.wget-ocsp_hosts' > 19.104901.507 Successfully updated '/root/.local/share/wget/.wget-ocsp'. > 19.104901.507 Saved OCSP fingerprints to '/root/.local/share/wget/.wget-ocsp' > 19.104901.507 blacklist https://busybox.net/index.html > > > On 18 Jan 2023 at 21:19, Peter Korsgaard wrote: > > From: Peter Korsgaard > To: Maxim Kochetkov > Subject: Re: The busybox website is unbearably > slow > Date sent: Wed, 18 Jan 2023 21:19:36 +0100 > Copies to: busybox at busybox.net > > > >>>>> "Maxim" == Maxim Kochetkov writes: > > > > > On 18.01.2023 22:51, Xabier Oneca -- xOneca wrote: > > >> Thank you Peter, but still not improved... :/ > > >> Trying HTTP is veeery laggy, and HTTPS just hangs on TLS > > >> handshake... > > >> $ curl --verbose https://busybox.net/ > > >> * ? Trying 140.211.167.122:443... > > >> * Connected to busybox.net (140.211.167.122) > > >> port 443 (#0) > > >> * ALPN: offers h2 > > >> * ALPN: offers http/1.1 > > >> * TLSv1.3 (OUT), TLS handshake, Client hello (1): > > >> > > > The same for buildroot: > > > > > $ curl --verbose https://git.buildroot.net/ > > > * Trying 140.211.167.122:443... > > > curl --verbose https://busybox.net/ > > > * Trying 140.211.167.122:443... > > > > Yes, it is the same machine. > > > > -- > > Bye, Peter Korsgaard > > _______________________________________________ > > busybox mailing list > > busybox at busybox.net > > http://lists.busybox.net/mailman/listinfo/busybox > > > +------------------------------------------------------------+ > Michael D. Setzer II - Computer Science Instructor > (Retired) > mailto:mikes at guam.net > mailto:msetzerii at gmail.com > Guam - Where America's Day Begins > G4L Disk Imaging Project maintainer > http://sourceforge.net/projects/g4l/ > +------------------------------------------------------------+ > > > > _______________________________________________ > busybox mailing list > busybox at busybox.net > http://lists.busybox.net/mailman/listinfo/busybox Hi, seems to work now. Name registration was updated Registrar Registration Expiration Date: 2024-01-17T23:59:59Z Ciao, Tito From peter at korsgaard.com Thu Jan 19 06:58:51 2023 From: peter at korsgaard.com (Peter Korsgaard) Date: Thu, 19 Jan 2023 07:58:51 +0100 Subject: The busybox website is unbearably slow In-Reply-To: <63C89584.18493.789396B@mikes.guam.net> (Michael D. Setzer, II's message of "Thu, 19 Jan 2023 10:57:40 +1000") References: <29ff1ca4-a40d-0785-2cfe-cf9165348655@gmail.com> <87sfg7d293.fsf@dell.be.48ers.dk> <63C89584.18493.789396B@mikes.guam.net> Message-ID: <87o7qvc8no.fsf@dell.be.48ers.dk> >>>>> "Michael" == Michael D Setzer writes: > Don't know if this has any info. I had downloaded whole > site with wget2 the other day, and that seemed to have > no problem, but was seein occassional timeouts just > going to page. > Do note that isitdown is now showing site as up, but > another isitup.org is showing it as down? > Also, find that traceroute busybox.net doesn't reach site, > but traceroute -I busybox.net does? > Redid download of https://busybox.net/index.html to see > what it shows with the -dv option. It doesn't seem to > show and error, but seems there are some lines that > show if isn't finding what it wants. Please don't load the web server any more than it already is. The old VM / low memory / CGI scripts for cgit / bugzilla limits the amount of concurrent requests it can handle. Apache is running, but it sometimes ends up running out of workers: [mpm_worker:error] [pid 21136:tid 3080316736] AH00286: server reached MaxRequestWorkers setting, consider raising the MaxRequestWorkers setting Raising MaxRequestWorkers has to be done carefully as otherwise the machine OOM's under load. -- Bye, Peter Korsgaard From vda.linux at googlemail.com Thu Jan 19 09:07:27 2023 From: vda.linux at googlemail.com (Denys Vlasenko) Date: Thu, 19 Jan 2023 10:07:27 +0100 Subject: The busybox website is unbearably slow In-Reply-To: <87wn5jdc6r.fsf@dell.be.48ers.dk> References: <29ff1ca4-a40d-0785-2cfe-cf9165348655@gmail.com> <87wn5jdc6r.fsf@dell.be.48ers.dk> Message-ID: On Wed, Jan 18, 2023 at 5:45 PM Peter Korsgaard wrote: > >>>>> "Xabier" == Xabier Oneca <-- xOneca > writes: > Hi, > > > Yes, I see the same in git.busybox.net since a while back. I thought it was > > my browser's fault (because it sticks in "performing TLS handshake"), but > > now tried with wget and it connects and waits too. > > I've restarted Apache on the VM, which seems to have improved things > somewhat. It's slow because it is configured to have limited small number of concurrent connections. When there are more connections, they are held up and can time out. There are several periodic "git pull" scripts somewhere on the Net querying the site all the time. With larger connection limit, they can spawn so many git processes that machine OOMs (hangs) and needs to be manually rebooted. From guille.rodriguez at gmail.com Thu Jan 19 15:06:02 2023 From: guille.rodriguez at gmail.com (Guillermo Rodriguez Garcia) Date: Thu, 19 Jan 2023 16:06:02 +0100 Subject: The busybox website is unbearably slow In-Reply-To: References: <29ff1ca4-a40d-0785-2cfe-cf9165348655@gmail.com> <87wn5jdc6r.fsf@dell.be.48ers.dk> Message-ID: Perhaps the static website could be moved somewhere else (Github Pages, Netlify, etc). This would solve the problem for the static sites, and alleviate the load for git.busybox.net. Guillermo El jue, 19 ene 2023 a las 10:08, Denys Vlasenko () escribi?: > On Wed, Jan 18, 2023 at 5:45 PM Peter Korsgaard > wrote: > > >>>>> "Xabier" == Xabier Oneca <-- xOneca > writes: > > Hi, > > > > > Yes, I see the same in git.busybox.net since a while back. I thought > it was > > > my browser's fault (because it sticks in "performing TLS handshake"), > but > > > now tried with wget and it connects and waits too. > > > > I've restarted Apache on the VM, which seems to have improved things > > somewhat. > > It's slow because it is configured to have limited small number of > concurrent > connections. When there are more connections, they are held up and can > time out. > > There are several periodic "git pull" scripts somewhere on the Net > querying the site > all the time. With larger connection limit, they can spawn so many git > processes > that machine OOMs (hangs) and needs to be manually rebooted. > _______________________________________________ > busybox mailing list > busybox at busybox.net > http://lists.busybox.net/mailman/listinfo/busybox > -- Guillermo Rodriguez Garcia guille.rodriguez at gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From steffen at sdaoden.eu Thu Jan 19 18:48:44 2023 From: steffen at sdaoden.eu (Steffen Nurpmeso) Date: Thu, 19 Jan 2023 19:48:44 +0100 Subject: The busybox website is unbearably slow In-Reply-To: References: <29ff1ca4-a40d-0785-2cfe-cf9165348655@gmail.com> <87wn5jdc6r.fsf@dell.be.48ers.dk> Message-ID: <20230119184844._3x1D%steffen@sdaoden.eu> Guillermo Rodriguez Garcia wrote in : |Perhaps the static website could be moved somewhere else (Github Pages, |Netlify, etc). This would solve the problem for the static sites, and |alleviate the load for git.busybox.net. lighttpd now supports KTLS. I am super happy with it. But i have rather strict firewall rules that downgrade things that come often (or download much), and have server.max-keep-alive-requests=1 for git access (could do connection.kbytes-per-second= also for it, but luckily that not needed for me _YET_), so they get used to it. git browsing only with basic HTTP authentication, that cut my distress by an enormous amount, most bots are so primitive. curl -I and lynx show the HTTP realm, unfortunately firefox not, so those have to read the web site to know about the right password and user. --steffen | |Der Kragenbaer, The moon bear, |der holt sich munter he cheerfully and one by one |einen nach dem anderen runter wa.ks himself off |(By Robert Gernhardt) From mjt at tls.msk.ru Sat Jan 21 15:37:17 2023 From: mjt at tls.msk.ru (Michael Tokarev) Date: Sat, 21 Jan 2023 18:37:17 +0300 Subject: [PATCH] buildsys: resurrect PLATFORM_LINUX and depend on it for linux-specific applets In-Reply-To: <20221104164927.95804-1-mjt@msgid.tls.msk.ru> References: <20221104164927.95804-1-mjt@msgid.tls.msk.ru> Message-ID: A friendly ping? This patch still applies and works okay with current 1.36 version. Thanks, /mjt 04.11.2022 19:49, Michael Tokarev wrote: > This effectively reverts the following two commits: > > commit e3b1a1fd28558f7a1b3c0ec33313bedb675be8a1 > Author: Denys Vlasenko > Date: Sat Feb 26 22:24:08 2011 +0100 > > Replace "depends on PLATFORM_LINUX" with "select PLATFORM_LINUX" > > and > > commit 5c69ad0ecdc18cf51b312c7c82848f4438fe1c8d > Author: Ron Yorston > Date: Tue Aug 4 08:24:19 2020 +0100 > > build system: drop PLATFORM_LINUX > > but does, hopefully, the right thing. ? From peron.clem at gmail.com Sat Jan 21 16:49:25 2023 From: peron.clem at gmail.com (=?UTF-8?B?Q2zDqW1lbnQgUMOpcm9u?=) Date: Sat, 21 Jan 2023 17:49:25 +0100 Subject: [PATCH] buildsys: resurrect PLATFORM_LINUX and depend on it for linux-specific applets In-Reply-To: References: <20221104164927.95804-1-mjt@msgid.tls.msk.ru> Message-ID: Hi Michael, On Sat, 21 Jan 2023 at 16:38, Michael Tokarev wrote: > > A friendly ping? > > This patch still applies and works okay with current 1.36 version. diff --git a/miscutils/lsscsi.c b/miscutils/lsscsi.c index 8f7eda761..a9d8c3772 100644 --- a/miscutils/lsscsi.c +++ b/miscutils/lsscsi.c @@ -9,6 +9,7 @@ //config:config LSSCSI //config: bool "lsscsi (2.5 kb)" //config: default y +//config: #depends on PLATFORM_LINUX Why is there a '#' here? Should we not drop it? same for lspci.c /lsusb.c Maybe add a small comment in the Makefile about the .platform.in: Regards, Clement > > Thanks, > > /mjt > > 04.11.2022 19:49, Michael Tokarev wrote: > > This effectively reverts the following two commits: > > > > commit e3b1a1fd28558f7a1b3c0ec33313bedb675be8a1 > > Author: Denys Vlasenko > > Date: Sat Feb 26 22:24:08 2011 +0100 > > > > Replace "depends on PLATFORM_LINUX" with "select PLATFORM_LINUX" > > > > and > > > > commit 5c69ad0ecdc18cf51b312c7c82848f4438fe1c8d > > Author: Ron Yorston > > Date: Tue Aug 4 08:24:19 2020 +0100 > > > > build system: drop PLATFORM_LINUX > > > > but does, hopefully, the right thing. > ? > > _______________________________________________ > busybox mailing list > busybox at busybox.net > http://lists.busybox.net/mailman/listinfo/busybox From mjt at tls.msk.ru Sat Jan 21 17:05:44 2023 From: mjt at tls.msk.ru (Michael Tokarev) Date: Sat, 21 Jan 2023 20:05:44 +0300 Subject: [PATCH] buildsys: resurrect PLATFORM_LINUX and depend on it for linux-specific applets In-Reply-To: References: <20221104164927.95804-1-mjt@msgid.tls.msk.ru> Message-ID: <1fbeacf6-43d4-e1b1-6ca3-d7a09faf8afc@msgid.tls.msk.ru> 21.01.2023 19:49, Cl?ment P?ron ?????: > Hi Michael, > > On Sat, 21 Jan 2023 at 16:38, Michael Tokarev wrote: >> >> A friendly ping? >> >> This patch still applies and works okay with current 1.36 version. > > diff --git a/miscutils/lsscsi.c b/miscutils/lsscsi.c > index 8f7eda761..a9d8c3772 100644 > --- a/miscutils/lsscsi.c > +++ b/miscutils/lsscsi.c > @@ -9,6 +9,7 @@ > //config:config LSSCSI > //config: bool "lsscsi (2.5 kb)" > //config: default y > +//config: #depends on PLATFORM_LINUX > Why is there a '#' here? Should we not drop it? > > same for lspci.c /lsusb.c These has been there before this PLATFORM_LINUX has been dropped. It is basically a revert of the previous patch (rebased to current version). To me, it looks like it weren't clear if these applets are linux-specific or not, so I decided to keep it this way now, - we'll know it once others will start using this stuff on other platforms. Think of it as a documentation, - when you grep for PLATFORM_LINUX you'll see them. It's trivial to drop these though. > Maybe add a small comment in the Makefile about the > .platform.in: That might be a good idea indeed. But having in mind the age of this context and the previous attempts to change it, I'd love to have some feedback for the approach itself, before adding cosmetics. I don't like this .platform.in file, - linux-kernel kconfig now has some variables support so things like that does not require temp files, but busybox's kconfig is older, so this hack is the only way to do that which I found. Maybe I'm wrong here. Either way, this change allowed us to build and use busybox on hurd and kfreebsd, finally.. /mjt From marian.buschsieweke at ovgu.de Tue Jan 24 11:27:59 2023 From: marian.buschsieweke at ovgu.de (Marian Buschsieweke) Date: Tue, 24 Jan 2023 12:27:59 +0100 Subject: Proposed fix for issue 15256 Message-ID: <20230124122759.74c03092@flerk.lan> Hi everyone, the attached patch fixes the issue https://bugs.busybox.net/show_bug.cgi?id=15256 for me. It is the same as the one uploaded in the issue report. Kind regards, Marian -------------- next part -------------- A non-text attachment was scrubbed... Name: 0026-lineedit-Handle-SIGWINCH-gracefully.patch Type: text/x-patch Size: 2062 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 228 bytes Desc: OpenPGP digital signature URL: From ahe at helmcke.name Wed Jan 25 18:25:36 2023 From: ahe at helmcke.name (Andreas Helmcke) Date: Wed, 25 Jan 2023 19:25:36 +0100 Subject: [PATCH v4] pw_encrypt: Add option to enable bcrypt support In-Reply-To: <0d194913-e463-8d26-42c8-d012858f36c3@helmcke.name> References: <78ce2003-fab6-d3b7-05f6-619fdf331071@Z5T1.com> <2250d85c-419e-933e-cef6-764791bd24e9@dinapo.li> <8f7fc9b5-4171-4e7a-e89d-97e22d864779@helmcke.name> <0d194913-e463-8d26-42c8-d012858f36c3@helmcke.name> Message-ID: <1d02ab2c-d1bf-e8d9-06af-42fb1bfa757b@helmcke.name> Adds an option to the Login/Password Management Utilities menu to enable bcrypt support in passwd and chpasswd. Add support for bcrypt to BusyBox chpasswd & passwd. Based on patch proposed by Scott Court. Changes to the orignal patch: - added config option for bcrypt cost - made code changes fully dependend on config option - changed algorithm tag to $2b$ - help texts added for bcrypt option Signed-off-by: Andreas Helmcke --- include/libbb.h | 5 +++++ include/usage.src.h | 5 +++++ libbb/pw_encrypt.c | 14 ++++++++++++++ loginutils/Config.src | 23 +++++++++++++++++++++++ loginutils/chpasswd.c | 3 ++- 5 files changed, 49 insertions(+), 1 deletion(-) diff --git a/include/libbb.h b/include/libbb.h index cca33a177..6e78df974 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -1777,8 +1777,13 @@ extern int obscure(const char *old, const char *newval, const struct passwd *pwd * (otherwise we risk having same salt generated) */ extern int crypt_make_salt(char *p, int cnt /*, int rnd*/) FAST_FUNC; +#if ENABLE_USE_BCRYPT +/* "$NX$10$" + bcrypt_salt_24_bytes + NUL */ +#define MAX_PW_SALT_LEN (7 + 24 + 1) +#else /* "$N$" + sha_salt_16_bytes + NUL */ #define MAX_PW_SALT_LEN (3 + 16 + 1) +#endif extern char* crypt_make_pw_salt(char p[MAX_PW_SALT_LEN], const char *algo) FAST_FUNC; diff --git a/include/usage.src.h b/include/usage.src.h index 5d2038834..d8a679ab3 100644 --- a/include/usage.src.h +++ b/include/usage.src.h @@ -18,8 +18,13 @@ #define scripted_full_usage "" #if !ENABLE_USE_BB_CRYPT || ENABLE_USE_BB_CRYPT_SHA +#if ENABLE_USE_BCRYPT +# define CRYPT_METHODS_HELP_STR "des,md5,sha256/512,bcrypt" \ + " (default "CONFIG_FEATURE_DEFAULT_PASSWD_ALGO")" +#else # define CRYPT_METHODS_HELP_STR "des,md5,sha256/512" \ " (default "CONFIG_FEATURE_DEFAULT_PASSWD_ALGO")" +#endif #else # define CRYPT_METHODS_HELP_STR "des,md5" \ " (default "CONFIG_FEATURE_DEFAULT_PASSWD_ALGO")" diff --git a/libbb/pw_encrypt.c b/libbb/pw_encrypt.c index 3463fd95b..5b71a54a5 100644 --- a/libbb/pw_encrypt.c +++ b/libbb/pw_encrypt.c @@ -70,6 +70,20 @@ char* FAST_FUNC crypt_make_pw_salt(char salt[MAX_PW_SALT_LEN], const char *algo) salt[1] = '5' + (strcasecmp(algo, "sha512") == 0); len = 16/2; } +#endif +#if ENABLE_USE_BCRYPT +#if !ENABLE_FEATURE_BCRYPT_COST || CONFIG_FEATURE_BCRYPT_COST < 4 || CONFIG_FEATURE_BCRYPT_COST > 31 +#error Bad FEATURE_BCRYPT_COST in .config +#endif + if ((algo[0]|0x20) == 'b') { /* bcrypt */ + salt[1] = '2'; + salt[2] = 'b'; + *salt_ptr++ = '$'; + *salt_ptr++ = ((CONFIG_FEATURE_BCRYPT_COST) / 10) + '0'; + *salt_ptr++ = ((CONFIG_FEATURE_BCRYPT_COST) % 10) + '0'; + *salt_ptr++ = '$'; + len = 24/2; + } #endif } crypt_make_salt(salt_ptr, len); diff --git a/loginutils/Config.src b/loginutils/Config.src index cbb09646b..cdf36a55f 100644 --- a/loginutils/Config.src +++ b/loginutils/Config.src @@ -91,6 +91,29 @@ config USE_BB_CRYPT_SHA With this option off, login will fail password check for any user which has password encrypted with these algorithms. +config USE_BCRYPT + bool "Enable bcrypt and other password hashes." + default n + depends on !USE_BB_CRYPT + help + Enable this if you use newer password hashes like bcrypt. E.g. + if you have passwords starting with $2a$, $2y$ or $2b$ in your + /etc/passwd or /etc/shadow files. Requires the use of a C + library that supports these hashes. + Adds support for bcrypt to passwd, cryptpw and chpasswd. + +config FEATURE_BCRYPT_COST + int "bcrypt cost" + range 4 31 + default 10 + depends on USE_BCRYPT + help + Cost parameter for the bcrypt hashing algorithm. + Specifies the number of rounds to use. Must be between 4 and 31, + inclusive. This value is logarithmic, the actual number of + iterations used will be 2**rounds ? increasing the rounds by +1 + will double the amount of time taken. + INSERT endmenu diff --git a/loginutils/chpasswd.c b/loginutils/chpasswd.c index a032abbed..74673fa6f 100644 --- a/loginutils/chpasswd.c +++ b/loginutils/chpasswd.c @@ -17,7 +17,8 @@ //config: default "des" //config: depends on PASSWD || CRYPTPW || CHPASSWD //config: help -//config: Possible choices are "d[es]", "m[d5]", "s[ha256]" or "sha512". +//config: Possible choices are "d[es]", "m[d5]", "s[ha256]", +//config: "sha512" or "b[crypt]" (when enabled). //applet:IF_CHPASSWD(APPLET(chpasswd, BB_DIR_USR_SBIN, BB_SUID_DROP)) -- 2.37.2 From vda.linux at googlemail.com Thu Jan 26 12:00:34 2023 From: vda.linux at googlemail.com (Denys Vlasenko) Date: Thu, 26 Jan 2023 13:00:34 +0100 Subject: Proposed fix for issue 15256 In-Reply-To: <20230124122759.74c03092@flerk.lan> References: <20230124122759.74c03092@flerk.lan> Message-ID: (1) This can race with other signals. (2) This allows SIGWINCH to "erase" a concurrently arriving signal. I am trying to fix this instead by ignoring signals (poll returning EINTR) which do *not* set bb_got_signal. (This needs a bit of surgery in hush to not set it on SIGCHLD). Please try current git. On Tue, Jan 24, 2023 at 12:34 PM Marian Buschsieweke wrote: > > Hi everyone, > > the attached patch fixes the issue > https://bugs.busybox.net/show_bug.cgi?id=15256 for me. It is the same as the one uploaded in the issue report. > > Kind regards, > Marian > _______________________________________________ > busybox mailing list > busybox at busybox.net > http://lists.busybox.net/mailman/listinfo/busybox From berff2014 at outlook.com Sat Jan 28 16:54:13 2023 From: berff2014 at outlook.com (Fred Friedrich) Date: Sat, 28 Jan 2023 16:54:13 +0000 Subject: Update Copyright 2023 Message-ID: Hello, it seems like the copyright was not updated for a long time :-). Consider this small fix for it: --- libbb/appletlib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libbb/appletlib.c b/libbb/appletlib.c index d5335d353..bac277aa9 100644 --- a/libbb/appletlib.c +++ b/libbb/appletlib.c @@ -780,7 +780,7 @@ int busybox_main(int argc UNUSED_PARAM, char **argv) full_write2_str(bb_banner); /* reuse const string */ full_write2_str(" multi-call binary.\n"); /* reuse */ full_write2_str( - "BusyBox is copyrighted by many authors between 1998-2015.\n" + "BusyBox is copyrighted by many authors between 1998-2023.\n" "Licensed under GPLv2. See source distribution for detailed\n" "copyright notices.\n" "\n" -- 2.39.0 From d+busybox at adaptive-enterprises.com Sun Jan 29 02:07:08 2023 From: d+busybox at adaptive-enterprises.com (David Leonard) Date: Sun, 29 Jan 2023 12:07:08 +1000 (AEST) Subject: [PATCH] find: implement -ok In-Reply-To: <9p395o38-9o30-q397-83nn-612r2orors5s@nqncgvir-ragrecevfrf.pbz> References: <9p395o38-9o30-q397-83nn-612r2orors5s@nqncgvir-ragrecevfrf.pbz> Message-ID: <36947oo9-4s69-904r-10r7-n66o9s24or46@nqncgvir-ragrecevfrf.pbz> Resending patch for 'find -ok'. I re-ran bloatcheck (x86_64). Subject: [PATCH] find: implement -ok https://pubs.opengroup.org/onlinepubs/9699919799/utilities/find.html -ok utility_name [argument?...]?; The -ok primary shall be equivalent to -exec, except that the use of a to punctuate the end of the primary expression need not be supported, and find shall request affirmation of the invocation of utility_name using the current file as an argument by writing to standard error as described in the STDERR section. If the response on standard input is affirmative, the utility shall be invoked. Otherwise, the command shall not be invoked and the value of the -ok operand shall be false. function old new delta do_exec 438 517 +79 parse_params 1833 1845 +12 static.params 288 292 +4 .rodata 100771 100775 +4 packed_usage 34543 34541 -2 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 4/1 up/down: 99/-2) Total: 97 bytes text data bss dec hex filename 1064433 16587 1816 1082836 1085d4 busybox_old 1064530 16587 1816 1082933 108635 busybox_unstripped --- findutils/find.c | 32 ++++++++++++++++++++++++++++++-- testsuite/find.tests | 6 ++++++ 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/findutils/find.c b/findutils/find.c index bb6ad31e5..40f66ab2e 100644 --- a/findutils/find.c +++ b/findutils/find.c @@ -180,6 +180,13 @@ //config: Without this option, -exec + is a synonym for -exec ; //config: (IOW: it works correctly, but without expected speedup) //config: +//config:config FEATURE_FIND_EXEC_OK +//config: bool "Enable -ok: execute confirmed commands" +//config: default y +//config: depends on FEATURE_FIND_EXEC +//config: help +//config: Support the 'find -ok' option which prompts before executing. +//config: //config:config FEATURE_FIND_USER //config: bool "Enable -user: username/uid matching" //config: default y @@ -395,6 +402,9 @@ //usage: IF_FEATURE_FIND_EXEC_PLUS( //usage: "\n -exec CMD ARG + Run CMD with {} replaced by list of file names" //usage: ) +//usage: IF_FEATURE_FIND_EXEC_OK( +//usage: "\n -ok CMD ARG ; Prompt and run CMD with {} replaced" +//usage: ) //usage: IF_FEATURE_FIND_DELETE( //usage: "\n -delete Delete current file/directory. Turns on -depth option" //usage: ) @@ -467,6 +477,9 @@ IF_FEATURE_FIND_EXEC( ACTS(exec, char **exec_argv; /* -exec ARGS */ unsigned *subst_count; int exec_argc; /* count of ARGS */ + IF_FEATURE_FIND_EXEC_OK( + int ok; /* -ok */ + ) IF_FEATURE_FIND_EXEC_PLUS( /* * filelist is NULL if "exec ;" @@ -802,10 +815,22 @@ static int do_exec(action_exec *ap, const char *fileName) } # endif +# if ENABLE_FEATURE_FIND_EXEC_OK + if (ap->ok) { + for (i = 0; argv[i]; i++) + fprintf(stderr, "%s ", argv[i]); + fprintf(stderr, "?"); + if (!bb_ask_y_confirmation()) + goto not_ok; + } +# endif rc = spawn_and_wait(argv); if (rc < 0) bb_simple_perror_msg(argv[0]); +# if ENABLE_FEATURE_FIND_EXEC_OK + not_ok: +# endif i = 0; while (argv[i]) free(argv[i++]); @@ -1120,6 +1145,7 @@ static action*** parse_params(char **argv) IF_FEATURE_FIND_DELETE( PARM_delete ,) IF_FEATURE_FIND_EMPTY( PARM_empty ,) IF_FEATURE_FIND_EXEC( PARM_exec ,) + IF_FEATURE_FIND_EXEC_OK(PARM_ok ,) IF_FEATURE_FIND_EXECUTABLE(PARM_executable,) IF_FEATURE_FIND_PAREN( PARM_char_brace,) /* All options/actions starting from here require argument */ @@ -1171,6 +1197,7 @@ static action*** parse_params(char **argv) IF_FEATURE_FIND_DELETE( "-delete\0" ) IF_FEATURE_FIND_EMPTY( "-empty\0" ) IF_FEATURE_FIND_EXEC( "-exec\0" ) + IF_FEATURE_FIND_EXEC_OK("-ok\0" ) IF_FEATURE_FIND_EXECUTABLE("-executable\0") IF_FEATURE_FIND_PAREN( "(\0" ) /* All options/actions starting from here require argument */ @@ -1351,18 +1378,19 @@ static action*** parse_params(char **argv) } #endif #if ENABLE_FEATURE_FIND_EXEC - else if (parm == PARM_exec) { + else if (parm == PARM_exec IF_FEATURE_FIND_EXEC_OK(|| parm == PARM_ok)) { int i; action_exec *ap; IF_FEATURE_FIND_EXEC_PLUS(int all_subst = 0;) dbg("%d", __LINE__); G.need_print = 0; ap = ALLOC_ACTION(exec); + IF_FEATURE_FIND_EXEC_OK(ap->ok = (parm == PARM_ok);) ap->exec_argv = ++argv; /* first arg after -exec */ /*ap->exec_argc = 0; - ALLOC_ACTION did it */ while (1) { if (!*argv) /* did not see ';' or '+' until end */ - bb_error_msg_and_die(bb_msg_requires_arg, "-exec"); + bb_error_msg_and_die(bb_msg_requires_arg, arg); // find -exec echo Foo ">{}<" ";" // executes "echo Foo >FILENAME<", // find -exec echo Foo ">{}<" "+" diff --git a/testsuite/find.tests b/testsuite/find.tests index 138236c81..effdf60a6 100755 --- a/testsuite/find.tests +++ b/testsuite/find.tests @@ -28,6 +28,12 @@ testing "find -exec exitcode 2" \ "0\n" \ "" "" SKIP= +optional FEATURE_FIND_EXEC_OK +testing "find -ok" \ + "cd find.tempdir && find testfile -ok true {} + 2>&1; echo \$?" \ + "true testfile ?\n0\n" \ + "" "y" +SKIP= # Surprisingly, "-exec false ;" results in exitcode 0! "-exec false +" is different!!! optional FEATURE_FIND_EXEC testing "find -exec exitcode 3" \ -- 2.34.1 From d+busybox at adaptive-enterprises.com Sun Jan 29 02:08:36 2023 From: d+busybox at adaptive-enterprises.com (David Leonard) Date: Sun, 29 Jan 2023 12:08:36 +1000 (AEST) Subject: [PATCH] find: implement -nouser, -nogroup In-Reply-To: References: Message-ID: Resending patch for 'find -nouser', 'find -nogroup'. Refreshed bloatcheck Subject: [PATCH] find: implement -nouser, -nogroup https://pubs.opengroup.org/onlinepubs/9699919799/utilities/find.html -nouser The primary shall evaluate as true if the file belongs to a user ID for which the getpwuid() function defined in the System Interfaces volume of POSIX.1-2017 (or equivalent) returns NULL. -nogroup The primary shall evaluate as true if the file belongs to a group ID for which the getgrgid() function defined in the System Interfaces volume of POSIX.1-2017 (or equivalent) returns NULL. function old new delta parse_params 1811 1845 +34 func_nouser - 24 +24 func_nogroup - 24 +24 static.params 275 292 +17 .rodata 100767 100775 +8 packed_usage 34553 34541 -12 ------------------------------------------------------------------------------ (add/remove: 2/0 grow/shrink: 3/1 up/down: 107/-12) Total: 95 bytes text data bss dec hex filename 1064435 16587 1816 1082838 1085d6 busybox_old 1064530 16587 1816 1082933 108635 busybox_unstripped --- findutils/find.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/findutils/find.c b/findutils/find.c index 40f66ab2e..2a0a867e3 100644 --- a/findutils/find.c +++ b/findutils/find.c @@ -197,6 +197,16 @@ //config: default y //config: depends on FIND //config: +//config:config FEATURE_FIND_NOUSER +//config: bool "Enable -nouser matching" +//config: default y +//config: depends on FIND +//config: +//config:config FEATURE_FIND_NOGROUP +//config: bool "Enable -nogroup matching" +//config: default y +//config: depends on FIND +//config: //config:config FEATURE_FIND_NOT //config: bool "Enable the 'not' (!) operator" //config: default y @@ -373,6 +383,12 @@ //usage: IF_FEATURE_FIND_GROUP( //usage: "\n -group NAME/ID File is owned by given group" //usage: ) +//usage: IF_FEATURE_FIND_NOUSER( +//usage: "\n -nouser File is owned by unknown uid" +//usage: ) +//usage: IF_FEATURE_FIND_NOGROUP( +//usage: "\n -nogroup File is owned by unknown gid" +//usage: ) //usage: IF_FEATURE_FIND_SIZE( //usage: "\n -size N[bck] File size is N (c:bytes,k:kbytes,b:512 bytes(def.))" //usage: "\n +/-N: file size is bigger/smaller than N" @@ -466,6 +482,8 @@ IF_FEATURE_FIND_NEWER( ACTS(newer, time_t newer_mtime;)) IF_FEATURE_FIND_INUM( ACTS(inum, ino_t inode_num;)) IF_FEATURE_FIND_SAMEFILE(ACTS(samefile, ino_t inode_num; dev_t device;)) IF_FEATURE_FIND_USER( ACTS(user, uid_t uid;)) +IF_FEATURE_FIND_NOUSER( ACTS(nouser)) +IF_FEATURE_FIND_NOUSER( ACTS(nogroup)) IF_FEATURE_FIND_SIZE( ACTS(size, char size_char; off_t size;)) IF_FEATURE_FIND_CONTEXT(ACTS(context, security_context_t context;)) IF_FEATURE_FIND_PAREN( ACTS(paren, action ***subexpr;)) @@ -891,6 +909,18 @@ ACTF(group) return (statbuf->st_gid == ap->gid); } #endif +#if ENABLE_FEATURE_FIND_NOUSER +ACTF(nouser) +{ + return !getpwuid(statbuf->st_uid); +} +#endif +#if ENABLE_FEATURE_FIND_NOGROUP +ACTF(nogroup) +{ + return !getgrgid(statbuf->st_gid); +} +#endif #if ENABLE_FEATURE_FIND_PRINT0 ACTF(print0) { @@ -1144,6 +1174,8 @@ static action*** parse_params(char **argv) IF_FEATURE_FIND_QUIT( PARM_quit ,) IF_FEATURE_FIND_DELETE( PARM_delete ,) IF_FEATURE_FIND_EMPTY( PARM_empty ,) + IF_FEATURE_FIND_NOUSER( PARM_nouser ,) + IF_FEATURE_FIND_NOGROUP(PARM_nogroup ,) IF_FEATURE_FIND_EXEC( PARM_exec ,) IF_FEATURE_FIND_EXEC_OK(PARM_ok ,) IF_FEATURE_FIND_EXECUTABLE(PARM_executable,) @@ -1196,6 +1228,8 @@ static action*** parse_params(char **argv) IF_FEATURE_FIND_QUIT( "-quit\0" ) IF_FEATURE_FIND_DELETE( "-delete\0" ) IF_FEATURE_FIND_EMPTY( "-empty\0" ) + IF_FEATURE_FIND_NOUSER( "-nouser\0" ) + IF_FEATURE_FIND_NOGROUP("-nogroup\0" ) IF_FEATURE_FIND_EXEC( "-exec\0" ) IF_FEATURE_FIND_EXEC_OK("-ok\0" ) IF_FEATURE_FIND_EXECUTABLE("-executable\0") @@ -1594,6 +1628,18 @@ static action*** parse_params(char **argv) ap->gid = xgroup2gid(arg1); } #endif +#if ENABLE_FEATURE_FIND_NOUSER + else if (parm == PARM_nouser) { + dbg("%d", __LINE__); + (void) ALLOC_ACTION(nouser); + } +#endif +#if ENABLE_FEATURE_FIND_NOGROUP + else if (parm == PARM_nogroup) { + dbg("%d", __LINE__); + (void) ALLOC_ACTION(nogroup); + } +#endif #if ENABLE_FEATURE_FIND_SIZE else if (parm == PARM_size) { /* -size n[bckw]: file uses n units of space -- 2.34.1 From explorer09 at gmail.com Sun Jan 29 07:56:59 2023 From: explorer09 at gmail.com (Kang-Che Sung) Date: Sun, 29 Jan 2023 15:56:59 +0800 Subject: [PATCH] find: implement -nouser, -nogroup In-Reply-To: References: Message-ID: On Sunday, January 29, 2023, David Leonard < d+busybox at adaptive-enterprises.com> wrote: > > Resending patch for 'find -nouser', 'find -nogroup'. Refreshed bloatcheck > > Subject: [PATCH] find: implement -nouser, -nogroup > > https://pubs.opengroup.org/onlinepubs/9699919799/utilities/find.html > > -nouser > The primary shall evaluate as true if the file belongs to a user ID > for which the getpwuid() function defined in the System Interfaces > volume of POSIX.1-2017 (or equivalent) returns NULL. > > -nogroup > The primary shall evaluate as true if the file belongs to a group ID > for which the getgrgid() function defined in the System Interfaces > volume of POSIX.1-2017 (or equivalent) returns NULL. > > function old new delta > parse_params 1811 1845 +34 > func_nouser - 24 +24 > func_nogroup - 24 +24 > static.params 275 292 +17 > .rodata 100767 100775 +8 > packed_usage 34553 34541 -12 > ------------------------------------------------------------------------------ > (add/remove: 2/0 grow/shrink: 3/1 up/down: 107/-12) Total: 95 bytes > text data bss dec hex filename > 1064435 16587 1816 1082838 1085d6 busybox_old > 1064530 16587 1816 1082933 108635 busybox_unstripped > --- > findutils/find.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 46 insertions(+) > > diff --git a/findutils/find.c b/findutils/find.c > index 40f66ab2e..2a0a867e3 100644 > --- a/findutils/find.c > +++ b/findutils/find.c > @@ -197,6 +197,16 @@ > //config: default y > //config: depends on FIND > //config: > +//config:config FEATURE_FIND_NOUSER > +//config: bool "Enable -nouser matching" > +//config: default y > +//config: depends on FIND > +//config: > +//config:config FEATURE_FIND_NOGROUP > +//config: bool "Enable -nogroup matching" > +//config: default y > +//config: depends on FIND > +//config: > //config:config FEATURE_FIND_NOT > //config: bool "Enable the 'not' (!) operator" > //config: default y > @@ -373,6 +383,12 @@ > //usage: IF_FEATURE_FIND_GROUP( > //usage: "\n -group NAME/ID File is owned by given group" > //usage: ) > +//usage: IF_FEATURE_FIND_NOUSER( > +//usage: "\n -nouser File is owned by unknown uid" > +//usage: ) > +//usage: IF_FEATURE_FIND_NOGROUP( > +//usage: "\n -nogroup File is owned by unknown gid" > +//usage: ) > //usage: IF_FEATURE_FIND_SIZE( > //usage: "\n -size N[bck] File size is N (c:bytes,k:kbytes,b:512 bytes(def.))" > //usage: "\n +/-N: file size is bigger/smaller than N" > @@ -466,6 +482,8 @@ IF_FEATURE_FIND_NEWER( ACTS(newer, time_t newer_mtime;)) > IF_FEATURE_FIND_INUM( ACTS(inum, ino_t inode_num;)) > IF_FEATURE_FIND_SAMEFILE(ACTS(samefile, ino_t inode_num; dev_t device;)) > IF_FEATURE_FIND_USER( ACTS(user, uid_t uid;)) > +IF_FEATURE_FIND_NOUSER( ACTS(nouser)) > +IF_FEATURE_FIND_NOUSER( ACTS(nogroup)) Typo. (Should be IF_FEATURE_FIND_NOGROUP) > IF_FEATURE_FIND_SIZE( ACTS(size, char size_char; off_t size;)) > IF_FEATURE_FIND_CONTEXT(ACTS(context, security_context_t context;)) > IF_FEATURE_FIND_PAREN( ACTS(paren, action ***subexpr;)) > @@ -891,6 +909,18 @@ ACTF(group) > return (statbuf->st_gid == ap->gid); > } > #endif > +#if ENABLE_FEATURE_FIND_NOUSER > +ACTF(nouser) > +{ > + return !getpwuid(statbuf->st_uid); > +} I think there is a logic hole here. getpwuid may return a NULL pointer on an error that's not "UID not found in database". Although your logic written like this conforms to POSIX, I don't know whether in practice this would bring in security risk. > +#endif > +#if ENABLE_FEATURE_FIND_NOGROUP > +ACTF(nogroup) > +{ > + return !getgrgid(statbuf->st_gid); > +} Same problem as above (getgrgid may return NULL on an error other than "not found") > +#endif > #if ENABLE_FEATURE_FIND_PRINT0 > ACTF(print0) > { > @@ -1144,6 +1174,8 @@ static action*** parse_params(char **argv) > IF_FEATURE_FIND_QUIT( PARM_quit ,) > IF_FEATURE_FIND_DELETE( PARM_delete ,) > IF_FEATURE_FIND_EMPTY( PARM_empty ,) > + IF_FEATURE_FIND_NOUSER( PARM_nouser ,) > + IF_FEATURE_FIND_NOGROUP(PARM_nogroup ,) > IF_FEATURE_FIND_EXEC( PARM_exec ,) > IF_FEATURE_FIND_EXEC_OK(PARM_ok ,) > IF_FEATURE_FIND_EXECUTABLE(PARM_executable,) > @@ -1196,6 +1228,8 @@ static action*** parse_params(char **argv) > IF_FEATURE_FIND_QUIT( "-quit\0" ) > IF_FEATURE_FIND_DELETE( "-delete\0" ) > IF_FEATURE_FIND_EMPTY( "-empty\0" ) > + IF_FEATURE_FIND_NOUSER( "-nouser\0" ) > + IF_FEATURE_FIND_NOGROUP("-nogroup\0" ) > IF_FEATURE_FIND_EXEC( "-exec\0" ) > IF_FEATURE_FIND_EXEC_OK("-ok\0" ) > IF_FEATURE_FIND_EXECUTABLE("-executable\0") > @@ -1594,6 +1628,18 @@ static action*** parse_params(char **argv) > ap->gid = xgroup2gid(arg1); > } > #endif > +#if ENABLE_FEATURE_FIND_NOUSER > + else if (parm == PARM_nouser) { > + dbg("%d", __LINE__); > + (void) ALLOC_ACTION(nouser); > + } > +#endif > +#if ENABLE_FEATURE_FIND_NOGROUP > + else if (parm == PARM_nogroup) { > + dbg("%d", __LINE__); > + (void) ALLOC_ACTION(nogroup); > + } > +#endif > #if ENABLE_FEATURE_FIND_SIZE > else if (parm == PARM_size) { > /* -size n[bckw]: file uses n units of space > -- > 2.34.1 > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From d+busybox at adaptive-enterprises.com Sun Jan 29 12:00:50 2023 From: d+busybox at adaptive-enterprises.com (David Leonard) Date: Sun, 29 Jan 2023 22:00:50 +1000 (AEST) Subject: [PATCH] find: implement -nouser, -nogroup In-Reply-To: References: Message-ID: On Sun, 29 Jan 2023, Kang-Che Sung wrote: > > +IF_FEATURE_FIND_NOUSER( ACTS(nouser)) > > +IF_FEATURE_FIND_NOUSER( ACTS(nogroup)) > > Typo. (Should be IF_FEATURE_FIND_NOGROUP) Thanks! > > +ACTF(nouser) > > +{ > > +? ? ? ?return !getpwuid(statbuf->st_uid); > > +} > > I think there is a logic hole here. > getpwuid may return a NULL pointer on an error that's not "UID not found in > database". > Although your logic written like this conforms to POSIX, I don't know > whether in practice this would bring in security risk. > > > +#endif > > +#if ENABLE_FEATURE_FIND_NOGROUP > > +ACTF(nogroup) > > +{ > > +? ? ? ?return !getgrgid(statbuf->st_gid); > > +} > > Same problem as above (getgrgid may return NULL on an error other than "not > found") This may not persuade you, but other implementations do the same: https://git.savannah.gnu.org/cgit/findutils.git/tree/find/pred.c#n671 https://cgit.freebsd.org/src/tree/usr.bin/find/function.c#n1255 https://github.com/kofemann/opensolaris/blob/master/usr/src/cmd/find/find.c#L953 A scenario I can imagine is a system with a periodic find job that deletes all -nouser files. Say that something (an adversary?) exhausts system resources. Now getpwuid() always returns NULL (ENFILE, ENOMEM) and now all files are deleted. I would conclude that -nouser is imperfectly reliable (as it inherits subsystem reliability), and that users of find should take that into consideration. That said, the lack of error messages was an important part of this unresolved tale: https://bugzilla.redhat.com/show_bug.cgi?id=847878 They ended up suggesting ltrace. Even so, I don't think error logging for getpwuid/getgrgid in find is needed in busybox, which is looking to stay slim. From d+busybox at adaptive-enterprises.com Sun Jan 29 12:13:52 2023 From: d+busybox at adaptive-enterprises.com (David Leonard) Date: Sun, 29 Jan 2023 22:13:52 +1000 (AEST) Subject: [PATCH v2] find: implement -nouser, -nogroup In-Reply-To: References: Message-ID: <1n6r2222-r11q-pn9q-5372-s489q9158pq@nqncgvir-ragrecevfrf.pbz> * v2 Fix ifdef guard typo found by Kang-Che Sung Subject: [PATCH v2] find: implement -nouser, -nogroup https://pubs.opengroup.org/onlinepubs/9699919799/utilities/find.html -nouser The primary shall evaluate as true if the file belongs to a user ID for which the getpwuid() function defined in the System Interfaces volume of POSIX.1-2017 (or equivalent) returns NULL. -nogroup The primary shall evaluate as true if the file belongs to a group ID for which the getgrgid() function defined in the System Interfaces volume of POSIX.1-2017 (or equivalent) returns NULL. function old new delta parse_params 1811 1845 +34 func_nouser - 24 +24 func_nogroup - 24 +24 static.params 275 292 +17 .rodata 100767 100775 +8 packed_usage 34553 34541 -12 ------------------------------------------------------------------------------ (add/remove: 2/0 grow/shrink: 3/1 up/down: 107/-12) Total: 95 bytes text data bss dec hex filename 1064435 16587 1816 1082838 1085d6 busybox_old 1064530 16587 1816 1082933 108635 busybox_unstripped --- findutils/find.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/findutils/find.c b/findutils/find.c index 40f66ab2e..fc7fd14b5 100644 --- a/findutils/find.c +++ b/findutils/find.c @@ -197,6 +197,16 @@ //config: default y //config: depends on FIND //config: +//config:config FEATURE_FIND_NOUSER +//config: bool "Enable -nouser matching" +//config: default y +//config: depends on FIND +//config: +//config:config FEATURE_FIND_NOGROUP +//config: bool "Enable -nogroup matching" +//config: default y +//config: depends on FIND +//config: //config:config FEATURE_FIND_NOT //config: bool "Enable the 'not' (!) operator" //config: default y @@ -373,6 +383,12 @@ //usage: IF_FEATURE_FIND_GROUP( //usage: "\n -group NAME/ID File is owned by given group" //usage: ) +//usage: IF_FEATURE_FIND_NOUSER( +//usage: "\n -nouser File is owned by unknown uid" +//usage: ) +//usage: IF_FEATURE_FIND_NOGROUP( +//usage: "\n -nogroup File is owned by unknown gid" +//usage: ) //usage: IF_FEATURE_FIND_SIZE( //usage: "\n -size N[bck] File size is N (c:bytes,k:kbytes,b:512 bytes(def.))" //usage: "\n +/-N: file size is bigger/smaller than N" @@ -466,6 +482,8 @@ IF_FEATURE_FIND_NEWER( ACTS(newer, time_t newer_mtime;)) IF_FEATURE_FIND_INUM( ACTS(inum, ino_t inode_num;)) IF_FEATURE_FIND_SAMEFILE(ACTS(samefile, ino_t inode_num; dev_t device;)) IF_FEATURE_FIND_USER( ACTS(user, uid_t uid;)) +IF_FEATURE_FIND_NOUSER( ACTS(nouser)) +IF_FEATURE_FIND_NOGROUP(ACTS(nogroup)) IF_FEATURE_FIND_SIZE( ACTS(size, char size_char; off_t size;)) IF_FEATURE_FIND_CONTEXT(ACTS(context, security_context_t context;)) IF_FEATURE_FIND_PAREN( ACTS(paren, action ***subexpr;)) @@ -891,6 +909,18 @@ ACTF(group) return (statbuf->st_gid == ap->gid); } #endif +#if ENABLE_FEATURE_FIND_NOUSER +ACTF(nouser) +{ + return !getpwuid(statbuf->st_uid); +} +#endif +#if ENABLE_FEATURE_FIND_NOGROUP +ACTF(nogroup) +{ + return !getgrgid(statbuf->st_gid); +} +#endif #if ENABLE_FEATURE_FIND_PRINT0 ACTF(print0) { @@ -1144,6 +1174,8 @@ static action*** parse_params(char **argv) IF_FEATURE_FIND_QUIT( PARM_quit ,) IF_FEATURE_FIND_DELETE( PARM_delete ,) IF_FEATURE_FIND_EMPTY( PARM_empty ,) + IF_FEATURE_FIND_NOUSER( PARM_nouser ,) + IF_FEATURE_FIND_NOGROUP(PARM_nogroup ,) IF_FEATURE_FIND_EXEC( PARM_exec ,) IF_FEATURE_FIND_EXEC_OK(PARM_ok ,) IF_FEATURE_FIND_EXECUTABLE(PARM_executable,) @@ -1196,6 +1228,8 @@ static action*** parse_params(char **argv) IF_FEATURE_FIND_QUIT( "-quit\0" ) IF_FEATURE_FIND_DELETE( "-delete\0" ) IF_FEATURE_FIND_EMPTY( "-empty\0" ) + IF_FEATURE_FIND_NOUSER( "-nouser\0" ) + IF_FEATURE_FIND_NOGROUP("-nogroup\0" ) IF_FEATURE_FIND_EXEC( "-exec\0" ) IF_FEATURE_FIND_EXEC_OK("-ok\0" ) IF_FEATURE_FIND_EXECUTABLE("-executable\0") @@ -1594,6 +1628,18 @@ static action*** parse_params(char **argv) ap->gid = xgroup2gid(arg1); } #endif +#if ENABLE_FEATURE_FIND_NOUSER + else if (parm == PARM_nouser) { + dbg("%d", __LINE__); + (void) ALLOC_ACTION(nouser); + } +#endif +#if ENABLE_FEATURE_FIND_NOGROUP + else if (parm == PARM_nogroup) { + dbg("%d", __LINE__); + (void) ALLOC_ACTION(nogroup); + } +#endif #if ENABLE_FEATURE_FIND_SIZE else if (parm == PARM_size) { /* -size n[bckw]: file uses n units of space -- 2.34.1 From magnus.armholt at gmail.com Mon Jan 30 05:05:47 2023 From: magnus.armholt at gmail.com (Magnus Armholt) Date: Mon, 30 Jan 2023 07:05:47 +0200 Subject: [PATCH 1/1] delgroup: Add --only-if-empty argument option In-Reply-To: <20221115105914.925851-2-magnus.armholt@fi.abb.com> References: <20221115105914.925851-1-magnus.armholt@fi.abb.com> <20221115105914.925851-2-magnus.armholt@fi.abb.com> Message-ID: Any opinions about this? -Magnus On Tue, Nov 15, 2022 at 12:59 PM Magnus Armholt wrote: > Add option to only remove group if it is empty. > The option can also be given to deluser, if delgroup is enabled. > When --only-if-empty flag is given to deluser, it will not > return failure when removing same named group fails due to > being non-empty. > --- > loginutils/deluser.c | 50 +++++++++++++++++++++++++++++++++++++------- > 1 file changed, 42 insertions(+), 8 deletions(-) > > diff --git a/loginutils/deluser.c b/loginutils/deluser.c > index 8e7df737c..689adc7db 100644 > --- a/loginutils/deluser.c > +++ b/loginutils/deluser.c > @@ -36,16 +36,23 @@ > //kbuild:lib-$(CONFIG_DELGROUP) += deluser.o > > //usage:#define deluser_trivial_usage > -//usage: IF_LONG_OPTS("[--remove-home] ") "USER" > +//usage: IF_LONG_OPTS("[--remove-home] ") > +//usage: IF_DELGROUP(IF_LONG_OPTS("[--only-if-empty] ")) "USER" > //usage:#define deluser_full_usage "\n\n" > //usage: "Delete USER from the system" > -// --remove-home is self-explanatory enough to put it in --help > +//usage: "\n --remove-home Remove also home folder of user > USER" > +//usage: "\n --only-if-empty Only remove group, with same > name as user USER," > +//usage: "\n from the system if it is empty" > + > > //usage:#define delgroup_trivial_usage > -//usage: IF_FEATURE_DEL_USER_FROM_GROUP("[USER] ")"GROUP" > +//usage: IF_LONG_OPTS("[--only-if-empty] ") > +//usage: IF_FEATURE_DEL_USER_FROM_GROUP("[USER] ")"GROUP" > //usage:#define delgroup_full_usage "\n\n" > //usage: "Delete group GROUP from the system" > //usage: IF_FEATURE_DEL_USER_FROM_GROUP(" or user USER from group > GROUP") > +//usage: "\n --only-if-empty Only remove group GROUP from the > system" > +//usage: "\n if it is empty" > > #include "libbb.h" > > @@ -65,13 +72,34 @@ int deluser_main(int argc, char **argv) > > #if !ENABLE_LONG_OPTS > const int opt_delhome = 0; > + const int opt_delgroup_onlyifempty = 0; > #else > + int opt_delgroup_onlyifempty = 0; > int opt_delhome = 0; > if (do_deluser) { > - opt_delhome = getopt32long(argv, "", > - "remove-home\0" No_argument "\xff"); > - argv += opt_delhome; > - argc -= opt_delhome; > + int num_opts = 0; > + int opts = getopt32long(argv, "", > + "remove-home\0" No_argument "\xef" > + "only-if-empty\0" No_argument "\xff"); > + if (opts & 1 << 0) > + { > + opt_delhome = 1; > + num_opts++; > + } > + if (opts & 1 << 1) > + { > + opt_delgroup_onlyifempty = 1; > + num_opts++; > + } > + > + argv += num_opts; > + argc -= num_opts; > + > + } else { > + opt_delgroup_onlyifempty = getopt32long(argv, "", > + "only-if-empty\0" No_argument "\xff"); > + argv += opt_delgroup_onlyifempty; > + argc -= opt_delgroup_onlyifempty; > } > #endif > > @@ -114,10 +142,16 @@ int deluser_main(int argc, char **argv) > if (do_deluser < 0) { /* delgroup after deluser? */ > gr = getgrnam(name); > if (!gr) > - return EXIT_SUCCESS; > + return EXIT_SUCCESS; > > } else { > gr = xgetgrnam(name); /* bail out if GROUP > is wrong */ > } > + if (opt_delgroup_onlyifempty && gr->gr_mem != > NULL) { > + if (do_deluser < 0) { /* delgroup after > deluser? */ > + return EXIT_SUCCESS; > + } > + bb_error_msg_and_die("'%s' is not empty", > name); > + } > if (!member) { > /* "delgroup GROUP" */ > struct passwd *pw; > -- > 2.34.1 > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From peter at korsgaard.com Mon Jan 30 08:26:07 2023 From: peter at korsgaard.com (Peter Korsgaard) Date: Mon, 30 Jan 2023 09:26:07 +0100 Subject: Update Copyright 2023 In-Reply-To: (Fred Friedrich's message of "Sat, 28 Jan 2023 16:54:13 +0000") References: Message-ID: <87r0vc2zts.fsf@dell.be.48ers.dk> >>>>> "Fred" == Fred Friedrich writes: > Hello, > it seems like the copyright was not updated for a long time > :-). Consider this small fix for it: Alternatively we could consider dropping the explicit copyright years like we recently did in Buildroot: https://gitlab.com/buildroot.org/buildroot/-/commit/f1d7155952d9abcad4d5d75b56508114469c2a1c -- Bye, Peter Korsgaard