[PATCH] Add a 'busybox --list name' option to display script content Re: License concerns when embedding script in busybox binary
Tito
farmatito at tiscali.it
Fri Nov 9 19:47:07 UTC 2018
Hi,
I'am speechless.......
but we still need an option to colorize the output ;-)
Ciao,
Tito
On 09/11/18 19:10, Ron Yorston wrote:
> Add an option to allow the content of embedded scripts to be
> displayed.
>
> It's disabled by default. When enabled:
>
> function old new delta
> run_applet_and_exit 728 801 +73
> .rodata 168561 168610 +49
> ------------------------------------------------------------------------------
> (add/remove: 0/0 grow/shrink: 2/0 up/down: 122/0) Total: 122 bytes
>
> Signed-off-by: Ron Yorston <rmy at pobox.com>
> ---
> libbb/appletlib.c | 28 ++++++++++++++++++++++++++++
> shell/ash.c | 9 +++++++++
> 2 files changed, 37 insertions(+)
>
> diff --git a/libbb/appletlib.c b/libbb/appletlib.c
> index f616a2453..05d7d8fec 100644
> --- a/libbb/appletlib.c
> +++ b/libbb/appletlib.c
> @@ -60,6 +60,15 @@
> # define NUM_APPLET_SCRIPTS 0
> # define IF_CUSTOM_SCRIPTS(...)
> #endif
> +
> +#if ENABLE_ASH_LIST_EMBEDDED_SCRIPTS && (NUM_SCRIPTS > 0 || HAS_PROFILE)
> +# define LIST_CONTENT 1
> +# define IF_LIST_CONTENT(...) __VA_ARGS__
> +#else
> +# define LIST_CONTENT 0
> +# define IF_LIST_CONTENT(...)
> +#endif
> +
> #if NUM_SCRIPTS > 0 || HAS_PROFILE
> # include "bb_archive.h"
> static const char packed_scripts[] ALIGN1 = { PACKED_SCRIPTS };
> @@ -807,6 +816,9 @@ int busybox_main(int argc UNUSED_PARAM, char **argv)
> "\n"
> "Usage: busybox [function [arguments]...]\n"
> " or: busybox --list"IF_FEATURE_INSTALLER("[-full]")"\n"
> + IF_LIST_CONTENT(
> + " or: busybox --list name\n"
> + )
> IF_CUSTOM_SCRIPTS(
> " or: busybox --scripts\n"
> )
> @@ -865,6 +877,22 @@ int busybox_main(int argc UNUSED_PARAM, char **argv)
> # else
> const char *a = applet_names;
> # endif
> +
> + if (LIST_CONTENT && argv[1][6] == '\0' && argv[2] != NULL) {
> + int n = (HAS_PROFILE && strcmp(argv[2], ".profile") == 0) ? 0 :
> + find_script_by_name(argv[2]);
> + if (n >= 0) {
> + char *script = get_script_content(n);
> + if (script != NULL) {
> + full_write1_str(script);
> + }
> + }
> + else {
> + bb_error_msg_and_die("script '%s' not found", argv[2]);
> + }
> + return 0;
> + }
> +
> dup2(1, 2);
> while (*a) {
> # if ENABLE_FEATURE_INSTALLER
> diff --git a/shell/ash.c b/shell/ash.c
> index dd9eea1ac..0fac2ac01 100644
> --- a/shell/ash.c
> +++ b/shell/ash.c
> @@ -162,6 +162,15 @@
> //config: the script in 'applets_sh' and a stub C file containing
> //config: configuration in the appropriate subsystem directory.
> //config:
> +//config:config ASH_LIST_EMBEDDED_SCRIPTS
> +//config: bool "Allow listing of embedded script content"
> +//config: default n
> +//config: depends on ASH_EMBEDDED_SCRIPTS
> +//config: help
> +//config: Allow the contents of embedded scripts to be listed by the
> +//config: '--list name' BusyBox argument. Select this if you don't mind
> +//config: users seeing what's in your scripts.
> +//config:
> //config:endif # ash options
>
> //applet:IF_ASH(APPLET(ash, BB_DIR_BIN, BB_SUID_DROP))
>
More information about the busybox
mailing list