diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2020-06-24 13:39:13 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2020-06-24 15:05:22 +0200 |
commit | 67e1529b921416d6c3f33fb43691bc9919e3eacc (patch) | |
tree | 874946bf7b52062d7496ea612b62f1cfe95f864f /libbb | |
parent | d5314e71294d228cff5d86e00d15661461f68fc9 (diff) | |
download | busybox-67e1529b921416d6c3f33fb43691bc9919e3eacc.tar.gz |
nologin: make it possible to build it as single applet
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb')
-rw-r--r-- | libbb/appletlib.c | 38 |
1 files changed, 33 insertions, 5 deletions
diff --git a/libbb/appletlib.c b/libbb/appletlib.c index f842e73cc..a515c3fe3 100644 --- a/libbb/appletlib.c +++ b/libbb/appletlib.c @@ -754,7 +754,9 @@ static void install_links(const char *busybox UNUSED_PARAM, } # endif +# if ENABLE_BUSYBOX || NUM_APPLETS > 0 static void run_applet_and_exit(const char *name, char **argv) NORETURN; +#endif # if NUM_SCRIPTS > 0 static int find_script_by_name(const char *name) @@ -775,13 +777,13 @@ int scripted_main(int argc UNUSED_PARAM, char **argv) { int script = find_script_by_name(applet_name); if (script >= 0) -#if ENABLE_ASH || ENABLE_SH_IS_ASH || ENABLE_BASH_IS_ASH +# if ENABLE_SHELL_ASH exit(ash_main(-script - 1, argv)); -#elif ENABLE_HUSH || ENABLE_SH_IS_HUSH || ENABLE_BASH_IS_HUSH +# elif ENABLE_SHELL_HUSH exit(hush_main(-script - 1, argv)); -#else +# else return 1; -#endif +# endif return 0; } @@ -1024,7 +1026,33 @@ static NORETURN void run_applet_and_exit(const char *name, char **argv) } # endif -#endif /* !defined(SINGLE_APPLET_MAIN) */ +#else /* defined(SINGLE_APPLET_MAIN) */ + +# if NUM_SCRIPTS > 0 +/* if SINGLE_APPLET_MAIN, these two functions are simpler: */ +int scripted_main(int argc UNUSED_PARAM, char **argv) MAIN_EXTERNALLY_VISIBLE; +int scripted_main(int argc UNUSED_PARAM, char **argv) +{ +# if ENABLE_SHELL_ASH + int script = 0; + exit(ash_main(-script - 1, argv)); +# elif ENABLE_SHELL_HUSH + int script = 0; + exit(hush_main(-script - 1, argv)); +# else + return 1; +# endif +} +char* FAST_FUNC +get_script_content(unsigned n UNUSED_PARAM) +{ + char *t = unpack_bz2_data(packed_scripts, sizeof(packed_scripts), + UNPACKED_SCRIPTS_LENGTH); + return t; +} +# endif /* NUM_SCRIPTS > 0 */ + +#endif /* defined(SINGLE_APPLET_MAIN) */ #if ENABLE_BUILD_LIBBUSYBOX |