From Matthew.Chae at axis.com Wed Nov 1 09:17:39 2023 From: Matthew.Chae at axis.com (Matthew Chae) Date: Wed, 1 Nov 2023 09:17:39 +0000 Subject: fix large PID overflow their column in top command Message-ID: Hi maintainer, I'd like to hear your opinion regarding large PID can overflow its column in top command. The max PID value can have 7 digits as the 4194304. Busybox v1.36 released a new patch to handle large PID value in top command. However, it still causes misalignment between the title and the number for 7 digits or 6 digits PID. The presence of a large number of PID and PPID digits in the column may cause overflow, making it impossible to display the entire data accurately. Plus, the large PID causes that user name can't be displayed up to 8 characters and result in the truncation of less than 8 characters. I can contribute new patch which allocates appropriate space for the number of digits in the PID and PPID to represent the values in each column correctly. This can make alignment between the title and the number for 7 digits PID and 5 digits PID and also display user name up to 8 characters. What do you think? If you agree, I will send a patch. BR-Matthew Chae -------------- next part -------------- An HTML attachment was scrubbed... URL: From louai at astranis.com Thu Nov 2 06:53:34 2023 From: louai at astranis.com (Louai Al-Khanji) Date: Wed, 1 Nov 2023 23:53:34 -0700 Subject: -o option for start-stop-daemon Message-ID: Hi, I am interested in implementing the -o|--output option that the Debian start-stop-daemon supports. Might such a patch be considered for upstreaming? Thanks, Louai -- ________ This email and any attachments may contain Astranis confidential and/or proprietary information governed by a non-disclosure agreement, and are intended solely for the individual or entity specified by the message. -------------- next part -------------- An HTML attachment was scrubbed... URL: From pvorel at suse.cz Fri Nov 3 20:14:00 2023 From: pvorel at suse.cz (Petr Vorel) Date: Fri, 3 Nov 2023 21:14:00 +0100 Subject: [PATCH 1/1] sleep: Update doc Message-ID: <20231103201400.1136447-1-pvorel@suse.cz> 4c20d9f2b removed FEATURE_FLOAT_SLEEP option, thus since then there are only two variants. Fixes: 4c20d9f2b ("extend fractional duration support to "top -d N.N" and "timeout"") Signed-off-by: Petr Vorel --- coreutils/sleep.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/coreutils/sleep.c b/coreutils/sleep.c index 442841210..93b39f6f5 100644 --- a/coreutils/sleep.c +++ b/coreutils/sleep.c @@ -17,14 +17,15 @@ //config: default y //config: help //config: sleep is used to pause for a specified number of seconds. -//config: It comes in 3 versions: +//config: It comes in 2 versions: //config: - small: takes one integer parameter -//config: - fancy: takes multiple integer arguments with suffixes: -//config: sleep 1d 2h 3m 15s -//config: - fancy with fractional numbers: -//config: sleep 2.3s 4.5h sleeps for 16202.3 seconds -//config: Last one is "the most compatible" with coreutils sleep, -//config: but it adds around 1k of code. +//config: - fancy: +//config: * takes multiple integer arguments with suffixes: +//config: sleep 1d 2h 3m 15s +//config: * allows fractional numbers: +//config: sleep 2.3s 4.5h sleeps for 16202.3 seconds +//config: fancy is more compatible with coreutils sleep, but it adds around +//config: 1k of code. //config: //config:config FEATURE_FANCY_SLEEP //config: bool "Enable multiple arguments and s/m/h/d suffixes" -- 2.42.0 From louai at astranis.com Fri Nov 3 22:31:06 2023 From: louai at astranis.com (Louai Al-Khanji) Date: Fri, 3 Nov 2023 15:31:06 -0700 Subject: -o option for start-stop-daemon In-Reply-To: References: Message-ID: On Wed, Nov 1, 2023 at 11:53?PM Louai Al-Khanji wrote: > > Hi, > > I am interested in implementing the -o|--output option that the Debian start-stop-daemon supports. Might such a patch be considered for upstreaming? > > Thanks, > Louai Hello, Attached is a proposed patch. Any feedback would be appreciated. Thank you, Louai -- ________ This email and any attachments may contain Astranis confidential and/or proprietary information governed by a non-disclosure agreement, and are intended solely for the individual or entity specified by the message. -------------- next part -------------- A non-text attachment was scrubbed... Name: 0001-start-stop-daemon-implement-option-O-output.patch Type: text/x-patch Size: 5278 bytes Desc: not available URL: From peter at korsgaard.com Sat Nov 4 09:51:35 2023 From: peter at korsgaard.com (Peter Korsgaard) Date: Sat, 04 Nov 2023 10:51:35 +0100 Subject: -o option for start-stop-daemon In-Reply-To: (Louai Al-Khanji's message of "Fri, 3 Nov 2023 15:31:06 -0700") References: Message-ID: <87y1fdyhg8.fsf@48ers.dk> >>>>> "Louai" == Louai Al-Khanji writes: > On Wed, Nov 1, 2023 at 11:53?PM Louai Al-Khanji wrote: >> >> Hi, >> >> I am interested in implementing the -o|--output option that the NIT: It is -O, not -o. > +#if ENABLE_FEATURE_START_STOP_DAEMON_FANCY > + if (opt & OPT_OUTPUT) { > + int output_fd = xopen(output, O_CREAT | O_WRONLY); > + original_stdout = xdup(STDOUT_FILENO); > + original_stderr = xdup(STDERR_FILENO); > + xdup2(output_fd, STDOUT_FILENO); > + xdup2(output_fd, STDERR_FILENO); > + } -O is documented to only work with the -b, so wouldn't it make more sense to add this logic around bb_daemon_helper() instead, then you also don't have to clean it up again? -- Bye, Peter Korsgaard From vda.linux at googlemail.com Tue Nov 7 06:15:06 2023 From: vda.linux at googlemail.com (Denys Vlasenko) Date: Tue, 7 Nov 2023 07:15:06 +0100 Subject: [PATCH] start-stop-daemon: add chdir option In-Reply-To: <773993398.39073.1698244581973@office.mailbox.org> References: <993765347.100429.1697960685286@office.mailbox.org> <773993398.39073.1698244581973@office.mailbox.org> Message-ID: Applied, thank you. On Wed, Oct 25, 2023 at 4:44?PM Esa J??skel? wrote: > > Add option to change the running directory before starting the process. > This can be done using -d or --chdir options. Add also test cases to > start-stop-daemon to test out the directory change option. > > Signed-off-by: ejaaskel > --- > TODO | 2 -- > debianutils/start_stop_daemon.c | 21 ++++++++++++++------- > testsuite/start-stop-daemon.tests | 20 ++++++++++++++++++++ > 3 files changed, 34 insertions(+), 9 deletions(-) > > diff --git a/TODO b/TODO > index 72ae0f88d..6c7415a81 100644 > --- a/TODO > +++ b/TODO > @@ -222,8 +222,6 @@ Minor stuff: > --- > unify progress_meter. wget, flash_eraseall, pipe_progress, fbsplash, setfiles. > --- > - support start-stop-daemon -d > ---- > > (TODO list after discussion 11.05.2009) > > diff --git a/debianutils/start_stop_daemon.c b/debianutils/start_stop_daemon.c > index 3e5dd9faa..88c2be11c 100644 > --- a/debianutils/start_stop_daemon.c > +++ b/debianutils/start_stop_daemon.c > @@ -105,6 +105,7 @@ Misc options: > //usage: "\n -N N Change nice level" > //usage: ) > //usage: "\n -c USER[:[GRP]] Change user/group" > +//usage: "\n -d PATH Change path" > //usage: "\n -m Write PID to pidfile specified by -p" > //usage: "\n-K only:" > //usage: "\n -s SIG Signal to send" > @@ -138,11 +139,12 @@ enum { > OPT_s = (1 << 8), // -s > OPT_u = (1 << 9), // -u > OPT_c = (1 << 10), // -c > - OPT_x = (1 << 11), // -x > - OPT_p = (1 << 12), // -p > - OPT_OKNODO = (1 << 13) * ENABLE_FEATURE_START_STOP_DAEMON_FANCY, // -o > - OPT_VERBOSE = (1 << 14) * ENABLE_FEATURE_START_STOP_DAEMON_FANCY, // -v > - OPT_NICELEVEL = (1 << 15) * ENABLE_FEATURE_START_STOP_DAEMON_FANCY, // -N > + OPT_d = (1 << 11), // -d > + OPT_x = (1 << 12), // -x > + OPT_p = (1 << 13), // -p > + OPT_OKNODO = (1 << 14) * ENABLE_FEATURE_START_STOP_DAEMON_FANCY, // -o > + OPT_VERBOSE = (1 << 15) * ENABLE_FEATURE_START_STOP_DAEMON_FANCY, // -v > + OPT_NICELEVEL = (1 << 16) * ENABLE_FEATURE_START_STOP_DAEMON_FANCY, // -N > }; > #define QUIET (option_mask32 & OPT_QUIET) > #define TEST (option_mask32 & OPT_TEST) > @@ -391,6 +393,7 @@ static const char start_stop_daemon_longopts[] ALIGN1 = > "signal\0" Required_argument "s" > "user\0" Required_argument "u" > "chuid\0" Required_argument "c" > + "chdir\0" Required_argument "d" > "exec\0" Required_argument "x" > "pidfile\0" Required_argument "p" > # if ENABLE_FEATURE_START_STOP_DAEMON_FANCY > @@ -411,6 +414,7 @@ int start_stop_daemon_main(int argc UNUSED_PARAM, char **argv) > char *signame; > char *startas = NULL; > char *chuid; > + char *chdir; > #if ENABLE_FEATURE_START_STOP_DAEMON_FANCY > // char *retry_arg = NULL; > // int retries = -1; > @@ -420,7 +424,7 @@ int start_stop_daemon_main(int argc UNUSED_PARAM, char **argv) > INIT_G(); > > opt = GETOPT32(argv, "^" > - "KSbqtma:n:s:u:c:x:p:" > + "KSbqtma:n:s:u:c:d:x:p:" > IF_FEATURE_START_STOP_DAEMON_FANCY("ovN:R:") > /* -K or -S is required; they are mutually exclusive */ > /* -p is required if -m is given */ > @@ -432,7 +436,7 @@ int start_stop_daemon_main(int argc UNUSED_PARAM, char **argv) > "K:S:K--S:S--K:m?p:K?xpun" > IF_FEATURE_START_STOP_DAEMON_FANCY("q-v"), > LONGOPTS > - &startas, &cmdname, &signame, &userspec, &chuid, &execname, &pidfile > + &startas, &cmdname, &signame, &userspec, &chuid, &chdir, &execname, &pidfile > IF_FEATURE_START_STOP_DAEMON_FANCY(,&opt_N) > /* We accept and ignore -R / --retry */ > IF_FEATURE_START_STOP_DAEMON_FANCY(,NULL) > @@ -560,6 +564,9 @@ int start_stop_daemon_main(int argc UNUSED_PARAM, char **argv) > setgroups(1, &ugid.gid); > } > } > + if (opt & OPT_d) { > + xchdir(chdir); > + } > /* Try: > * strace -oLOG start-stop-daemon -S -x /bin/usleep -a qwerty 500000 > * should exec "/bin/usleep", but argv[0] should be "qwerty": > diff --git a/testsuite/start-stop-daemon.tests b/testsuite/start-stop-daemon.tests > index 0757b1288..e1e49ab5f 100755 > --- a/testsuite/start-stop-daemon.tests > +++ b/testsuite/start-stop-daemon.tests > @@ -11,6 +11,21 @@ testing "start-stop-daemon -x without -a" \ > "0\n" \ > "" "" > > +testing "start-stop-daemon -x with -d on existing directory" \ > + 'start-stop-daemon -S -d /tmp -x true 2>&1; echo $?' \ > + "0\n" \ > + "" "" > + > +testing "start-stop-daemon -x with -d on existing and check dir" \ > + 'output=$(start-stop-daemon -S -d /tmp -x pwd); echo $output' \ > + "/tmp\n" \ > + "" "" > + > +testing "start-stop-daemon -x with --chdir on existing and check dir" \ > + 'output=$(start-stop-daemon -S --chdir /tmp -x pwd); echo $output' \ > + "/tmp\n" \ > + "" "" > + > testing "start-stop-daemon -a without -x" \ > 'start-stop-daemon -S -a false 2>&1; echo $?' \ > "1\n" \ > @@ -21,6 +36,11 @@ testing "start-stop-daemon without -x and -a" \ > "1\n" \ > "" "" > > +testing "start-stop-daemon -x with -d on non-existing directory" \ > + 'start-stop-daemon -S -d /non-existent -x true > /dev/null 2>&1; echo $?' \ > + "1\n" \ > + "" "" > + > # This runs /bin/false with argv[0..2] of { "qwerty", "false", NULL }. > # > # Unfortunately, this does not actually check argv[0] correctness, > -- > 2.34.1 > _______________________________________________ > busybox mailing list > busybox at busybox.net > http://lists.busybox.net/mailman/listinfo/busybox From vda.linux at googlemail.com Tue Nov 7 16:00:54 2023 From: vda.linux at googlemail.com (Denys Vlasenko) Date: Tue, 7 Nov 2023 17:00:54 +0100 Subject: [PATCH 1/1] sleep: Update doc In-Reply-To: <20231103201400.1136447-1-pvorel@suse.cz> References: <20231103201400.1136447-1-pvorel@suse.cz> Message-ID: Applied, thank you. On Fri, Nov 3, 2023 at 9:14?PM Petr Vorel wrote: > > 4c20d9f2b removed FEATURE_FLOAT_SLEEP option, thus since then there are > only two variants. > > Fixes: 4c20d9f2b ("extend fractional duration support to "top -d N.N" and "timeout"") > Signed-off-by: Petr Vorel > --- > coreutils/sleep.c | 15 ++++++++------- > 1 file changed, 8 insertions(+), 7 deletions(-) > > diff --git a/coreutils/sleep.c b/coreutils/sleep.c > index 442841210..93b39f6f5 100644 > --- a/coreutils/sleep.c > +++ b/coreutils/sleep.c > @@ -17,14 +17,15 @@ > //config: default y > //config: help > //config: sleep is used to pause for a specified number of seconds. > -//config: It comes in 3 versions: > +//config: It comes in 2 versions: > //config: - small: takes one integer parameter > -//config: - fancy: takes multiple integer arguments with suffixes: > -//config: sleep 1d 2h 3m 15s > -//config: - fancy with fractional numbers: > -//config: sleep 2.3s 4.5h sleeps for 16202.3 seconds > -//config: Last one is "the most compatible" with coreutils sleep, > -//config: but it adds around 1k of code. > +//config: - fancy: > +//config: * takes multiple integer arguments with suffixes: > +//config: sleep 1d 2h 3m 15s > +//config: * allows fractional numbers: > +//config: sleep 2.3s 4.5h sleeps for 16202.3 seconds > +//config: fancy is more compatible with coreutils sleep, but it adds around > +//config: 1k of code. > //config: > //config:config FEATURE_FANCY_SLEEP > //config: bool "Enable multiple arguments and s/m/h/d suffixes" > -- > 2.42.0 > From vda.linux at googlemail.com Tue Nov 7 16:03:42 2023 From: vda.linux at googlemail.com (Denys Vlasenko) Date: Tue, 7 Nov 2023 17:03:42 +0100 Subject: -o option for start-stop-daemon In-Reply-To: References: Message-ID: On Fri, Nov 3, 2023 at 11:31?PM Louai Al-Khanji wrote: > > On Wed, Nov 1, 2023 at 11:53?PM Louai Al-Khanji wrote: > > > > Hi, > > > > I am interested in implementing the -o|--output option that the Debian start-stop-daemon supports. Might such a patch be considered for upstreaming? > > > > Thanks, > > Louai > > Hello, > > Attached is a proposed patch. Any feedback would be appreciated. My experiments with ssd version 1.21.22 show that the file is opened with O_CREAT|O_APPEND, and it does not allow -O without -b. If execv fails, error message goes to this file. IOW: there is no need to save/restore old stderr fd. Just replace it with the new fd (and don't forget to not leak any extra open fds). From louai at astranis.com Tue Nov 7 18:27:28 2023 From: louai at astranis.com (Louai Al-Khanji) Date: Tue, 7 Nov 2023 10:27:28 -0800 Subject: -o option for start-stop-daemon In-Reply-To: References: Message-ID: On Tue, Nov 7, 2023 at 8:03?AM Denys Vlasenko wrote: > > On Fri, Nov 3, 2023 at 11:31?PM Louai Al-Khanji wrote: > > > > On Wed, Nov 1, 2023 at 11:53?PM Louai Al-Khanji wrote: > > > > > > Hi, > > > > > > I am interested in implementing the -o|--output option that the Debian start-stop-daemon supports. Might such a patch be considered for upstreaming? > > > > > > Thanks, > > > Louai > > > > Hello, > > > > Attached is a proposed patch. Any feedback would be appreciated. > > My experiments with ssd version 1.21.22 show that the file is opened with > O_CREAT|O_APPEND, and it does not allow -O without -b. > > If execv fails, error message goes to this file. > IOW: there is no need to save/restore old stderr fd. Just replace it > with the new fd > (and don't forget to not leak any extra open fds). Thank you for the feedback everyone. New version attached. It looked a little tricky to me to add the logic around bb_daemon_helper() since it closes open fds. Maybe I am missing something. The code now checks the args more strictly and prints usage if -O is given without -b. I dropped restoring of the stdout/stderr fds. I believe this patch cannot leak fds. One question I have is whether it's okay to lose error messages. On failure to open the output file I believe the error message currently goes into the void. Same if any of the dup2 calls or the close call fails. BTW I noticed that bb_daemon_helper() internally calls setsid() already, so the extra call in start_stop_daemon.c seems superfluous. I didn't however touch that in this patch. Thanks, Louai -- ________ This email and any attachments may contain Astranis confidential and/or proprietary information governed by a non-disclosure agreement, and are intended solely for the individual or entity specified by the message. -------------- next part -------------- A non-text attachment was scrubbed... Name: 0001-start-stop-daemon-implement-option-O-output.patch Type: text/x-patch Size: 4592 bytes Desc: not available URL: From louai at astranis.com Tue Nov 7 19:34:06 2023 From: louai at astranis.com (Louai Al-Khanji) Date: Tue, 7 Nov 2023 11:34:06 -0800 Subject: -o option for start-stop-daemon In-Reply-To: References: Message-ID: Hi all, V3 attached. Rebased against master to account for the -d option. Moves the output variable from the globals struct to be local to main. Thanks, Louai On Tue, Nov 7, 2023 at 10:27?AM Louai Al-Khanji wrote: > > On Tue, Nov 7, 2023 at 8:03?AM Denys Vlasenko wrote: > > > > On Fri, Nov 3, 2023 at 11:31?PM Louai Al-Khanji wrote: > > > > > > On Wed, Nov 1, 2023 at 11:53?PM Louai Al-Khanji wrote: > > > > > > > > Hi, > > > > > > > > I am interested in implementing the -o|--output option that the Debian start-stop-daemon supports. Might such a patch be considered for upstreaming? > > > > > > > > Thanks, > > > > Louai > > > > > > Hello, > > > > > > Attached is a proposed patch. Any feedback would be appreciated. > > > > My experiments with ssd version 1.21.22 show that the file is opened with > > O_CREAT|O_APPEND, and it does not allow -O without -b. > > > > If execv fails, error message goes to this file. > > IOW: there is no need to save/restore old stderr fd. Just replace it > > with the new fd > > (and don't forget to not leak any extra open fds). > > Thank you for the feedback everyone. New version attached. > > It looked a little tricky to me to add the logic around > bb_daemon_helper() since it closes open fds. Maybe I am missing > something. > > The code now checks the args more strictly and prints usage if -O is > given without -b. > > I dropped restoring of the stdout/stderr fds. I believe this patch > cannot leak fds. > > One question I have is whether it's okay to lose error messages. On > failure to open the output file I believe the error message currently > goes into the void. Same if any of the dup2 calls or the close call > fails. > > BTW I noticed that bb_daemon_helper() internally calls setsid() > already, so the extra call in start_stop_daemon.c seems superfluous. I > didn't however touch that in this patch. > > Thanks, > Louai -- ________ This email and any attachments may contain Astranis confidential and/or proprietary information governed by a non-disclosure agreement, and are intended solely for the individual or entity specified by the message. -------------- next part -------------- A non-text attachment was scrubbed... Name: 0001-start-stop-daemon-implement-option-O-output.patch Type: text/x-patch Size: 4143 bytes Desc: not available URL: From louai at astranis.com Tue Nov 7 19:37:07 2023 From: louai at astranis.com (Louai Al-Khanji) Date: Tue, 7 Nov 2023 11:37:07 -0800 Subject: -o option for start-stop-daemon In-Reply-To: References: Message-ID: Apologies for the spam, the previous patch had bad whitespace. Fixed here. On Tue, Nov 7, 2023 at 11:34?AM Louai Al-Khanji wrote: > > Hi all, > > V3 attached. > > Rebased against master to account for the -d option. Moves the output > variable from the globals struct to be local to main. > > Thanks, > Louai > > On Tue, Nov 7, 2023 at 10:27?AM Louai Al-Khanji wrote: > > > > On Tue, Nov 7, 2023 at 8:03?AM Denys Vlasenko wrote: > > > > > > On Fri, Nov 3, 2023 at 11:31?PM Louai Al-Khanji wrote: > > > > > > > > On Wed, Nov 1, 2023 at 11:53?PM Louai Al-Khanji wrote: > > > > > > > > > > Hi, > > > > > > > > > > I am interested in implementing the -o|--output option that the Debian start-stop-daemon supports. Might such a patch be considered for upstreaming? > > > > > > > > > > Thanks, > > > > > Louai > > > > > > > > Hello, > > > > > > > > Attached is a proposed patch. Any feedback would be appreciated. > > > > > > My experiments with ssd version 1.21.22 show that the file is opened with > > > O_CREAT|O_APPEND, and it does not allow -O without -b. > > > > > > If execv fails, error message goes to this file. > > > IOW: there is no need to save/restore old stderr fd. Just replace it > > > with the new fd > > > (and don't forget to not leak any extra open fds). > > > > Thank you for the feedback everyone. New version attached. > > > > It looked a little tricky to me to add the logic around > > bb_daemon_helper() since it closes open fds. Maybe I am missing > > something. > > > > The code now checks the args more strictly and prints usage if -O is > > given without -b. > > > > I dropped restoring of the stdout/stderr fds. I believe this patch > > cannot leak fds. > > > > One question I have is whether it's okay to lose error messages. On > > failure to open the output file I believe the error message currently > > goes into the void. Same if any of the dup2 calls or the close call > > fails. > > > > BTW I noticed that bb_daemon_helper() internally calls setsid() > > already, so the extra call in start_stop_daemon.c seems superfluous. I > > didn't however touch that in this patch. > > > > Thanks, > > Louai -- ________ This email and any attachments may contain Astranis confidential and/or proprietary information governed by a non-disclosure agreement, and are intended solely for the individual or entity specified by the message. -------------- next part -------------- A non-text attachment was scrubbed... Name: 0001-start-stop-daemon-implement-option-O-output.patch Type: text/x-patch Size: 4136 bytes Desc: not available URL: From vda.linux at googlemail.com Tue Nov 7 20:46:20 2023 From: vda.linux at googlemail.com (Denys Vlasenko) Date: Tue, 7 Nov 2023 21:46:20 +0100 Subject: -o option for start-stop-daemon In-Reply-To: References: Message-ID: Applied with some edits, please test current git. On Tue, Nov 7, 2023 at 8:37?PM Louai Al-Khanji wrote: > > Apologies for the spam, the previous patch had bad whitespace. Fixed here. > > On Tue, Nov 7, 2023 at 11:34?AM Louai Al-Khanji wrote: > > > > Hi all, > > > > V3 attached. > > > > Rebased against master to account for the -d option. Moves the output > > variable from the globals struct to be local to main. > > > > Thanks, > > Louai > > > > On Tue, Nov 7, 2023 at 10:27?AM Louai Al-Khanji wrote: > > > > > > On Tue, Nov 7, 2023 at 8:03?AM Denys Vlasenko wrote: > > > > > > > > On Fri, Nov 3, 2023 at 11:31?PM Louai Al-Khanji wrote: > > > > > > > > > > On Wed, Nov 1, 2023 at 11:53?PM Louai Al-Khanji wrote: > > > > > > > > > > > > Hi, > > > > > > > > > > > > I am interested in implementing the -o|--output option that the Debian start-stop-daemon supports. Might such a patch be considered for upstreaming? > > > > > > > > > > > > Thanks, > > > > > > Louai > > > > > > > > > > Hello, > > > > > > > > > > Attached is a proposed patch. Any feedback would be appreciated. > > > > > > > > My experiments with ssd version 1.21.22 show that the file is opened with > > > > O_CREAT|O_APPEND, and it does not allow -O without -b. > > > > > > > > If execv fails, error message goes to this file. > > > > IOW: there is no need to save/restore old stderr fd. Just replace it > > > > with the new fd > > > > (and don't forget to not leak any extra open fds). > > > > > > Thank you for the feedback everyone. New version attached. > > > > > > It looked a little tricky to me to add the logic around > > > bb_daemon_helper() since it closes open fds. Maybe I am missing > > > something. > > > > > > The code now checks the args more strictly and prints usage if -O is > > > given without -b. > > > > > > I dropped restoring of the stdout/stderr fds. I believe this patch > > > cannot leak fds. > > > > > > One question I have is whether it's okay to lose error messages. On > > > failure to open the output file I believe the error message currently > > > goes into the void. Same if any of the dup2 calls or the close call > > > fails. > > > > > > BTW I noticed that bb_daemon_helper() internally calls setsid() > > > already, so the extra call in start_stop_daemon.c seems superfluous. I > > > didn't however touch that in this patch. > > > > > > Thanks, > > > Louai > > -- > > > ________ > This email and any attachments may contain Astranis confidential > and/or proprietary information governed by a non-disclosure agreement, and > are intended solely for the individual or entity specified by the message. From peter at korsgaard.com Tue Nov 7 20:50:38 2023 From: peter at korsgaard.com (Peter Korsgaard) Date: Tue, 07 Nov 2023 21:50:38 +0100 Subject: -o option for start-stop-daemon In-Reply-To: (Denys Vlasenko's message of "Tue, 7 Nov 2023 21:46:20 +0100") References: Message-ID: <871qd1wan5.fsf@48ers.dk> >>>>> "Denys" == Denys Vlasenko writes: > Applied with some edits, please test current git. Looks sensible from a quick look. Notice that you added a s/PILE/FILE/ typo: +//usage: "\n -O PILE Append stdout and stderr to FILE" -- Bye, Peter Korsgaard From asmadeus at codewreck.org Wed Nov 8 02:57:57 2023 From: asmadeus at codewreck.org (Dominique Martinet) Date: Wed, 8 Nov 2023 11:57:57 +0900 Subject: [PATCH] xvfork: override die_func to _exit on child processes Message-ID: <20231108025757.1924934-1-asmadeus@codewreck.org> From: Dominique Martinet On alpine linux, calling busybox time with a nonexisting command would hang forever: ``` time: can't execute 'fdsa': No such file or directory Command exited with non-zero status 127 real 0m 0.00s user 0m 0.00s sys 0m 0.00s ``` This is because time uses vfork then BB_EXECVP_or_die, which ultimately calls exit() after execvp fails. exit() is explicitly listed as unsafe to call after vfork as the child process shares its memory with the parent; in particular on musl exit will take the init_fini_lock() and calling it twice in the same address space will just hang. _exit() on the other hand is safe to call, so replace die_func with it. For this particular problem die_func could just be overriden in time.c's run_command after vfork, but this problem actually came up before in shell/hush.c as per the fflush_and__exit comment so it seems more appropriate to do this globally in the xvfork macro and get rid of this whole class of bugs forever. Unfortunately, since it is a macro the code change impacts all its callers. The bloatcheck below depends on the compiler and build options. This bloatcheck has been obtained with alpine 3.18's busyboxconfig on debian testing (gcc 12.2.0): function old new delta vfork_compressor 213 233 +20 timeout_main 379 399 +20 run_command 199 217 +18 xvfork_parent_waits_and_exits 67 81 +14 launch_helper 200 214 +14 dolisten 934 948 +14 only__exit - 13 +13 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 6/0 up/down: 113/0) Total: 113 bytes text data bss dec hex filename 796233 14332 1976 812541 c65fd busybox_old 796360 14332 1976 812668 c667c busybox_unstripped --- include/libbb.h | 6 +++++- libbb/xfunc_die.c | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/include/libbb.h b/include/libbb.h index 0883fb565fa9..720271fecba5 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -1228,12 +1228,15 @@ int BB_EXECVP(const char *file, char *const argv[]) FAST_FUNC; void BB_EXECVP_or_die(char **argv) NORETURN FAST_FUNC; /* xvfork() can't be a _function_, return after vfork in child mangles stack - * in the parent. It must be a macro. */ + * in the parent. It must be a macro. + * Child process must also not call exit so override die func in child */ #define xvfork() \ ({ \ pid_t bb__xvfork_pid = vfork(); \ if (bb__xvfork_pid < 0) \ bb_simple_perror_msg_and_die("vfork"); \ + if (bb__xvfork_pid == 0) \ + die_func = only__exit; \ bb__xvfork_pid; \ }) #if BB_MMU @@ -1426,6 +1429,7 @@ extern smallint logmode; extern uint8_t xfunc_error_retval; extern void (*die_func)(void); void xfunc_die(void) NORETURN FAST_FUNC; +void only__exit(void) NORETURN; void bb_show_usage(void) NORETURN FAST_FUNC; void bb_error_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2))) FAST_FUNC; void bb_simple_error_msg(const char *s) FAST_FUNC; diff --git a/libbb/xfunc_die.c b/libbb/xfunc_die.c index 25b99066df3e..2e67f07801f3 100644 --- a/libbb/xfunc_die.c +++ b/libbb/xfunc_die.c @@ -19,3 +19,7 @@ void FAST_FUNC xfunc_die(void) die_func(); exit(xfunc_error_retval); } + +void only__exit(void) { + _exit(xfunc_error_retval); +} -- 2.39.2 From vda.linux at googlemail.com Wed Nov 8 11:35:27 2023 From: vda.linux at googlemail.com (Denys Vlasenko) Date: Wed, 8 Nov 2023 12:35:27 +0100 Subject: fix large PID overflow their column in top command In-Reply-To: References: Message-ID: On Wed, Nov 1, 2023 at 10:18?AM Matthew Chae wrote: > > Hi maintainer, > > I'd like to hear your opinion regarding large PID can overflow its column in top command. > > The max PID value can have 7 digits as the 4194304. > Busybox v1.36 released a new patch to handle large PID value in top command. > However, it still causes misalignment between the title and the number for 7 digits or 6 digits PID. > The presence of a large number of PID and PPID digits in the column may cause overflow, making it impossible to display the entire data accurately. > Plus, the large PID causes that user name can't be displayed up to 8 characters and result in the truncation of less than 8 characters. > > I can contribute new patch which allocates appropriate space for the number of digits in the PID and PPID to represent the values in each column correctly. > This can make alignment between the title and the number for 7 digits PID and 5 digits PID and also display user name up to 8 characters. > > What do you think? If you agree, I will send a patch. Absolutely, please send a patch. Would be interesting to see a good solution. From vda.linux at googlemail.com Wed Nov 8 11:36:39 2023 From: vda.linux at googlemail.com (Denys Vlasenko) Date: Wed, 8 Nov 2023 12:36:39 +0100 Subject: -o option for start-stop-daemon In-Reply-To: <871qd1wan5.fsf@48ers.dk> References: <871qd1wan5.fsf@48ers.dk> Message-ID: Fixed! Thank you On Tue, Nov 7, 2023 at 9:50?PM Peter Korsgaard wrote: > > >>>>> "Denys" == Denys Vlasenko writes: > > > Applied with some edits, please test current git. > > Looks sensible from a quick look. Notice that you added a s/PILE/FILE/ > typo: > > +//usage: "\n -O PILE Append stdout and stderr to FILE" > > -- > Bye, Peter Korsgaard From vda.linux at googlemail.com Wed Nov 8 13:08:06 2023 From: vda.linux at googlemail.com (Denys Vlasenko) Date: Wed, 8 Nov 2023 14:08:06 +0100 Subject: -o option for start-stop-daemon In-Reply-To: References: Message-ID: On Tue, Nov 7, 2023 at 7:27?PM Louai Al-Khanji wrote: > On Tue, Nov 7, 2023 at 8:03?AM Denys Vlasenko wrote: > > On Fri, Nov 3, 2023 at 11:31?PM Louai Al-Khanji wrote: > > > Attached is a proposed patch. Any feedback would be appreciated. > > > > My experiments with ssd version 1.21.22 show that the file is opened with > > O_CREAT|O_APPEND, and it does not allow -O without -b. > > > > If execv fails, error message goes to this file. > > IOW: there is no need to save/restore old stderr fd. Just replace it > > with the new fd > > (and don't forget to not leak any extra open fds). > > Thank you for the feedback everyone. New version attached. > > It looked a little tricky to me to add the logic around > bb_daemon_helper() since it closes open fds. Maybe I am missing > something. > > The code now checks the args more strictly and prints usage if -O is > given without -b. > > I dropped restoring of the stdout/stderr fds. I believe this patch > cannot leak fds. > > One question I have is whether it's okay to lose error messages. On > failure to open the output file I believe the error message currently > goes into the void. Same if any of the dup2 calls or the close call > fails. Yes, that's not good. I tried to fix it in git now. Please try. > BTW I noticed that bb_daemon_helper() internally calls setsid() > already, so the extra call in start_stop_daemon.c seems superfluous. I > didn't however touch that in this patch. No: #define bb_daemon_helper(arg) bb_daemonize_or_rexec((arg) | DAEMON_ONLY_SANITIZE, NULL) DAEMON_ONLY_SANITIZE bit prevents setsid() and daemonization (the vfork). From vda.linux at googlemail.com Wed Nov 8 15:50:12 2023 From: vda.linux at googlemail.com (Denys Vlasenko) Date: Wed, 8 Nov 2023 16:50:12 +0100 Subject: [PATCH] xvfork: override die_func to _exit on child processes In-Reply-To: <20231108025757.1924934-1-asmadeus@codewreck.org> References: <20231108025757.1924934-1-asmadeus@codewreck.org> Message-ID: On Wed, Nov 8, 2023 at 3:58?AM Dominique Martinet wrote: > > From: Dominique Martinet > > On alpine linux, calling busybox time with a nonexisting command would > hang forever: > ``` > time: can't execute 'fdsa': No such file or directory > Command exited with non-zero status 127 > real 0m 0.00s > user 0m 0.00s > sys 0m 0.00s > > ``` > > This is because time uses vfork then BB_EXECVP_or_die, which ultimately > calls exit() after execvp fails. exit() is explicitly listed as unsafe > to call after vfork as the child process shares its memory with the > parent; in particular on musl exit will take the init_fini_lock() and > calling it twice in the same address space will just hang. > _exit() on the other hand is safe to call, so replace die_func with it. Doesn't happen to me... maybe I have an older musl. > For this particular problem die_func could just be overriden in > time.c's run_command after vfork, but this problem actually came up > before in shell/hush.c as per the fflush_and__exit comment so it seems > more appropriate to do this globally in the xvfork macro and get rid of > this whole class of bugs forever. Maybe we can always use _exit(), or fflush_all(); _exit() in xfunc_die()? From Matthew.Chae at axis.com Wed Nov 8 16:33:14 2023 From: Matthew.Chae at axis.com (Matthew Chae) Date: Wed, 8 Nov 2023 16:33:14 +0000 Subject: fix large PID overflow their column in top command In-Reply-To: References: Message-ID: Hi Denys, Ok. Good to hear. If I understand correctly, will you first review my patch and then give me Morris's account to commit the change? Then, let me send a patch soon. Br-Matthew ________________________________ From: Denys Vlasenko Sent: Wednesday, November 8, 2023 12:35 PM To: Matthew Chae Cc: busybox at busybox.net ; Christopher Wong Subject: Re: fix large PID overflow their column in top command On Wed, Nov 1, 2023 at 10:18?AM Matthew Chae wrote: > > Hi maintainer, > > I'd like to hear your opinion regarding large PID can overflow its column in top command. > > The max PID value can have 7 digits as the 4194304. > Busybox v1.36 released a new patch to handle large PID value in top command. > However, it still causes misalignment between the title and the number for 7 digits or 6 digits PID. > The presence of a large number of PID and PPID digits in the column may cause overflow, making it impossible to display the entire data accurately. > Plus, the large PID causes that user name can't be displayed up to 8 characters and result in the truncation of less than 8 characters. > > I can contribute new patch which allocates appropriate space for the number of digits in the PID and PPID to represent the values in each column correctly. > This can make alignment between the title and the number for 7 digits PID and 5 digits PID and also display user name up to 8 characters. > > What do you think? If you agree, I will send a patch. Absolutely, please send a patch. Would be interesting to see a good solution. -------------- next part -------------- An HTML attachment was scrubbed... URL: From louai at astranis.com Wed Nov 8 17:37:06 2023 From: louai at astranis.com (Louai Al-Khanji) Date: Wed, 8 Nov 2023 09:37:06 -0800 Subject: -o option for start-stop-daemon In-Reply-To: References: Message-ID: On Wed, Nov 8, 2023 at 5:08?AM Denys Vlasenko wrote: > > On Tue, Nov 7, 2023 at 7:27?PM Louai Al-Khanji wrote: > > On Tue, Nov 7, 2023 at 8:03?AM Denys Vlasenko wrote: > > > On Fri, Nov 3, 2023 at 11:31?PM Louai Al-Khanji wrote: > > > > Attached is a proposed patch. Any feedback would be appreciated. > > > > > > My experiments with ssd version 1.21.22 show that the file is opened with > > > O_CREAT|O_APPEND, and it does not allow -O without -b. > > > > > > If execv fails, error message goes to this file. > > > IOW: there is no need to save/restore old stderr fd. Just replace it > > > with the new fd > > > (and don't forget to not leak any extra open fds). > > > > Thank you for the feedback everyone. New version attached. > > > > It looked a little tricky to me to add the logic around > > bb_daemon_helper() since it closes open fds. Maybe I am missing > > something. > > > > The code now checks the args more strictly and prints usage if -O is > > given without -b. > > > > I dropped restoring of the stdout/stderr fds. I believe this patch > > cannot leak fds. > > > > One question I have is whether it's okay to lose error messages. On > > failure to open the output file I believe the error message currently > > goes into the void. Same if any of the dup2 calls or the close call > > fails. > > Yes, that's not good. > I tried to fix it in git now. Please try. > The new behavior seems correct to me - if the output file cannot be opened an error is printed at invocation site. If the exec fails it goes to the requested output file. Thank you for adding the -O functionality, it is very handy for my use case. > > BTW I noticed that bb_daemon_helper() internally calls setsid() > > already, so the extra call in start_stop_daemon.c seems superfluous. I > > didn't however touch that in this patch. > > No: > > #define bb_daemon_helper(arg) bb_daemonize_or_rexec((arg) | > DAEMON_ONLY_SANITIZE, NULL) > > DAEMON_ONLY_SANITIZE bit prevents setsid() and daemonization (the vfork). Ah, I missed that the macro set the flag. I see you added a comment to catch future readers, thank you. -- ________ This email and any attachments may contain Astranis confidential and/or proprietary information governed by a non-disclosure agreement, and are intended solely for the individual or entity specified by the message. From asmadeus at codewreck.org Wed Nov 8 21:23:00 2023 From: asmadeus at codewreck.org (Dominique Martinet) Date: Thu, 9 Nov 2023 06:23:00 +0900 Subject: [PATCH] xvfork: override die_func to _exit on child processes In-Reply-To: References: <20231108025757.1924934-1-asmadeus@codewreck.org> Message-ID: Denys Vlasenko wrote on Wed, Nov 08, 2023 at 04:50:12PM +0100: > On Wed, Nov 8, 2023 at 3:58?AM Dominique Martinet > wrote: > > > > From: Dominique Martinet > > > > On alpine linux, calling busybox time with a nonexisting command would > > hang forever: > > ``` > > time: can't execute 'fdsa': No such file or directory > > Command exited with non-zero status 127 > > real 0m 0.00s > > user 0m 0.00s > > sys 0m 0.00s > > > > ``` > > > > This is because time uses vfork then BB_EXECVP_or_die, which ultimately > > calls exit() after execvp fails. exit() is explicitly listed as unsafe > > to call after vfork as the child process shares its memory with the > > parent; in particular on musl exit will take the init_fini_lock() and > > calling it twice in the same address space will just hang. > > _exit() on the other hand is safe to call, so replace die_func with it. > > Doesn't happen to me... maybe I have an older musl. I've just checked old alpines -- I can reproduce this all the way from alpine 3.10 (musl 1.1.22, busybox 1.30.1) to current edge (musl 1.2.4). alpine 3.9 (musl 1.1.20, busybox 1.29.3) didn't hang; I didn't check all the way but time.c didn't seem to change in that time frame so it's probably a "new" (~2019) bug introduced by the libc change, yes. > > For this particular problem die_func could just be overriden in > > time.c's run_command after vfork, but this problem actually came up > > before in shell/hush.c as per the fflush_and__exit comment so it seems > > more appropriate to do this globally in the xvfork macro and get rid of > > this whole class of bugs forever. > > Maybe we can always use _exit(), > or fflush_all(); _exit() in xfunc_die()? hmm, exit does a bunch of stuff: - we apparently use atexit() in a few applets, so these would need the real exit() to get invoked - any lib destructor would also be called, I'm not sure we rely on any so that's probably fine. Same with on_exit(), not used directly. - The man page for exit(3) on my system also says files created by tmpfile(3) are removed; we don't seem to use it either. - flushing and closinig all FILEs; I agree close itself isn't needed, fflush_all() as you've suggested is probably enough... And hush.c has been calling it after vfork so it's probably fine? because while the address space is shared, that takes and releases locks when it's done, so while it's not explicitely safe it's probably ok. And fflush is definitely needed in the normal case. I'm not sure there's anything else that needs to be done on exit? So that leaves atexit hooks which we need in some applets (mount, sed -- the one in libpwdgrp is just a free "to make valgrind happy" so can be skipped); if we update these two to override die_func instead (don't even need to use exit there, they can just register their hook as die_func instead of atexit), then I guess it would be ok to do `fflush_all(); _exit()` in xfunc_die(), but I'm not 100% comfortable with that so that'll require a bunch of testing. I can update the patch if you really prefer this, but I won't be able to test much more than running the test suite on x86_64/debian and alpines (I guess it's a good excuse to add a new test item for 'time notavalidcommand' at the same time), it'll probably require a bit more validiation. -- Dominique Martinet | Asmadeus From Matthew.Chae at axis.com Fri Nov 10 15:22:26 2023 From: Matthew.Chae at axis.com (Matthew Chae) Date: Fri, 10 Nov 2023 15:22:26 +0000 Subject: fix large PID overflow their column in top command In-Reply-To: References: Message-ID: Hi Denys, I'm sending the patch what I've mentioned. Can you take a look at this? If I don't understand correctly what you said before, let me know. Have a nice weekend, Matthew Chae ________________________________ From: busybox on behalf of Matthew Chae Sent: Wednesday, November 8, 2023 5:33 PM To: Denys Vlasenko Cc: busybox at busybox.net ; Christopher Wong Subject: Re: fix large PID overflow their column in top command Hi Denys, Ok. Good to hear. If I understand correctly, will you first review my patch and then give me Morris's account to commit the change? Then, let me send a patch soon. Br-Matthew ________________________________ From: Denys Vlasenko Sent: Wednesday, November 8, 2023 12:35 PM To: Matthew Chae Cc: busybox at busybox.net ; Christopher Wong Subject: Re: fix large PID overflow their column in top command On Wed, Nov 1, 2023 at 10:18?AM Matthew Chae wrote: > > Hi maintainer, > > I'd like to hear your opinion regarding large PID can overflow its column in top command. > > The max PID value can have 7 digits as the 4194304. > Busybox v1.36 released a new patch to handle large PID value in top command. > However, it still causes misalignment between the title and the number for 7 digits or 6 digits PID. > The presence of a large number of PID and PPID digits in the column may cause overflow, making it impossible to display the entire data accurately. > Plus, the large PID causes that user name can't be displayed up to 8 characters and result in the truncation of less than 8 characters. > > I can contribute new patch which allocates appropriate space for the number of digits in the PID and PPID to represent the values in each column correctly. > This can make alignment between the title and the number for 7 digits PID and 5 digits PID and also display user name up to 8 characters. > > What do you think? If you agree, I will send a patch. Absolutely, please send a patch. Would be interesting to see a good solution. -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: 0001-fix-large-PID-overflow-their-column-in-top-command.patch Type: text/x-patch Size: 3765 bytes Desc: 0001-fix-large-PID-overflow-their-column-in-top-command.patch URL: From dario.binacchi at amarulasolutions.com Sat Nov 11 10:53:46 2023 From: dario.binacchi at amarulasolutions.com (Dario Binacchi) Date: Sat, 11 Nov 2023 11:53:46 +0100 Subject: [RESEND PATCH] ip link: support for the CAN netlink Message-ID: <20231111105346.138172-1-dario.binacchi@amarulasolutions.com> I developed this application to test the Linux kernel series [1]. As described in it I could not use the iproute2 package since the microcontroller is without MMU. cc: Marc Kleine-Budde [1] https://marc.info/?l=linux-netdev&m=167999323611710&w=2 Signed-off-by: Dario Binacchi --- configs/TEST_nommu_defconfig | 1 + networking/ip.c | 84 ++++++++++ networking/libiproute/iplink.c | 298 ++++++++++++++++++++++++++++++++- 3 files changed, 374 insertions(+), 9 deletions(-) diff --git a/configs/TEST_nommu_defconfig b/configs/TEST_nommu_defconfig index 415f5a8027f9..fa3e9632622a 100644 --- a/configs/TEST_nommu_defconfig +++ b/configs/TEST_nommu_defconfig @@ -703,6 +703,7 @@ CONFIG_FEATURE_INETD_RPC=y CONFIG_IP=y CONFIG_FEATURE_IP_ADDRESS=y CONFIG_FEATURE_IP_LINK=y +CONFIG_FEATURE_IP_LINK_CAN=y CONFIG_FEATURE_IP_ROUTE=y CONFIG_FEATURE_IP_TUNNEL=y CONFIG_FEATURE_IP_RULE=y diff --git a/networking/ip.c b/networking/ip.c index 36126b74738c..e5b704df5b85 100644 --- a/networking/ip.c +++ b/networking/ip.c @@ -32,6 +32,14 @@ //config: help //config: Short form of "ip link" //config: +//config:config IPLINK_CAN +//config: bool "iplink for CAN (4.6 kb)" +//config: default n +//config: depends on IPLINK +//config: select FEATURE_IP_LINK_CAN +//config: help +//config: Short form of "ip link" for CAN +//config: //config:config IPROUTE //config: bool "iproute (15 kb)" //config: default y @@ -74,6 +82,13 @@ //config: help //config: Configure network devices with "ip". //config: +//config:config FEATURE_IP_LINK_CAN +//config: bool "ip link can" +//config: default n +//config: depends on IP_LINK_CAN +//config: help +//config: Configure CAN devices with "ip". +//config: //config:config FEATURE_IP_ROUTE //config: bool "ip route" //config: default y @@ -122,6 +137,7 @@ //applet:IF_IP( APPLET_NOEXEC(ip , ip , BB_DIR_SBIN, BB_SUID_DROP, ip )) //applet:IF_IPADDR( APPLET_NOEXEC(ipaddr , ipaddr , BB_DIR_SBIN, BB_SUID_DROP, ipaddr )) //applet:IF_IPLINK( APPLET_NOEXEC(iplink , iplink , BB_DIR_SBIN, BB_SUID_DROP, iplink )) +//applet:IF_IPLINK_CAN(APPLET_NOEXEC(iplinkcan , iplinkcan , BB_DIR_SBIN, BB_SUID_DROP, iplinkcan)) //applet:IF_IPROUTE( APPLET_NOEXEC(iproute , iproute , BB_DIR_SBIN, BB_SUID_DROP, iproute )) //applet:IF_IPRULE( APPLET_NOEXEC(iprule , iprule , BB_DIR_SBIN, BB_SUID_DROP, iprule )) //applet:IF_IPTUNNEL(APPLET_NOEXEC(iptunnel, iptunnel, BB_DIR_SBIN, BB_SUID_DROP, iptunnel)) @@ -130,6 +146,7 @@ //kbuild:lib-$(CONFIG_IP) += ip.o //kbuild:lib-$(CONFIG_IPADDR) += ip.o //kbuild:lib-$(CONFIG_IPLINK) += ip.o +//kbuild:lib-$(CONFIG_IPLINK_CAN) += ip.o //kbuild:lib-$(CONFIG_IPROUTE) += ip.o //kbuild:lib-$(CONFIG_IPRULE) += ip.o //kbuild:lib-$(CONFIG_IPTUNNEL) += ip.o @@ -149,10 +166,16 @@ //usage: "ipaddr show|flush [dev IFACE] [scope SCOPE] [to PREFIX] [label PATTERN]" //usage: //--------------123456789.123456789.123456789.123456789.123456789.123456789.123456789.123....79 +//usage:#if ENABLE_FEATURE_IP_LINK_CAN +//usage:#define iplink_type_usage "\n [type TYPE ARGS]" +//usage:#else +//usage:#define iplink_type_usage "" +//usage:#endif //usage:#define iplink_trivial_usage //usage: /*Usage:iplink*/"set IFACE [up|down] [arp on|off] [multicast on|off]\n" //usage: " [promisc on|off] [mtu NUM] [name NAME] [qlen NUM] [address MAC]\n" //usage: " [master IFACE | nomaster] [netns PID]" +//usage: IF_FEATURE_IP_LINK(iplink_type_usage) // * short help shows only "set" command, long help continues (with just one "\n") // * and shows all other commands: //usage:#define iplink_full_usage "\n" @@ -207,6 +230,59 @@ // bond_slave | ipvlan | geneve | bridge_slave | vrf } //usage: //--------------123456789.123456789.123456789.123456789.123456789.123456789.123456789.123....79 +//usage:#define iplinkcan_trivial_usage +//usage: /*Usage:iplinkcan*/"set DEVICE type can" +//usage:#define iplinkcan_full_usage "\n\n" +//usage: " [bitrate BITRATE [sample-point SAMPLE-POINT]] |\n" +//usage: " [tq TQ prop-seg PROP_SEG phase-seg1 PHASE-SEG1\n" +//usage: " phase-seg2 PHASE-SEG2 [sjw SJW]]\n" +//usage: "\n" +//usage: " [dbitrate BITRATE [dsample-point SAMPLE-POINT]] |\n" +//usage: " [dtq TQ dprop-seg PROP_SEG dphase-seg1 PHASE-SEG1\n" +//usage: " dphase-seg2 PHASE-SEG2 [dsjw SJW]]\n" +//usage: "\n" +//usage: " [loopback on|off] [listen-only on|off] [triple-sampling on|off]\n" +//usage: " [one-shot on|off] [berr-reporting on|off]\n" +//usage: " [fd on|off] [fd-non-iso on|off] [presume-ack on|off]\n" +//usage: "\n" +//usage: " [restart-ms TIME-MS] [restart]\n" +//usage: "\n" +//usage: " [termination 0..65535]\n" +//usage: +//upstream man ip-link-can: +//Usage: ip link set DEVICE type can +// [ bitrate BITRATE [ sample-point SAMPLE-POINT] ] | +// [ tq TQ prop-seg PROP_SEG phase-seg1 PHASE-SEG1 +// phase-seg2 PHASE-SEG2 [ sjw SJW ] ] +// +// [ dbitrate BITRATE [ dsample-point SAMPLE-POINT] ] | +// [ dtq TQ dprop-seg PROP_SEG dphase-seg1 PHASE-SEG1 +// dphase-seg2 PHASE-SEG2 [ dsjw SJW ] ] +// +// [ loopback { on | off } ] +// [ listen-only { on | off } ] +// [ triple-sampling { on | off } ] +// [ one-shot { on | off } ] +// [ berr-reporting { on | off } ] +// [ fd { on | off } ] +// [ fd-non-iso { on | off } ] +// [ presume-ack { on | off } ] +// +// [ restart-ms TIME-MS ] +// [ restart ] +// +// [ termination { 0..65535 } ] +// +// Where: BITRATE := { 1..1000000 } +// SAMPLE-POINT := { 0.000..0.999 } +// TQ := { NUMBER } +// PROP-SEG := { 1..8 } +// PHASE-SEG1 := { 1..8 } +// PHASE-SEG2 := { 1..8 } +// SJW := { 1..4 } +// RESTART-MS := { 0 | NUMBER } +//usage: +//--------------123456789.123456789.123456789.123456789.123456789.123456789.123456789.123....79 //usage:#define iproute_trivial_usage //usage: "list|flush|add|del|change|append|replace|test ROUTE" //usage:#define iproute_full_usage "\n\n" @@ -327,6 +403,7 @@ typedef int FAST_FUNC (*ip_func_ptr_t)(char**); #if ENABLE_IPADDR \ || ENABLE_IPLINK \ + || ENABLE_IPLINK_CAN \ || ENABLE_IPROUTE \ || ENABLE_IPRULE \ || ENABLE_IPTUNNEL \ @@ -352,6 +429,13 @@ int iplink_main(int argc UNUSED_PARAM, char **argv) return ip_do(do_iplink, argv); } #endif +#if ENABLE_IPLINK_CAN +int iplinkcan_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; +int iplinkcan_main(int argc UNUSED_PARAM, char **argv) +{ + return ip_do(do_iplink, argv); +} +#endif #if ENABLE_IPROUTE int iproute_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int iproute_main(int argc UNUSED_PARAM, char **argv) diff --git a/networking/libiproute/iplink.c b/networking/libiproute/iplink.c index 9eb0b4f5f118..c3be54f841dd 100644 --- a/networking/libiproute/iplink.c +++ b/networking/libiproute/iplink.c @@ -11,10 +11,17 @@ #include #include +#include #include "ip_common.h" /* #include "libbb.h" is inside */ #include "rt_names.h" #include "utils.h" +#if ENABLE_FEATURE_IP_LINK_CAN +#define ENABLE_FEATURE_IP_LINK_IFACE 1 +#else +#define ENABLE_FEATURE_IP_LINK_IFACE 0 +#endif + #undef ETH_P_8021AD #define ETH_P_8021AD 0x88A8 #undef VLAN_FLAG_REORDER_HDR @@ -28,6 +35,11 @@ #undef IFLA_VLAN_PROTOCOL #define IFLA_VLAN_PROTOCOL 5 +#ifndef NLMSG_TAIL +#define NLMSG_TAIL(nmsg) \ + ((struct rtattr *) (((void *) (nmsg)) + NLMSG_ALIGN((nmsg)->nlmsg_len))) +#endif + #ifndef IFLA_LINKINFO # define IFLA_LINKINFO 18 # define IFLA_INFO_KIND 1 @@ -55,6 +67,13 @@ struct ifla_vlan_flags { #define str_on_off "on\0""off\0" +enum { + PARM_on = 0, + PARM_off +}; + +typedef void FAST_FUNC(*ip_type_set_func_ptr_t)(char*, char**); + /* Exits on error */ static int get_ctl_fd(void) { @@ -241,10 +260,261 @@ static void die_must_be_on_off(const char *msg) bb_error_msg_and_die("argument of \"%s\" must be \"on\" or \"off\"", msg); } +#if ENABLE_FEATURE_IP_LINK_CAN +static float FAST_FUNC get_float(char *arg, const char *errmsg) +{ + float ret; + char *ptr; + + if (!arg || !*arg) + invarg_1_to_2(arg, errmsg); /* does not return */ + + ret = strtof(arg, &ptr); + if (!ptr || ptr == arg || *ptr) + invarg_1_to_2(arg, errmsg); /* does not return */ + + return ret; +} + +static void do_set_can(char *dev, char **argv) +{ + struct can_bittiming bt = {}, dbt = {}; + struct can_ctrlmode cm = {}; + char *keyword; + static const char keywords[] ALIGN1 = + "bitrate\0""sample-point\0""tq\0" + "prop-seg\0""phase-seg1\0""phase-seg2\0""sjw\0" + "dbitrate\0""dsample-point\0""dtq\0" + "dprop-seg\0""dphase-seg1\0""dphase-seg2\0""dsjw\0" + "loopback\0""listen-only\0""triple-sampling\0" + "one-shot\0""berr-reporting\0" + "fd\0""fd-non-iso\0""presume-ack\0" + "cc-len8-dlc\0""restart\0""restart-ms\0" + "termination\0"; + enum { ARG_bitrate = 0, ARG_sample_point, ARG_tq, + ARG_prop_seg, ARG_phase_seg1, ARG_phase_seg2, ARG_sjw, + ARG_dbitrate, ARG_dsample_point, ARG_dtq, + ARG_dprop_seg, ARG_dphase_seg1, ARG_dphase_seg2, ARG_dsjw, + ARG_loopback, ARG_listen_only, ARG_triple_sampling, + ARG_one_shot, ARG_berr_reporting, + ARG_fd, ARG_fd_non_iso, ARG_presume_ack, + ARG_cc_len8_dlc, ARG_restart, ARG_restart_ms, + ARG_termination }; + struct rtnl_handle rth; + struct { + struct nlmsghdr n; + struct ifinfomsg i; + char buf[1024]; + } req; + size_t dev_len; + struct rtattr *linkinfo, *data; + smalluint key, param; + + memset(&req, 0, sizeof(req)); + + req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifinfomsg)); + req.n.nlmsg_flags = NLM_F_REQUEST; + req.n.nlmsg_type = RTM_NEWLINK; + req.i.ifi_family = preferred_family; + xrtnl_open(&rth); + req.i.ifi_index = xll_name_to_index(dev); + dev_len = strlen(dev); + if (dev_len < 2 || dev_len > IFNAMSIZ) + invarg_1_to_2(dev, "dev"); + + addattr_l(&req.n, sizeof(req), IFLA_IFNAME, dev, dev_len); + linkinfo = NLMSG_TAIL(&req.n); + addattr_l(&req.n, sizeof(req), IFLA_LINKINFO, NULL, 0); + addattr_l(&req.n, sizeof(req), IFLA_INFO_KIND, (void *)"can", + strlen("can")); + data = NLMSG_TAIL(&req.n); + addattr_l(&req.n, sizeof(req), IFLA_INFO_DATA, NULL, 0); + while (*argv) { + key = index_in_substrings(keywords, *argv); + keyword = *argv; + //printf("%s: key: %d, *argv: %s\n", __func__, key, *argv); + switch (key) { + case ARG_bitrate: + case ARG_tq: + case ARG_prop_seg: + case ARG_phase_seg1: + case ARG_phase_seg2: + case ARG_sjw: { + __u32 *val; + + NEXT_ARG(); + if (key == ARG_bitrate) + val = &bt.bitrate; + else if (key == ARG_tq) + val = &bt.tq; + else if (key == ARG_prop_seg) + val = &bt.prop_seg; + else if (key == ARG_phase_seg1) + val = &bt.phase_seg1; + else if (key == ARG_phase_seg2) + val = &bt.phase_seg2; + else + val = &bt.sjw; + + *val = get_u32(*argv, keyword); + break; + } + case ARG_sample_point: { + float sp; + + NEXT_ARG(); + sp = get_float(*argv, keyword); + bt.sample_point = (__u32)(sp * 1000); + break; + } + case ARG_dbitrate: + case ARG_dtq: + case ARG_dprop_seg: + case ARG_dphase_seg1: + case ARG_dphase_seg2: + case ARG_dsjw: { + __u32 *val; + + NEXT_ARG(); + if (key == ARG_dbitrate) + val = &dbt.bitrate; + else if (key == ARG_dtq) + val = &dbt.tq; + else if (key == ARG_dprop_seg) + val = &dbt.prop_seg; + else if (key == ARG_dphase_seg1) + val = &dbt.phase_seg1; + else if (key == ARG_dphase_seg2) + val = &dbt.phase_seg2; + else + val = &dbt.sjw; + + *val = get_u32(*argv, keyword); + break; + } + case ARG_dsample_point: { + float sp; + + NEXT_ARG(); + sp = get_float(*argv, keyword); + dbt.sample_point = (__u32)(sp * 1000); + break; + } + case ARG_loopback: + case ARG_listen_only: + case ARG_triple_sampling: + case ARG_one_shot: + case ARG_berr_reporting: + case ARG_fd: + case ARG_fd_non_iso: + case ARG_presume_ack: + case ARG_cc_len8_dlc: { + __u32 flag = 0; + + NEXT_ARG(); + param = index_in_strings(str_on_off, *argv); + if (param < 0) + die_must_be_on_off(keyword); + + if (key == ARG_loopback) + flag = CAN_CTRLMODE_LOOPBACK; + else if (key == ARG_listen_only) + flag = CAN_CTRLMODE_LISTENONLY; + else if (key == ARG_triple_sampling) + flag = CAN_CTRLMODE_3_SAMPLES; + else if (key == ARG_one_shot) + flag = CAN_CTRLMODE_ONE_SHOT; + else if (key == ARG_berr_reporting) + flag = CAN_CTRLMODE_BERR_REPORTING; + else if (key == ARG_fd) + flag = CAN_CTRLMODE_FD; + else if (key == ARG_fd_non_iso) + flag = CAN_CTRLMODE_FD_NON_ISO; + else if (key == ARG_presume_ack) + flag = CAN_CTRLMODE_PRESUME_ACK; + else +#if defined(CAN_CTRLMODE_CC_LEN8_DLC) + flag = CAN_CTRLMODE_CC_LEN8_DLC; +#else + die_must_be_on_off(keyword); +#endif + cm.mask |= flag; + if (param == PARM_on) + cm.flags |= flag; + + break; + } + case ARG_restart: { + __u32 val = 1; + + NEXT_ARG(); + addattr_l(&req.n, sizeof(req), IFLA_CAN_RESTART, &val, sizeof(val)); + break; + } + case ARG_restart_ms: { + __u32 val; + + NEXT_ARG(); + val = get_u32(*argv, keyword); + addattr_l(&req.n, sizeof(req), IFLA_CAN_RESTART_MS, &val, sizeof(val)); + break; + } + case ARG_termination: { + __u16 val; + + NEXT_ARG(); + val = get_u16(*argv, keyword); + addattr_l(&req.n, sizeof(req), IFLA_CAN_TERMINATION, &val, sizeof(val)); + break; + } + default: + break; + } + + argv++; + } + + if (bt.bitrate || bt.tq) + addattr_l(&req.n, sizeof(req), IFLA_CAN_BITTIMING, &bt, sizeof(bt)); + + if (cm.mask) + addattr_l(&req.n, sizeof(req), IFLA_CAN_CTRLMODE, &cm, sizeof(cm)); + + data->rta_len = (void *)NLMSG_TAIL(&req.n) - (void *)data; + linkinfo->rta_len = (void *)NLMSG_TAIL(&req.n) - (void *)linkinfo; + + if (rtnl_talk(&rth, &req.n, 0, 0, NULL, NULL, NULL) < 0) + xfunc_die(); +} +#endif + +#if ENABLE_FEATURE_IP_LINK_IFACE +static void do_set_iface(char *type, char *dev, char **argv) +{ + static const char keywords[] ALIGN1 = "" + IF_FEATURE_IP_LINK_CAN("can\0") + ; + static const ip_type_set_func_ptr_t funcs[] ALIGN_PTR = { + IF_FEATURE_IP_LINK_CAN(do_set_can,) + }; + ip_type_set_func_ptr_t func; + int key; + + key = index_in_substrings(keywords, type); + if (key < 0) + return; + func = funcs[key]; + func(dev, argv); +} +#endif + /* Return value becomes exitcode. It's okay to not return at all */ static int do_set(char **argv) { char *dev = NULL; +#if ENABLE_FEATURE_IP_LINK_IFACE + char *type = NULL; +#endif uint32_t mask = 0; uint32_t flags = 0; int qlen = -1; @@ -261,18 +531,24 @@ static int do_set(char **argv) "up\0""down\0""name\0""mtu\0""qlen\0""multicast\0" "arp\0""promisc\0""address\0""netns\0" "master\0""nomaster\0" +#if ENABLE_FEATURE_IP_LINK_IFACE + "type\0" +#endif "dev\0" /* must be last */; enum { ARG_up = 0, ARG_down, ARG_name, ARG_mtu, ARG_qlen, ARG_multicast, ARG_arp, ARG_promisc, ARG_addr, ARG_netns, ARG_master, ARG_nomaster, +#if ENABLE_FEATURE_IP_LINK_IFACE + ARG_type, +#endif ARG_dev }; - enum { PARM_on = 0, PARM_off }; smalluint key; while (*argv) { /* substring search ensures that e.g. "addr" and "address" * are both accepted */ key = index_in_substrings(keywords, *argv); + //printf("%s: key: %d, *argv: %s\n", __func__, key, *argv); if (key == ARG_up) { mask |= IFF_UP; flags |= IFF_UP; @@ -304,6 +580,13 @@ static int do_set(char **argv) } else if (key == ARG_netns) { NEXT_ARG(); netns = get_unsigned(*argv, "netns"); +#if ENABLE_FEATURE_IP_LINK_IFACE + } else if (key == ARG_type) { + NEXT_ARG(); + type = *argv; + argv++; + break; +#endif } else if (key >= ARG_dev) { /* ^^^^^^ ">=" here results in "dev IFACE" treated as default */ if (key == ARG_dev) { @@ -311,6 +594,7 @@ static int do_set(char **argv) } if (dev) duparg2("dev", *argv); + dev = *argv; } else { /* "on|off" options */ @@ -496,6 +780,10 @@ static int do_set(char **argv) } if (mask) do_chflags(dev, flags, mask); +#if ENABLE_FEATURE_IP_LINK_IFACE + if (type) + do_set_iface(type, dev, argv); +#endif return 0; } @@ -531,10 +819,6 @@ static void vlan_parse_opt(char **argv, struct nlmsghdr *n, unsigned int size) PROTO_8021Q = 0, PROTO_8021AD, }; - enum { - PARM_on = 0, - PARM_off - }; int arg; uint16_t id, proto; struct ifla_vlan_flags flags = {}; @@ -610,10 +894,6 @@ static void vrf_parse_opt(char **argv, struct nlmsghdr *n, unsigned int size) addattr_l(n, size, IFLA_VRF_TABLE, &table, sizeof(table)); } -#ifndef NLMSG_TAIL -#define NLMSG_TAIL(nmsg) \ - ((struct rtattr *) (((void *) (nmsg)) + NLMSG_ALIGN((nmsg)->nlmsg_len))) -#endif /* Return value becomes exitcode. It's okay to not return at all */ static int do_add_or_delete(char **argv, const unsigned rtm) { -- 2.42.0 From christophe.blaess at logilin.fr Sun Nov 12 17:41:43 2023 From: christophe.blaess at logilin.fr (Christophe Blaess) Date: Sun, 12 Nov 2023 18:41:43 +0100 Subject: [PATCH] Remove 'W' flag in status column of 'ps' Message-ID: <20231112174143.2574237-1-christophe.blaess@logilin.fr> Hi, Here's a small patch to remove the `W` flag in the `ps` status column. This `W` flag appears for every kernel thread in `I` or `S` state with Busybox `ps` command but it never appears with Procps one. Here's an example with the two versions of `ps`: ``` $ busybox ps -o pid,stat,comm PID STAT COMMAND 1 S systemd 2 SW kthreadd 3 IW< rcu_gp 4 IW< rcu_par_gp 5 IW< slub_flushwq 6 IW< netns 8 IW< kworker/0:0H-ev 10 IW< mm_percpu_wq 11 SW rcu_tasks_rude_ 12 SW rcu_tasks_trace 13 SW ksoftirqd/0 [...] $ ps ax PID TTY STAT TIME COMMAND 1 ? Ss 0:20 /sbin/init splash 2 ? S 0:00 [kthreadd] 3 ? I< 0:00 [rcu_gp] 4 ? I< 0:00 [rcu_par_gp] 5 ? I< 0:00 [slub_flushwq] 6 ? I< 0:00 [netns] 8 ? I< 0:00 [kworker/0:0H-events_highpri] 10 ? I< 0:00 [mm_percpu_wq] 11 ? S 0:00 [rcu_tasks_rude_] 12 ? S 0:00 [rcu_tasks_trace] 13 ? S 0:57 [ksoftirqd/0] [...] ``` Note that a `W` flag once existed with Procps, but it is no more used since 2.6 kernel (see ps man page). Signed-off-by: Christophe Blaess --- libbb/procps.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/libbb/procps.c b/libbb/procps.c index f56b71b21..8f210117d 100644 --- a/libbb/procps.c +++ b/libbb/procps.c @@ -468,11 +468,6 @@ procps_status_t* FAST_FUNC procps_scan(procps_status_t* sp, int flags) sp->state[1] = ' '; sp->state[2] = ' '; s_idx = 1; - if (sp->vsz == 0 && sp->state[0] != 'Z') { - /* not sure what the purpose of this flag */ - sp->state[1] = 'W'; - s_idx = 2; - } if (tasknice != 0) { if (tasknice < 0) sp->state[s_idx] = '<'; -- 2.34.1 From mjt at tls.msk.ru Mon Nov 13 08:18:22 2023 From: mjt at tls.msk.ru (Michael Tokarev) Date: Mon, 13 Nov 2023 11:18:22 +0300 Subject: syslogd problem In-Reply-To: References: <2b869ce9-af91-81ab-038d-ba89ee7b334e@tls.msk.ru> Message-ID: <5706a663-190a-4e84-b0f7-66458efb045a@tls.msk.ru> 21.09.2023 15:10, Jeff Pohlmeyer : > On Wed, Sep 20, 2023 at 11:54?AM Michael Tokarev wrote: >> It's been broken for quite some time > > Thanks, I didn't know about that one. These are actually two different > problems, your "read() not blocking" fix, and my "OPT_locallog not in > opts" fix. After applying both fixes I was finally able to get syslogd > working from my init script. > > Sure hope these can make it into master soon! Ping? This fix hasn'f found its way to busybos, it seems.. Thanks, /mjt From mjt at tls.msk.ru Mon Nov 13 13:30:22 2023 From: mjt at tls.msk.ru (Michael Tokarev) Date: Mon, 13 Nov 2023 16:30:22 +0300 Subject: Spelling: recevied, delimeter Message-ID: <1699882222.479842.1979247.nullmailer@tls.msk.ru> --- a/coreutils/cut.c +++ b/coreutils/cut.c @@ -33,8 +33,8 @@ //usage: "\n -b LIST Output only bytes from LIST" //usage: "\n -c LIST Output only characters from LIST" //usage: "\n -d SEP Field delimiter for input (default -f TAB, -F run of whitespace)" -//usage: "\n -O SEP Field delimeter for output (default = -d for -f, one space for -F)" -//usage: "\n -D Don't sort/collate sections or match -fF lines without delimeter" +//usage: "\n -O SEP Field delimiter for output (default = -d for -f, one space for -F)" +//usage: "\n -D Don't sort/collate sections or match -fF lines without delimiter" //usage: "\n -f LIST Print only these fields (-d is single char)" //usage: IF_FEATURE_CUT_REGEX( //usage: "\n -F LIST Print only these fields (-d is regex)" From Matthew.Chae at axis.com Mon Nov 20 12:41:44 2023 From: Matthew.Chae at axis.com (Matthew Chae) Date: Mon, 20 Nov 2023 12:41:44 +0000 Subject: fix large PID overflow their column in top command In-Reply-To: References: Message-ID: Hi Denys, A gentle reminder that when you're available, can you take a look at this? Have a great day, Matthew Chae ________________________________ From: Matthew Chae Sent: Friday, November 10, 2023 4:22 PM To: Denys Vlasenko Cc: busybox at busybox.net ; Christopher Wong Subject: Re: fix large PID overflow their column in top command Hi Denys, I'm sending the patch what I've mentioned. Can you take a look at this? If I don't understand correctly what you said before, let me know. Have a nice weekend, Matthew Chae ________________________________ From: busybox on behalf of Matthew Chae Sent: Wednesday, November 8, 2023 5:33 PM To: Denys Vlasenko Cc: busybox at busybox.net ; Christopher Wong Subject: Re: fix large PID overflow their column in top command Hi Denys, Ok. Good to hear. If I understand correctly, will you first review my patch and then give me Morris's account to commit the change? Then, let me send a patch soon. Br-Matthew ________________________________ From: Denys Vlasenko Sent: Wednesday, November 8, 2023 12:35 PM To: Matthew Chae Cc: busybox at busybox.net ; Christopher Wong Subject: Re: fix large PID overflow their column in top command On Wed, Nov 1, 2023 at 10:18?AM Matthew Chae wrote: > > Hi maintainer, > > I'd like to hear your opinion regarding large PID can overflow its column in top command. > > The max PID value can have 7 digits as the 4194304. > Busybox v1.36 released a new patch to handle large PID value in top command. > However, it still causes misalignment between the title and the number for 7 digits or 6 digits PID. > The presence of a large number of PID and PPID digits in the column may cause overflow, making it impossible to display the entire data accurately. > Plus, the large PID causes that user name can't be displayed up to 8 characters and result in the truncation of less than 8 characters. > > I can contribute new patch which allocates appropriate space for the number of digits in the PID and PPID to represent the values in each column correctly. > This can make alignment between the title and the number for 7 digits PID and 5 digits PID and also display user name up to 8 characters. > > What do you think? If you agree, I will send a patch. Absolutely, please send a patch. Would be interesting to see a good solution. -------------- next part -------------- An HTML attachment was scrubbed... URL: From vda.linux at googlemail.com Thu Nov 23 16:44:57 2023 From: vda.linux at googlemail.com (Denys Vlasenko) Date: Thu, 23 Nov 2023 17:44:57 +0100 Subject: fix large PID overflow their column in top command In-Reply-To: References: Message-ID: On Fri, Nov 10, 2023 at 4:22?PM Matthew Chae wrote: > Hi Denys, > > I'm sending the patch what I've mentioned. Can you take a look at this? > If I don't understand correctly what you said before, let me know. > > The max PID value can have 7 digits as the 4194304. > > Busybox v1.36 released a new patch to handle large PID value in top command. > > However, it still causes misalignment between the title and the number for 7 digits or 6 digits PID. > > The presence of a large number of PID and PPID digits in the column may cause overflow, making it impossible to display the entire data accurately. > > Plus, the large PID causes that user name can't be displayed up to 8 characters and result in the truncation of less than 8 characters. > > > > I can contribute new patch which allocates appropriate space for the number of digits in the PID and PPID to represent the values in each column correctly. > > This can make alignment between the title and the number for 7 digits PID and 5 digits PID and also display user name up to 8 characters. > > > > What do you think? If you agree, I will send a patch. > > Absolutely, please send a patch. Would be interesting to see a good solution. + 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 above is not sound. Even if sysctl kernel.pid_max is 32768, there can be already running processes with pids > 99999. Ideally, the code should handle any pids correctly. From David.Laight at ACULAB.COM Thu Nov 23 17:10:01 2023 From: David.Laight at ACULAB.COM (David Laight) Date: Thu, 23 Nov 2023 17:10:01 +0000 Subject: fix large PID overflow their column in top command In-Reply-To: References: Message-ID: <4458638ee54e4ae7a47a9586de9b874d@AcuMS.aculab.com> ... > + 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 above is not sound. Even if sysctl kernel.pid_max > is 32768, there can be already running processes with pids > 99999. It's also probably wrong for pretty much all other values. I'd just base the column width on strlen(pid_buf) with a minimum value of 5. It is unlikely that pid_max has been reduced - so column overflow it that case probably doesn't really matter. The more interesting case is really a system with a very large pid_max that has never run many processes. You don't really want lots of blank space. I can't remember whether top reads everything before doing any output? Since the output is sorted it probably almost always does. In which case it knows the column width it will need. I did post a patch a while back that enabled 'Irix mode'. (100% cpu is one cpu at 100%, not all cpus at 100%) Maybe I should dig it out again. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales) From jli05 at icloud.com Sun Nov 26 11:49:48 2023 From: jli05 at icloud.com (Jencir Lee) Date: Sun, 26 Nov 2023 11:49:48 +0000 Subject: Any built-in HTTP server with SSL to work with Python Flask apps? Message-ID: Is there a built-in HTTP server, configurable with SSL certificate, and which works with Python Flask applications, via communicating with uWSGI (https://uwsgi-docs.readthedocs.io/ ), for example? Regards, J -------------- next part -------------- An HTML attachment was scrubbed... URL: From jli05 at icloud.com Sun Nov 26 11:46:48 2023 From: jli05 at icloud.com (Jencir Lee) Date: Sun, 26 Nov 2023 11:46:48 +0000 Subject: crond: log both timestamp and command output Message-ID: <1198B65C-5F2A-4FC5-A6BF-F0AB50A6DEC1@icloud.com> Hi, Would it be possible - either when logging to syslog, record as well commands output to stderr (at least) ? at the moment no output to stdout or stderr is logged - or when logging to a file, record the timestamp ? at the moment command output to stderr is recorded but no timestamp there regardless the loglevel The use case is that if syslog (or an external logging file) is used as a central place for all information and errors, we need both timestamp and command output (written to stderr at least) recorded. Regards, J From valdemirs at gmail.com Mon Nov 27 22:31:41 2023 From: valdemirs at gmail.com (Valdemir Santos) Date: Mon, 27 Nov 2023 19:31:41 -0300 Subject: html2text in busybox Message-ID: Hi, is there any way to install html2text in Busybox ? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: