/* Fixed by Erik Andersen to do passwords the tinylogin way...
* It now works with md5, sha1, etc passwords. */
-#include <sys/vt.h>
#include "libbb.h"
+#ifdef __linux__
+#include <sys/vt.h>
+
static void release_vt(int signo UNUSED_PARAM)
{
/* If -a, param is 0, which means:
/* ACK to kernel that switch to console is successful */
ioctl(STDIN_FILENO, VT_RELDISP, VT_ACKACQ);
}
+#endif
int vlock_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int vlock_main(int argc UNUSED_PARAM, char **argv)
{
+#ifdef __linux__
struct vt_mode vtm;
+ struct vt_mode ovtm;
+#endif
struct termios term;
struct termios oterm;
- struct vt_mode ovtm;
struct passwd *pw;
pw = xgetpwuid(getuid());
+ (1 << SIGINT )
, SIG_IGN);
+#ifdef __linux__
/* We will use SIGUSRx for console switch control: */
/* 1: set handlers */
signal_SA_RESTART_empty_mask(SIGUSR1, release_vt);
/* 2: unmask them */
sig_unblock(SIGUSR1);
sig_unblock(SIGUSR2);
+#endif
/* Revert stdin/out to our controlling tty
* (or die if we have none) */
xmove_fd(xopen(CURRENT_TTY, O_RDWR), STDIN_FILENO);
xdup2(STDIN_FILENO, STDOUT_FILENO);
+#ifdef __linux__
xioctl(STDIN_FILENO, VT_GETMODE, &vtm);
ovtm = vtm;
/* "console switches are controlled by us, not kernel!" */
vtm.relsig = SIGUSR1;
vtm.acqsig = SIGUSR2;
ioctl(STDIN_FILENO, VT_SETMODE, &vtm);
+#endif
tcgetattr(STDIN_FILENO, &oterm);
term = oterm;
puts("Password incorrect");
} while (1);
+#ifdef __linux__
ioctl(STDIN_FILENO, VT_SETMODE, &ovtm);
+#endif
tcsetattr_stdin_TCSANOW(&oterm);
fflush_stdout_and_exit(EXIT_SUCCESS);
}