[or-cvs] r17126: {torvm} Complete DHCP fixes including mimicry of hostname and renew (in torvm/trunk/build: kamikaze/patches win32/src/torvm-w32)
coderman at seul.org
coderman at seul.org
Thu Oct 16 04:21:30 UTC 2008
Author: coderman
Date: 2008-10-16 00:21:28 -0400 (Thu, 16 Oct 2008)
New Revision: 17126
Modified:
torvm/trunk/build/kamikaze/patches/001-kamikaze-tor-package.patch
torvm/trunk/build/kamikaze/patches/002-kamikaze-mod-basefiles.patch
torvm/trunk/build/win32/src/torvm-w32/registry.h
torvm/trunk/build/win32/src/torvm-w32/torvm.c
Log:
Complete DHCP fixes including mimicry of hostname and renew with requested IP.
Modified: torvm/trunk/build/kamikaze/patches/001-kamikaze-tor-package.patch
===================================================================
--- torvm/trunk/build/kamikaze/patches/001-kamikaze-tor-package.patch 2008-10-16 03:23:00 UTC (rev 17125)
+++ torvm/trunk/build/kamikaze/patches/001-kamikaze-tor-package.patch 2008-10-16 04:21:28 UTC (rev 17126)
@@ -115,8 +115,8 @@
+$(eval $(call BuildPackage,tor))
diff -Naur orig-kamikaze/package/tor/files/tor.init mod-torpkg-kamikaze/package/tor/files/tor.init
--- orig-kamikaze/package/tor/files/tor.init 1970-01-01 00:00:00.000000000 +0000
-+++ mod-torpkg-kamikaze/package/tor/files/tor.init 2008-10-16 01:08:41.832711721 +0000
-@@ -0,0 +1,112 @@
++++ mod-torpkg-kamikaze/package/tor/files/tor.init 2008-10-16 03:58:30.534196384 +0000
+@@ -0,0 +1,113 @@
+#!/bin/sh
+
+BIN=tor
@@ -171,6 +171,7 @@
+ echo "ControlListenAddress ${CTLSOCK}" >> $TMP_F; \
+ mv -f $TMP_F $CONF_F; \
+ fi;
++ chown $RUN_USER:$RUN_GROUP $CONF_F
+ # start tor process
+ $BIN -f $CONF_F $OPTIONS > $SLOG_F 2>&1
+ # TODO for now used fixed control port accept rule
Modified: torvm/trunk/build/kamikaze/patches/002-kamikaze-mod-basefiles.patch
===================================================================
--- torvm/trunk/build/kamikaze/patches/002-kamikaze-mod-basefiles.patch 2008-10-16 03:23:00 UTC (rev 17125)
+++ torvm/trunk/build/kamikaze/patches/002-kamikaze-mod-basefiles.patch 2008-10-16 04:21:28 UTC (rev 17126)
@@ -970,8 +970,8 @@
-dest ram /tmp
diff -Naur orig-kamikaze/package/base-files/files/etc/preinit mod-basefiles-kamikaze/package/base-files/files/etc/preinit
--- orig-kamikaze/package/base-files/files/etc/preinit 2008-04-23 16:20:46.084166000 +0000
-+++ mod-basefiles-kamikaze/package/base-files/files/etc/preinit 2008-10-05 13:37:29.995981748 +0000
-@@ -1,92 +1,174 @@
++++ mod-basefiles-kamikaze/package/base-files/files/etc/preinit 2008-10-16 03:56:25.281916765 +0000
+@@ -1,92 +1,194 @@
#!/bin/sh
-# Copyright (C) 2006 OpenWrt.org
+# Copyright (C) 2008 The Tor Project, Inc.
@@ -1120,6 +1120,11 @@
+fi
+echo $TZ > /etc/TZ
+
++echo $ARGS | grep ' NOINIT' >/dev/null 2>&1
++if [ $? -eq 0 ]; then
++ echo 'tty1::askfirst:/bin/ash --login' >> /etc/inittab
++else
++
+PRIVIP=10.99.11.1
+echo $ARGS | grep ' PRIVIP=' >/dev/null 2>&1
+if [ $? -eq 0 ]; then
@@ -1145,16 +1150,28 @@
+netup=0
+echo $ARGS | grep ' IP=' >/dev/null 2>&1
+if [ $? -eq 0 ]; then
++ LEASE=""
++ DHCPSVR=""
++ DHCPNAME=""
+ IP=`echo $ARGS | sed 's/.* IP=//' | sed 's/ .*//'`
+ MASK=`echo $ARGS | sed 's/.* MASK=//' | sed 's/ .*//'`
+ GW=`echo $ARGS | sed 's/.* GW=//' | sed 's/ .*//'`
+ MAC=`echo $ARGS | sed 's/.* MAC=//' | sed 's/ .*//'`
+ MTU=`echo $ARGS | sed 's/.* MTU=//' | sed 's/ .*//'`
++ ISDHCP=0
+ dn "Setting IP $IP / $MASK via $GW ..."
+ ifconfig eth0 hw ether $MAC
+ ifconfig eth0 $IP netmask $MASK up
+ ifconfig eth0 mtu $MTU
+ route add default gw $GW
++ echo $ARGS | grep ' ISDHCP ' >/dev/null 2>&1
++ if [ $? -eq 0 ]; then
++ ISDHCP=1
++ DHCPSVR=`echo $ARGS | sed 's/.* DHCPSVR=//' | sed 's/ .*//'`
++ DHCPNAME=`echo $ARGS | sed 's/.* DHCPNAME=//' | sed 's/ .*//'`
++ # fire up udhcpc to keep the lease active for however long is needed
++ udhcpc -b -h $DHCPNAME -r $IP -i eth0 -p /var/run/dhcp.eth0.pid >/dev/null 2>&1 &
++ fi
+ netup=1
+else
+ # dhcp for address
@@ -1175,6 +1192,21 @@
+ # XXX MRP enforce MTU under 1500 to work around winpcap issue until resolved
+ ifconfig eth0 mtu 1482
+fi
++
++if [ $netup -eq 0 ]; then
++ echo " FAILED."
++ d "ERROR: Unable to get an IP address."
++ d "Check your DHCP server or configure one manually with ifconfig."
++ d "Remember to start Tor via /etc/init.d/tor start when ready."
++else
++ echo " done."
++ dn "Starting tor ... "
++ /etc/init.d/tor start
++ echo "done."
++ echo
++ d "Run /etc/init.d/tor status"
++ d " for bootstrap status."
++fi
-echo "- preinit -"
-trap 'FAILSAFE=true' USR1
@@ -1199,19 +1231,7 @@
-
- killall hotplug2
- exec /sbin/init
-+if [ $netup -eq 0 ]; then
-+ echo " FAILED."
-+ d "ERROR: Unable to get an IP address."
-+ d "Check your DHCP server or configure one manually with ifconfig."
-+ d "Remember to start Tor via /etc/init.d/tor start when ready."
-+else
-+ echo " done."
-+ dn "Starting tor ... "
-+ /etc/init.d/tor start
-+ echo "done."
-+ echo
-+ d "Run /etc/init.d/tor status"
-+ d " for bootstrap status."
++# end if !NOINIT
fi
diff -Naur orig-kamikaze/package/base-files/files/etc/rc.common mod-basefiles-kamikaze/package/base-files/files/etc/rc.common
--- orig-kamikaze/package/base-files/files/etc/rc.common 2008-01-25 10:59:40.292163000 +0000
Modified: torvm/trunk/build/win32/src/torvm-w32/registry.h
===================================================================
--- torvm/trunk/build/win32/src/torvm-w32/registry.h 2008-10-16 03:23:00 UTC (rev 17125)
+++ torvm/trunk/build/win32/src/torvm-w32/registry.h 2008-10-16 04:21:28 UTC (rev 17126)
@@ -12,7 +12,8 @@
#define NETWORK_CLIENTS_KEY "SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E973-E325-11CE-BFC1-08002BE10318}"
#define NETWORK_SERVICES_KEY "SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E974-E325-11CE-BFC1-08002BE10318}"
#define NETWORK_PROTOCOLS_KEY "SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E975-E325-11CE-BFC1-08002BE10318}"
-#define TCPIP_KEY "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces"
+#define TCPIP_PARM_KEY "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters"
+#define TCPIP_INTF_KEY "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces"
#define SERVICES_KEY "SYSTEM\\CurrentControlSet\\Services"
#define REG_NAME_MAX 256
Modified: torvm/trunk/build/win32/src/torvm-w32/torvm.c
===================================================================
--- torvm/trunk/build/win32/src/torvm-w32/torvm.c 2008-10-16 03:23:00 UTC (rev 17125)
+++ torvm/trunk/build/win32/src/torvm-w32/torvm.c 2008-10-16 04:21:28 UTC (rev 17126)
@@ -44,6 +44,7 @@
LPTSTR netmask;
LPTSTR gateway;
LPTSTR dhcpsvr;
+ LPTSTR dhcpname;
LPTSTR driver;
struct s_rconnelem * next;
};
@@ -1095,7 +1096,7 @@
snprintf(tcpip_string,
sizeof(tcpip_string),
"%s\\%s",
- TCPIP_KEY, enum_name);
+ TCPIP_INTF_KEY, enum_name);
status = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
tcpip_string,
0,
@@ -1161,8 +1162,30 @@
ce->dhcpsvr = strdup(name_data);
ldebug ("Connection %s dhcp server: %s.", ce->name, ce->dhcpsvr);
}
+ RegCloseKey (tkey);
+ status = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
+ TCPIP_PARM_KEY,
+ 0,
+ KEY_READ,
+ &tkey);
+ if (status == ERROR_SUCCESS) {
+ len = sizeof (name_data);
+ status = RegQueryValueEx(tkey,
+ "Hostname",
+ NULL,
+ &name_type,
+ name_data,
+ &len);
+ if (status == ERROR_SUCCESS) {
+ ce->dhcpname = strdup(name_data);
+ ldebug ("Connection %s using dhcp hostname: %s", ce->name, ce->dhcpname);
+ }
+ RegCloseKey (tkey);
+ }
}
- RegCloseKey (tkey);
+ else {
+ RegCloseKey (tkey);
+ }
}
}
}
@@ -1377,14 +1400,14 @@
}
else {
snprintf (*cmdline, 4095,
- "%s IP=%s MASK=%s GW=%s MAC=%s MTU=1480 PRIVIP=10.10.10.1 ISDHCP DHCPSVR=%s LEASE=%d CTLSOCK=10.10.10.1:9051 HASHPW=%s",
+ "%s IP=%s MASK=%s GW=%s MAC=%s MTU=1480 PRIVIP=10.10.10.1 ISDHCP DHCPSVR=%s DHCPNAME=%s CTLSOCK=10.10.10.1:9051 HASHPW=%s",
usedebug ? dbgcmds : basecmds,
brif->ipaddr,
brif->netmask,
brif->gateway,
brif->macaddr,
brif->dhcpsvr,
- 0,
+ brif->dhcpname,
/* control port password is "password"
* TODO: use Crypto API to collect entropy for ephemeral password generation
*/
More information about the tor-commits
mailing list