login.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * Licensed under GPLv2 or later, see file LICENSE in this source tree.
  4. */
  5. //config:config LOGIN
  6. //config: bool "login (24 kb)"
  7. //config: default y
  8. //config: select FEATURE_SYSLOG
  9. //config: help
  10. //config: login is used when signing onto a system.
  11. //config:
  12. //config: Note that busybox binary must be setuid root for this applet to
  13. //config: work properly.
  14. //config:
  15. //config:config LOGIN_SESSION_AS_CHILD
  16. //config: bool "Run logged in session in a child process"
  17. //config: default y if PAM
  18. //config: depends on LOGIN
  19. //config: help
  20. //config: Run the logged in session in a child process. This allows
  21. //config: login to clean up things such as utmp entries or PAM sessions
  22. //config: when the login session is complete. If you use PAM, you
  23. //config: almost always would want this to be set to Y, else PAM session
  24. //config: will not be cleaned up.
  25. //config:
  26. //config:config LOGIN_SCRIPTS
  27. //config: bool "Support login scripts"
  28. //config: depends on LOGIN
  29. //config: default y
  30. //config: help
  31. //config: Enable this if you want login to execute $LOGIN_PRE_SUID_SCRIPT
  32. //config: just prior to switching from root to logged-in user.
  33. //config:
  34. //config:config FEATURE_NOLOGIN
  35. //config: bool "Support /etc/nologin"
  36. //config: default y
  37. //config: depends on LOGIN
  38. //config: help
  39. //config: The file /etc/nologin is used by (some versions of) login(1).
  40. //config: If it exists, non-root logins are prohibited.
  41. //config:
  42. //config:config FEATURE_SECURETTY
  43. //config: bool "Support /etc/securetty"
  44. //config: default y
  45. //config: depends on LOGIN
  46. //config: help
  47. //config: The file /etc/securetty is used by (some versions of) login(1).
  48. //config: The file contains the device names of tty lines (one per line,
  49. //config: without leading /dev/) on which root is allowed to login.
  50. //applet:/* Needs to be run by root or be suid root - needs to change uid and gid: */
  51. //applet:IF_LOGIN(APPLET(login, BB_DIR_BIN, BB_SUID_REQUIRE))
  52. //kbuild:lib-$(CONFIG_LOGIN) += login.o
  53. //usage:#define login_trivial_usage
  54. //usage: "[-p] [-h HOST] [[-f] USER]"
  55. //usage:#define login_full_usage "\n\n"
  56. //usage: "Begin a new session on the system\n"
  57. //usage: "\n -f Don't authenticate (user already authenticated)"
  58. //usage: "\n -h HOST Host user came from (for network logins)"
  59. //usage: "\n -p Preserve environment"
  60. //usage: "\n"
  61. //usage: "\n$LOGIN_TIMEOUT Seconds (default 60, 0 - disable)"
  62. //usage: IF_LOGIN_SCRIPTS(
  63. //usage: "\n$LOGIN_PRE_SUID_SCRIPT Execute before user ID change"
  64. //usage: )
  65. #include "libbb.h"
  66. #include "common_bufsiz.h"
  67. #include <syslog.h>
  68. #if ENABLE_SELINUX
  69. # include <selinux/selinux.h> /* for is_selinux_enabled() */
  70. # include <selinux/get_context_list.h> /* for get_default_context() */
  71. # /* from deprecated <selinux/flask.h>: */
  72. # undef SECCLASS_CHR_FILE
  73. # define SECCLASS_CHR_FILE 10
  74. #endif
  75. #if ENABLE_PAM
  76. /* PAM may include <locale.h>. We may need to undefine bbox's stub define: */
  77. # undef setlocale
  78. /* For some obscure reason, PAM is not in pam/xxx, but in security/xxx.
  79. * Apparently they like to confuse people. */
  80. # include <security/pam_appl.h>
  81. # include <security/pam_misc.h>
  82. # if 0
  83. /* This supposedly can be used to avoid double password prompt,
  84. * if used instead of standard misc_conv():
  85. *
  86. * "When we want to authenticate first with local method and then with tacacs for example,
  87. * the password is asked for local method and if not good is asked a second time for tacacs.
  88. * So if we want to authenticate a user with tacacs, and the user exists localy, the password is
  89. * asked two times before authentication is accepted."
  90. *
  91. * However, code looks shaky. For example, why misc_conv() return value is ignored?
  92. * Are msg[i] and resp[i] indexes handled correctly?
  93. */
  94. static char *passwd = NULL;
  95. static int my_conv(int num_msg, const struct pam_message **msg,
  96. struct pam_response **resp, void *data)
  97. {
  98. int i;
  99. for (i = 0; i < num_msg; i++) {
  100. switch (msg[i]->msg_style) {
  101. case PAM_PROMPT_ECHO_OFF:
  102. if (passwd == NULL) {
  103. misc_conv(num_msg, msg, resp, data);
  104. passwd = xstrdup(resp[i]->resp);
  105. return PAM_SUCCESS;
  106. }
  107. resp[0] = xzalloc(sizeof(struct pam_response));
  108. resp[0]->resp = passwd;
  109. passwd = NULL;
  110. resp[0]->resp_retcode = PAM_SUCCESS;
  111. resp[1] = NULL;
  112. return PAM_SUCCESS;
  113. default:
  114. break;
  115. }
  116. }
  117. return PAM_SUCCESS;
  118. }
  119. # endif
  120. static const struct pam_conv conv = {
  121. misc_conv,
  122. NULL
  123. };
  124. #endif
  125. enum {
  126. EMPTY_USERNAME_COUNT = 10,
  127. /* Some users found 32 chars limit to be too low: */
  128. USERNAME_SIZE = 64,
  129. TTYNAME_SIZE = 32,
  130. };
  131. struct globals {
  132. struct termios tty_attrs;
  133. int timeout;
  134. } FIX_ALIASING;
  135. #define G (*(struct globals*)bb_common_bufsiz1)
  136. #define INIT_G() do { setup_common_bufsiz(); } while (0)
  137. #if ENABLE_FEATURE_NOLOGIN
  138. static void die_if_nologin(void)
  139. {
  140. FILE *fp;
  141. int c;
  142. int empty = 1;
  143. fp = fopen_for_read("/etc/nologin");
  144. if (!fp) /* assuming it does not exist */
  145. return;
  146. while ((c = getc(fp)) != EOF) {
  147. if (c == '\n')
  148. bb_putchar('\r');
  149. bb_putchar(c);
  150. empty = 0;
  151. }
  152. if (empty)
  153. puts("\r\nSystem closed for routine maintenance\r");
  154. fclose(fp);
  155. fflush_all();
  156. /* Users say that they do need this prior to exit: */
  157. tcdrain(STDOUT_FILENO);
  158. exit(EXIT_FAILURE);
  159. }
  160. #else
  161. # define die_if_nologin() ((void)0)
  162. #endif
  163. #if ENABLE_SELINUX
  164. static void initselinux(char *username, char *full_tty,
  165. security_context_t *user_sid)
  166. {
  167. security_context_t old_tty_sid, new_tty_sid;
  168. if (!is_selinux_enabled())
  169. return;
  170. if (get_default_context(username, NULL, user_sid)) {
  171. bb_error_msg_and_die("can't get SID for %s", username);
  172. }
  173. if (getfilecon(full_tty, &old_tty_sid) < 0) {
  174. bb_perror_msg_and_die("getfilecon(%s) failed", full_tty);
  175. }
  176. if (security_compute_relabel(*user_sid, old_tty_sid,
  177. SECCLASS_CHR_FILE, &new_tty_sid) != 0) {
  178. bb_perror_msg_and_die("security_change_sid(%s) failed", full_tty);
  179. }
  180. if (setfilecon(full_tty, new_tty_sid) != 0) {
  181. bb_perror_msg_and_die("chsid(%s, %s) failed", full_tty, new_tty_sid);
  182. }
  183. }
  184. #endif
  185. #if ENABLE_LOGIN_SCRIPTS
  186. static void run_login_script(struct passwd *pw, char *full_tty)
  187. {
  188. char *t_argv[2];
  189. t_argv[0] = getenv("LOGIN_PRE_SUID_SCRIPT");
  190. if (t_argv[0]) {
  191. t_argv[1] = NULL;
  192. xsetenv("LOGIN_TTY", full_tty);
  193. xsetenv("LOGIN_USER", pw->pw_name);
  194. xsetenv("LOGIN_UID", utoa(pw->pw_uid));
  195. xsetenv("LOGIN_GID", utoa(pw->pw_gid));
  196. xsetenv("LOGIN_SHELL", pw->pw_shell);
  197. spawn_and_wait(t_argv); /* NOMMU-friendly */
  198. unsetenv("LOGIN_TTY");
  199. unsetenv("LOGIN_USER");
  200. unsetenv("LOGIN_UID");
  201. unsetenv("LOGIN_GID");
  202. unsetenv("LOGIN_SHELL");
  203. }
  204. }
  205. #else
  206. void run_login_script(struct passwd *pw, char *full_tty);
  207. #endif
  208. #if ENABLE_LOGIN_SESSION_AS_CHILD && ENABLE_PAM
  209. static void login_pam_end(pam_handle_t *pamh)
  210. {
  211. int pamret;
  212. pamret = pam_setcred(pamh, PAM_DELETE_CRED);
  213. if (pamret != PAM_SUCCESS) {
  214. bb_error_msg("pam_%s failed: %s (%d)", "setcred",
  215. pam_strerror(pamh, pamret), pamret);
  216. }
  217. pamret = pam_close_session(pamh, 0);
  218. if (pamret != PAM_SUCCESS) {
  219. bb_error_msg("pam_%s failed: %s (%d)", "close_session",
  220. pam_strerror(pamh, pamret), pamret);
  221. }
  222. pamret = pam_end(pamh, pamret);
  223. if (pamret != PAM_SUCCESS) {
  224. bb_error_msg("pam_%s failed: %s (%d)", "end",
  225. pam_strerror(pamh, pamret), pamret);
  226. }
  227. }
  228. #else
  229. # define login_pam_end(pamh) ((void)0)
  230. #endif
  231. static void get_username_or_die(char *buf, int size_buf)
  232. {
  233. int c, cntdown;
  234. cntdown = EMPTY_USERNAME_COUNT;
  235. prompt:
  236. print_login_prompt();
  237. /* skip whitespace */
  238. do {
  239. c = getchar();
  240. if (c == EOF)
  241. exit(EXIT_FAILURE);
  242. if (c == '\n') {
  243. if (!--cntdown)
  244. exit(EXIT_FAILURE);
  245. goto prompt;
  246. }
  247. } while (isspace(c)); /* maybe isblank? */
  248. *buf++ = c;
  249. if (!fgets(buf, size_buf-2, stdin))
  250. exit(EXIT_FAILURE);
  251. if (!strchr(buf, '\n'))
  252. exit(EXIT_FAILURE);
  253. while ((unsigned char)*buf > ' ')
  254. buf++;
  255. *buf = '\0';
  256. }
  257. static void motd(void)
  258. {
  259. int fd;
  260. fd = open(bb_path_motd_file, O_RDONLY);
  261. if (fd >= 0) {
  262. fflush_all();
  263. bb_copyfd_eof(fd, STDOUT_FILENO);
  264. close(fd);
  265. }
  266. }
  267. static void alarm_handler(int sig UNUSED_PARAM)
  268. {
  269. /* This is the escape hatch! Poor serial line users and the like
  270. * arrive here when their connection is broken.
  271. * We don't want to block here */
  272. ndelay_on(STDOUT_FILENO);
  273. /* Test for correct attr restoring:
  274. * run "getty 0 -" from a shell, enter bogus username, stop at
  275. * password prompt, let it time out. Without the tcsetattr below,
  276. * when you are back at shell prompt, echo will be still off.
  277. */
  278. tcsetattr_stdin_TCSANOW(&G.tty_attrs);
  279. printf("\r\nLogin timed out after %u seconds\r\n", G.timeout);
  280. fflush_all();
  281. /* unix API is brain damaged regarding O_NONBLOCK,
  282. * we should undo it, or else we can affect other processes */
  283. ndelay_off(STDOUT_FILENO);
  284. _exit(EXIT_SUCCESS);
  285. }
  286. int login_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
  287. int login_main(int argc UNUSED_PARAM, char **argv)
  288. {
  289. enum {
  290. LOGIN_OPT_f = (1<<0),
  291. LOGIN_OPT_h = (1<<1),
  292. LOGIN_OPT_p = (1<<2),
  293. };
  294. char *fromhost;
  295. char username[USERNAME_SIZE];
  296. int run_by_root;
  297. unsigned opt;
  298. int count = 0;
  299. struct passwd *pw;
  300. char *opt_host = NULL;
  301. char *opt_user = opt_user; /* for compiler */
  302. char *full_tty;
  303. char *short_tty;
  304. IF_SELINUX(security_context_t user_sid = NULL;)
  305. #if ENABLE_PAM
  306. int pamret;
  307. pam_handle_t *pamh;
  308. const char *pamuser;
  309. const char *failed_msg;
  310. struct passwd pwdstruct;
  311. char pwdbuf[256];
  312. char **pamenv;
  313. #endif
  314. #if ENABLE_LOGIN_SESSION_AS_CHILD
  315. pid_t child_pid;
  316. #endif
  317. IF_FEATURE_UTMP(pid_t my_pid;)
  318. INIT_G();
  319. G.timeout = xatoi_positive(getenv("LOGIN_TIMEOUT") ? : "60");
  320. /* More of suid paranoia if called by non-root: */
  321. /* Clear dangerous stuff, set PATH */
  322. run_by_root = !sanitize_env_if_suid();
  323. /* Mandatory paranoia for suid applet:
  324. * ensure that fd# 0,1,2 are opened (at least to /dev/null)
  325. * and any extra open fd's are closed.
  326. */
  327. bb_daemon_helper(DAEMON_CLOSE_EXTRA_FDS);
  328. username[0] = '\0';
  329. opt = getopt32(argv, "f:h:p", &opt_user, &opt_host);
  330. if (opt & LOGIN_OPT_f) {
  331. if (!run_by_root)
  332. bb_simple_error_msg_and_die("-f is for root only");
  333. safe_strncpy(username, opt_user, sizeof(username));
  334. }
  335. argv += optind;
  336. if (argv[0]) /* user from command line (getty) */
  337. safe_strncpy(username, argv[0], sizeof(username));
  338. /* Save tty attributes - and by doing it, check that it's indeed a tty */
  339. if (tcgetattr(STDIN_FILENO, &G.tty_attrs) < 0
  340. || !isatty(STDOUT_FILENO)
  341. /*|| !isatty(STDERR_FILENO) - no, guess some people might want to redirect this */
  342. ) {
  343. return EXIT_FAILURE; /* Must be a terminal */
  344. }
  345. /* We install timeout handler only _after_ we saved G.tty_attrs */
  346. signal(SIGALRM, alarm_handler);
  347. alarm(G.timeout);
  348. /* Find out and memorize our tty name */
  349. full_tty = xmalloc_ttyname(STDIN_FILENO);
  350. if (!full_tty)
  351. full_tty = xstrdup("UNKNOWN");
  352. short_tty = skip_dev_pfx(full_tty);
  353. if (opt_host) {
  354. fromhost = xasprintf(" on '%s' from '%s'", short_tty, opt_host);
  355. } else {
  356. fromhost = xasprintf(" on '%s'", short_tty);
  357. }
  358. /* Was breaking "login <username>" from shell command line: */
  359. /*bb_setpgrp();*/
  360. openlog(applet_name, LOG_PID | LOG_CONS, LOG_AUTH);
  361. while (1) {
  362. /* flush away any type-ahead (as getty does) */
  363. tcflush(0, TCIFLUSH);
  364. if (!username[0])
  365. get_username_or_die(username, sizeof(username));
  366. #if ENABLE_PAM
  367. pamret = pam_start("login", username, &conv, &pamh);
  368. if (pamret != PAM_SUCCESS) {
  369. failed_msg = "start";
  370. goto pam_auth_failed;
  371. }
  372. /* set TTY (so things like securetty work) */
  373. pamret = pam_set_item(pamh, PAM_TTY, short_tty);
  374. if (pamret != PAM_SUCCESS) {
  375. failed_msg = "set_item(TTY)";
  376. goto pam_auth_failed;
  377. }
  378. /* set RHOST */
  379. if (opt_host) {
  380. pamret = pam_set_item(pamh, PAM_RHOST, opt_host);
  381. if (pamret != PAM_SUCCESS) {
  382. failed_msg = "set_item(RHOST)";
  383. goto pam_auth_failed;
  384. }
  385. }
  386. if (!(opt & LOGIN_OPT_f)) {
  387. pamret = pam_authenticate(pamh, 0);
  388. if (pamret != PAM_SUCCESS) {
  389. failed_msg = "authenticate";
  390. goto pam_auth_failed;
  391. /* TODO: or just "goto auth_failed"
  392. * since user seems to enter wrong password
  393. * (in this case pamret == 7)
  394. */
  395. }
  396. }
  397. /* check that the account is healthy */
  398. pamret = pam_acct_mgmt(pamh, 0);
  399. if (pamret != PAM_SUCCESS) {
  400. failed_msg = "acct_mgmt";
  401. goto pam_auth_failed;
  402. }
  403. /* read user back */
  404. pamuser = NULL;
  405. /* gcc: "dereferencing type-punned pointer breaks aliasing rules..."
  406. * thus we cast to (void*) */
  407. if (pam_get_item(pamh, PAM_USER, (void*)&pamuser) != PAM_SUCCESS) {
  408. failed_msg = "get_item(USER)";
  409. goto pam_auth_failed;
  410. }
  411. if (!pamuser || !pamuser[0])
  412. goto auth_failed;
  413. safe_strncpy(username, pamuser, sizeof(username));
  414. /* Don't use "pw = getpwnam(username);",
  415. * PAM is said to be capable of destroying static storage
  416. * used by getpwnam(). We are using safe(r) function */
  417. pw = NULL;
  418. getpwnam_r(username, &pwdstruct, pwdbuf, sizeof(pwdbuf), &pw);
  419. if (!pw)
  420. goto auth_failed;
  421. pamret = pam_open_session(pamh, 0);
  422. if (pamret != PAM_SUCCESS) {
  423. failed_msg = "open_session";
  424. goto pam_auth_failed;
  425. }
  426. pamret = pam_setcred(pamh, PAM_ESTABLISH_CRED);
  427. if (pamret != PAM_SUCCESS) {
  428. failed_msg = "setcred";
  429. goto pam_auth_failed;
  430. }
  431. break; /* success, continue login process */
  432. pam_auth_failed:
  433. /* syslog, because we don't want potential attacker
  434. * to know _why_ login failed */
  435. syslog(LOG_WARNING, "pam_%s call failed: %s (%d)", failed_msg,
  436. pam_strerror(pamh, pamret), pamret);
  437. login_pam_end(pamh);
  438. safe_strncpy(username, "UNKNOWN", sizeof(username));
  439. #else /* not PAM */
  440. pw = getpwnam(username);
  441. if (!pw) {
  442. strcpy(username, "UNKNOWN");
  443. goto fake_it;
  444. }
  445. if (pw->pw_passwd[0] == '!' || pw->pw_passwd[0] == '*')
  446. goto auth_failed;
  447. if (opt & LOGIN_OPT_f)
  448. break; /* -f USER: success without asking passwd */
  449. if (pw->pw_uid == 0 && !is_tty_secure(short_tty))
  450. goto auth_failed;
  451. /* Don't check the password if password entry is empty (!) */
  452. if (!pw->pw_passwd[0])
  453. break;
  454. fake_it:
  455. /* Password reading and authorization takes place here.
  456. * Note that reads (in no-echo mode) trash tty attributes.
  457. * If we get interrupted by SIGALRM, we need to restore attrs.
  458. */
  459. if (ask_and_check_password(pw) > 0)
  460. break;
  461. #endif /* ENABLE_PAM */
  462. auth_failed:
  463. opt &= ~LOGIN_OPT_f;
  464. pause_after_failed_login();
  465. /* TODO: doesn't sound like correct English phrase to me */
  466. puts("Login incorrect");
  467. syslog(LOG_WARNING, "invalid password for '%s'%s",
  468. username, fromhost);
  469. if (++count == 3) {
  470. if (ENABLE_FEATURE_CLEAN_UP)
  471. free(fromhost);
  472. return EXIT_FAILURE;
  473. }
  474. username[0] = '\0';
  475. } /* while (1) */
  476. alarm(0);
  477. /* We can ignore /etc/nologin if we are logging in as root,
  478. * it doesn't matter whether we are run by root or not */
  479. if (pw->pw_uid != 0)
  480. die_if_nologin();
  481. IF_FEATURE_UTMP(my_pid = getpid();)
  482. update_utmp(my_pid, USER_PROCESS, short_tty, username, run_by_root ? opt_host : NULL);
  483. #if ENABLE_LOGIN_SESSION_AS_CHILD
  484. child_pid = vfork();
  485. if (child_pid != 0) {
  486. if (child_pid < 0)
  487. bb_simple_perror_msg("vfork");
  488. else {
  489. wait_for_exitstatus(child_pid);
  490. }
  491. update_utmp_DEAD_PROCESS(my_pid);
  492. login_pam_end(pamh);
  493. return 0;
  494. }
  495. #endif
  496. IF_SELINUX(initselinux(username, full_tty, &user_sid);)
  497. /* Try these, but don't complain if they fail.
  498. * _f_chown is safe wrt race t=ttyname(0);...;chown(t); */
  499. fchown(0, pw->pw_uid, pw->pw_gid);
  500. fchmod(0, 0600);
  501. /* We trust environment only if we run by root */
  502. if (ENABLE_LOGIN_SCRIPTS && run_by_root)
  503. run_login_script(pw, full_tty);
  504. change_identity(pw);
  505. setup_environment(pw->pw_shell,
  506. (!(opt & LOGIN_OPT_p) * SETUP_ENV_CLEARENV) + SETUP_ENV_CHANGEENV,
  507. pw);
  508. #if ENABLE_PAM
  509. /* Modules such as pam_env will setup the PAM environment,
  510. * which should be copied into the new environment. */
  511. pamenv = pam_getenvlist(pamh);
  512. if (pamenv) while (*pamenv) {
  513. putenv(*pamenv);
  514. pamenv++;
  515. }
  516. #endif
  517. if (access(".hushlogin", F_OK) != 0)
  518. motd();
  519. if (pw->pw_uid == 0)
  520. syslog(LOG_INFO, "root login%s", fromhost);
  521. if (ENABLE_FEATURE_CLEAN_UP)
  522. free(fromhost);
  523. /* well, a simple setexeccon() here would do the job as well,
  524. * but let's play the game for now */
  525. IF_SELINUX(set_current_security_context(user_sid);)
  526. // util-linux login also does:
  527. // /* start new session */
  528. // setsid();
  529. // /* TIOCSCTTY: steal tty from other process group */
  530. // if (ioctl(0, TIOCSCTTY, 1)) error_msg...
  531. // BBox login used to do this (see above):
  532. // bb_setpgrp();
  533. // If this stuff is really needed, add it and explain why!
  534. /* Set signals to defaults */
  535. /* Non-ignored signals revert to SIG_DFL on exec anyway */
  536. /*signal(SIGALRM, SIG_DFL);*/
  537. /* Is this correct? This way user can ctrl-c out of /etc/profile,
  538. * potentially creating security breach (tested with bash 3.0).
  539. * But without this, bash 3.0 will not enable ctrl-c either.
  540. * Maybe bash is buggy?
  541. * Need to find out what standards say about /bin/login -
  542. * should we leave SIGINT etc enabled or disabled? */
  543. signal(SIGINT, SIG_DFL);
  544. /* Exec login shell with no additional parameters */
  545. exec_login_shell(pw->pw_shell);
  546. /* return EXIT_FAILURE; - not reached */
  547. }