aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2024-07-08 14:10:31 +0100
committerRon Yorston <rmy@pobox.com>2024-07-08 14:10:31 +0100
commitfff1c91e642f4d62e5dc542594e79b0972a3db78 (patch)
tree549230ec628e19105fc814ab8746264d96c0d9ea
parent9e0db7ef4a231cdf619e3fb7223ad1345b2adcf0 (diff)
downloadbusybox-w32-fff1c91e642f4d62e5dc542594e79b0972a3db78.tar.gz
busybox-w32-fff1c91e642f4d62e5dc542594e79b0972a3db78.tar.bz2
busybox-w32-fff1c91e642f4d62e5dc542594e79b0972a3db78.zip
ash: read profile script relative to binary
As well as trying to read '/etc/profile' also look for the script 'etc/profile' relative to the location of the running binary. Adds 64-96 bytes.
-rw-r--r--include/mingw.h1
-rw-r--r--miscutils/man.c5
-rw-r--r--shell/ash.c4
-rw-r--r--win32/mingw.c8
4 files changed, 15 insertions, 3 deletions
diff --git a/include/mingw.h b/include/mingw.h
index b0342337d..c4c2e199a 100644
--- a/include/mingw.h
+++ b/include/mingw.h
@@ -639,3 +639,4 @@ char *find_first_executable(const char *name);
639char *xappendword(const char *str, const char *word); 639char *xappendword(const char *str, const char *word);
640int windows_env(void); 640int windows_env(void);
641void change_critical_error_dialogs(const char *newval) FAST_FUNC; 641void change_critical_error_dialogs(const char *newval) FAST_FUNC;
642char *exe_relative_path(const char *tail);
diff --git a/miscutils/man.c b/miscutils/man.c
index c3efe4484..3954455b4 100644
--- a/miscutils/man.c
+++ b/miscutils/man.c
@@ -261,7 +261,7 @@ int man_main(int argc UNUSED_PARAM, char **argv)
261 char *token[2]; 261 char *token[2];
262#if ENABLE_PLATFORM_MINGW32 262#if ENABLE_PLATFORM_MINGW32
263 char **ptr; 263 char **ptr;
264 char *exepath, *relpath; 264 char *relpath;
265 const char *mpl[] = { "/usr/man", "/usr/share/man", NULL, NULL }; 265 const char *mpl[] = { "/usr/man", "/usr/share/man", NULL, NULL };
266#endif 266#endif
267 267
@@ -316,8 +316,7 @@ int man_main(int argc UNUSED_PARAM, char **argv)
316 316
317#if ENABLE_PLATFORM_MINGW32 317#if ENABLE_PLATFORM_MINGW32
318 /* allow man pages to be stored relative to the executable */ 318 /* allow man pages to be stored relative to the executable */
319 exepath = xstrdup(bb_busybox_exec_path); 319 relpath = exe_relative_path("man");
320 relpath = concat_path_file(dirname(exepath), "man");
321 320
322 if (!man_path_list) { 321 if (!man_path_list) {
323 mpl[2] = relpath; 322 mpl[2] = relpath;
diff --git a/shell/ash.c b/shell/ash.c
index 881bc12ab..d9ab3feb5 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -16295,6 +16295,10 @@ int ash_main(int argc UNUSED_PARAM, char **argv)
16295 hp = concat_path_file(get_system_drive(), "/etc/profile"); 16295 hp = concat_path_file(get_system_drive(), "/etc/profile");
16296 read_profile(hp); 16296 read_profile(hp);
16297 free((void *)hp); 16297 free((void *)hp);
16298
16299 hp = exe_relative_path("/etc/profile");
16300 read_profile(hp);
16301 free((void *)hp);
16298#else 16302#else
16299 read_profile("/etc/profile"); 16303 read_profile("/etc/profile");
16300#endif 16304#endif
diff --git a/win32/mingw.c b/win32/mingw.c
index 273b8d840..f2b025e43 100644
--- a/win32/mingw.c
+++ b/win32/mingw.c
@@ -2507,3 +2507,11 @@ change_critical_error_dialogs(const char *newval)
2507 SetErrorMode(newval && newval[0] == '1' && newval[1] == '\0' ? 2507 SetErrorMode(newval && newval[0] == '1' && newval[1] == '\0' ?
2508 0 : SEM_FAILCRITICALERRORS); 2508 0 : SEM_FAILCRITICALERRORS);
2509} 2509}
2510
2511char *exe_relative_path(const char *tail)
2512{
2513 char *exepath = xstrdup(bb_busybox_exec_path);
2514 char *relpath = concat_path_file(dirname(exepath), tail);
2515 free(exepath);
2516 return relpath;
2517}