diff options
author | Ron Yorston <rmy@pobox.com> | 2022-01-13 08:02:41 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2022-01-13 08:02:41 +0000 |
commit | 4734416a21312488a5099a297907783bee4ccc22 (patch) | |
tree | e42b034f9685a0a07ad080076b757bfba654cf7d /loginutils | |
parent | b8751bbc9ac24e71fbe1e79c69074b4c87a134d8 (diff) | |
parent | b3eec1651fb02d70716caa355f49320719f74c75 (diff) | |
download | busybox-w32-4734416a21312488a5099a297907783bee4ccc22.tar.gz busybox-w32-4734416a21312488a5099a297907783bee4ccc22.tar.bz2 busybox-w32-4734416a21312488a5099a297907783bee4ccc22.zip |
Merge busybox into merge
Fix merge conflicts in coreutils/ls.c and shell/ash.c.
Update config files to turn off SHA1_HWACCEL. It uses non-portable
assembler.
Diffstat (limited to 'loginutils')
-rw-r--r-- | loginutils/login.c | 4 | ||||
-rw-r--r-- | loginutils/sulogin.c | 48 |
2 files changed, 43 insertions, 9 deletions
diff --git a/loginutils/login.c b/loginutils/login.c index 569053c12..cac4349b2 100644 --- a/loginutils/login.c +++ b/loginutils/login.c | |||
@@ -608,7 +608,9 @@ int login_main(int argc UNUSED_PARAM, char **argv) | |||
608 | * But without this, bash 3.0 will not enable ctrl-c either. | 608 | * But without this, bash 3.0 will not enable ctrl-c either. |
609 | * Maybe bash is buggy? | 609 | * Maybe bash is buggy? |
610 | * Need to find out what standards say about /bin/login - | 610 | * Need to find out what standards say about /bin/login - |
611 | * should we leave SIGINT etc enabled or disabled? */ | 611 | * should we leave SIGINT etc enabled or disabled? |
612 | * Also note: sulogin does not do it! Why? | ||
613 | */ | ||
612 | signal(SIGINT, SIG_DFL); | 614 | signal(SIGINT, SIG_DFL); |
613 | 615 | ||
614 | /* Exec login shell with no additional parameters */ | 616 | /* Exec login shell with no additional parameters */ |
diff --git a/loginutils/sulogin.c b/loginutils/sulogin.c index 69d8b5ec7..c9817960c 100644 --- a/loginutils/sulogin.c +++ b/loginutils/sulogin.c | |||
@@ -20,7 +20,8 @@ | |||
20 | //usage: "[-t N] [TTY]" | 20 | //usage: "[-t N] [TTY]" |
21 | //usage:#define sulogin_full_usage "\n\n" | 21 | //usage:#define sulogin_full_usage "\n\n" |
22 | //usage: "Single user login\n" | 22 | //usage: "Single user login\n" |
23 | //usage: "\n -t N Timeout" | 23 | //usage: "\n -p Start a login shell" |
24 | //usage: "\n -t SEC Timeout" | ||
24 | 25 | ||
25 | #include "libbb.h" | 26 | #include "libbb.h" |
26 | #include <syslog.h> | 27 | #include <syslog.h> |
@@ -28,7 +29,9 @@ | |||
28 | int sulogin_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 29 | int sulogin_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
29 | int sulogin_main(int argc UNUSED_PARAM, char **argv) | 30 | int sulogin_main(int argc UNUSED_PARAM, char **argv) |
30 | { | 31 | { |
32 | int tsid; | ||
31 | int timeout = 0; | 33 | int timeout = 0; |
34 | unsigned opts; | ||
32 | struct passwd *pwd; | 35 | struct passwd *pwd; |
33 | const char *shell; | 36 | const char *shell; |
34 | 37 | ||
@@ -43,7 +46,7 @@ int sulogin_main(int argc UNUSED_PARAM, char **argv) | |||
43 | logmode = LOGMODE_BOTH; | 46 | logmode = LOGMODE_BOTH; |
44 | openlog(applet_name, 0, LOG_AUTH); | 47 | openlog(applet_name, 0, LOG_AUTH); |
45 | 48 | ||
46 | getopt32(argv, "t:+", &timeout); | 49 | opts = getopt32(argv, "pt:+", &timeout); |
47 | argv += optind; | 50 | argv += optind; |
48 | 51 | ||
49 | if (argv[0]) { | 52 | if (argv[0]) { |
@@ -63,12 +66,13 @@ int sulogin_main(int argc UNUSED_PARAM, char **argv) | |||
63 | int r; | 66 | int r; |
64 | 67 | ||
65 | r = ask_and_check_password_extended(pwd, timeout, | 68 | r = ask_and_check_password_extended(pwd, timeout, |
66 | "Give root password for system maintenance\n" | 69 | "Give root password for maintenance\n" |
67 | "(or type Control-D for normal startup):" | 70 | "(or type Ctrl-D to continue): " |
68 | ); | 71 | ); |
69 | if (r < 0) { | 72 | if (r < 0) { |
70 | /* ^D, ^C, timeout, or read error */ | 73 | /* ^D, ^C, timeout, or read error */ |
71 | bb_simple_info_msg("normal startup"); | 74 | /* util-linux 2.36.1 compat: no message */ |
75 | /*bb_simple_info_msg("normal startup");*/ | ||
72 | return 0; | 76 | return 0; |
73 | } | 77 | } |
74 | if (r > 0) { | 78 | if (r > 0) { |
@@ -78,7 +82,8 @@ int sulogin_main(int argc UNUSED_PARAM, char **argv) | |||
78 | bb_simple_info_msg("Login incorrect"); | 82 | bb_simple_info_msg("Login incorrect"); |
79 | } | 83 | } |
80 | 84 | ||
81 | bb_simple_info_msg("starting shell for system maintenance"); | 85 | /* util-linux 2.36.1 compat: no message */ |
86 | /*bb_simple_info_msg("starting shell for system maintenance");*/ | ||
82 | 87 | ||
83 | IF_SELINUX(renew_current_security_context()); | 88 | IF_SELINUX(renew_current_security_context()); |
84 | 89 | ||
@@ -88,6 +93,33 @@ int sulogin_main(int argc UNUSED_PARAM, char **argv) | |||
88 | if (!shell) | 93 | if (!shell) |
89 | shell = pwd->pw_shell; | 94 | shell = pwd->pw_shell; |
90 | 95 | ||
91 | /* Exec login shell with no additional parameters. Never returns. */ | 96 | /* util-linux 2.36.1 compat: cd to root's HOME, set a few envvars */ |
92 | exec_login_shell(shell); | 97 | setup_environment(shell, SETUP_ENV_CHANGEENV | SETUP_ENV_CHANGEENV_LOGNAME, pwd); |
98 | // no SETUP_ENV_CLEARENV | ||
99 | // SETUP_ENV_CHANGEENV[+LOGNAME] - set HOME, SHELL, USER,and LOGNAME | ||
100 | // no SETUP_ENV_NO_CHDIR - IOW: cd to $HOME | ||
101 | |||
102 | /* util-linux 2.36.1 compat: steal ctty if we don't have it yet | ||
103 | * (yes, util-linux uses force=1) */ | ||
104 | tsid = tcgetsid(STDIN_FILENO); | ||
105 | if (tsid < 0 || getpid() != tsid) { | ||
106 | if (ioctl(STDIN_FILENO, TIOCSCTTY, /*force:*/ (long)1) != 0) { | ||
107 | // bb_perror_msg("TIOCSCTTY1 tsid:%d", tsid); | ||
108 | if (setsid() > 0) { | ||
109 | // bb_error_msg("done setsid()"); | ||
110 | /* If it still does not work, ignore */ | ||
111 | if (ioctl(STDIN_FILENO, TIOCSCTTY, /*force:*/ (long)1) != 0) { | ||
112 | // bb_perror_msg("TIOCSCTTY2 tsid:%d", tsid); | ||
113 | } | ||
114 | } | ||
115 | } | ||
116 | } | ||
117 | |||
118 | /* | ||
119 | * Note: login does this (should we do it too?): | ||
120 | */ | ||
121 | /*signal(SIGINT, SIG_DFL);*/ | ||
122 | |||
123 | /* Exec shell with no additional parameters. Never returns. */ | ||
124 | exec_shell(shell, /* -p? then shell is login:*/(opts & 1), NULL); | ||
93 | } | 125 | } |