1997-10-10 01:20:16 +04:00
|
|
|
/* $NetBSD: fix_options.c,v 1.3 1997/10/09 21:20:26 christos Exp $ */
|
|
|
|
|
1996-11-26 19:48:08 +03:00
|
|
|
/*
|
|
|
|
* Routine to disable IP-level socket options. This code was taken from 4.4BSD
|
|
|
|
* rlogind source, but all mistakes in it are my fault.
|
|
|
|
*
|
|
|
|
* Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
|
|
|
|
*/
|
|
|
|
|
1997-10-10 01:20:16 +04:00
|
|
|
#include <sys/cdefs.h>
|
1996-11-26 19:48:08 +03:00
|
|
|
#ifndef lint
|
1997-10-10 01:20:16 +04:00
|
|
|
#if 0
|
1996-11-26 19:48:08 +03:00
|
|
|
static char sccsid[] = "@(#) fix_options.c 1.3 94/12/28 17:42:22";
|
1997-10-10 01:20:16 +04:00
|
|
|
#else
|
|
|
|
__RCSID("$NetBSD: fix_options.c,v 1.3 1997/10/09 21:20:26 christos Exp $");
|
|
|
|
#endif
|
1996-11-26 19:48:08 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/param.h>
|
1997-10-10 01:20:16 +04:00
|
|
|
#include <sys/socket.h>
|
1996-11-26 19:48:08 +03:00
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <netdb.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <syslog.h>
|
1997-10-10 01:20:16 +04:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <unistd.h>
|
1996-11-26 19:48:08 +03:00
|
|
|
#include "tcpd.h"
|
|
|
|
|
|
|
|
/* fix_options - get rid of IP-level socket options */
|
|
|
|
|
1997-10-10 01:20:16 +04:00
|
|
|
void
|
1996-11-26 19:48:08 +03:00
|
|
|
fix_options(request)
|
|
|
|
struct request_info *request;
|
|
|
|
{
|
|
|
|
#ifdef IP_OPTIONS
|
|
|
|
unsigned char optbuf[BUFSIZ / 3], *cp;
|
|
|
|
char lbuf[BUFSIZ], *lp;
|
|
|
|
int optsize = sizeof(optbuf), ipproto;
|
|
|
|
struct protoent *ip;
|
|
|
|
int fd = request->fd;
|
1997-01-23 17:01:45 +03:00
|
|
|
int len = sizeof lbuf;
|
1996-11-26 19:48:08 +03:00
|
|
|
|
|
|
|
if ((ip = getprotobyname("ip")) != 0)
|
|
|
|
ipproto = ip->p_proto;
|
|
|
|
else
|
|
|
|
ipproto = IPPROTO_IP;
|
|
|
|
|
|
|
|
if (getsockopt(fd, ipproto, IP_OPTIONS, (char *) optbuf, &optsize) == 0
|
|
|
|
&& optsize != 0) {
|
|
|
|
lp = lbuf;
|
|
|
|
for (cp = optbuf; optsize > 0; cp++, optsize--, lp += 3)
|
1997-01-23 17:01:45 +03:00
|
|
|
len -= snprintf(lp, len, " %2.2x", *cp);
|
1996-11-26 19:48:08 +03:00
|
|
|
syslog(LOG_NOTICE,
|
|
|
|
"connect from %s with IP options (ignored):%s",
|
|
|
|
eval_client(request), lbuf);
|
|
|
|
if (setsockopt(fd, ipproto, IP_OPTIONS, (char *) 0, optsize) != 0) {
|
|
|
|
syslog(LOG_ERR, "setsockopt IP_OPTIONS NULL: %m");
|
|
|
|
clean_exit(request);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|