[821] | 1 | /* vi: set sw=4 ts=4: */
|
---|
[1765] | 2 | /*
|
---|
[2725] | 3 | * Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
---|
[1765] | 4 | */
|
---|
| 5 | #include "libbb.h"
|
---|
[2725] | 6 | #include <syslog.h>
|
---|
| 7 | #if ENABLE_FEATURE_UTMP
|
---|
| 8 | # include <utmp.h> /* USER_PROCESS */
|
---|
| 9 | #endif
|
---|
[821] | 10 | #include <sys/resource.h>
|
---|
| 11 |
|
---|
[1765] | 12 | #if ENABLE_SELINUX
|
---|
[2725] | 13 | # include <selinux/selinux.h> /* for is_selinux_enabled() */
|
---|
| 14 | # include <selinux/get_context_list.h> /* for get_default_context() */
|
---|
| 15 | # include <selinux/flask.h> /* for security class definitions */
|
---|
[821] | 16 | #endif
|
---|
| 17 |
|
---|
[1765] | 18 | #if ENABLE_PAM
|
---|
| 19 | /* PAM may include <locale.h>. We may need to undefine bbox's stub define: */
|
---|
[2725] | 20 | # undef setlocale
|
---|
[1765] | 21 | /* For some obscure reason, PAM is not in pam/xxx, but in security/xxx.
|
---|
| 22 | * Apparently they like to confuse people. */
|
---|
[2725] | 23 | # include <security/pam_appl.h>
|
---|
| 24 | # include <security/pam_misc.h>
|
---|
[1765] | 25 | static const struct pam_conv conv = {
|
---|
| 26 | misc_conv,
|
---|
| 27 | NULL
|
---|
| 28 | };
|
---|
[821] | 29 | #endif
|
---|
| 30 |
|
---|
[1765] | 31 | enum {
|
---|
| 32 | TIMEOUT = 60,
|
---|
| 33 | EMPTY_USERNAME_COUNT = 10,
|
---|
| 34 | USERNAME_SIZE = 32,
|
---|
| 35 | TTYNAME_SIZE = 32,
|
---|
| 36 | };
|
---|
[821] | 37 |
|
---|
[1765] | 38 | static char* short_tty;
|
---|
[821] | 39 |
|
---|
[2725] | 40 | #if ENABLE_FEATURE_NOLOGIN
|
---|
| 41 | static void die_if_nologin(void)
|
---|
[1765] | 42 | {
|
---|
[2725] | 43 | FILE *fp;
|
---|
| 44 | int c;
|
---|
| 45 | int empty = 1;
|
---|
[821] | 46 |
|
---|
[2725] | 47 | fp = fopen_for_read("/etc/nologin");
|
---|
| 48 | if (!fp) /* assuming it does not exist */
|
---|
| 49 | return;
|
---|
[821] | 50 |
|
---|
[2725] | 51 | while ((c = getc(fp)) != EOF) {
|
---|
| 52 | if (c == '\n')
|
---|
| 53 | bb_putchar('\r');
|
---|
| 54 | bb_putchar(c);
|
---|
| 55 | empty = 0;
|
---|
| 56 | }
|
---|
| 57 | if (empty)
|
---|
| 58 | puts("\r\nSystem closed for routine maintenance\r");
|
---|
[821] | 59 |
|
---|
[2725] | 60 | fclose(fp);
|
---|
| 61 | fflush_all();
|
---|
| 62 | /* Users say that they do need this prior to exit: */
|
---|
| 63 | tcdrain(STDOUT_FILENO);
|
---|
| 64 | exit(EXIT_FAILURE);
|
---|
[1765] | 65 | }
|
---|
[2725] | 66 | #else
|
---|
| 67 | # define die_if_nologin() ((void)0)
|
---|
| 68 | #endif
|
---|
[821] | 69 |
|
---|
[2725] | 70 | #if ENABLE_FEATURE_SECURETTY && !ENABLE_PAM
|
---|
| 71 | static int check_securetty(void)
|
---|
[821] | 72 | {
|
---|
[2725] | 73 | char *buf = (char*)"/etc/securetty"; /* any non-NULL is ok */
|
---|
| 74 | parser_t *parser = config_open2("/etc/securetty", fopen_for_read);
|
---|
| 75 | while (config_read(parser, &buf, 1, 1, "# \t", PARSE_NORMAL)) {
|
---|
| 76 | if (strcmp(buf, short_tty) == 0)
|
---|
| 77 | break;
|
---|
| 78 | buf = NULL;
|
---|
[1765] | 79 | }
|
---|
[2725] | 80 | config_close(parser);
|
---|
| 81 | /* buf != NULL here if config file was not found, empty
|
---|
| 82 | * or line was found which equals short_tty */
|
---|
| 83 | return buf != NULL;
|
---|
| 84 | }
|
---|
| 85 | #else
|
---|
| 86 | static ALWAYS_INLINE int check_securetty(void) { return 1; }
|
---|
[1765] | 87 | #endif
|
---|
[821] | 88 |
|
---|
[2725] | 89 | #if ENABLE_SELINUX
|
---|
| 90 | static void initselinux(char *username, char *full_tty,
|
---|
| 91 | security_context_t *user_sid)
|
---|
[821] | 92 | {
|
---|
[2725] | 93 | security_context_t old_tty_sid, new_tty_sid;
|
---|
[821] | 94 |
|
---|
[2725] | 95 | if (!is_selinux_enabled())
|
---|
[1765] | 96 | return;
|
---|
[821] | 97 |
|
---|
[2725] | 98 | if (get_default_context(username, NULL, user_sid)) {
|
---|
| 99 | bb_error_msg_and_die("can't get SID for %s", username);
|
---|
| 100 | }
|
---|
| 101 | if (getfilecon(full_tty, &old_tty_sid) < 0) {
|
---|
| 102 | bb_perror_msg_and_die("getfilecon(%s) failed", full_tty);
|
---|
| 103 | }
|
---|
| 104 | if (security_compute_relabel(*user_sid, old_tty_sid,
|
---|
| 105 | SECCLASS_CHR_FILE, &new_tty_sid) != 0) {
|
---|
| 106 | bb_perror_msg_and_die("security_change_sid(%s) failed", full_tty);
|
---|
| 107 | }
|
---|
| 108 | if (setfilecon(full_tty, new_tty_sid) != 0) {
|
---|
| 109 | bb_perror_msg_and_die("chsid(%s, %s) failed", full_tty, new_tty_sid);
|
---|
| 110 | }
|
---|
[1765] | 111 | }
|
---|
| 112 | #endif
|
---|
[821] | 113 |
|
---|
[2725] | 114 | #if ENABLE_LOGIN_SCRIPTS
|
---|
| 115 | static void run_login_script(struct passwd *pw, char *full_tty)
|
---|
[1765] | 116 | {
|
---|
[2725] | 117 | char *t_argv[2];
|
---|
[821] | 118 |
|
---|
[2725] | 119 | t_argv[0] = getenv("LOGIN_PRE_SUID_SCRIPT");
|
---|
| 120 | if (t_argv[0]) {
|
---|
| 121 | t_argv[1] = NULL;
|
---|
| 122 | xsetenv("LOGIN_TTY", full_tty);
|
---|
| 123 | xsetenv("LOGIN_USER", pw->pw_name);
|
---|
| 124 | xsetenv("LOGIN_UID", utoa(pw->pw_uid));
|
---|
| 125 | xsetenv("LOGIN_GID", utoa(pw->pw_gid));
|
---|
| 126 | xsetenv("LOGIN_SHELL", pw->pw_shell);
|
---|
| 127 | spawn_and_wait(t_argv); /* NOMMU-friendly */
|
---|
| 128 | unsetenv("LOGIN_TTY");
|
---|
| 129 | unsetenv("LOGIN_USER");
|
---|
| 130 | unsetenv("LOGIN_UID");
|
---|
| 131 | unsetenv("LOGIN_GID");
|
---|
| 132 | unsetenv("LOGIN_SHELL");
|
---|
[1765] | 133 | }
|
---|
| 134 | }
|
---|
| 135 | #else
|
---|
[2725] | 136 | void run_login_script(struct passwd *pw, char *full_tty);
|
---|
[1765] | 137 | #endif
|
---|
[821] | 138 |
|
---|
[1765] | 139 | static void get_username_or_die(char *buf, int size_buf)
|
---|
| 140 | {
|
---|
| 141 | int c, cntdown;
|
---|
[821] | 142 |
|
---|
[1765] | 143 | cntdown = EMPTY_USERNAME_COUNT;
|
---|
| 144 | prompt:
|
---|
| 145 | print_login_prompt();
|
---|
| 146 | /* skip whitespace */
|
---|
| 147 | do {
|
---|
| 148 | c = getchar();
|
---|
[2725] | 149 | if (c == EOF)
|
---|
| 150 | exit(EXIT_FAILURE);
|
---|
[1765] | 151 | if (c == '\n') {
|
---|
[2725] | 152 | if (!--cntdown)
|
---|
| 153 | exit(EXIT_FAILURE);
|
---|
[1765] | 154 | goto prompt;
|
---|
| 155 | }
|
---|
[2725] | 156 | } while (isspace(c)); /* maybe isblank? */
|
---|
[821] | 157 |
|
---|
[1765] | 158 | *buf++ = c;
|
---|
| 159 | if (!fgets(buf, size_buf-2, stdin))
|
---|
[2725] | 160 | exit(EXIT_FAILURE);
|
---|
[1765] | 161 | if (!strchr(buf, '\n'))
|
---|
[2725] | 162 | exit(EXIT_FAILURE);
|
---|
| 163 | while ((unsigned char)*buf > ' ')
|
---|
| 164 | buf++;
|
---|
[1765] | 165 | *buf = '\0';
|
---|
| 166 | }
|
---|
[821] | 167 |
|
---|
[1765] | 168 | static void motd(void)
|
---|
| 169 | {
|
---|
| 170 | int fd;
|
---|
[821] | 171 |
|
---|
[1765] | 172 | fd = open(bb_path_motd_file, O_RDONLY);
|
---|
[2725] | 173 | if (fd >= 0) {
|
---|
| 174 | fflush_all();
|
---|
[1765] | 175 | bb_copyfd_eof(fd, STDOUT_FILENO);
|
---|
| 176 | close(fd);
|
---|
[821] | 177 | }
|
---|
[1765] | 178 | }
|
---|
[821] | 179 |
|
---|
[2725] | 180 | static void alarm_handler(int sig UNUSED_PARAM)
|
---|
[1765] | 181 | {
|
---|
| 182 | /* This is the escape hatch! Poor serial line users and the like
|
---|
| 183 | * arrive here when their connection is broken.
|
---|
| 184 | * We don't want to block here */
|
---|
| 185 | ndelay_on(1);
|
---|
| 186 | printf("\r\nLogin timed out after %d seconds\r\n", TIMEOUT);
|
---|
[2725] | 187 | fflush_all();
|
---|
| 188 | /* unix API is brain damaged regarding O_NONBLOCK,
|
---|
| 189 | * we should undo it, or else we can affect other processes */
|
---|
| 190 | ndelay_off(1);
|
---|
| 191 | _exit(EXIT_SUCCESS);
|
---|
[1765] | 192 | }
|
---|
[821] | 193 |
|
---|
[2725] | 194 | int login_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
---|
| 195 | int login_main(int argc UNUSED_PARAM, char **argv)
|
---|
[1765] | 196 | {
|
---|
| 197 | enum {
|
---|
| 198 | LOGIN_OPT_f = (1<<0),
|
---|
| 199 | LOGIN_OPT_h = (1<<1),
|
---|
| 200 | LOGIN_OPT_p = (1<<2),
|
---|
| 201 | };
|
---|
| 202 | char *fromhost;
|
---|
| 203 | char username[USERNAME_SIZE];
|
---|
[2725] | 204 | const char *shell;
|
---|
| 205 | int run_by_root;
|
---|
[1765] | 206 | unsigned opt;
|
---|
| 207 | int count = 0;
|
---|
| 208 | struct passwd *pw;
|
---|
| 209 | char *opt_host = NULL;
|
---|
[2725] | 210 | char *opt_user = opt_user; /* for compiler */
|
---|
| 211 | char *full_tty;
|
---|
| 212 | IF_SELINUX(security_context_t user_sid = NULL;)
|
---|
| 213 | #if ENABLE_PAM
|
---|
| 214 | int pamret;
|
---|
| 215 | pam_handle_t *pamh;
|
---|
| 216 | const char *pamuser;
|
---|
| 217 | const char *failed_msg;
|
---|
| 218 | struct passwd pwdstruct;
|
---|
| 219 | char pwdbuf[256];
|
---|
| 220 | #endif
|
---|
[821] | 221 |
|
---|
[1765] | 222 | username[0] = '\0';
|
---|
| 223 | signal(SIGALRM, alarm_handler);
|
---|
| 224 | alarm(TIMEOUT);
|
---|
[821] | 225 |
|
---|
[2725] | 226 | /* More of suid paranoia if called by non-root: */
|
---|
| 227 | /* Clear dangerous stuff, set PATH */
|
---|
| 228 | run_by_root = !sanitize_env_if_suid();
|
---|
| 229 |
|
---|
[1765] | 230 | /* Mandatory paranoia for suid applet:
|
---|
| 231 | * ensure that fd# 0,1,2 are opened (at least to /dev/null)
|
---|
| 232 | * and any extra open fd's are closed.
|
---|
| 233 | * (The name of the function is misleading. Not daemonizing here.) */
|
---|
| 234 | bb_daemonize_or_rexec(DAEMON_ONLY_SANITIZE | DAEMON_CLOSE_EXTRA_FDS, NULL);
|
---|
[821] | 235 |
|
---|
[1765] | 236 | opt = getopt32(argv, "f:h:p", &opt_user, &opt_host);
|
---|
| 237 | if (opt & LOGIN_OPT_f) {
|
---|
[2725] | 238 | if (!run_by_root)
|
---|
[1765] | 239 | bb_error_msg_and_die("-f is for root only");
|
---|
| 240 | safe_strncpy(username, opt_user, sizeof(username));
|
---|
| 241 | }
|
---|
[2725] | 242 | argv += optind;
|
---|
| 243 | if (argv[0]) /* user from command line (getty) */
|
---|
| 244 | safe_strncpy(username, argv[0], sizeof(username));
|
---|
[821] | 245 |
|
---|
[1765] | 246 | /* Let's find out and memorize our tty */
|
---|
[2725] | 247 | if (!isatty(STDIN_FILENO) || !isatty(STDOUT_FILENO) || !isatty(STDERR_FILENO))
|
---|
| 248 | return EXIT_FAILURE; /* Must be a terminal */
|
---|
| 249 | full_tty = xmalloc_ttyname(STDIN_FILENO);
|
---|
| 250 | if (!full_tty)
|
---|
| 251 | full_tty = xstrdup("UNKNOWN");
|
---|
| 252 | short_tty = skip_dev_pfx(full_tty);
|
---|
[821] | 253 |
|
---|
[1765] | 254 | if (opt_host) {
|
---|
| 255 | fromhost = xasprintf(" on '%s' from '%s'", short_tty, opt_host);
|
---|
[2725] | 256 | } else {
|
---|
[1765] | 257 | fromhost = xasprintf(" on '%s'", short_tty);
|
---|
[2725] | 258 | }
|
---|
[821] | 259 |
|
---|
[1765] | 260 | /* Was breaking "login <username>" from shell command line: */
|
---|
| 261 | /*bb_setpgrp();*/
|
---|
| 262 |
|
---|
[2725] | 263 | openlog(applet_name, LOG_PID | LOG_CONS, LOG_AUTH);
|
---|
[1765] | 264 |
|
---|
| 265 | while (1) {
|
---|
[2725] | 266 | /* flush away any type-ahead (as getty does) */
|
---|
| 267 | tcflush(0, TCIFLUSH);
|
---|
| 268 |
|
---|
[1765] | 269 | if (!username[0])
|
---|
| 270 | get_username_or_die(username, sizeof(username));
|
---|
| 271 |
|
---|
| 272 | #if ENABLE_PAM
|
---|
| 273 | pamret = pam_start("login", username, &conv, &pamh);
|
---|
| 274 | if (pamret != PAM_SUCCESS) {
|
---|
[2725] | 275 | failed_msg = "start";
|
---|
[1765] | 276 | goto pam_auth_failed;
|
---|
[821] | 277 | }
|
---|
[1765] | 278 | /* set TTY (so things like securetty work) */
|
---|
| 279 | pamret = pam_set_item(pamh, PAM_TTY, short_tty);
|
---|
| 280 | if (pamret != PAM_SUCCESS) {
|
---|
[2725] | 281 | failed_msg = "set_item(TTY)";
|
---|
[1765] | 282 | goto pam_auth_failed;
|
---|
| 283 | }
|
---|
| 284 | pamret = pam_authenticate(pamh, 0);
|
---|
| 285 | if (pamret != PAM_SUCCESS) {
|
---|
[2725] | 286 | failed_msg = "authenticate";
|
---|
[1765] | 287 | goto pam_auth_failed;
|
---|
| 288 | /* TODO: or just "goto auth_failed"
|
---|
| 289 | * since user seems to enter wrong password
|
---|
| 290 | * (in this case pamret == 7)
|
---|
| 291 | */
|
---|
| 292 | }
|
---|
| 293 | /* check that the account is healthy */
|
---|
| 294 | pamret = pam_acct_mgmt(pamh, 0);
|
---|
| 295 | if (pamret != PAM_SUCCESS) {
|
---|
[2725] | 296 | failed_msg = "acct_mgmt";
|
---|
[1765] | 297 | goto pam_auth_failed;
|
---|
| 298 | }
|
---|
| 299 | /* read user back */
|
---|
[2725] | 300 | pamuser = NULL;
|
---|
| 301 | /* gcc: "dereferencing type-punned pointer breaks aliasing rules..."
|
---|
| 302 | * thus we cast to (void*) */
|
---|
| 303 | if (pam_get_item(pamh, PAM_USER, (void*)&pamuser) != PAM_SUCCESS) {
|
---|
| 304 | failed_msg = "get_item(USER)";
|
---|
| 305 | goto pam_auth_failed;
|
---|
[1765] | 306 | }
|
---|
[2725] | 307 | if (!pamuser || !pamuser[0])
|
---|
| 308 | goto auth_failed;
|
---|
| 309 | safe_strncpy(username, pamuser, sizeof(username));
|
---|
| 310 | /* Don't use "pw = getpwnam(username);",
|
---|
| 311 | * PAM is said to be capable of destroying static storage
|
---|
| 312 | * used by getpwnam(). We are using safe(r) function */
|
---|
| 313 | pw = NULL;
|
---|
| 314 | getpwnam_r(username, &pwdstruct, pwdbuf, sizeof(pwdbuf), &pw);
|
---|
| 315 | if (!pw)
|
---|
| 316 | goto auth_failed;
|
---|
| 317 | pamret = pam_open_session(pamh, 0);
|
---|
| 318 | if (pamret != PAM_SUCCESS) {
|
---|
| 319 | failed_msg = "open_session";
|
---|
| 320 | goto pam_auth_failed;
|
---|
| 321 | }
|
---|
| 322 | pamret = pam_setcred(pamh, PAM_ESTABLISH_CRED);
|
---|
| 323 | if (pamret != PAM_SUCCESS) {
|
---|
| 324 | failed_msg = "setcred";
|
---|
| 325 | goto pam_auth_failed;
|
---|
| 326 | }
|
---|
| 327 | break; /* success, continue login process */
|
---|
| 328 |
|
---|
[1765] | 329 | pam_auth_failed:
|
---|
[2725] | 330 | /* syslog, because we don't want potential attacker
|
---|
| 331 | * to know _why_ login failed */
|
---|
| 332 | syslog(LOG_WARNING, "pam_%s call failed: %s (%d)", failed_msg,
|
---|
| 333 | pam_strerror(pamh, pamret), pamret);
|
---|
[1765] | 334 | safe_strncpy(username, "UNKNOWN", sizeof(username));
|
---|
| 335 | #else /* not PAM */
|
---|
| 336 | pw = getpwnam(username);
|
---|
| 337 | if (!pw) {
|
---|
| 338 | strcpy(username, "UNKNOWN");
|
---|
| 339 | goto fake_it;
|
---|
| 340 | }
|
---|
[821] | 341 |
|
---|
[1765] | 342 | if (pw->pw_passwd[0] == '!' || pw->pw_passwd[0] == '*')
|
---|
| 343 | goto auth_failed;
|
---|
[821] | 344 |
|
---|
[1765] | 345 | if (opt & LOGIN_OPT_f)
|
---|
| 346 | break; /* -f USER: success without asking passwd */
|
---|
[821] | 347 |
|
---|
[1765] | 348 | if (pw->pw_uid == 0 && !check_securetty())
|
---|
| 349 | goto auth_failed;
|
---|
[821] | 350 |
|
---|
[1765] | 351 | /* Don't check the password if password entry is empty (!) */
|
---|
| 352 | if (!pw->pw_passwd[0])
|
---|
[821] | 353 | break;
|
---|
[1765] | 354 | fake_it:
|
---|
| 355 | /* authorization takes place here */
|
---|
| 356 | if (correct_password(pw))
|
---|
| 357 | break;
|
---|
| 358 | #endif /* ENABLE_PAM */
|
---|
| 359 | auth_failed:
|
---|
| 360 | opt &= ~LOGIN_OPT_f;
|
---|
[821] | 361 | bb_do_delay(FAIL_DELAY);
|
---|
[1765] | 362 | /* TODO: doesn't sound like correct English phrase to me */
|
---|
[821] | 363 | puts("Login incorrect");
|
---|
[1765] | 364 | if (++count == 3) {
|
---|
| 365 | syslog(LOG_WARNING, "invalid password for '%s'%s",
|
---|
| 366 | username, fromhost);
|
---|
[2725] | 367 |
|
---|
| 368 | if (ENABLE_FEATURE_CLEAN_UP)
|
---|
| 369 | free(fromhost);
|
---|
| 370 |
|
---|
[821] | 371 | return EXIT_FAILURE;
|
---|
[1765] | 372 | }
|
---|
| 373 | username[0] = '\0';
|
---|
[2725] | 374 | } /* while (1) */
|
---|
[821] | 375 |
|
---|
[1765] | 376 | alarm(0);
|
---|
[2725] | 377 | /* We can ignore /etc/nologin if we are logging in as root,
|
---|
| 378 | * it doesn't matter whether we are run by root or not */
|
---|
| 379 | if (pw->pw_uid != 0)
|
---|
| 380 | die_if_nologin();
|
---|
[821] | 381 |
|
---|
[2725] | 382 | IF_SELINUX(initselinux(username, full_tty, &user_sid));
|
---|
[821] | 383 |
|
---|
[1765] | 384 | /* Try these, but don't complain if they fail.
|
---|
| 385 | * _f_chown is safe wrt race t=ttyname(0);...;chown(t); */
|
---|
| 386 | fchown(0, pw->pw_uid, pw->pw_gid);
|
---|
| 387 | fchmod(0, 0600);
|
---|
[821] | 388 |
|
---|
[2725] | 389 | update_utmp(getpid(), USER_PROCESS, short_tty, username, run_by_root ? opt_host : NULL);
|
---|
[821] | 390 |
|
---|
[2725] | 391 | /* We trust environment only if we run by root */
|
---|
| 392 | if (ENABLE_LOGIN_SCRIPTS && run_by_root)
|
---|
| 393 | run_login_script(pw, full_tty);
|
---|
[1765] | 394 |
|
---|
| 395 | change_identity(pw);
|
---|
[2725] | 396 | shell = pw->pw_shell;
|
---|
| 397 | if (!shell || !shell[0])
|
---|
| 398 | shell = DEFAULT_SHELL;
|
---|
| 399 | setup_environment(shell,
|
---|
| 400 | (!(opt & LOGIN_OPT_p) * SETUP_ENV_CLEARENV) + SETUP_ENV_CHANGEENV,
|
---|
| 401 | pw);
|
---|
[821] | 402 |
|
---|
[1765] | 403 | motd();
|
---|
[821] | 404 |
|
---|
[1765] | 405 | if (pw->pw_uid == 0)
|
---|
| 406 | syslog(LOG_INFO, "root login%s", fromhost);
|
---|
[2725] | 407 |
|
---|
| 408 | if (ENABLE_FEATURE_CLEAN_UP)
|
---|
| 409 | free(fromhost);
|
---|
| 410 |
|
---|
[821] | 411 | /* well, a simple setexeccon() here would do the job as well,
|
---|
| 412 | * but let's play the game for now */
|
---|
[2725] | 413 | IF_SELINUX(set_current_security_context(user_sid);)
|
---|
[821] | 414 |
|
---|
[1765] | 415 | // util-linux login also does:
|
---|
| 416 | // /* start new session */
|
---|
| 417 | // setsid();
|
---|
| 418 | // /* TIOCSCTTY: steal tty from other process group */
|
---|
| 419 | // if (ioctl(0, TIOCSCTTY, 1)) error_msg...
|
---|
| 420 | // BBox login used to do this (see above):
|
---|
| 421 | // bb_setpgrp();
|
---|
| 422 | // If this stuff is really needed, add it and explain why!
|
---|
[821] | 423 |
|
---|
[2725] | 424 | /* Set signals to defaults */
|
---|
| 425 | /* Non-ignored signals revert to SIG_DFL on exec anyway */
|
---|
| 426 | /*signal(SIGALRM, SIG_DFL);*/
|
---|
| 427 |
|
---|
[1765] | 428 | /* Is this correct? This way user can ctrl-c out of /etc/profile,
|
---|
| 429 | * potentially creating security breach (tested with bash 3.0).
|
---|
| 430 | * But without this, bash 3.0 will not enable ctrl-c either.
|
---|
| 431 | * Maybe bash is buggy?
|
---|
| 432 | * Need to find out what standards say about /bin/login -
|
---|
[2725] | 433 | * should we leave SIGINT etc enabled or disabled? */
|
---|
[1765] | 434 | signal(SIGINT, SIG_DFL);
|
---|
[821] | 435 |
|
---|
[1765] | 436 | /* Exec login shell with no additional parameters */
|
---|
[2725] | 437 | run_shell(shell, 1, NULL, NULL);
|
---|
[821] | 438 |
|
---|
[1765] | 439 | /* return EXIT_FAILURE; - not reached */
|
---|
[821] | 440 | }
|
---|