summaryrefslogtreecommitdiff
path: root/security/PAM/patches/patch-aj
blob: 573b2c75b66bfa9f908e4870693fb51fc5ed61b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
$NetBSD: patch-aj,v 1.2 2002/01/29 17:10:11 jlam Exp $

--- modules/pam_filter/pam_filter.c.orig	Sun Nov 19 18:54:03 2000
+++ modules/pam_filter/pam_filter.c
@@ -21,7 +21,7 @@
 #include <sys/stat.h>
 #include <sys/socket.h>
 #include <sys/ioctl.h>
-#include <termio.h>
+#include <termios.h>
 
 #include <signal.h>
 
@@ -278,7 +278,7 @@
 {
     int status=-1;
     char terminal[TERMINAL_LEN];
-    struct termio stored_mode;           /* initial terminal mode settings */
+    struct termios stored_mode;           /* initial terminal mode settings */
     int fd[2], child=0, child2=0, aterminal;
 
     if (filtername == NULL || *filtername != '/') {
@@ -305,28 +305,32 @@
 	/* set terminal into raw mode.. remember old mode so that we can
 	   revert to it after the child has quit. */
 
-	/* this is termio terminal handling... */
+	/* this is termios 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 termios t_mode = stored_mode;
 
 	    t_mode.c_iflag = 0;            /* no input control */
 	    t_mode.c_oflag &= ~OPOST;      /* no ouput post processing */
 
 	    /* no signals, canonical input, echoing, upper/lower output */
+#ifdef XCASE
 	    t_mode.c_lflag &= ~(ISIG|ICANON|ECHO|XCASE);
+#else
+	    t_mode.c_lflag &= ~(ISIG|ICANON|ECHO);
+#endif
 	    t_mode.c_cflag &= ~(CSIZE|PARENB);  /* no parity */
 	    t_mode.c_cflag |= CS8;              /* 8 bit chars */
 
 	    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, TCSANOW, &t_mode) < 0) {
 		close(fd[0]);
 		_pam_log(LOG_WARNING, "couldn't put terminal in RAW mode");
 		return PAM_ABORT;
@@ -356,7 +360,7 @@
 
 	_pam_log(LOG_WARNING,"first fork failed");
 	if (aterminal) {
-	    (void) ioctl(STDIN_FILENO, TCSETA, (char *) &stored_mode);
+	    (void) tcsetattr(STDIN_FILENO, TCSANOW, &stored_mode);
 	}
 
 	return PAM_AUTH_ERR;
@@ -398,7 +402,7 @@
 	    /* 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], TCSANOW, &stored_mode) < 0) {
 		_pam_log(LOG_WARNING,"cannot set slave terminal mode; %s"
 			 ,terminal);
 		close(fd[1]);
@@ -572,7 +576,7 @@
 
     if (aterminal) {
 	/* reset to initial terminal mode */
-	(void) ioctl(STDIN_FILENO, TCSETA, (char *) &stored_mode);
+	(void) tcsetattr(STDIN_FILENO, TCSANOW, &stored_mode);
     }
 
     if (ctrl & FILTER_DEBUG) {