- tcsetattr(0, TCSANOW, &termbuf);
-
- print_login_issue(issuefile, NULL);
-
- /* exec shell, with correct argv and env */
- execv(loginpath, (char *const *)argv_init);
- bb_perror_msg_and_die("execv");
+ tcsetattr_stdin_TCSANOW(&termbuf);
+
+ /* Uses FILE-based I/O to stdout, but does fflush_all(),
+ * so should be safe with vfork.
+ * I fear, though, that some users will have ridiculously big
+ * issue files, and they may block writing to fd 1,
+ * (parent is supposed to read it, but parent waits
+ * for vforked child to exec!) */
+ print_login_issue(G.issuefile, tty_name);
+
+ /* Exec shell / login / whatever */
+ login_argv[0] = G.loginpath;
+ login_argv[1] = NULL;
+ /* exec busybox applet (if PREFER_APPLETS=y), if that fails,
+ * exec external program.
+ * NB: sock is either 0 or has CLOEXEC set on it.
+ * fd has CLOEXEC set on it too. These two fds will be closed here.
+ */
+ BB_EXECVP(G.loginpath, (char **)login_argv);
+ /* _exit is safer with vfork, and we shouldn't send message
+ * to remote clients anyway */
+ _exit(EXIT_FAILURE); /*bb_perror_msg_and_die("execv %s", G.loginpath);*/