* Wed Sep 21 2011 Paul Wouters <paul@xelerance.com> - 1.7.1.3-3

- support TUN endpoint without IP address (rhbz#706226) [Till Maas]
This commit is contained in:
Paul Wouters 2011-09-21 14:28:11 -04:00
parent 94d3533bc5
commit 47404fc914
2 changed files with 75 additions and 1 deletions

View File

@ -0,0 +1,69 @@
diff -up socat-1.7.1.3/xio-tun.c.orig socat-1.7.1.3/xio-tun.c
--- socat-1.7.1.3/xio-tun.c.orig 2011-05-19 20:25:38.654799000 +0200
+++ socat-1.7.1.3/xio-tun.c 2011-05-19 20:37:48.675627004 +0200
@@ -78,8 +78,8 @@ static int xioopen_tun(int argc, const c
char *ifaddr;
int result;
- if (argc != 2) {
- Error2("%s: wrong number of parameters (%d instead of 1)",
+ if (argc > 2 || argc < 0) {
+ Error2("%s: wrong number of parameters (%d instead of 0 or 1)",
argv[0], argc-1);
}
@@ -146,30 +146,31 @@ static int xioopen_tun(int argc, const c
}
/*--------------------- setting interface address and netmask ------------*/
- if ((ifaddr = strdup(argv[1])) == NULL) {
- Error1("strdup(\"%s\"): out of memory", argv[1]);
- return STAT_RETRYLATER;
+ if (argc == 2) {
+ if ((ifaddr = strdup(argv[1])) == NULL) {
+ Error1("strdup(\"%s\"): out of memory", argv[1]);
+ return STAT_RETRYLATER;
+ }
+ if ((result = xioparsenetwork(ifaddr, pf, &network)) != STAT_OK) {
+ /*! recover */
+ return result;
+ }
+ socket_init(pf, (union sockaddr_union *)&ifr.ifr_addr);
+ ((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr =
+ network.netaddr.ip4.sin_addr;
+ if (Ioctl(sockfd, SIOCSIFADDR, &ifr) < 0) {
+ Error4("ioctl(%d, SIOCSIFADDR, {\"%s\", \"%s\"}: %s",
+ sockfd, ifr.ifr_name, ifaddr, strerror(errno));
+ }
+ ((struct sockaddr_in *)&ifr.ifr_netmask)->sin_addr =
+ network.netmask.ip4.sin_addr;
+ if (Ioctl(sockfd, SIOCSIFNETMASK, &ifr) < 0) {
+ Error4("ioctl(%d, SIOCSIFNETMASK, {\"0x%08u\", \"%s\"}, %s",
+ sockfd, ((struct sockaddr_in *)&ifr.ifr_netmask)->sin_addr.s_addr,
+ ifaddr, strerror(errno));
+ }
+ free(ifaddr);
}
- if ((result = xioparsenetwork(ifaddr, pf, &network)) != STAT_OK) {
- /*! recover */
- return result;
- }
- socket_init(pf, (union sockaddr_union *)&ifr.ifr_addr);
- ((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr =
- network.netaddr.ip4.sin_addr;
- if (Ioctl(sockfd, SIOCSIFADDR, &ifr) < 0) {
- Error4("ioctl(%d, SIOCSIFADDR, {\"%s\", \"%s\"}: %s",
- sockfd, ifr.ifr_name, ifaddr, strerror(errno));
- }
- ((struct sockaddr_in *)&ifr.ifr_netmask)->sin_addr =
- network.netmask.ip4.sin_addr;
- if (Ioctl(sockfd, SIOCSIFNETMASK, &ifr) < 0) {
- Error4("ioctl(%d, SIOCSIFNETMASK, {\"0x%08u\", \"%s\"}, %s",
- sockfd, ((struct sockaddr_in *)&ifr.ifr_netmask)->sin_addr.s_addr,
- ifaddr, strerror(errno));
- }
- free(ifaddr);
-
/*--------------------- setting interface flags --------------------------*/
applyopts_single(&xfd->stream, opts, PH_FD);

View File

@ -1,10 +1,11 @@
Summary: Bidirectional data relay between two data channels ('netcat++')
Name: socat
Version: 1.7.1.3
Release: 2%{?dist}
Release: 3%{?dist}
License: GPLv2
Url: http://www.dest-unreach.org/%{name}
Source: http://www.dest-unreach.org/socat/download/%{name}-%{version}.tar.gz
Patch1: socat-1.7.1.3-support-ipless-tuntap.patch
Group: Applications/Internet
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: openssl-devel compat-readline5-devel ncurses-devel
@ -23,6 +24,7 @@ The compat-readline5 library is used to avoid GPLv2 vs GPLv3 issues.
%setup -q
iconv -f iso8859-1 -t utf-8 CHANGES > CHANGES.utf8
mv CHANGES.utf8 CHANGES
%patch1 -p1
%build
autoconf
@ -62,6 +64,9 @@ rm -rf %{buildroot}
%doc %{_mandir}/man1/socat.1*
%changelog
* Wed Sep 21 2011 Paul Wouters <paul@xelerance.com> - 1.7.1.3-3
- support TUN endpoint without IP address (rhbz#706226) [Till Maas]
* Wed Feb 09 2011 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.7.1.3-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild