aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-06-12 22:35:19 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-06-12 22:35:19 +0000
commitf5f75c5e82d47613847c356664e47c4be69e73aa (patch)
treee71a09d744a9db75a1cbe6cb73d55e71a435e7d1
parentf312e32662f6d98f86c68d8f781b3255547f8200 (diff)
downloadbusybox-w32-f5f75c5e82d47613847c356664e47c4be69e73aa.tar.gz
busybox-w32-f5f75c5e82d47613847c356664e47c4be69e73aa.tar.bz2
busybox-w32-f5f75c5e82d47613847c356664e47c4be69e73aa.zip
remove nearly-duplicate PATHs in several places
function old new delta bb_PATH_root_path - 35 +35 varunset 60 58 -2 arith 2042 2033 -9 bb_default_root_login_path 30 - -30 .rodata 128794 128762 -32 which_main 152 117 -35 defpathvar 40 - -40 ------------------------------------------------------------------------------ (add/remove: 1/2 grow/shrink: 0/4 up/down: 35/-148) Total: -113 bytes
-rw-r--r--debianutils/which.c4
-rw-r--r--include/libbb.h5
-rw-r--r--init/init.c6
-rw-r--r--libbb/messages.c2
-rw-r--r--libbb/setup_environment.c2
-rw-r--r--shell/ash.c6
-rw-r--r--shell/msh.c4
7 files changed, 13 insertions, 16 deletions
diff --git a/debianutils/which.c b/debianutils/which.c
index 2c71ed32d..b556a9fd9 100644
--- a/debianutils/which.c
+++ b/debianutils/which.c
@@ -22,9 +22,11 @@ int which_main(int argc, char **argv)
22 bb_show_usage(); 22 bb_show_usage();
23 } 23 }
24 24
25/* We shouldn't do this. Ever. Not our business.
25 if (!getenv("PATH")) { 26 if (!getenv("PATH")) {
26 setenv("PATH", "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin", 1); 27 putenv((char*)bb_PATH_root_path);
27 } 28 }
29*/
28 30
29 while (--argc > 0) { 31 while (--argc > 0) {
30 argv++; 32 argv++;
diff --git a/include/libbb.h b/include/libbb.h
index 4f418e7c1..ce62f4529 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -953,8 +953,9 @@ extern const char bb_dev_null[];
953extern const char bb_busybox_exec_path[]; 953extern const char bb_busybox_exec_path[];
954/* util-linux manpage says /sbin:/bin:/usr/sbin:/usr/bin, 954/* util-linux manpage says /sbin:/bin:/usr/sbin:/usr/bin,
955 * but I want to save a few bytes here */ 955 * but I want to save a few bytes here */
956extern const char bb_default_root_login_path[]; /* "/sbin:/usr/sbin:/bin:/usr/bin" */ 956extern const char bb_PATH_root_path[]; /* "PATH=/sbin:/usr/sbin:/bin:/usr/bin" */
957#define bb_default_login_path (bb_default_root_login_path + sizeof("/sbin:/usr/sbin")) 957#define bb_default_root_path (bb_PATH_root_path + sizeof("PATH"))
958#define bb_default_path (bb_PATH_root_path + sizeof("PATH=/sbin:/usr/sbin"))
958 959
959extern const int const_int_0; 960extern const int const_int_0;
960extern const int const_int_1; 961extern const int const_int_1;
diff --git a/init/init.c b/init/init.c
index cb83b088d..6fcdc03c1 100644
--- a/init/init.c
+++ b/init/init.c
@@ -24,10 +24,6 @@
24#define CONSOLE_NAME_SIZE 32 24#define CONSOLE_NAME_SIZE 32
25#define MAXENV 16 /* Number of env. vars */ 25#define MAXENV 16 /* Number of env. vars */
26 26
27#ifndef _PATH_STDPATH
28#define _PATH_STDPATH "/usr/bin:/bin:/usr/sbin:/sbin"
29#endif
30
31#if ENABLE_FEATURE_INIT_COREDUMPS 27#if ENABLE_FEATURE_INIT_COREDUMPS
32/* 28/*
33 * When a file named CORE_ENABLE_FLAG_FILE exists, setrlimit is called 29 * When a file named CORE_ENABLE_FLAG_FILE exists, setrlimit is called
@@ -112,7 +108,7 @@ enum {
112 108
113static const char * const environment[] = { 109static const char * const environment[] = {
114 "HOME=/", 110 "HOME=/",
115 "PATH=" _PATH_STDPATH, 111 bb_PATH_root_path,
116 "SHELL=/bin/sh", 112 "SHELL=/bin/sh",
117 "USER=root", 113 "USER=root",
118 NULL 114 NULL
diff --git a/libbb/messages.c b/libbb/messages.c
index 27d2cc157..56cccaf2c 100644
--- a/libbb/messages.c
+++ b/libbb/messages.c
@@ -40,7 +40,7 @@ const char bb_busybox_exec_path[] = CONFIG_BUSYBOX_EXEC_PATH;
40const char bb_default_login_shell[] = LIBBB_DEFAULT_LOGIN_SHELL; 40const char bb_default_login_shell[] = LIBBB_DEFAULT_LOGIN_SHELL;
41/* util-linux manpage says /sbin:/bin:/usr/sbin:/usr/bin, 41/* util-linux manpage says /sbin:/bin:/usr/sbin:/usr/bin,
42 * but I want to save a few bytes here. Check libbb.h before changing! */ 42 * but I want to save a few bytes here. Check libbb.h before changing! */
43const char bb_default_root_login_path[] = "/sbin:/usr/sbin:/bin:/usr/bin"; 43const char bb_PATH_root_path[] = "PATH=/sbin:/usr/sbin:/bin:/usr/bin";
44 44
45 45
46const int const_int_0; 46const int const_int_0;
diff --git a/libbb/setup_environment.c b/libbb/setup_environment.c
index a98b9a5bd..a6f44f7f0 100644
--- a/libbb/setup_environment.c
+++ b/libbb/setup_environment.c
@@ -56,7 +56,7 @@ void setup_environment(const char *shell, int loginshell, int changeenv, const s
56 xsetenv("SHELL", shell); 56 xsetenv("SHELL", shell);
57 xsetenv("USER", pw->pw_name); 57 xsetenv("USER", pw->pw_name);
58 xsetenv("LOGNAME", pw->pw_name); 58 xsetenv("LOGNAME", pw->pw_name);
59 xsetenv("PATH", (pw->pw_uid ? bb_default_login_path : bb_default_root_login_path)); 59 xsetenv("PATH", (pw->pw_uid ? bb_default_path : bb_default_root_path));
60 } 60 }
61 else if (changeenv) { 61 else if (changeenv) {
62 /* Set HOME, SHELL, and if not becoming a super-user, 62 /* Set HOME, SHELL, and if not becoming a super-user,
diff --git a/shell/ash.c b/shell/ash.c
index 29d8713b7..ae078e609 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -1581,7 +1581,6 @@ static unsigned long rseed;
1581# define VDYNAMIC 0 1581# define VDYNAMIC 0
1582#endif 1582#endif
1583 1583
1584static const char defpathvar[] = "PATH=/usr/local/bin:/usr/bin:/sbin:/bin";
1585#ifdef IFS_BROKEN 1584#ifdef IFS_BROKEN
1586static const char defifsvar[] = "IFS= \t\n"; 1585static const char defifsvar[] = "IFS= \t\n";
1587#define defifs (defifsvar + 4) 1586#define defifs (defifsvar + 4)
@@ -1674,7 +1673,7 @@ static struct var varinit[] = {
1674 { NULL, VSTRFIXED|VTEXTFIXED|VUNSET, "MAIL\0", changemail }, 1673 { NULL, VSTRFIXED|VTEXTFIXED|VUNSET, "MAIL\0", changemail },
1675 { NULL, VSTRFIXED|VTEXTFIXED|VUNSET, "MAILPATH\0", changemail }, 1674 { NULL, VSTRFIXED|VTEXTFIXED|VUNSET, "MAILPATH\0", changemail },
1676#endif 1675#endif
1677 { NULL, VSTRFIXED|VTEXTFIXED, defpathvar, changepath }, 1676 { NULL, VSTRFIXED|VTEXTFIXED, bb_PATH_root_path, changepath },
1678 { NULL, VSTRFIXED|VTEXTFIXED, "PS1=$ ", NULL }, 1677 { NULL, VSTRFIXED|VTEXTFIXED, "PS1=$ ", NULL },
1679 { NULL, VSTRFIXED|VTEXTFIXED, "PS2=> ", NULL }, 1678 { NULL, VSTRFIXED|VTEXTFIXED, "PS2=> ", NULL },
1680 { NULL, VSTRFIXED|VTEXTFIXED, "PS4=+ ", NULL }, 1679 { NULL, VSTRFIXED|VTEXTFIXED, "PS4=+ ", NULL },
@@ -1710,7 +1709,6 @@ static struct var varinit[] = {
1710#else 1709#else
1711#define vrandom (&vps4)[1] 1710#define vrandom (&vps4)[1]
1712#endif 1711#endif
1713#define defpath (defpathvar + 5)
1714 1712
1715/* 1713/*
1716 * The following macros access the values of the above variables. 1714 * The following macros access the values of the above variables.
@@ -7874,7 +7872,7 @@ parse_command_args(char **argv, const char **path)
7874 do { 7872 do {
7875 switch (c) { 7873 switch (c) {
7876 case 'p': 7874 case 'p':
7877 *path = defpath; 7875 *path = bb_default_path;
7878 break; 7876 break;
7879 default: 7877 default:
7880 /* run 'typecmd' for other options */ 7878 /* run 'typecmd' for other options */
diff --git a/shell/msh.c b/shell/msh.c
index 2ee5256f7..dc2fa9c16 100644
--- a/shell/msh.c
+++ b/shell/msh.c
@@ -5213,9 +5213,9 @@ int msh_main(int argc, char **argv)
5213 if (path->value == null) { 5213 if (path->value == null) {
5214 /* Can be merged with same string elsewhere in bbox */ 5214 /* Can be merged with same string elsewhere in bbox */
5215 if (geteuid() == 0) 5215 if (geteuid() == 0)
5216 setval(path, bb_default_root_login_path); 5216 setval(path, bb_default_root_path);
5217 else 5217 else
5218 setval(path, bb_default_login_path); 5218 setval(path, bb_default_path);
5219 } 5219 }
5220 export(path); 5220 export(path);
5221 5221