aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--shell/ash.c45
-rw-r--r--win32/mingw.c6
2 files changed, 26 insertions, 25 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 8c39a504a..f7c12f8e1 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -13508,27 +13508,43 @@ init(void)
13508 * 13508 *
13509 * We may end up having both Path and PATH. Then Path will be chosen 13509 * We may end up having both Path and PATH. Then Path will be chosen
13510 * because it appears first. 13510 * because it appears first.
13511 *
13512 * Also, replace backslashes with forward slashes.
13513 */ 13511 */
13514 for (envp = environ; envp && *envp; envp++) 13512 for (envp = environ; envp && *envp; envp++) {
13515 if (!strncasecmp(*envp, "PATH=", 5) && 13513 if (strncasecmp(*envp, "PATH=", 5) == 0 &&
13516 strncmp(*envp, "PATH=", 5)) 13514 strncmp(*envp, "PATH=", 5) != 0) {
13517 break; 13515 break;
13516 }
13517 }
13518
13518 if (envp && *envp) { 13519 if (envp && *envp) {
13520 /*
13521 * If we get here it's because the environment contains a path
13522 * variable called something other than PATH. This suggests we
13523 * haven't been invoked from an earlier instance of BusyBox.
13524 */
13519 char *start, *end; 13525 char *start, *end;
13526 struct passwd *pw;
13527
13520 for (envp = environ; envp && *envp; envp++) { 13528 for (envp = environ; envp && *envp; envp++) {
13521 end = strchr(*envp, '='); 13529 end = strchr(*envp, '=');
13522 if (!end) 13530 if (!end)
13523 continue; 13531 continue;
13532
13533 /* make all variable names uppercase */
13524 for (start = *envp;start < end;start++) 13534 for (start = *envp;start < end;start++)
13525 *start = toupper(*start); 13535 *start = toupper(*start);
13536
13537 /* convert backslashes to forward slashes */
13526 for ( ++end; *end; ++end ) { 13538 for ( ++end; *end; ++end ) {
13527 if ( *end == '\\' ) { 13539 if ( *end == '\\' ) {
13528 *end = '/'; 13540 *end = '/';
13529 } 13541 }
13530 } 13542 }
13531 } 13543 }
13544
13545 /* some initialisation normally performed at login */
13546 pw = xgetpwuid(getuid());
13547 setup_environment(pw->pw_shell, SETUP_ENV_CHANGEENV, pw);
13532 } 13548 }
13533#endif 13549#endif
13534 for (envp = environ; envp && *envp; envp++) { 13550 for (envp = environ; envp && *envp; envp++) {
@@ -13537,25 +13553,6 @@ init(void)
13537 } 13553 }
13538 } 13554 }
13539 13555
13540#if ENABLE_PLATFORM_MINGW32
13541 p = lookupvar("HOME");
13542 if (!p) {
13543 const char *hd, *hp;
13544
13545 hd = lookupvar("HOMEDRIVE");
13546 hp = lookupvar("HOMEPATH");
13547 if (hd && hp) {
13548 char *s;
13549
13550 if ((s=malloc(strlen(hd) + strlen(hp) + 1)) != NULL) {
13551 strcat(strcpy(s, hd), hp);
13552 setvar("HOME", s, VEXPORT);
13553 free(s);
13554 }
13555 }
13556 }
13557#endif
13558
13559 if (!ENABLE_PLATFORM_MINGW32) 13556 if (!ENABLE_PLATFORM_MINGW32)
13560 setvar("PPID", utoa(getppid()), 0); 13557 setvar("PPID", utoa(getppid()), 0);
13561 13558
diff --git a/win32/mingw.c b/win32/mingw.c
index 4c7465482..be08c5bd5 100644
--- a/win32/mingw.c
+++ b/win32/mingw.c
@@ -527,14 +527,18 @@ struct passwd *getpwuid(int uid UNUSED_PARAM)
527{ 527{
528 static char user_name[100]; 528 static char user_name[100];
529 static struct passwd p; 529 static struct passwd p;
530
531 DWORD len = sizeof(user_name); 530 DWORD len = sizeof(user_name);
531
532 user_name[0] = '\0';
532 if (!GetUserName(user_name, &len)) 533 if (!GetUserName(user_name, &len))
533 return NULL; 534 return NULL;
534 p.pw_name = user_name; 535 p.pw_name = user_name;
535 p.pw_gecos = "unknown"; 536 p.pw_gecos = "unknown";
536 p.pw_dir = gethomedir(); 537 p.pw_dir = gethomedir();
537 p.pw_shell = NULL; 538 p.pw_shell = NULL;
539 p.pw_uid = 1000;
540 p.pw_gid = 1000;
541
538 return &p; 542 return &p;
539} 543}
540 544