$NetBSD: patch-ak,v 1.3 2002/12/23 21:23:59 jlam Exp $ --- modules/pam_filter/pam_filter.c.orig Sun Nov 11 02:43:54 2001 +++ modules/pam_filter/pam_filter.c @@ -21,7 +21,17 @@ #include #include #include +#ifdef HAVE_TERMIOS_H +#include +#define STRUCT_TERMIO struct termios +#define TCGETATTR(fd, p_termio) tcgetattr(fd, p_termio) +#define TCSETATTR(fd, p_termio) tcsetattr(fd, TCSANOW, p_termio) +#else #include +#define STRUCT_TERMIO struct termio +#define TCGETATTR(fd, p_termio) ioctl(fd, TCGETA, (char *) p_termio) +#define TCSETATTR(fd, p_termio) ioctl(fd, TCSETA, (char *) p_termio) +#endif #include @@ -278,7 +288,7 @@ static int set_filter(pam_handle_t *pamh { int status=-1; char terminal[TERMINAL_LEN]; - struct termio stored_mode; /* initial terminal mode settings */ + STRUCT_TERMIO stored_mode; /* initial terminal mode settings */ int fd[2], child=0, child2=0, aterminal; if (filtername == NULL || *filtername != '/') { @@ -307,17 +317,20 @@ static int set_filter(pam_handle_t *pamh /* this is termio terminal handling... */ - if (ioctl(STDIN_FILENO, TCGETA, (char *) &stored_mode ) < 0) { + if (TCGETATTR(STDIN_FILENO, &stored_mode ) < 0) { /* in trouble, so close down */ close(fd[0]); _pam_log(LOG_CRIT, "couldn't copy terminal mode"); return PAM_ABORT; } else { - struct termio t_mode = stored_mode; + STRUCT_TERMIO t_mode = stored_mode; t_mode.c_iflag = 0; /* no input control */ t_mode.c_oflag &= ~OPOST; /* no ouput post processing */ +#ifndef XCASE +#define XCASE 0 +#endif /* no signals, canonical input, echoing, upper/lower output */ t_mode.c_lflag &= ~(ISIG|ICANON|ECHO|XCASE); t_mode.c_cflag &= ~(CSIZE|PARENB); /* no parity */ @@ -326,7 +339,7 @@ static int set_filter(pam_handle_t *pamh t_mode.c_cc[VMIN] = 1; /* number of chars to satisfy a read */ t_mode.c_cc[VTIME] = 0; /* 0/10th second for chars */ - if (ioctl(STDIN_FILENO, TCSETA, (char *) &t_mode) < 0) { + if (TCSETATTR(STDIN_FILENO, &t_mode) < 0) { close(fd[0]); _pam_log(LOG_WARNING, "couldn't put terminal in RAW mode"); return PAM_ABORT; @@ -356,7 +369,7 @@ static int set_filter(pam_handle_t *pamh _pam_log(LOG_WARNING,"first fork failed"); if (aterminal) { - (void) ioctl(STDIN_FILENO, TCSETA, (char *) &stored_mode); + (void) TCSETATTR(STDIN_FILENO, &stored_mode); } return PAM_AUTH_ERR; @@ -398,7 +411,7 @@ static int set_filter(pam_handle_t *pamh /* initialize the child's terminal to be the way the parent's was before we set it into RAW mode */ - if (ioctl(fd[1], TCSETA, (char *) &stored_mode) < 0) { + if (TCSETATTR(fd[1], &stored_mode) < 0) { _pam_log(LOG_WARNING,"cannot set slave terminal mode; %s" ,terminal); close(fd[1]); @@ -572,7 +585,7 @@ static int set_filter(pam_handle_t *pamh if (aterminal) { /* reset to initial terminal mode */ - (void) ioctl(STDIN_FILENO, TCSETA, (char *) &stored_mode); + (void) TCSETATTR(STDIN_FILENO, &stored_mode); } if (ctrl & FILTER_DEBUG) {