#include <sys/ttydefaults.h>
#include <errno.h>
#include <sys/ioctl.h>
-#if defined(__GLIBC__)
-# include <crypt.h>
-# define dovoid(f) if ((f)){}
-#endif
#ifdef __linux__
# include <sys/statfs.h>
# include <sys/mount.h>
# ifndef MNT_DETACH
# define MNT_DETACH 2
# endif
+# define dovoid(f) if ((f)){}
#endif
#define BS CTRL('h')
static
void tcfinal(struct console *con)
{
- int serial;
struct termios *tio = &con->tio;
int fd = con->fd;
/* Expected error */
- serial = errno = 0;
+ errno = 0;
if ((con->flags & CON_SERIAL) == 0) {
#ifdef __linux__
struct termios tty;
char *ret = pass;
unsigned char tc;
- char ascval;
+ char c, ascval;
int eightbit;
- int c, fd;
+ int fd;
if (con->flags & CON_NOTTY)
goto out;
while (1) {
char *passwd = pwd->pw_passwd;
char *answer;
- int failed = 0;
+ int failed = 0, doshell = 0;
doprompt(passwd, con);
if ((answer = getpasswd(con)) == NULL)
break;
- if (passwd[0] == '\0' ||
- strcmp(crypt(answer, passwd), passwd) == 0) {
+ if (passwd[0] == '\0')
+ doshell++;
+ else {
+ char *cryptbuf;
+ cryptbuf = crypt(answer, passwd);
+ if (cryptbuf == NULL)
+ fprintf(stderr, "sulogin: crypt failed: %m\n\r");
+ else if (strcmp(cryptbuf, pwd->pw_passwd) == 0)
+ doshell++;
+ }
+
+ if (doshell) {
*usemask |= (1<<con->id);
sushell(pwd);
*usemask &= ~(1<<con->id);
failed++;
}
+
signal(SIGQUIT, SIG_IGN);
signal(SIGTSTP, SIG_IGN);
signal(SIGINT, SIG_IGN);
}
if (alarm_rised) {
tcfinal(con);
- printf("Timed out.\n\r");
+ fprintf(stderr, "Timed out.\n\r");
}
/*
* User may pressed Control-D.