aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2020-12-02 21:51:08 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2020-12-02 21:51:08 +0100
commitf4f6e5144b9af71dc687dc14dba4a6caf8c28361 (patch)
tree6787d6f0d48798df34ef9a829a067e5381a0f718
parent0622416fece00507cf0ac53a2aa17ca3b1e565b2 (diff)
downloadbusybox-w32-f4f6e5144b9af71dc687dc14dba4a6caf8c28361.tar.gz
busybox-w32-f4f6e5144b9af71dc687dc14dba4a6caf8c28361.tar.bz2
busybox-w32-f4f6e5144b9af71dc687dc14dba4a6caf8c28361.zip
libbb: exec_login_shell() - new function
function old new delta exec_login_shell - 12 +12 sulogin_main 247 240 -7 login_main 960 953 -7 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 0/2 up/down: 12/-14) Total: -2 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--include/libbb.h1
-rw-r--r--libbb/run_shell.c9
-rw-r--r--loginutils/login.c2
-rw-r--r--loginutils/sulogin.c2
4 files changed, 10 insertions, 4 deletions
diff --git a/include/libbb.h b/include/libbb.h
index c23018f17..8f1ee7eec 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -1607,6 +1607,7 @@ void msleep(unsigned ms) FAST_FUNC;
1607void sleep1(void) FAST_FUNC; 1607void sleep1(void) FAST_FUNC;
1608void change_identity(const struct passwd *pw) FAST_FUNC; 1608void change_identity(const struct passwd *pw) FAST_FUNC;
1609void exec_shell(const char *shell, int loginshell, const char **args) NORETURN FAST_FUNC; 1609void exec_shell(const char *shell, int loginshell, const char **args) NORETURN FAST_FUNC;
1610void exec_login_shell(const char *shell) NORETURN FAST_FUNC;
1610void exec_prog_or_SHELL(char **argv) NORETURN FAST_FUNC; 1611void exec_prog_or_SHELL(char **argv) NORETURN FAST_FUNC;
1611 1612
1612/* Returns $SHELL, getpwuid(getuid())->pw_shell, or DEFAULT_SHELL. 1613/* Returns $SHELL, getpwuid(getuid())->pw_shell, or DEFAULT_SHELL.
diff --git a/libbb/run_shell.c b/libbb/run_shell.c
index 9bec43b7c..c22bba87b 100644
--- a/libbb/run_shell.c
+++ b/libbb/run_shell.c
@@ -84,14 +84,19 @@ void FAST_FUNC exec_shell(const char *shell, int loginshell, const char **additi
84 bb_perror_msg_and_die("can't execute '%s'", shell); 84 bb_perror_msg_and_die("can't execute '%s'", shell);
85} 85}
86 86
87void FAST_FUNC exec_login_shell(const char *shell)
88{
89 exec_shell(shell, 1, NULL);
90}
91
87/* Typical idiom for applets which exec *optional* PROG [ARGS] */ 92/* Typical idiom for applets which exec *optional* PROG [ARGS] */
88void FAST_FUNC exec_prog_or_SHELL(char **argv) 93void FAST_FUNC exec_prog_or_SHELL(char **argv)
89{ 94{
90 if (argv[0]) { 95 if (argv[0]) {
91 BB_EXECVP_or_die(argv); 96 BB_EXECVP_or_die(argv);
92 } 97 }
93 /* Why login=1? Both users (nsenter and unshare) do indeed exec 98 /* Both users (nsenter and unshare) do indeed exec
94 * a _login_ shell (with dash in argv[0])! 99 * a _login_ shell (with dash in argv[0])!
95 */ 100 */
96 exec_shell(getenv("SHELL"), /*login:*/ 1, NULL); 101 exec_login_shell(getenv("SHELL"));
97} 102}
diff --git a/loginutils/login.c b/loginutils/login.c
index aacd47241..de05631d2 100644
--- a/loginutils/login.c
+++ b/loginutils/login.c
@@ -602,7 +602,7 @@ int login_main(int argc UNUSED_PARAM, char **argv)
602 signal(SIGINT, SIG_DFL); 602 signal(SIGINT, SIG_DFL);
603 603
604 /* Exec login shell with no additional parameters */ 604 /* Exec login shell with no additional parameters */
605 exec_shell(pw->pw_shell, 1, NULL); 605 exec_login_shell(pw->pw_shell);
606 606
607 /* return EXIT_FAILURE; - not reached */ 607 /* return EXIT_FAILURE; - not reached */
608} 608}
diff --git a/loginutils/sulogin.c b/loginutils/sulogin.c
index 127aa1de9..69d8b5ec7 100644
--- a/loginutils/sulogin.c
+++ b/loginutils/sulogin.c
@@ -89,5 +89,5 @@ int sulogin_main(int argc UNUSED_PARAM, char **argv)
89 shell = pwd->pw_shell; 89 shell = pwd->pw_shell;
90 90
91 /* Exec login shell with no additional parameters. Never returns. */ 91 /* Exec login shell with no additional parameters. Never returns. */
92 exec_shell(shell, 1, NULL); 92 exec_login_shell(shell);
93} 93}