login.c 17 KB

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