aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2018-04-04 19:55:09 +0100
committerRon Yorston <rmy@pobox.com>2018-04-04 19:55:09 +0100
commit33a914da6bba61e27aee82675276bf1dccc52966 (patch)
tree2242719bf4bb7705504967d54d137d6fe19cc8f3 /libbb
parent016ca978455df7257a92236bbfb0c67de4a4bcd8 (diff)
downloadbusybox-w32-33a914da6bba61e27aee82675276bf1dccc52966.tar.gz
busybox-w32-33a914da6bba61e27aee82675276bf1dccc52966.tar.bz2
busybox-w32-33a914da6bba61e27aee82675276bf1dccc52966.zip
ps: obtain applet names from other BusyBox processes
Remove the code which passed applet names to child processes using environment variables. This only allowed ps to display names for its ancestors. Instead attempt to read applet names from the memory of unrelated processes. The Microsoft documentation alone wasn't enough to figure out how to do this. Additional hints from: https://stackoverflow.com/questions/4298331/exe-or-dll-image-base-address https://stackoverflow.com/questions/14467229/get-base-address-of-process
Diffstat (limited to 'libbb')
-rw-r--r--libbb/appletlib.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/libbb/appletlib.c b/libbb/appletlib.c
index 1488d4bd6..3e740363a 100644
--- a/libbb/appletlib.c
+++ b/libbb/appletlib.c
@@ -796,13 +796,6 @@ static void install_links(const char *busybox UNUSED_PARAM,
796 796
797static void run_applet_and_exit(const char *name, char **argv) NORETURN; 797static void run_applet_and_exit(const char *name, char **argv) NORETURN;
798 798
799#if ENABLE_PLATFORM_MINGW32
800char *bb_applet_pid(void)
801{
802 return auto_string(xasprintf("BB_APPLET_%d=%s", getpid(), applet_name));
803}
804#endif
805
806# if ENABLE_BUSYBOX 799# if ENABLE_BUSYBOX
807# if ENABLE_FEATURE_SH_STANDALONE && ENABLE_FEATURE_TAB_COMPLETION 800# if ENABLE_FEATURE_SH_STANDALONE && ENABLE_FEATURE_TAB_COMPLETION
808 /* 801 /*
@@ -979,6 +972,11 @@ int busybox_main(int argc UNUSED_PARAM, char **argv)
979# endif 972# endif
980 973
981# if NUM_APPLETS > 0 974# if NUM_APPLETS > 0
975
976# if ENABLE_PLATFORM_MINGW32
977char bb_applet_name[MAX_APPLET_NAME_LEN+1];
978# endif
979
982void FAST_FUNC run_applet_no_and_exit(int applet_no, const char *name, char **argv) 980void FAST_FUNC run_applet_no_and_exit(int applet_no, const char *name, char **argv)
983{ 981{
984 int argc = string_array_len(argv); 982 int argc = string_array_len(argv);
@@ -988,6 +986,9 @@ void FAST_FUNC run_applet_no_and_exit(int applet_no, const char *name, char **ar
988 * "-/sbin/halt" -> "halt", for example. 986 * "-/sbin/halt" -> "halt", for example.
989 */ 987 */
990 applet_name = name; 988 applet_name = name;
989#if ENABLE_PLATFORM_MINGW32
990 strcpy(bb_applet_name, applet_name);
991#endif
991 992
992 /* Special case. POSIX says "test --help" 993 /* Special case. POSIX says "test --help"
993 * should be no different from e.g. "test --foo". 994 * should be no different from e.g. "test --foo".
@@ -1014,10 +1015,6 @@ void FAST_FUNC run_applet_no_and_exit(int applet_no, const char *name, char **ar
1014 if (ENABLE_FEATURE_SUID) 1015 if (ENABLE_FEATURE_SUID)
1015 check_suid(applet_no); 1016 check_suid(applet_no);
1016 1017
1017#if ENABLE_PLATFORM_MINGW32
1018 putenv(bb_applet_pid());
1019#endif
1020
1021 xfunc_error_retval = applet_main[applet_no](argc, argv); 1018 xfunc_error_retval = applet_main[applet_no](argc, argv);
1022 /* Note: applet_main() may also not return (die on a xfunc or such) */ 1019 /* Note: applet_main() may also not return (die on a xfunc or such) */
1023 xfunc_die(); 1020 xfunc_die();