12 #include <net/netlib.h>
13 #include <net/gen/in.h>
14 #include <net/gen/inet.h>
15 #include <net/gen/tcp.h>
16 #include <net/gen/tcp_io.h>
17 #include <net/gen/netdb.h>
18 #include <net/gen/socket.h>
21 static void getstr(char *buf
, int cnt
, char *errmsg
);
23 void authenticate(void)
26 struct nwio_tcpconf tcpconf
;
27 struct hostent
*hostent
;
30 /* Let's lookup the hostname for the connection. */
31 result
= ioctl (0, NWIOGTCPCONF
, &tcpconf
);
34 fprintf(stderr
, "%s: ioctl(NWIOTCPCONF): %s\r\n",
35 prog_name
, strerror(errno
));
38 hostent
= gethostbyaddr((char *)&tcpconf
.nwtc_remaddr
,
39 sizeof(tcpconf
.nwtc_remaddr
), AF_INET
);
42 strncpy(hostname
, hostent
->h_name
, sizeof(hostname
)-1);
43 hostname
[sizeof(hostname
)-1]= '\0';
47 strcpy(hostname
, inet_ntoa(tcpconf
.nwtc_remaddr
));
52 getstr(&c
, 1, "protocol violation");
53 getstr(rusername
, sizeof(rusername
), "remuser too long");
54 getstr(lusername
, sizeof(lusername
), "locuser too long");
55 strcpy(term
, "TERM=");
56 getstr(term
+5, sizeof(term
)-5, "Terminal type too long");
59 fprintf(stderr
, "got lu= %s, ru= %s, te= %s\r\n", lusername
, rusername
,
62 if (iruserok(tcpconf
.nwtc_remaddr
, 0, rusername
, lusername
) == 0)
66 static void getstr(char *buf
, int cnt
, char *errmsg
)
73 if (read(0, &c
, 1) != 1)
74 fatal(1, "read failed", errno
);
82 void tcp_urg(int fd
, int on
)
84 struct nwio_tcpopt tcpopt
;
86 tcpopt
.nwto_flags
= on
? (NWTO_BSD_URG
| NWTO_SND_URG
) : NWTO_SND_NOTURG
;
87 if (ioctl(1, NWIOSTCPOPT
, &tcpopt
) == -1)
89 fprintf(stderr
, "rlogind: NWIOSTCPOPT failed: %s\r\n",