Fixed overlooked problems and improved integration

2025-02-08 Thread Nadav Tasher
Hi all, This update to the patchset contains the following changes: 1. Re-implemented BB_EXECVE and BB_EXECVPE to use utility functions like BB_APPLET_EXECVE and BB_APPLET_EXECVPE. 2. Introduced BB_APPLET_EXECVE, which copies argv to a new heap allocated string array. This allows applets to modify

[PATCH v6 01/10] Config.in: FEATURE_PREFER_APPLETS depends on !BUILD_INDIVIDUAL

2025-02-08 Thread Nadav Tasher
Having FEATURE_PREFER_APPLETS on while building individual applets seems like a bad idea. Applets would try to execute theirselves with different argument if applets are prefered. Signed-off-by: Nadav Tasher --- Config.in | 1 + 1 file changed, 1 insertion(+) diff --git a/Config.in b/Config.in

[PATCH v6 06/10] ash: use BB_EXECVE to execute commands and applets in tryexec

2025-02-08 Thread Nadav Tasher
This change makes the standalone shell use the BB_EXECVE utility. BB_EXECVE calls BB_APPLET_EXECVE which has NOEXEC and applets only logic. This allows for better control of the executed processes. Signed-off-by: Nadav Tasher --- shell/ash.c | 72 +++-

[PATCH v6 09/10] httpd: disable FEATURE_HTTPD_CGI when FEATURE_FORCE_APPLETS is enabled

2025-02-08 Thread Nadav Tasher
Due to a limit imposed by FEATURE_FORCE_APPLETS, execv is not allowed. The execv call is required to execute CGI binaries, so it makes FEATURE_HTTPD_CGI depend on FEATURE_FORCE_APPLET being disabled. The execv call was changed to BB_EXECV, mostly for keeping the codebase consistent, as all applets

[PATCH v6 08/10] applets: use BB_EXECVP and BB_EXECVPE instead of exec calls

2025-02-08 Thread Nadav Tasher
This replaces all invocations of execs with BB_EXECVP(E). It provides better control over executed programs and allows all applets to seamlessly execute other applets instead of just calling exec. Signed-off-by: Nadav Tasher --- console-tools/reset.c | 2 +- debianutils/start_stop_dae

[PATCH v6 02/10] executable: introduce BB_EXECVE and BB_EXECVPE to handle applet execution and replace BB_EXECVP with a macro

2025-02-08 Thread Nadav Tasher
This patch aims to provide suitable proxy functions to the exec syscall family. BB_EXECVE and BB_EXECVPE were introduced, acting as a proxies to the libc execve and execvpe functions. When called, they first use BB_APPLET_EXECVE and BB_APPLET_EXECVPE to look for a matching applet (assuming FEATURE

[PATCH v6 03/10] vfork_daemon_rexec: update spawn_and_wait function to use BB_EXECVP

2025-02-08 Thread Nadav Tasher
Using BB_EXECVP ensures consistency with spawn() function, and allows moving NOEXEC support to BB_EXECVP, which makes BB_EXECVP to go-to function for running new processes. Signed-off-by: Nadav Tasher --- libbb/vfork_daemon_rexec.c | 25 + 1 file changed, 13 insertions(+)

[PATCH v6 04/10] vfork_daemon_rexec: implement bb_system using spawn_and_wait

2025-02-08 Thread Nadav Tasher
Implemented bb_system using spawn_and_wait in conjuction with "sh", to allow bb_system to execute the internal shell when using the FEATURE_PREFER_APPLETS config option. When FEATURE_PREFER_APPLETS is disabled, libc "system()" is used. Signed-off-by: Nadav Tasher --- include/libbb.h

[PATCH v6 07/10] tar: replace execlp call with BB_EXECVP and disable xz compression when applets are prefered

2025-02-08 Thread Nadav Tasher
Using BB_EXECVP allows for more control over the compressor program executed. The xz compressor is disabled when applets are prefered, since the xz applet does not support compression. Signed-off-by: Nadav Tasher --- archival/tar.c | 28 +++- 1 file changed, 23 insertion

[PATCH v6 10/10] executable: allow forcing all applets to behave as NOEXEC applets

2025-02-08 Thread Nadav Tasher
This patch adds an experimental configuration option to allow the BB_EXECVPE function to treat all applets as if they were NOEXEC. This is experimental, as noted in the configuration description. Signed-off-by: Nadav Tasher --- Config.in | 12 libbb/executable.c | 2 +- 2

[PATCH v6 05/10] applets: change system() calls to bb_system()

2025-02-08 Thread Nadav Tasher
Allows for execution of the internal shell when the FEATURE_PREFER_APPLETS configuration option is enabled.. Signed-off-by: Nadav Tasher --- archival/dpkg.c | 2 +- editors/awk.c | 2 +- editors/vi.c | 2 +- init/bootchartd.c | 2 +- miscutils/man.c | 2 +- netwo

Re: [PATCH v5 6/9] ash: use BB_EXECVPE to execute commands with FEATURE_SH_STANDALONE

2025-02-08 Thread Nadav Tasher
On Sat, Feb 01, 2025 at 11:14:55AM +, Ron Yorston wrote: > Differences between how ash searches for an executable and how this > patch set using execvpe() does: > > 1) execvpe() uses the environment variable PATH while ash uses the shell >variable PATH. These may not be the same. > > 2)

Re: [PATCH] miscutils: fix DIVISION_BY_ZERO.EX in beep.c

2025-02-08 Thread Xabier Oneca -- xOneca
Hi Anton, Thanks for the patch. > Report of the static analyzer: > DIVISION_BY_ZERO.EX Variable xatou(...), > whose possible value set allows a zero value at xatonum_template.c:118 by > calling function 'xatou' at beep.c:90, > is used as a denominator at beep.c:90. > > Corrections explained: > -

Re: [PATCH] miscutils: fix DIVISION_BY_ZERO.EX in beep.c

2025-02-08 Thread tito
On Sat, 8 Feb 2025 18:26:12 +0100 Xabier Oneca -- xOneca wrote: > Hi Anton, > > Thanks for the patch. > > > Report of the static analyzer: > > DIVISION_BY_ZERO.EX Variable xatou(...), > > whose possible value set allows a zero value at xatonum_template.c:118 by > > calling function 'xatou' a