1: /*
2: * Routine to disable IP-level socket options. This code was taken from 4.4BSD
3: * rlogind source, but all mistakes in it are my fault.
4: *
5: * Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
6: */
7:
8: #ifndef lint
9: static char sccsid[] = "@(#) fix_options.c 1.3 94/12/28 17:42:22";
10: #endif
11:
12: #include <sys/types.h>
13: #include <sys/param.h>
14: #include <netinet/in.h>
15: #include <netdb.h>
16: #include <stdio.h>
17: #include <syslog.h>
18:
19: #include "tcpd.h"
20:
21: /* fix_options - get rid of IP-level socket options */
22:
23: fix_options(request)
24: struct request_info *request;
25: {
26: #ifdef IP_OPTIONS
27: unsigned char optbuf[BUFSIZ / 3], *cp;
28: char lbuf[BUFSIZ], *lp;
29: int optsize = sizeof(optbuf), ipproto;
30: struct protoent *ip;
31: int fd = request->fd;
32:
33: if ((ip = getprotobyname("ip")) != 0)
34: ipproto = ip->p_proto;
35: else
36: ipproto = IPPROTO_IP;
37:
38: if (getsockopt(fd, ipproto, IP_OPTIONS, (char *) optbuf, &optsize) == 0
39: && optsize != 0) {
40: lp = lbuf;
41: for (cp = optbuf; optsize > 0; cp++, optsize--, lp += 3)
42: sprintf(lp, " %2.2x", *cp);
43: syslog(LOG_NOTICE,
44: "connect from %s with IP options (ignored):%s",
45: eval_client(request), lbuf);
46: if (setsockopt(fd, ipproto, IP_OPTIONS, (char *) 0, optsize) != 0) {
47: syslog(LOG_ERR, "setsockopt IP_OPTIONS NULL: %m");
48: clean_exit(request);
49: }
50: }
51: #endif
52: }
Defined functions
Defined variables
sccsid
defined in line
9;
never used