RE: Off-topic: filtering stream of pathnames for glob'd exclusions

2024-04-22 Thread David Laight
From: Philip Prindeville > Sent: 22 April 2024 17:16 > Somewhat off-topic post but this is on a system that has Busybox installed so > I can't use features > that other shells might provide. > > I have a stream generated by "find" of pathnames, and I want to delete > (filter out) certain paths

RE: Print full username and groupname for ls command

2024-02-25 Thread David Laight
From: Denys Vlasenko > Sent: 25 February 2024 00:06 > > I think we can simply stop the truncation, like this: > > - column += printf("%-8.8s %-8.8s ", > + column += printf("%-8s %-8s ", > > without additional loop to measure max

RE: Failing shell code under busybox 1.36.1 that worked with 1.31.1

2024-02-15 Thread David Laight
From: David Leonard > Sent: 15 February 2024 08:46 > To: Harvey > Cc: busybox@busybox.net > Subject: Re: Failing shell code under busybox 1.36.1 that worked with 1.31.1 > > > > _result="$_result '${_p//'/'\"'\"'}'" > > Busybox ash has a CONFIG_ASH_BASH_COMPAT config to get this

RE: Failing shell code under busybox 1.36.1 that worked with 1.31.1

2024-02-15 Thread David Laight
From: Harvey > Sent: 14 February 2024 18:18 > Sorry, posted the wrong version of the pack_args() funtion: > I have payed with possible solutions for so long that I forgot the > restore the original before posting -blush- > > Here is the original version: >

RE: [PATCH] crond: add LOG_NDELAY to openlog

2023-12-12 Thread David Laight
From: Jones Syue > Sent: 12 December 2023 01:49 > > > You aren't allowed to do very much between vfork() and exec(). > > Basically just sort out the child's fd table. > > And I suspect that needs to only look at on-stack data. > > > > Having the child execute first is only an optimisation. > >

RE: [PATCH] crond: add LOG_NDELAY to openlog

2023-12-11 Thread David Laight
From: Jones Syue > Sent: 11 December 2023 07:59 > > After digging further into textbook APUE 2/e and TLPI in this weekend, > it looks like more clear to explain what is happening. > In vfork() implementation, > 1. The process address space is shared among parent and child processes. > The process

RE: fix large PID overflow their column in top command

2023-11-23 Thread David Laight
... > + fp = xfopen_for_read("/proc/sys/kernel/pid_max"); > + if (!fgets(pid_buf, PID_DIGITS_MAX + 1, fp)) { > ... > + if (strncmp(pid_buf, "32768", 5) == 0) > + pid_digits_num = 5; > + else > + pid_digits_num = PID_DIGITS_MAX; > > The logic

RE: RFC: initialize /dev/urandom, is it necessary? Can we do it in a better way?

2023-09-19 Thread David Laight
> Fine, then use > (write) to reset the entropy and >> (append) to add entropy. IIRC writing to /dev/urandom doesn't do what you want it to do. You have to use an ioctl() to actually set entropy. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK

RE: [PATCH] udhcpd: Per-client boot_file

2023-06-25 Thread David Laight
From: busybox On Behalf Of Michael Tokarev > Sent: 25 June 2023 06:58 > > 25.06.2023 02:23, Adam Goldman wrote: > > This patch adds the ability to specify a different boot_file for each > > client. This is useful if clients have different CPU architectures or if > > some clients are legacy BIOS

RE: [PATCH] mount: add option to disable NFS completely

2023-05-25 Thread David Laight
From: Reimu > Sent: 25 May 2023 15:04 > > This can save up to ~40 kbytes with uclibc and it helps a lot when > you're building a very tiny busybox for embedded systems. > --- >  util-linux/mount.c | 14 +- >  1 file changed, 13 insertions(+), 1 deletion(-) > > diff --git

RE: [PATCH] nslookup: ensure unique transaction IDs for the DNS queries

2023-05-10 Thread David Laight
From: Laurent Bercot > Sent: 10 May 2023 12:36 > > >You miss the point. CLOCK_MONOTONIC may simply be too granular > >on some hardware - returning the same value for the duration of > >several milliseconds. > > Wait, what? Is that a thing? Is there actual hardware where > CLOCK_MONOTONIC

RE: [PATCH v2] readlink: slight size optimization

2023-04-18 Thread David Laight
From: Harald van Dijk > Sent: 17 April 2023 22:44 ... > I am assuming it was intended to be > >printf("%s%s", buf, &"\n"[opt & 1]); That is fine, as is "\n" + (opt & 1) It can also be written: &(opt & 1)["\n"] since [] is commutative in C. Basically x[y] <=> *(x+y) <=> *(y+x)

RE: busybox seq doesn't handle negative numbers

2023-04-05 Thread David Laight
... > Yeah, the thing rather is that GNU getopt parses the command line > and performs reorders. I never really looked, but since the > (entire family of the) mailer i maintain earned a security > advisory for possible option injection attacks i always wondered > how secure that can be... Yes,

RE: Problem with test -r

2023-02-14 Thread David Laight
From: Dominique Martinet > Sent: 13 February 2023 23:22 ... > - Reproduce under strace and provide the full strace.log: > strace -o /tmp/strace.log bash -c '[ -r file ]; echo $?' > strace might not want to run within the container without some extra > privileges, it's also possible to attach your

RE: Problem with test -r

2023-02-13 Thread David Laight
From: alice > Sent: 13 February 2023 09:24 > > The 'test/[' command is almost certainly a shell builtin. > > The program in /usr/bin is almost never executed. > > when one is using busybox ash as a shell, is /usr/bin/test (from busybox > symlink) and "builtin test" not the same code in the

RE: Problem with test -r

2023-02-13 Thread David Laight
From: Vladimír Macek > Sent: 11 February 2023 19:15 > > Hi, > > I'd like to report what seems to be a bug in the busybox's test command. I > use the official alpine:3 docker container. > > The test -r does not return true even when the file is indeed readable > (testing by head command). Yes,

RE: [PATCH] build system: fix linking on Red Hat systems

2022-12-31 Thread David Laight
From: Michael Tokarev > Sent: 31 December 2022 09:44 > > 31.12.2022 11:48, Ron Yorston wrote: > > Commit 77216c368 (Fix non-Linux builds) made linking with libresolv > > conditional on the output of 'gcc -dumpmachine' containing 'gnu'. > > > > This broke builds on Red Hat systems (Fedora, RHEL)

RE: [PATCH] ed: don't use memcpy with overlapping memory regions

2022-12-22 Thread David Laight
From: Sören Tempel > Sent: 22 December 2022 14:23 > > PING. > > Any love for good old ed(1)? Some versions of glibc will also do 'not strictly increasing' memcpy() on some x86 cpu. Just copying the last 4/8 bytes first and then doing a forwards copy is enough to break things. David >

RE: udhcpc6 missing source address

2022-12-14 Thread David Laight
From: Denys Vlasenko > Sent: 14 December 2022 21:17 ... > For comparison, this is how DHCPv4 looks on the wire: > > 28:df:eb:11:48:92 > Broadcast, ethertype IPv4 (0x0800), length 342: > (tos 0x0, ttl 64, id 0, offset 0, flags [none], proto UDP (17), length > 328) > 0.0.0.0.bootpc >

RE: udhcpc6 missing source address

2022-12-14 Thread David Laight
From: Denys Vlasenko > Sent: 14 December 2022 10:04 > > On Wed, Dec 14, 2022 at 10:52 AM David Laight wrote: ... > If it's the code from the above, then no, kernel will not fill in > any IPv6 source addresses, as it does not even know it's > an IPv6/UDP packet - we use raw sock

RE: udhcpc6 missing source address

2022-12-14 Thread David Laight
From: John Lemonovich > Sent: 13 December 2022 20:35 > > How are you getting a solicit message through with :: as the source > address, which I've found no > server likes as I've tested 3 of them? Or is mine not using the link local > address because I'm not > doing anything with the

RE: udhcpc6 missing source address

2022-12-13 Thread David Laight
From: John Lemonovich > Sent: 13 December 2022 15:59 > > Thanks for the replies. Yes David, it's also my understanding per the spec, > that the client's link- > local address must be included for the solicit message. The reply from the > server is unicast. What > do you mean by the proper

RE: udhcpc6 missing source address

2022-12-13 Thread David Laight
From: Denys Vlasenko > Sent: 13 December 2022 15:22 > > On Fri, Dec 9, 2022 at 5:09 PM John Lemonovich > wrote: > > Hello Denys, > > > > I am working on an embedded Linux project using an intel Arria 10 FPGA and > > have been using IPv4 for > a long time, and now need IPv6. I found your email

RE: [PATCH] sed: check errors writing file with sed -i

2022-11-16 Thread David Laight
From: busybox Dominique Martinet > Sent: 16 November 2022 02:53 > > From: Dominique Martinet > > sed would currently not error if write failed when modifying a file. > diff --git a/editors/sed.c b/editors/sed.c > index 32a4b61f6d4c..31ade17477ca 100644 > --- a/editors/sed.c > +++

RE: Subject: [PATCH] ash: make 'sleep' a builtin

2022-08-30 Thread David Laight
One question is why? Shell builtins (mostly) exist to speed things up. But sleep doesn’t need speeding up. David From: busybox On Behalf Of shawnland...@tutanota.com Sent: 30 August 2022 02:25 To: Denys Vlasenko Cc: Busybox Subject: Re: Subject: [PATCH] ash: make 'sleep' a

RE: Bash compatibility TODO

2022-06-27 Thread David Laight
From: Aaro Koskinen > Sent: 27 June 2022 21:43 > > Hi all, > > Looks like it's not possible to build mainline Linux anymore with the > busybox as "bash". :-( Have you posted that to LKML ? They really ought to solve the problem a different way. David > > $ make > CC

RE: [PATCH v2] seedrng: limit poolsize to 256 bytes and document flock() and fsync() usage

2022-05-02 Thread David Laight
From: Alexander Dahl > Sent: 02 May 2022 06:15 > > Am Sat, Apr 30, 2022 at 03:12:11PM +0200 schrieb Denys Vlasenko: > > Do you often pull power cords from machines you use for > > somewhat important crypto operations, such as generating keys? > > What are the chances that you also do it on a

RE: [PATCH v2] seedrng: limit poolsize to 256 bytes and document flock() and fsync() usage

2022-05-01 Thread David Laight
From: Jason A. Donenfeld > Sent: 30 April 2022 14:48 > > Hi Denys, > > On Sat, Apr 30, 2022 at 3:12 PM Denys Vlasenko > wrote: > > > + /* The fsync() here is necessary for safety here, so that power > > > being pulled > > > +* at the wrong moment doesn't result in the seed being

RE: [PATCH v9] seedrng: import SeedRNG utility for kernel RNG seed files

2022-04-29 Thread David Laight
From: Denys Vlasenko > Sent: 29 April 2022 17:17 > > On Wed, Apr 27, 2022 at 6:55 PM Jason A. Donenfeld wrote: > > On Wed, Apr 27, 2022 at 06:15:50PM +0200, Denys Vlasenko wrote: > > > Can we replace all [s]size_t's with ints/unsigneds? We do not expect > > > random pools anywhere near 4

RE: [PATCH] ash: avoid some redirection oddities

2022-04-26 Thread David Laight
From: Ron Yorston > Sent: 26 April 2022 16:10 > > A user reports: > >I know this code is wrong but it shouldn't cause the shell to exit: >echo text >& >This instead cause the creation of a file: >echo text >&99 > >I think it would be better if they report Bad

RE: IPv6 support with busybox

2022-04-19 Thread David Laight
I’d check that the script that udhcpc6 runs to configure IPv6 is actually doing something sensible. Especially if you are also trying to use IPv4 as well. You’ll need a network that is running (IIRC) radv – otherwise you won’t get a prefix length (aka netmask) or any routes. So if IPv6

RE: [PATCH v8] seedrng: import SeedRNG utility for kernel RNG seed files

2022-04-19 Thread David Laight
From: Bernhard Reutner-Fischer > Sent: 19 April 2022 09:32 > > On Tue, 12 Apr 2022 21:07:36 +0200 > "Jason A. Donenfeld" wrote: > > > Hi Bernhard, > > > > On Tue, Apr 12, 2022 at 8:37 PM Bernhard Reutner-Fischer > > wrote: > > > > > > Hi Jason! > > > I'm a bit surprised that even if i give -n

RE: Question about isolating and re-using code from busybox

2022-03-04 Thread David Laight
From: Bernhard Reutner-Fischer > Sent: 04 March 2022 13:38 > > On 4 March 2022 07:48:58 CET, Emmanuel Deloget wrote: > >Hello Tim, > > > >it seems to me that it should not be that complicated, as the tar > >handling code is mostly encapsulated into a library of its own. > > > >See

RE: suspected bug in timeout command

2022-03-01 Thread David Laight
From: Denys Vlasenko > Sent: 01 March 2022 22:40 > > On Tue, Mar 1, 2022 at 11:15 PM David Laight wrote: > > From: Denys Vlasenko > > > and a separate "spawn 40k 'sleep 0.03'" loop > > > seems to indicate that openat(fd, ".") on the exited &g

RE: suspected bug in timeout command

2022-03-01 Thread David Laight
From: Steffen Nurpmeso > Sent: 01 March 2022 17:49 ... > > David Laight wrote in > : > |From: Denys Vlasenko > |> Sent: 01 March 2022 16:40 > |> On Tue, Feb 15, 2022 at 12:31 PM Rob Landley wrote: > |>> On 2/14/22 10:09 AM, Roberto A. Foglietta w

RE: suspected bug in timeout command

2022-03-01 Thread David Laight
From: Denys Vlasenko > Sent: 01 March 2022 21:57 > > On Tue, Mar 1, 2022 at 5:39 PM Denys Vlasenko > wrote: > > Meanwhile: what "timeout" is doing is it tries to get out > > of the way of the PROG to be launched so that timeout's parent > > sees PROG (not timeout) as a child. E.g. it can send

RE: suspected bug in timeout command

2022-03-01 Thread David Laight
From: Denys Vlasenko > Sent: 01 March 2022 16:40 > > On Tue, Feb 15, 2022 at 12:31 PM Rob Landley wrote: > > On 2/14/22 10:09 AM, Roberto A. Foglietta wrote: > > > However, if this bug shows-up, probably it means that the system has > > > a lot of processes running and a lot of processes

RE: [PATCH v2] ash: use memmove instead of mempcpy in subevalvar

2022-02-26 Thread David Laight
From: busybox > Sent: 26 February 2022 18:53 > > While investigating a sporadic crash issue relating to variable substitution > in > Alpine Linux, we managed to get a reliable crash when building BusyBox with > ASan, > due to the source and destination overlapping for mempcpy, which resulted in

RE: suspected bug in timeout command

2022-02-14 Thread David Laight
Yes it does. But it is unlikely to happen in the short time between some kind of test that the process is the right one, and sending the signal. But hoping to see the process ‘gone’ on a 1 second poll is pretty useless. So if the process’s ‘start time’ is found (before any of the forks) that can

RE: suspected bug in timeout command

2022-02-12 Thread David Laight
From: Michael Conrad > Sent: 12 February 2022 12:59 > > On 2/12/22 07:38, Michael Conrad wrote: > > Correctly using pidfd *still* requires that you be the parent process, > > else the child could get reaped and replaced before the pidfd is > > created.  As far as I can tell, the only purpose of

RE: suspected bug in timeout command

2022-02-12 Thread David Laight
From: Raffaello D. Di Napoli > Sent: 12 February 2022 01:33 > > > On 2/11/22 16:22, Rob Landley wrote: > > On 2/9/22 11:12 AM, Baruch Siach wrote: > >> Hi Sun, > >> > >> On Wed, Feb 09 2022, סאן עמר wrote: > >>> Hi, I'm using busybox for a while now (v1.29.2). and I had an issue with > >>> a

RE: [PATCH v2] Improve support for long options to grep

2022-01-26 Thread David Laight
From: Walter Lozano > Sent: 26 January 2022 14:14 > > In order to improve compatibility with GNU grep improve support for long > options to busybox grep. You've broken backwards compatibility by removing --color from default builds. There is also unnecessary duplication of source code. Just use

RE: [PATCH] top '-c' switch to enable output of SMP cpu lines.

2022-01-26 Thread David Laight
From: Jonathan Sambrook > Sent: 25 January 2022 17:44 > > This allows access to SMP cpu lines for batch output, as well as > displaying SMP info in interactive mode without having to press '1'. > > My motivation here is to be able to access the SMP information when > graphing BusyBox top batch

RE: [PATCH] Improve support for long options to grep

2022-01-24 Thread David Laight
From: Walter Lozano > Sent: 24 January 2022 14:48 > > In order to improve compatibility with GNU grep improve support for long > options to busybox grep. Why? Does anyone ever actually type these long strings? Looks like bloat to me. David - Registered Address Lakeside, Bramley Road,

RE: [PATCH] XXXsum: handle binary sums with " " in the path

2022-01-07 Thread David Laight
From: Emanuele Giacomelli > Sent: 07 January 2022 11:00 > > If a line specifies a binary checksum whose path contains two adjacent > spaces, when checking digests with -c the two spaces will be used as the > separator between the digest and the pathname instead of " *", as shown: > > $ echo foo

RE: [PATCH] printf: allow 0 as a flag and allow multiple flags

2021-12-19 Thread David Laight
From: Denys Vlasenko > Sent: 17 December 2021 20:10 > > On Thu, Dec 16, 2021 at 12:26 PM Ron Yorston wrote: > > The '%' character in a format specification may be followed by > > one or more flags from the list "+- #0". BusyBox printf didn't > > support the '0' flag or allow multiple flags to

RE: [PATCH 3/3] nslookup: query class: remove support for class HS and ANY

2021-12-09 Thread David Laight
From: Moraes Holschuh > Sent: 08 December 2021 14:20 > > Remove the support for classes HS (Hesiod) and ANY (wildcard), and with > these gone, also remove the nice, table-driven support for specifying > query classes and use an if(strcasecmp()) hardcoded tree instead. > > This reduces some

RE: Tar component in busybox version 1.34.1 has a memory leak bug when trying to unpack a tar file.

2021-12-01 Thread David Laight
From: busybox On Behalf Of Ping Lee > Sent: 01 December 2021 01:42 > It seems that I found a bug on busybox version 1.34.1: > In libbb/xfuncs_printf.c:50, malloc twice for archive_handle and > archive_hadle->fileheader with 184 and 72 bytes heap space. > Back to tar_main function, the two >

RE: return type demotion remarks

2021-11-28 Thread David Laight
From: Bernhard Reutner-Fischer > Sent: 28 November 2021 19:37 > > On Sun, 28 Nov 2021 18:00:31 +0000 > David Laight wrote: > > > From: Bernhard Reutner-Fischer > > > Sent: 27 November 2021 20:57 > > > > > > Hi! > > > > > >

RE: return type demotion remarks

2021-11-28 Thread David Laight
From: Bernhard Reutner-Fischer > Sent: 27 November 2021 20:57 > > Hi! > > I'm attaching a color log of some spots that may benefit of using > narrower return types; See "could return". My mailer won't expand a .gz file . However making function arguments and return values smaller than a

RE: [PATCH v2] ed: add support for -p command-line option as mandated by POSIX

2021-11-22 Thread David Laight
From: soe...@soeren-tempel.net > Sent: 21 November 2021 11:25 > > The POSIX.1-2008 specification of ed(1) mandates two command-line > options: -p (for specifying a prompt string) and -s (to suppress writing > of byte counts). This commit adds support for the former. Furthermore, > it also changes

RE: [PATCH] ed: add support for -p command-line option as mandated by POSIX

2021-11-20 Thread David Laight
From: soe...@soeren-tempel.net > Sent: 20 November 2021 17:17 > > The POSIX.1-2008 specification of ed(1) mandates two command-line > options: -p (for specifying a prompt string) and -s (to suppress writing > of byte counts). This commit adds support for the former. Furthermore, > it also changes

re: [PATCH] Fix const pointer assignment trick on clang 9+

2021-11-15 Thread David Laight
If you are trying to tell the compiler that a pointer (or other value) might change and it mustn't reload it (etc) then this might work: #define LAUNDER(val_in, val_out) \ asm volatile ( "" : "" (val_out) : "0" (val_in)) That is (more or less) equivalent to: val_out =

[PATCH v2 2/2] top: Add 'IRIX mode'

2021-11-12 Thread David Laight
'Solaris mode' (even for -H) where the maximum cpu% for a single thread is 100/num_cpus. Signed-off-by: David Laight --- --- b/top.c 2021-11-12 11:25:43.849264597 + +++ c/top.c 2021-11-12 11:36:49.510234350 + @@ -165,6 +165,7 @@ #endif #if ENABLE_FEATURE_TOP_SMP_CPU smallint

[PATCH v2 1/2] top: remove 'cruft' the process display code.

2021-11-12 Thread David Laight
are in 'jiffies' so there is no need to re-scale the values based on the sum of the process times. (This was already assumed because of issues with short lived processes.) Signed-off-by: David Laight --- --- a/top.c 2021-11-11 09:49:08.165982660 + +++ b/top.c 2021-11-12 11:25:43.849264597

[PATCH v2 0/2] top: Add 'IRIX mode'

2021-11-12 Thread David Laight
The busybox top always runs in 'Solaris mode' where the cpu% for a process is a percentage across all the cpu. So a single threaded process in an infinite loop on a 16cpu system only reports 8% cpu use. In 'IRIX mode' it will report 100% - much more useful. In IRIX mode a multi-threaded process

Add 'IRIX mode' to top.

2021-11-11 Thread David Laight
> 100%. Enabled by -I on the command line or 'i' on stdin. Remove some (uint16_t) casts from the 'delta jiffies' value. With enough cpu, fast enough HZ, and long enough delay I think 64k can be exceeded. I doubt intended efficiency of 16x16 multiple makes any difference. Signed-off-by: Da