/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Routine to disable IP-level socket options. This code was taken from 4.4BSD
* rlogind and kernel source, but all mistakes in it are my fault.
*
* Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
*/
#ifndef lint
#endif
#include <netinet/in_systm.h>
#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <syslog.h>
#ifndef IPOPT_OPTVAL
#define IPOPT_OPTVAL 0
#endif
#include "tcpd.h"
/* fix_options - get rid of IP-level socket options */
void
struct request_info *request;
{
#ifdef IP_OPTIONS
unsigned int opt;
int optlen;
else
&& optsize != 0) {
/*
* Horror! 4.[34] BSD getsockopt() prepends the first-hop destination
* address to the result IP options list when source routing options
* other IP options. Solaris 2.x getsockopt() does produce output for
* non-routing IP options, and uses the same format as BSD even when
* the space for the destination address is unused. The code below
* does the right thing with 4.[34]BSD derivatives and Solaris 2, but
* may occasionally miss source routing options on incompatible
* systems such as Linux. Their choice.
*
* Look for source routing options. Drop the connection when one is
* found. Just wiping the IP options is insufficient: we would still
* help the attacker by providing a real TCP sequence number, and the
* attacker would still be able to send packets (blind spoofing). I
* discussed this attack with Niels Provos, half a year before the
* attack was described in open mailing lists.
*
* decide how to deal with it. Resident servers should not terminate.
* However I am not prepared to make changes to internal interfaces
* on short notice.
*/
"refused connect from %s with IP source routing options",
return;
}
break;
optlen = 1;
} else {
if (optlen <= 0) /* Do not loop! */
break;
}
}
"connect from %s with IP options (ignored):%s",
}
}
#endif
}