aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbug1 <bug1@69ca8d6d-28ef-0310-b511-8ec308f3f277>2003-09-02 02:36:18 +0000
committerbug1 <bug1@69ca8d6d-28ef-0310-b511-8ec308f3f277>2003-09-02 02:36:18 +0000
commitd7cb97b8bf8945b6f04bcccbb9be72d638158321 (patch)
treed2ff4fef7b9192de63761935103699569ecbb2ee
parent253ff43f62644ee79597eed14b49dcf291f198a1 (diff)
downloadbusybox-w32-d7cb97b8bf8945b6f04bcccbb9be72d638158321.tar.gz
busybox-w32-d7cb97b8bf8945b6f04bcccbb9be72d638158321.tar.bz2
busybox-w32-d7cb97b8bf8945b6f04bcccbb9be72d638158321.zip
move all "-/bin/sh" "/bin/sh" and "sh" to libbb/messages.c file as one
constant. Vodz last_patch_107 git-svn-id: svn://busybox.net/trunk/busybox@7365 69ca8d6d-28ef-0310-b511-8ec308f3f277
-rw-r--r--coreutils/chroot.c2
-rw-r--r--include/libbb.h15
-rw-r--r--init/init.c18
-rw-r--r--libbb/Makefile.in2
-rw-r--r--libbb/messages.c4
-rw-r--r--loginutils/adduser.c3
-rw-r--r--loginutils/login.c10
-rw-r--r--loginutils/su.c1
-rw-r--r--miscutils/crond.c13
-rw-r--r--miscutils/crontab.c4
-rw-r--r--networking/ifupdown.c2
-rw-r--r--networking/telnetd.c4
-rw-r--r--shell/ash.c2
-rw-r--r--shell/msh.c7
14 files changed, 50 insertions, 37 deletions
diff --git a/coreutils/chroot.c b/coreutils/chroot.c
index 5562e58c8..eeed01302 100644
--- a/coreutils/chroot.c
+++ b/coreutils/chroot.c
@@ -43,7 +43,7 @@ int chroot_main(int argc, char **argv)
43 if (argc == 2) { 43 if (argc == 2) {
44 argv -= 2; 44 argv -= 2;
45 if (!(*argv = getenv("SHELL"))) { 45 if (!(*argv = getenv("SHELL"))) {
46 *argv = (char *) "/bin/sh"; 46 *argv = (char *) DEFAULT_SHELL;
47 } 47 }
48 argv[1] = (char *) "-i"; 48 argv[1] = (char *) "-i";
49 } 49 }
diff --git a/include/libbb.h b/include/libbb.h
index a6d9a510b..64903732d 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -332,6 +332,21 @@ extern const char * const bb_path_group_file;
332extern const char * const bb_path_securetty_file; 332extern const char * const bb_path_securetty_file;
333extern const char * const bb_path_motd_file; 333extern const char * const bb_path_motd_file;
334 334
335/*
336 * You can change LIBBB_DEFAULT_LOGIN_SHELL, but don`t use,
337 * use bb_default_login_shell and next defines,
338 * if you LIBBB_DEFAULT_LOGIN_SHELL change,
339 * don`t lose change increment constant!
340 */
341#define LIBBB_DEFAULT_LOGIN_SHELL "-/bin/sh"
342
343extern const char * const bb_default_login_shell;
344/* "/bin/sh" */
345#define DEFAULT_SHELL (bb_default_login_shell+1)
346/* "sh" */
347#define DEFAULT_SHELL_SHORT_NAME (bb_default_login_shell+6)
348
349
335extern const char bb_path_mtab_file[]; 350extern const char bb_path_mtab_file[];
336 351
337extern int bb_default_error_retval; 352extern int bb_default_error_retval;
diff --git a/init/init.c b/init/init.c
index e52517e91..2f44e13bf 100644
--- a/init/init.c
+++ b/init/init.c
@@ -104,8 +104,6 @@ struct serial_struct {
104 104
105#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) 105#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
106 106
107#define SHELL "/bin/sh" /* Default shell */
108#define LOGIN_SHELL "-" SHELL /* Default login shell */
109#define INITTAB "/etc/inittab" /* inittab file location */ 107#define INITTAB "/etc/inittab" /* inittab file location */
110#ifndef INIT_SCRIPT 108#ifndef INIT_SCRIPT
111#define INIT_SCRIPT "/etc/init.d/rcS" /* Default sysinit script. */ 109#define INIT_SCRIPT "/etc/init.d/rcS" /* Default sysinit script. */
@@ -180,7 +178,7 @@ static const int RB_AUTOBOOT = 0x01234567;
180static const char * const environment[] = { 178static const char * const environment[] = {
181 "HOME=/", 179 "HOME=/",
182 "PATH=" _PATH_STDPATH, 180 "PATH=" _PATH_STDPATH,
183 "SHELL=" SHELL, 181 "SHELL=/bin/sh",
184 "USER=root", 182 "USER=root",
185 NULL 183 NULL
186}; 184};
@@ -526,7 +524,7 @@ static pid_t run(const struct init_action *a)
526 524
527 /* See if any special /bin/sh requiring characters are present */ 525 /* See if any special /bin/sh requiring characters are present */
528 if (strpbrk(a->command, "~`!$^&*()=|\\{}[];\"'<>?") != NULL) { 526 if (strpbrk(a->command, "~`!$^&*()=|\\{}[];\"'<>?") != NULL) {
529 cmd[0] = SHELL; 527 cmd[0] = (char *)DEFAULT_SHELL;
530 cmd[1] = "-c"; 528 cmd[1] = "-c";
531 cmd[2] = strcat(strcpy(buf, "exec "), a->command); 529 cmd[2] = strcat(strcpy(buf, "exec "), a->command);
532 cmd[3] = NULL; 530 cmd[3] = NULL;
@@ -840,7 +838,7 @@ static void child_handler(int sig)
840 838
841#endif /* ! DEBUG_INIT */ 839#endif /* ! DEBUG_INIT */
842 840
843static void new_init_action(int action, char *command, const char *cons) 841static void new_init_action(int action, const char *command, const char *cons)
844{ 842{
845 struct init_action *new_action, *a; 843 struct init_action *new_action, *a;
846 844
@@ -960,10 +958,10 @@ static void parse_inittab(void)
960 /* Prepare to restart init when a HUP is received */ 958 /* Prepare to restart init when a HUP is received */
961 new_init_action(RESTART, "/sbin/init", ""); 959 new_init_action(RESTART, "/sbin/init", "");
962 /* Askfirst shell on tty1-4 */ 960 /* Askfirst shell on tty1-4 */
963 new_init_action(ASKFIRST, LOGIN_SHELL, ""); 961 new_init_action(ASKFIRST, bb_default_login_shell, "");
964 new_init_action(ASKFIRST, LOGIN_SHELL, VC_2); 962 new_init_action(ASKFIRST, bb_default_login_shell, VC_2);
965 new_init_action(ASKFIRST, LOGIN_SHELL, VC_3); 963 new_init_action(ASKFIRST, bb_default_login_shell, VC_3);
966 new_init_action(ASKFIRST, LOGIN_SHELL, VC_4); 964 new_init_action(ASKFIRST, bb_default_login_shell, VC_4);
967 /* sysinit */ 965 /* sysinit */
968 new_init_action(SYSINIT, INIT_SCRIPT, ""); 966 new_init_action(SYSINIT, INIT_SCRIPT, "");
969 967
@@ -1116,7 +1114,7 @@ extern int init_main(int argc, char **argv)
1116 if (argc > 1 && (!strcmp(argv[1], "single") || 1114 if (argc > 1 && (!strcmp(argv[1], "single") ||
1117 !strcmp(argv[1], "-s") || !strcmp(argv[1], "1"))) { 1115 !strcmp(argv[1], "-s") || !strcmp(argv[1], "1"))) {
1118 /* Start a shell on console */ 1116 /* Start a shell on console */
1119 new_init_action(RESPAWN, LOGIN_SHELL, ""); 1117 new_init_action(RESPAWN, bb_default_login_shell, "");
1120 } else { 1118 } else {
1121 /* Not in single user mode -- see what inittab says */ 1119 /* Not in single user mode -- see what inittab says */
1122 1120
diff --git a/libbb/Makefile.in b/libbb/Makefile.in
index 0d7103ef0..0ccd85dbe 100644
--- a/libbb/Makefile.in
+++ b/libbb/Makefile.in
@@ -59,7 +59,7 @@ LIBBB_MOBJ0:=full_version.o \
59 can_not_create_raw_socket.o perm_denied_are_you_root.o \ 59 can_not_create_raw_socket.o perm_denied_are_you_root.o \
60 shadow_file.o passwd_file.o group_file.o gshadow_file.o nologin_file.o \ 60 shadow_file.o passwd_file.o group_file.o gshadow_file.o nologin_file.o \
61 securetty_file.o motd_file.o \ 61 securetty_file.o motd_file.o \
62 msg_standard_input.o msg_standard_output.o 62 msg_standard_input.o msg_standard_output.o shell_file.o
63 63
64LIBBB_MSRC1:=$(LIBBB_DIR)xfuncs.c 64LIBBB_MSRC1:=$(LIBBB_DIR)xfuncs.c
65LIBBB_MOBJ1:=xmalloc.o xrealloc.o xcalloc.o xstrdup.o xstrndup.o \ 65LIBBB_MOBJ1:=xmalloc.o xrealloc.o xcalloc.o xstrdup.o xstrndup.o \
diff --git a/libbb/messages.c b/libbb/messages.c
index 11493db12..adfd1ffcc 100644
--- a/libbb/messages.c
+++ b/libbb/messages.c
@@ -90,3 +90,7 @@ const char * const bb_path_securetty_file = SECURETTY_FILE;
90const char * const bb_path_motd_file = MOTD_FILE; 90const char * const bb_path_motd_file = MOTD_FILE;
91#endif 91#endif
92 92
93#ifdef L_shell_file
94const char * const bb_default_login_shell = LIBBB_DEFAULT_LOGIN_SHELL;
95#endif
96
diff --git a/loginutils/adduser.c b/loginutils/adduser.c
index 41dc9f019..c4ab557d0 100644
--- a/loginutils/adduser.c
+++ b/loginutils/adduser.c
@@ -53,7 +53,6 @@ typedef struct {
53static const char default_passwd[] = "x"; 53static const char default_passwd[] = "x";
54static const char default_gecos[] = "Linux User,,,"; 54static const char default_gecos[] = "Linux User,,,";
55static const char default_home_prefix[] = "/home"; 55static const char default_home_prefix[] = "/home";
56static const char default_shell[] = "/bin/sh";
57 56
58#ifdef CONFIG_FEATURE_SHADOWPASSWDS 57#ifdef CONFIG_FEATURE_SHADOWPASSWDS
59/* shadow in use? */ 58/* shadow in use? */
@@ -257,7 +256,7 @@ int adduser_main(int argc, char **argv)
257 const char *login; 256 const char *login;
258 const char *gecos = default_gecos; 257 const char *gecos = default_gecos;
259 const char *home = NULL; 258 const char *home = NULL;
260 const char *shell = default_shell; 259 const char *shell = DEFAULT_SHELL;
261 const char *usegroup = NULL; 260 const char *usegroup = NULL;
262 int flags; 261 int flags;
263 int setpass = 1; 262 int setpass = 1;
diff --git a/loginutils/login.c b/loginutils/login.c
index c2bada258..3fca899c0 100644
--- a/loginutils/login.c
+++ b/loginutils/login.c
@@ -65,7 +65,7 @@ extern int login_main(int argc, char **argv)
65 char full_tty[200]; 65 char full_tty[200];
66 char fromhost[512]; 66 char fromhost[512];
67 char username[USERNAME_SIZE]; 67 char username[USERNAME_SIZE];
68 char *tmp; 68 const char *tmp;
69 int amroot; 69 int amroot;
70 int flag; 70 int flag;
71 int failed; 71 int failed;
@@ -267,15 +267,17 @@ auth_ok:
267 chmod ( full_tty, 0600 ); 267 chmod ( full_tty, 0600 );
268 268
269 change_identity ( pw ); 269 change_identity ( pw );
270 setup_environment ( pw-> pw_shell, 1, !opt_preserve, pw ); 270 tmp = pw-> pw_shell;
271 if(!tmp || !*tmp)
272 tmp = DEFAULT_SHELL;
273 setup_environment ( tmp, 1, !opt_preserve, pw );
271 274
272 motd ( ); 275 motd ( );
273 signal ( SIGALRM, SIG_DFL ); /* default alarm signal */ 276 signal ( SIGALRM, SIG_DFL ); /* default alarm signal */
274 277
275 if ( pw-> pw_uid == 0 ) 278 if ( pw-> pw_uid == 0 )
276 syslog ( LOG_INFO, "root login %s\n", fromhost ); 279 syslog ( LOG_INFO, "root login %s\n", fromhost );
277 280 run_shell ( tmp, 1, 0, 0
278 run_shell ( pw-> pw_shell, 1, 0, 0
279#ifdef CONFIG_SELINUX 281#ifdef CONFIG_SELINUX
280 , sid 282 , sid
281#endif 283#endif
diff --git a/loginutils/su.c b/loginutils/su.c
index 04c213e4e..2d7a7ac05 100644
--- a/loginutils/su.c
+++ b/loginutils/su.c
@@ -21,7 +21,6 @@
21 21
22 22
23/* The shell to run if none is given in the user's passwd entry. */ 23/* The shell to run if none is given in the user's passwd entry. */
24#define DEFAULT_SHELL "/bin/sh"
25#define DEFAULT_USER "root" 24#define DEFAULT_USER "root"
26 25
27//#define SYSLOG_SUCCESS 26//#define SYSLOG_SUCCESS
diff --git a/miscutils/crond.c b/miscutils/crond.c
index f0920136f..637e09dd8 100644
--- a/miscutils/crond.c
+++ b/miscutils/crond.c
@@ -54,9 +54,6 @@
54#define MAXLINES 256 /* max lines in non-root crontabs */ 54#define MAXLINES 256 /* max lines in non-root crontabs */
55#endif 55#endif
56 56
57static const char def_sh[] = "/bin/sh";
58
59
60typedef struct CronFile { 57typedef struct CronFile {
61 struct CronFile *cf_Next; 58 struct CronFile *cf_Next;
62 struct CronLine *cf_LineBase; 59 struct CronLine *cf_LineBase;
@@ -313,7 +310,7 @@ ChangeUser(const char *user)
313 } 310 }
314 setenv("USER", pas->pw_name, 1); 311 setenv("USER", pas->pw_name, 1);
315 setenv("HOME", pas->pw_dir, 1); 312 setenv("HOME", pas->pw_dir, 1);
316 setenv("SHELL", def_sh, 1); 313 setenv("SHELL", DEFAULT_SHELL, 1);
317 314
318 /* 315 /*
319 * Change running state to the user in question 316 * Change running state to the user in question
@@ -997,7 +994,7 @@ RunJob(const char *user, CronLine *line)
997 user, mailFile); 994 user, mailFile);
998 } 995 }
999 996
1000 ForkJob(user, line, mailFd, def_sh, "-c", line->cl_Shell, mailFile); 997 ForkJob(user, line, mailFd, DEFAULT_SHELL, "-c", line->cl_Shell, mailFile);
1001} 998}
1002 999
1003/* 1000/*
@@ -1081,12 +1078,12 @@ RunJob(const char *user, CronLine *line)
1081 1078
1082#ifdef FEATURE_DEBUG_OPT 1079#ifdef FEATURE_DEBUG_OPT
1083 if (DebugOpt) 1080 if (DebugOpt)
1084 crondlog("\005Child Running %s\n", def_sh); 1081 crondlog("\005Child Running %s\n", DEFAULT_SHELL);
1085#endif 1082#endif
1086 1083
1087 execl(def_sh, def_sh, "-c", line->cl_Shell, NULL); 1084 execl(DEFAULT_SHELL, DEFAULT_SHELL, "-c", line->cl_Shell, NULL);
1088 crondlog("\024unable to exec, user %s cmd %s -c %s\n", user, 1085 crondlog("\024unable to exec, user %s cmd %s -c %s\n", user,
1089 def_sh, line->cl_Shell); 1086 DEFAULT_SHELL, line->cl_Shell);
1090 exit(0); 1087 exit(0);
1091 } else if (pid < 0) { 1088 } else if (pid < 0) {
1092 /* 1089 /*
diff --git a/miscutils/crontab.c b/miscutils/crontab.c
index 6b9446464..6c4da95fe 100644
--- a/miscutils/crontab.c
+++ b/miscutils/crontab.c
@@ -320,7 +320,7 @@ EditFile(const char *user, const char *file)
320 ptr = PATH_VI; 320 ptr = PATH_VI;
321 321
322 snprintf(visual, sizeof(visual), "%s %s", ptr, file); 322 snprintf(visual, sizeof(visual), "%s %s", ptr, file);
323 execl("/bin/sh", "/bin/sh", "-c", visual, NULL); 323 execl(DEFAULT_SHELL, DEFAULT_SHELL, "-c", visual, NULL);
324 perror("exec"); 324 perror("exec");
325 exit(0); 325 exit(0);
326 } 326 }
@@ -360,7 +360,7 @@ ChangeUser(const char *user, short dochdir)
360 } 360 }
361 setenv("USER", pas->pw_name, 1); 361 setenv("USER", pas->pw_name, 1);
362 setenv("HOME", pas->pw_dir, 1); 362 setenv("HOME", pas->pw_dir, 1);
363 setenv("SHELL", "/bin/sh", 1); 363 setenv("SHELL", DEFAULT_SHELL, 1);
364 364
365 /* 365 /*
366 * Change running state to the user in question 366 * Change running state to the user in question
diff --git a/networking/ifupdown.c b/networking/ifupdown.c
index 78f2bb0f1..1a23bac37 100644
--- a/networking/ifupdown.c
+++ b/networking/ifupdown.c
@@ -1009,7 +1009,7 @@ static int doit(char *str)
1009 case -1: /* failure */ 1009 case -1: /* failure */
1010 return 0; 1010 return 0;
1011 case 0: /* child */ 1011 case 0: /* child */
1012 execle("/bin/sh", "/bin/sh", "-c", str, NULL, environ); 1012 execle(DEFAULT_SHELL, DEFAULT_SHELL, "-c", str, NULL, environ);
1013 exit(127); 1013 exit(127);
1014 } 1014 }
1015 waitpid(child, &status, 0); 1015 waitpid(child, &status, 0);
diff --git a/networking/telnetd.c b/networking/telnetd.c
index 27b08aced..205661ba2 100644
--- a/networking/telnetd.c
+++ b/networking/telnetd.c
@@ -1,4 +1,4 @@
1/* $Id: telnetd.c,v 1.6 2003/04/25 12:32:37 andersen Exp $ 1/* $Id: telnetd.c,v 1.7 2003/09/02 02:36:16 bug1 Exp $
2 * 2 *
3 * Simple telnet server 3 * Simple telnet server
4 * Bjorn Wesen, Axis Communications AB (bjornw@axis.com) 4 * Bjorn Wesen, Axis Communications AB (bjornw@axis.com)
@@ -52,7 +52,7 @@ static const char *loginpath =
52#ifdef CONFIG_LOGIN 52#ifdef CONFIG_LOGIN
53"/bin/login"; 53"/bin/login";
54#else 54#else
55"/bin/sh"; 55DEFAULT_SHELL;
56#endif 56#endif
57static const char *issuefile = "/etc/issue.net"; 57static const char *issuefile = "/etc/issue.net";
58 58
diff --git a/shell/ash.c b/shell/ash.c
index 521d65ab6..59aa336cd 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -3729,7 +3729,7 @@ repeat:
3729 for (ap = argv; *ap; ap++) 3729 for (ap = argv; *ap; ap++)
3730 ; 3730 ;
3731 ap = new = ckmalloc((ap - argv + 2) * sizeof(char *)); 3731 ap = new = ckmalloc((ap - argv + 2) * sizeof(char *));
3732 *ap++ = cmd = "/bin/sh"; 3732 *ap++ = cmd = (char *)DEFAULT_SHELL;
3733 while ((*ap++ = *argv++)) 3733 while ((*ap++ = *argv++))
3734 ; 3734 ;
3735 argv = new; 3735 argv = new;
diff --git a/shell/msh.c b/shell/msh.c
index a142c451a..31dd04f3e 100644
--- a/shell/msh.c
+++ b/shell/msh.c
@@ -668,7 +668,6 @@ static char *null = "";
668static int heedint =1; 668static int heedint =1;
669static struct env e ={line, iostack, iostack-1, (xint *)NULL, FDBASE, (struct env *)NULL}; 669static struct env e ={line, iostack, iostack-1, (xint *)NULL, FDBASE, (struct env *)NULL};
670static void (*qflag)(int) = SIG_IGN; 670static void (*qflag)(int) = SIG_IGN;
671static char shellname[] = "/bin/sh";
672static int startl; 671static int startl;
673static int peeksym; 672static int peeksym;
674static int nlseen; 673static int nlseen;
@@ -717,7 +716,7 @@ extern int msh_main(int argc, char **argv)
717 716
718 shell = lookup("SHELL"); 717 shell = lookup("SHELL");
719 if (shell->value == null) 718 if (shell->value == null)
720 setval(shell, shellname); 719 setval(shell, DEFAULT_SHELL);
721 export(shell); 720 export(shell);
722 721
723 homedir = lookup("HOME"); 722 homedir = lookup("HOME");
@@ -2871,7 +2870,7 @@ char *c, **v, **envp;
2871 *v = e.linep; 2870 *v = e.linep;
2872 tp = *--v; 2871 tp = *--v;
2873 *v = e.linep; 2872 *v = e.linep;
2874 execve(shellname, v, envp); 2873 execve(DEFAULT_SHELL, v, envp);
2875 *v = tp; 2874 *v = tp;
2876 return("no Shell"); 2875 return("no Shell");
2877 2876
@@ -3902,7 +3901,7 @@ int quoted;
3902 dup2(pf[1], 1); 3901 dup2(pf[1], 1);
3903 closepipe(pf); 3902 closepipe(pf);
3904 3903
3905 argument_list[0] = shellname; 3904 argument_list[0] = (char *)DEFAULT_SHELL;
3906 argument_list[1] = "-c"; 3905 argument_list[1] = "-c";
3907 argument_list[2] = child_cmd; 3906 argument_list[2] = child_cmd;
3908 argument_list[3] = 0; 3907 argument_list[3] = 0;