[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] r19426: {torvm} Wrap up restricted bundle user tweaks and uninstaller improv (in torvm/trunk/build: kamikaze/patches win32 win32/files win32/patches win32/src/pkg win32/src/torvm-w32)



Author: coderman
Date: 2009-05-04 08:44:12 -0400 (Mon, 04 May 2009)
New Revision: 19426

Modified:
   torvm/trunk/build/kamikaze/patches/001-kamikaze-tor-package.patch
   torvm/trunk/build/win32/Makefile
   torvm/trunk/build/win32/files/buildall.sh
   torvm/trunk/build/win32/files/uninstall.bat
   torvm/trunk/build/win32/patches/vidalia-torvm.patch
   torvm/trunk/build/win32/src/pkg/bundle.nsi
   torvm/trunk/build/win32/src/pkg/netinst.nsi
   torvm/trunk/build/win32/src/torvm-w32/apicommon.c
   torvm/trunk/build/win32/src/torvm-w32/apicommon.h
   torvm/trunk/build/win32/src/torvm-w32/creds.c
   torvm/trunk/build/win32/src/torvm-w32/creds.h
   torvm/trunk/build/win32/src/torvm-w32/torvm.c
Log:
Wrap up restricted bundle user tweaks and uninstaller improvements for last of 0.0.2 work.

Modified: torvm/trunk/build/kamikaze/patches/001-kamikaze-tor-package.patch
===================================================================
--- torvm/trunk/build/kamikaze/patches/001-kamikaze-tor-package.patch	2009-05-04 12:19:04 UTC (rev 19425)
+++ torvm/trunk/build/kamikaze/patches/001-kamikaze-tor-package.patch	2009-05-04 12:44:12 UTC (rev 19426)
@@ -1,6 +1,6 @@
 diff -Naur a/package/tor/Makefile b/package/tor/Makefile
 --- a/package/tor/Makefile	1970-01-01 00:00:00.000000000 +0000
-+++ b/package/tor/Makefile	2009-03-15 09:11:17.875237984 +0000
++++ b/package/tor/Makefile	2009-03-15 09:11:17.875237000 +0000
 @@ -0,0 +1,113 @@
 +#
 +# Copyright (C) 2008 OpenWrt.org
@@ -117,7 +117,7 @@
 +$(eval $(call BuildPackage,tor))
 diff -Naur a/package/tor/files/prio.sh b/package/tor/files/prio.sh
 --- a/package/tor/files/prio.sh	1970-01-01 00:00:00.000000000 +0000
-+++ b/package/tor/files/prio.sh	2009-03-15 04:16:44.189046680 +0000
++++ b/package/tor/files/prio.sh	2009-03-15 04:16:44.189046000 +0000
 @@ -0,0 +1,192 @@
 +#!/bin/bash
 +# Written by Marco Bonetti & Mike Perry
@@ -313,8 +313,8 @@
 +
 diff -Naur a/package/tor/files/tor.init b/package/tor/files/tor.init
 --- a/package/tor/files/tor.init	1970-01-01 00:00:00.000000000 +0000
-+++ b/package/tor/files/tor.init	2009-03-29 00:40:02.951384384 +0000
-@@ -0,0 +1,139 @@
++++ b/package/tor/files/tor.init	2009-05-03 22:36:11.026346847 +0000
+@@ -0,0 +1,159 @@
 +#!/bin/sh 
 +# make sure we check the system bin dirs
 +export PATH=/usr/sbin:/sbin:$PATH
@@ -332,11 +332,24 @@
 +RUN_USER=$BIN
 +RUN_GROUP=$BIN
 +TOR_INTF=eth0
++
 +grep eth1: /proc/net/dev >/dev/null 2>&1
 +if [ $? -eq 0 ]; then
 +  TOR_INTF=eth1
 +fi
 +MYIP=$(ifconfig $TOR_INTF | grep 'inet addr' | sed 's/.*inet addr://' | sed 's/ .*//')
++ARGS=`cat /proc/cmdline`
++ARGS="_ $ARGS _"
++echo $ARGS | grep ' CTLREADY=' >/dev/null 2>&1 
++if [ $? -eq 0 ]; then 
++  CTLREADY=$(echo $ARGS | sed 's/.* CTLREADY=//' | sed 's/ .*//') 
++fi 
++echo $ARGS | grep ' CTLSOCK=' >/dev/null 2>&1  
++if [ $? -eq 0 ]; then 
++  CTLADDR=$(echo $ARGS | sed 's/.* CTLSOCK=//' | sed 's/ .*//')
++  CTLIP=$(echo $CTLADDR | sed 's/:.*//')
++  CTLPORT=$(echo $CTLADDR | sed 's/.*://')
++fi
 +
 +if [ "$1" = "start" ]; then
 +	[ -f $DEFAULT ] && . $DEFAULT
@@ -354,8 +367,6 @@
 +	chmod 700 $RUN_D
 +	# append any runtime options as needed
 +	TMP_F="${CONF_F}_tmp"; \
-+	ARGS=`cat /proc/cmdline` ; \
-+	ARGS="_ $ARGS _" ; \
 +	echo $ARGS | grep ' FOLLOWTOR=TRUE ' >/dev/null 2>&1 ; \
 +	if [ $? -eq 0 ]; then \
 +	  FOLLOWTOR=1; \
@@ -369,9 +380,6 @@
 +	fi; \
 +	echo $ARGS | grep ' CTLSOCK=' >/dev/null 2>&1 ; \
 +	if [ $? -eq 0 ]; then \
-+	  CTLADDR=`echo $ARGS | sed 's/.* CTLSOCK=//' | sed 's/ .*//'`; \
-+	  CTLIP=`echo $CTLADDR | sed 's/:.*//'`; \
-+	  CTLPORT=`echo $CTLADDR | sed 's/.*://'`; \
 +	  cat $CONF_F | grep -v ControlListenAddress | grep -v ControlPort | grep -v SocksListenAddress | grep -v SocksPort > $TMP_F; \
 +	  echo "ControlListenAddress ${CTLADDR}" >> $TMP_F; \
 +	  echo "ControlPort ${CTLPORT}" >> $TMP_F; \
@@ -418,6 +426,7 @@
 +	$0 start
 +
 +elif [ "$1" = "dofollow" ]; then
++	nohup /etc/init.d/tor doready >/dev/null 2>&1 & 
 +	$BIN --runasdaemon 0 -f $CONF_F > $SLOG_F 2>&1
 +	if [ -f $LOG_F ]; then
 +	  # no log means we didn't really start; don't abort by default.
@@ -426,6 +435,17 @@
 +	  halt >/dev/null 2>&1
 +	fi
 +
++elif [ "$1" = "doready" ]; then
++	iptables -t nat -I PREROUTING -i $TOR_INTF -d $MYIP -p tcp --dport $CTLREADY -j DROP
++	waiting=1
++	while [ "$waiting" -eq "1" ]; do
++	  grep 'Bootstrapped 100' $LOG_F >/dev/null 2>&1
++	  if [ "$?" -eq "0" ]; then
++	    iptables -t nat -I PREROUTING -i $TOR_INTF -d $MYIP -p tcp --dport $CTLREADY -j REDIRECT --to $CTLPORT
++	    waiting=0
++          fi
++	done
++
 +elif [ "$1" = "status" ]; then
 +	while true; do
 +	  clear;echo
@@ -444,7 +464,7 @@
 +	  else
 +	  	echo "Tor is fully connected into the Tor network."
 +	  	echo "Transparent proxy traffic:"
-+	  	iptables -n --verbose -t nat --list PREROUTING | sed 's/opt .*destination.*/destination/'|sed 's/    0.0.0.0.0           //'|sed "s/\-\- .*${MYIP}   //"|grep -v PREROUTING
++	  	iptables -n --verbose -t nat --list PREROUTING | sed 's/opt .*destination.*/destination/'|sed 's/    0.0.0.0.0           //'|sed "s/\-\- .*${MYIP}   //"|grep -v PREROUTING|grep -v $CTLREADY|grep -v $CTLPORT
 +	  fi
 +	  sleep 2
 +	done  
@@ -456,8 +476,8 @@
 +exit 0
 diff -Naur a/package/tor/files/torrc b/package/tor/files/torrc
 --- a/package/tor/files/torrc	1970-01-01 00:00:00.000000000 +0000
-+++ b/package/tor/files/torrc	2009-04-04 19:53:45.195224832 +0000
-@@ -0,0 +1,21 @@
++++ b/package/tor/files/torrc	2009-05-02 20:36:18.116609117 +0000
+@@ -0,0 +1,22 @@
 +# Configuration for Tor VM
 +User tor
 +Group tor
@@ -475,6 +495,7 @@
 +
 +# options appended from command line placed below:
 +SocksPort 9050
++SocksListenAddress 0.0.0.0
 +DNSPort 9093
 +DNSListenAddress 0.0.0.0
 +TransPort 9095

Modified: torvm/trunk/build/win32/Makefile
===================================================================
--- torvm/trunk/build/win32/Makefile	2009-05-04 12:19:04 UTC (rev 19425)
+++ torvm/trunk/build/win32/Makefile	2009-05-04 12:44:12 UTC (rev 19426)
@@ -198,10 +198,10 @@
 WINDDK_URL=http://download.microsoft.com/download/9/0/f/90f019ac-8243-48d3-91cf-81fc4093ecfd/$(WINDDK_F)
 WINDDK_SUM=0d2154d88a5ee252cc908630c77863bb42777387
 
-QT_VER=4.5.0
+QT_VER=4.5.1
 QT_F=qt-all-opensource-src-$(QT_VER).tar.bz2
 QT_URL=ftp://ftp.qtsoftware.com/qt/source/$(QT_F)
-QT_SUM=51dc8c66bc0866e480e71b50a8ffe577b2937fcc
+QT_SUM=43f07468553ba14270a0dea351f549ebfd98a56a
 
 POLIPO_F=polipo-20080907.tar.gz
 POLIPO_URL=http://www.pps.jussieu.fr/~jch/software/files/polipo/$(POLIPO_F)
@@ -217,7 +217,7 @@
 VIDALIA_TGZ=$(VIDALIA_NAME).tar.gz
 VIDALIA_SVN=https://svn.vidalia-project.net/svn/vidalia/
 VIDALIA_BR=trunk
-VIDALIA_VER=3646
+VIDALIA_VER=3730
 
 # for package resources
 TORSVN_NAME=tor-latest

Modified: torvm/trunk/build/win32/files/buildall.sh
===================================================================
--- torvm/trunk/build/win32/files/buildall.sh	2009-05-04 12:19:04 UTC (rev 19425)
+++ torvm/trunk/build/win32/files/buildall.sh	2009-05-04 12:44:12 UTC (rev 19426)
@@ -122,12 +122,12 @@
   export CMAKEBIN="/$sysdrive/Program Files/CMake/bin"
   export PATH="${PATH}:${CMAKEBIN}:/src/$CMAKE_DIR/bin"
   
-  export QT_VER="4.5.0"
+  export QT_VER="4.5.1"
   export QT_DIR="qt-all-opensource-src-${QT_VER}"
   export QT_FILE="${QT_DIR}.tar.bz2"
   export QT_ROOT="/$sysdrive/Qt/${QT_VER}"
   export QT_BIN="${QT_ROOT}/bin"
-  export QTDIR="${sysdrive}:\Qt\4.5.0"
+  export QTDIR="${sysdrive}:\Qt\4.5.1"
   export QMAKESPEC=win32-g++
   export PATH="$PATH:$QT_BIN:$QTDIR\bin"
   

Modified: torvm/trunk/build/win32/files/uninstall.bat
===================================================================
--- torvm/trunk/build/win32/files/uninstall.bat	2009-05-04 12:19:04 UTC (rev 19425)
+++ torvm/trunk/build/win32/files/uninstall.bat	2009-05-04 12:44:12 UTC (rev 19426)
@@ -2,59 +2,73 @@
 IF EXIST "%USERPROFILE%\Local Settings\Application Data\Thandy\TorVM Updates" (
   cd "%USERPROFILE%\Local Settings\Application Data\Thandy\TorVM Updates"
   for %%f in (*.msi) do msiexec /x %%f /qn
-  for %%f in (*.msi) do del /F %%f
   cd ..
-  rmdir "TorVM Updates"
+  rmdir /S /Q "TorVM Updates"
 )
 IF EXIST "%USERPROFILE%\Local Settings\Application Data\Thandy\Tor Updates" (
   cd "%USERPROFILE%\Local Settings\Application Data\Thandy\Tor Updates"
   for %%f in (*.msi) do msiexec /x %%f /qn
-  for %%f in (*.msi) do del /F %%f
   cd ..
-  rmdir "Tor Updates"
+  rmdir /S /Q "Tor Updates"
 )
 IF EXIST "%USERPROFILE%\Local Settings\Application Data\Thandy\Polipo Updates" (
   cd "%USERPROFILE%\Local Settings\Application Data\Thandy\Polipo Updates"
   for %%f in (*.msi) do msiexec /x %%f /qn
-  for %%f in (*.msi) do del /F %%f
   cd ..
-  rmdir "Polipo Updates"
+  rmdir /S /Q "Polipo Updates"
 )
 IF EXIST "%USERPROFILE%\Local Settings\Application Data\Thandy\TorButton Updates" (
   cd "%USERPROFILE%\Local Settings\Application Data\Thandy\TorButton Updates"
   for %%f in (*.msi) do msiexec /x %%f /qn
-  for %%f in (*.msi) do del /F %%f
   cd ..
-  rmdir "TorButton Updates"
+  rmdir /S /Q "TorButton Updates"
 )
 IF EXIST "%USERPROFILE%\Local Settings\Application Data\Thandy\Vidalia Updates" (
   cd "%USERPROFILE%\Local Settings\Application Data\Thandy\Vidalia Updates"
   for %%f in (*.msi) do msiexec /x %%f /qn
-  for %%f in (*.msi) do del /F %%f
   cd ..
-  rmdir "Vidalia Updates"
+  rmdir /S /Q "Vidalia Updates"
 )
 IF EXIST "%USERPROFILE%\Local Settings\Application Data\Thandy\Vidalia Marble Updates" (
   cd "%USERPROFILE%\Local Settings\Application Data\Thandy\Vidalia Marble Updates"
   for %%f in (*.msi) do msiexec /x %%f /qn
-  for %%f in (*.msi) do del /F %%f
   cd ..
-  rmdir "Vidalia Marble Updates"
+  rmdir /S /Q "Vidalia Marble Updates"
 )
 IF EXIST %PROGRAMFILES%\TorInstPkgs (
   cd %PROGRAMFILES%\TorInstPkgs
   for %%f in (*.msi) do msiexec /x %%f /qn
-  for %%f in (*.msi) do del /F %%f
   cd ..
-  rmdir TorInstPkgs
+  rmdir /S /Q TorInstPkgs
 )
 IF EXIST "%USERPROFILE%\Local Settings\Application Data\TorInstPkgs" (
   cd "%USERPROFILE%\Local Settings\Application Data\TorInstPkgs"
   for %%f in (*.msi) do msiexec /x %%f /qn
-  for %%f in (*.msi) do del /F %%f
   cd ..
-  rmdir TorInstPkgs
+  rmdir /S /Q TorInstPkgs
 )
+IF EXIST "%USERPROFILE%\Local Settings\Application Data\Programs\Polipo" (
+  rmdir /S /Q "%USERPROFILE%\Local Settings\Application Data\Programs\Polipo"
+)
+IF EXIST "%USERPROFILE%\Local Settings\Application Data\Programs\Thandy" (
+  rmdir /S /Q "%USERPROFILE%\Local Settings\Application Data\Programs\Thandy"
+)
+IF EXIST "%USERPROFILE%\Local Settings\Application Data\Programs\Vidalia" (
+  rmdir /S /Q "%USERPROFILE%\Local Settings\Application Data\Programs\Vidalia"
+)
+IF EXIST "%USERPROFILE%\Local Settings\Application Data\Programs\Tor License" (
+  rmdir /S /Q "%USERPROFILE%\Local Settings\Application Data\Programs\Tor License"
+)
+IF EXIST "%SYSTEMDRIVE%\Documents and Settings\Tor" (
+  net user Tor /DELETE
+  rmdir /S /Q "%SYSTEMDRIVE%\Documents and Settings\Tor"
+)
+IF EXIST "%ALLUSERSPROFILE%\Application Data\Microsoft\User Account Pictures\Tor.bmp" (
+  rmdir /S /Q "%ALLUSERSPROFILE%\Application Data\Microsoft\User Account Pictures\Tor.bmp"
+)
+IF EXIST "%PROGRAMFILES%\Tor VM" (
+  rmdir /S /Q "%PROGRAMFILES%\Tor VM"
+)
 IF EXIST "%USERPROFILE%\Desktop\Uninstall_Tor.bat" (
   del /F "%USERPROFILE%\Desktop\Uninstall_Tor.bat"
 )

Modified: torvm/trunk/build/win32/patches/vidalia-torvm.patch
===================================================================
--- torvm/trunk/build/win32/patches/vidalia-torvm.patch	2009-05-04 12:19:04 UTC (rev 19425)
+++ torvm/trunk/build/win32/patches/vidalia-torvm.patch	2009-05-04 12:44:12 UTC (rev 19426)
@@ -1,25 +1,6 @@
-diff -Naur a/CMakeLists.txt b/CMakeLists.txt
---- a/CMakeLists.txt	2009-03-22 02:22:05.164345000 +0000
-+++ b/CMakeLists.txt	2009-03-15 06:58:51.000000000 +0000
-@@ -1,5 +1,5 @@
- ##
--##  $Id: CMakeLists.txt 3640 2009-03-22 02:22:05Z edmanm $
-+##  $Id: CMakeLists.txt 3598 2009-03-04 23:38:18Z edmanm $
- ## 
- ##  This file is part of Vidalia, and is subject to the license terms in the
- ##  LICENSE file, found in the top level directory of this distribution. If 
-@@ -104,6 +104,8 @@
- ## Check for system header files
- check_include_file("limits.h" HAVE_LIMITS_H)
- check_include_file("sys/limits.h" HAVE_SYS_LIMITS_H)
-+check_include_file("math.h"  HAVE_MATH_H)
-+check_include_file_cxx("cmath" HAVE_CMATH)
- 
- ## Check for the sizes of various data types
- check_type_size(int SIZEOF_INT)
 diff -Naur a/pkg/win32/polipo.conf b/pkg/win32/polipo.conf
 --- a/pkg/win32/polipo.conf	2008-04-06 00:00:07.066809000 +0000
-+++ b/pkg/win32/polipo.conf	2009-03-07 12:47:21.000000000 +0000
++++ b/pkg/win32/polipo.conf	2009-05-04 08:16:00.566347824 +0000
 @@ -35,7 +35,6 @@
  # parentProxy = "squid.example.org:3128"
  
@@ -50,7 +31,7 @@
  ### HTTP
 diff -Naur a/pkg/win32/vidalia.wxs.in b/pkg/win32/vidalia.wxs.in
 --- a/pkg/win32/vidalia.wxs.in	2009-03-21 04:03:31.345626000 +0000
-+++ b/pkg/win32/vidalia.wxs.in	2009-03-30 00:08:08.452635944 +0000
++++ b/pkg/win32/vidalia.wxs.in	2009-05-04 08:16:00.602521595 +0000
 @@ -1,345 +1,371 @@
  <?xml version="1.0" encoding="Windows-1252" ?>
  <!-- 
@@ -685,7 +666,7 @@
  </Wix>
 diff -Naur a/src/common/win32.cpp b/src/common/win32.cpp
 --- a/src/common/win32.cpp	2009-02-16 22:53:13.437184000 +0000
-+++ b/src/common/win32.cpp	2009-03-07 03:57:41.000000000 +0000
++++ b/src/common/win32.cpp	2009-05-04 08:16:00.610349670 +0000
 @@ -67,16 +67,20 @@
  QString
  win32_program_files_folder()
@@ -713,7 +694,7 @@
  /** Returns the value in keyName at keyLocation. 
 diff -Naur a/src/torcontrol/torcontrol.cpp b/src/torcontrol/torcontrol.cpp
 --- a/src/torcontrol/torcontrol.cpp	2009-02-24 03:20:58.105033000 +0000
-+++ b/src/torcontrol/torcontrol.cpp	2009-03-25 13:27:02.000000000 +0000
++++ b/src/torcontrol/torcontrol.cpp	2009-05-04 08:16:00.634352824 +0000
 @@ -57,6 +57,12 @@
  /** Default destructor */
  TorControl::~TorControl()
@@ -811,7 +792,7 @@
      return _controlConn->send(cmd, errmsg);
 diff -Naur a/src/vidalia/config/torsettings.cpp b/src/vidalia/config/torsettings.cpp
 --- a/src/vidalia/config/torsettings.cpp	2009-01-30 05:20:24.536180000 +0000
-+++ b/src/vidalia/config/torsettings.cpp	2009-03-16 10:58:45.000000000 +0000
++++ b/src/vidalia/config/torsettings.cpp	2009-05-04 08:16:00.642352223 +0000
 @@ -61,16 +61,28 @@
  {
  #if defined(Q_OS_WIN32)
@@ -888,7 +869,7 @@
  
 diff -Naur a/src/vidalia/config/vidaliasettings.cpp b/src/vidalia/config/vidaliasettings.cpp
 --- a/src/vidalia/config/vidaliasettings.cpp	2009-02-03 02:09:39.844750000 +0000
-+++ b/src/vidalia/config/vidaliasettings.cpp	2009-03-07 03:57:41.000000000 +0000
++++ b/src/vidalia/config/vidaliasettings.cpp	2009-05-04 08:16:00.658349562 +0000
 @@ -71,9 +71,16 @@
    setDefault(SETTING_SHOW_MAINWINDOW_AT_START, true);
    setDefault(SETTING_BROWSER_EXECUTABLE, "");
@@ -911,7 +892,7 @@
  #else
 diff -Naur a/src/vidalia/mainwindow.cpp b/src/vidalia/mainwindow.cpp
 --- a/src/vidalia/mainwindow.cpp	2009-02-23 01:36:04.102244000 +0000
-+++ b/src/vidalia/mainwindow.cpp	2009-03-16 10:42:36.000000000 +0000
++++ b/src/vidalia/mainwindow.cpp	2009-05-04 08:16:00.694347004 +0000
 @@ -127,6 +127,7 @@
    createTrayIcon();
    /* Start with Tor initially stopped */
@@ -987,7 +968,7 @@
    if (server.isServerEnabled() && !_delayedShutdownStarted) {
 diff -Naur a/src/vidalia/mainwindow.h b/src/vidalia/mainwindow.h
 --- a/src/vidalia/mainwindow.h	2009-02-03 02:09:39.844750000 +0000
-+++ b/src/vidalia/mainwindow.h	2009-03-16 10:33:26.000000000 +0000
++++ b/src/vidalia/mainwindow.h	2009-05-04 08:16:00.702348291 +0000
 @@ -241,6 +241,7 @@
    bool _useSavedPassword;
    /** The Vidalia icon that sits in the tray. */
@@ -997,9 +978,9 @@
  #if defined(USE_AUTOUPDATE)
    /** Timer used to remind us to check for software updates. */
 diff -Naur a/src/vidalia/network/geoipresolver.cpp b/src/vidalia/network/geoipresolver.cpp
---- a/src/vidalia/network/geoipresolver.cpp	2008-12-30 18:48:55.745877000 +0000
-+++ b/src/vidalia/network/geoipresolver.cpp	2009-03-13 16:51:51.000000000 +0000
-@@ -24,25 +24,31 @@
+--- a/src/vidalia/network/geoipresolver.cpp	2009-04-19 20:55:52.106192000 +0000
++++ b/src/vidalia/network/geoipresolver.cpp	2009-05-04 08:19:22.450335176 +0000
+@@ -24,19 +24,19 @@
  #endif
  
  /** Host for the geo ip information. */ 
@@ -1012,7 +993,7 @@
 +#define GEOIP_SSL_PORT  443
  /** Page that we request the geo ip information from. */
 -#define GEOIP_PAGE    "/cgi-bin/geoip"
-+#define GEOIP_PAGE    "/geoip"
++#define GEOIP_PAGE    "geoip"
  
  
  /** Default constructor. */
@@ -1021,24 +1002,11 @@
 -  _socksAddr = QHostAddress::LocalHost;
 +  _socksAddr = Vidalia::torAddress();
    _socksPort = 9050;
- 
- #if defined(USE_QSSLSOCKET)
-   QSslSocket::setDefaultCaCertificates(QList<QSslCertificate>());
-   if (! QSslSocket::addDefaultCaCertificates(":/geoip/cacert_root.crt"))
--    vWarn("Failed to add the GeoIP CA certificate to the default CA "
-+    vWarn("Failed to add the CACert root certificate to the default CA "
-+          "certificate database.");
-+  if (! QSslSocket::addDefaultCaCertificates(":/geoip/gd-class2-root.crt"))
-+    vWarn("Failed to add the GoDaddy Class2 root certificate to the default CA "
-+          "certificate database.");
-+  if (! QSslSocket::addDefaultCaCertificates(":/geoip/entrust-secure-server-root.crt"))
-+    vWarn("Failed to add the Entrust Secure Server root certificate to the default CA "
-           "certificate database.");
- #endif
  }
+ 
 diff -Naur a/src/vidalia/network/tormapwidget.cpp b/src/vidalia/network/tormapwidget.cpp
 --- a/src/vidalia/network/tormapwidget.cpp	2009-03-23 16:21:12.057893000 +0000
-+++ b/src/vidalia/network/tormapwidget.cpp	2009-03-07 03:57:41.000000000 +0000
++++ b/src/vidalia/network/tormapwidget.cpp	2009-05-04 08:16:00.726349547 +0000
 @@ -10,7 +10,7 @@
  
  /*
@@ -1063,7 +1031,7 @@
    TorMapWidgetPopupMenu *popupMenu  = new TorMapWidgetPopupMenu(this);
 diff -Naur a/src/vidalia/res/entrust-secure-server-root.crt b/src/vidalia/res/entrust-secure-server-root.crt
 --- a/src/vidalia/res/entrust-secure-server-root.crt	1970-01-01 00:00:00.000000000 +0000
-+++ b/src/vidalia/res/entrust-secure-server-root.crt	2009-03-07 03:57:41.000000000 +0000
++++ b/src/vidalia/res/entrust-secure-server-root.crt	2009-05-04 08:16:00.726349547 +0000
 @@ -0,0 +1,30 @@
 +-----BEGIN CERTIFICATE-----
 +MIIE2DCCBEGgAwIBAgIEN0rSQzANBgkqhkiG9w0BAQUFADCBwzELMAkGA1UE
@@ -1097,7 +1065,7 @@
 +-----END CERTIFICATE-----
 diff -Naur a/src/vidalia/res/gd-class2-root.crt b/src/vidalia/res/gd-class2-root.crt
 --- a/src/vidalia/res/gd-class2-root.crt	1970-01-01 00:00:00.000000000 +0000
-+++ b/src/vidalia/res/gd-class2-root.crt	2009-03-07 03:57:41.000000000 +0000
++++ b/src/vidalia/res/gd-class2-root.crt	2009-05-04 08:16:00.726349547 +0000
 @@ -0,0 +1,24 @@
 +-----BEGIN CERTIFICATE-----
 +MIIEADCCAuigAwIBAgIBADANBgkqhkiG9w0BAQUFADBjMQswCQYDVQQGEwJVUzEh
@@ -1124,19 +1092,18 @@
 +ReYNnyicsbkqWletNw+vHX/bvZ8=
 +-----END CERTIFICATE-----
 diff -Naur a/src/vidalia/res/vidalia.qrc b/src/vidalia/res/vidalia.qrc
---- a/src/vidalia/res/vidalia.qrc	2009-02-01 00:34:33.066938000 +0000
-+++ b/src/vidalia/res/vidalia.qrc	2009-03-07 03:57:41.000000000 +0000
-@@ -290,5 +290,7 @@
-     </qresource>
-     <qresource prefix="/geoip">
+--- a/src/vidalia/res/vidalia.qrc	2009-04-19 20:55:52.106192000 +0000
++++ b/src/vidalia/res/vidalia.qrc	2009-05-04 08:22:03.890347049 +0000
+@@ -291,5 +291,6 @@
+     <qresource prefix="/pki">
          <file>cacert_root.crt</file>
+         <file>EntrustSecureServerCA.crt</file>
 +        <file>gd-class2-root.crt</file>
-+        <file>entrust-secure-server-root.crt</file>
      </qresource>
  </RCC>
 diff -Naur a/src/vidalia/updateprocess.cpp b/src/vidalia/updateprocess.cpp
 --- a/src/vidalia/updateprocess.cpp	2009-03-12 05:06:19.591518000 +0000
-+++ b/src/vidalia/updateprocess.cpp	2009-03-07 03:57:41.000000000 +0000
++++ b/src/vidalia/updateprocess.cpp	2009-05-04 08:16:00.742348688 +0000
 @@ -39,8 +39,7 @@
  {
    QStringList args;
@@ -1173,9 +1140,9 @@
  
  QString
 diff -Naur a/src/vidalia/vidalia.cpp b/src/vidalia/vidalia.cpp
---- a/src/vidalia/vidalia.cpp	2009-02-24 04:56:35.504853000 +0000
-+++ b/src/vidalia/vidalia.cpp	2009-03-13 18:43:07.000000000 +0000
-@@ -45,6 +45,7 @@
+--- a/src/vidalia/vidalia.cpp	2009-04-19 20:55:52.106192000 +0000
++++ b/src/vidalia/vidalia.cpp	2009-05-04 08:24:57.787200131 +0000
+@@ -48,6 +48,7 @@
  #define ARG_PIDFILE    "pidfile"  /**< Location and name of our pidfile.*/
  #define ARG_LOGFILE    "logfile"  /**< Location of our logfile.         */
  #define ARG_LOGLEVEL   "loglevel" /**< Log verbosity.                   */
@@ -1183,7 +1150,7 @@
  #define ARG_READ_PASSWORD_FROM_STDIN  \
    "read-password-from-stdin" /**< Read password from stdin. */
  
-@@ -55,6 +56,7 @@
+@@ -58,6 +59,7 @@
  TorControl* Vidalia::_torControl = 0;  /**< Main TorControl object.          */
  Log Vidalia::_log;
  QList<QTranslator *> Vidalia::_translators;
@@ -1191,7 +1158,7 @@
  
  /** Catches debugging messages from Qt and sends them to Vidalia's logs. If Qt
   * emits a QtFatalMsg, we will write the message to the log and then abort().
-@@ -89,6 +91,11 @@
+@@ -92,6 +94,11 @@
  Vidalia::Vidalia(QStringList args, int &argc, char **argv)
  : QApplication(argc, argv)
  {
@@ -1203,18 +1170,21 @@
    qInstallMsgHandler(qt_msg_handler);
  
    /* Read in all our command-line arguments. */
-@@ -120,17 +127,16 @@
+@@ -123,6 +130,9 @@
    /* Set the GUI style appropriately. */
    setStyle(_args.value(ARG_GUISTYLE));
  
-+  if (_args.contains(ARG_TORADDR))
++  if (_args.contains(ARG_TORADDR)) 
 +    _torAddress = QHostAddress(_args.value(ARG_TORADDR));
 +
    /* Creates a TorControl object, used to talk to Tor. */
    _torControl = new TorControl();
  
+@@ -131,13 +141,8 @@
+   loadDefaultCaCertificates();
+ 
  #ifdef USE_MARBLE
-   /* Tell Marble where to stash its generated data */
+-  /* Tell Marble where to stash its generated data */
 -  Marble::MarbleDirs::setMarbleDataPath(dataDirectory());
 -
 -#ifdef Q_OS_WIN32
@@ -1226,7 +1196,7 @@
  #endif
  }
  
-@@ -346,6 +352,13 @@
+@@ -353,6 +358,13 @@
  #endif
  }
  
@@ -1240,9 +1210,19 @@
  /** Returns the location of Vidalia's pid file. */
  QString
  Vidalia::pidFile()
+@@ -499,6 +511,9 @@
+     vWarn("Failed to add the Entrust Secure Server CA certificate to the "
+           "default CA certificate database.");
+ 
++  if (! QSslSocket::addDefaultCaCertificates(":/pki/gd-class2-root.crt"))
++    vWarn("Failed to add the GoDaddy Class2 CA certificate to the default CA "
++          "certificate database.");
+ #endif
+ }
+ 
 diff -Naur a/src/vidalia/vidalia.h b/src/vidalia/vidalia.h
---- a/src/vidalia/vidalia.h	2009-01-12 03:33:41.473092000 +0000
-+++ b/src/vidalia/vidalia.h	2009-03-13 18:42:45.000000000 +0000
+--- a/src/vidalia/vidalia.h	2009-04-19 20:55:52.106192000 +0000
++++ b/src/vidalia/vidalia.h	2009-05-04 08:16:00.754340645 +0000
 @@ -82,6 +82,8 @@
    static QString dataDirectory();
    /** Returns the default location of Vidalia's data directory. */
@@ -1252,7 +1232,7 @@
    
    /** Returns the location of Vidalia's pid file. */
    static QString pidFile();
-@@ -156,6 +158,7 @@
+@@ -163,6 +165,7 @@
    static TorControl* _torControl;      /**< Vidalia's main TorControl object.*/
    static Log _log; /**< Logs debugging messages to file or stdout. */
    static QList<QTranslator *> _translators; /**< List of installed translators. */

Modified: torvm/trunk/build/win32/src/pkg/bundle.nsi
===================================================================
--- torvm/trunk/build/win32/src/pkg/bundle.nsi	2009-05-04 12:19:04 UTC (rev 19425)
+++ torvm/trunk/build/win32/src/pkg/bundle.nsi	2009-05-04 12:44:12 UTC (rev 19426)
@@ -53,7 +53,6 @@
 	ExecWait 'msiexec /i "$INSTDIR\vidalia.msi" NOSC=1 /qn'
 	ExecWait 'msiexec /i "$INSTDIR\thandy.msi" NOSC=1 /qn'
 	ExecWait 'msiexec /i "$INSTDIR\polipo.msi" NOSC=1 /qn'
-	ExecWait 'msiexec /i "$INSTDIR\torbutton.msi" /qn'
 	ExecWait 'msiexec /i "$INSTDIR\license.msi" NOSC=1 /qn'
         SetOutPath $DESKTOP
         File "Uninstall_Tor.bat"

Modified: torvm/trunk/build/win32/src/pkg/netinst.nsi
===================================================================
--- torvm/trunk/build/win32/src/pkg/netinst.nsi	2009-05-04 12:19:04 UTC (rev 19425)
+++ torvm/trunk/build/win32/src/pkg/netinst.nsi	2009-05-04 12:44:12 UTC (rev 19426)
@@ -53,7 +53,6 @@
 	ExecWait '"$LOCALAPPDATA\Programs\Thandy\thandy.exe" update "--repo=$LOCALAPPDATA\Thandy\Vidalia Updates" /bundleinfo/vidalia/win32/'
 	ExecWait '"$LOCALAPPDATA\Programs\Thandy\thandy.exe" update --install "--repo=$LOCALAPPDATA\Thandy\TorVM Updates" /bundleinfo/torvm/win32/'
 	ExecWait '"$LOCALAPPDATA\Programs\Thandy\thandy.exe" update --install "--repo=$LOCALAPPDATA\Thandy\Polipo Updates" /bundleinfo/polipo/win32/'
-	ExecWait '"$LOCALAPPDATA\Programs\Thandy\thandy.exe" update --install "--repo=$LOCALAPPDATA\Thandy\TorButton Updates" /bundleinfo/torbutton/win32/'
 	ExecWait '"$LOCALAPPDATA\Programs\Thandy\thandy.exe" update --install "--repo=$LOCALAPPDATA\Thandy\Vidalia Updates" /bundleinfo/vidalia/win32/'
         SetOutPath $DESKTOP
         File "Uninstall_Tor.bat"

Modified: torvm/trunk/build/win32/src/torvm-w32/apicommon.c
===================================================================
--- torvm/trunk/build/win32/src/torvm-w32/apicommon.c	2009-05-04 12:19:04 UTC (rev 19425)
+++ torvm/trunk/build/win32/src/torvm-w32/apicommon.c	2009-05-04 12:44:12 UTC (rev 19426)
@@ -295,18 +295,39 @@
 { 
   STARTUPINFO si;
   PROCESS_INFORMATION pi;
+  SECURITY_ATTRIBUTES sattr;
+  HANDLE stdin_rd;
+  HANDLE stdin_wr;
+  HANDLE stdout_rd;
+  HANDLE stdout_wr;
   DWORD exitcode;
   DWORD opts = CREATE_NEW_PROCESS_GROUP;
+  DWORD bufsz, numread;
+  CHAR * buff = NULL;
    
   ZeroMemory( &pi, sizeof(pi) );
   ZeroMemory( &si, sizeof(si) );
+  ZeroMemory( &sattr, sizeof(sattr) );
   si.cb = sizeof(si);
+  sattr.nLength = sizeof(SECURITY_ATTRIBUTES);
+  sattr.bInheritHandle = TRUE;
+  sattr.lpSecurityDescriptor = NULL;
+
+  CreatePipe(&stdout_rd, &stdout_wr, &sattr, 0);
+  SetHandleInformation(stdout_rd, HANDLE_FLAG_INHERIT, 0);
+  CreatePipe(&stdin_rd, &stdin_wr, &sattr, 0);
+  SetHandleInformation(stdin_wr, HANDLE_FLAG_INHERIT, 0);
+
+  si.hStdError = stdout_wr;
+  si.hStdOutput = stdout_wr;
+  si.hStdInput = stdin_rd;
+  si.dwFlags |= STARTF_USESTDHANDLES; 
          
   if( !CreateProcess(NULL,
                      cmd,
                      NULL,   // process handle no inherit
                      NULL,   // thread handle no inherit
-                     FALSE,  // default handle inheritance false
+                     TRUE,
                      opts,
                      NULL,   // environment block
                      dir,
@@ -315,11 +336,24 @@
     lerror ("Failed to launch process.  Error code: %d", GetLastError());
     return FALSE;
   }
+  ldebug ("runcommand started: %s", cmd);
 
+  CloseHandle(stdout_wr);
+  CloseHandle(stdin_rd);
+  CloseHandle(stdin_wr);
+
+  bufsz = 512; /* Write to log in small chunks. */
+  buff = malloc(bufsz);
   while ( GetExitCodeProcess(pi.hProcess, &exitcode) && (exitcode == STILL_ACTIVE) ) {
+    while (ReadFile(stdout_rd, buff, bufsz-1, &numread, NULL) && (numread > 0)) {
+      buff[bufsz-1] = 0;
+      ldebug ("runcommand output: %s", buff);
+    }
     Sleep (500);
   }
-  ldebug ("runcommand process %s exited with status: %d", cmd, exitcode);
+  ldebug ("runcommand process exited with status: %d", exitcode);
+  free(buff);
+  CloseHandle(stdout_rd);
   CloseHandle(pi.hThread); 
   CloseHandle(pi.hProcess);
   
@@ -416,7 +450,7 @@
     OSVERSIONINFOEXA exinfo;
     ZeroMemory(&exinfo, sizeof(OSVERSIONINFOEXA));
     exinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA);
-    GetVersionEx(&exinfo);
+    GetVersionExA(&exinfo);
     if (exinfo.wProductType != VER_NT_WORKSTATION) {
       ldebug ("Operating system version is Windows Vista");
       osver = OS_VISTA;
@@ -580,6 +614,17 @@
   return TRUE;
 }
 
+BOOL rmdirtree(LPSTR path)
+{
+  LPSTR cmd = NULL;
+  cmd = malloc(CMDMAX);
+  ldebug("Removing directory tree at path: %s", path);
+  snprintf(cmd, CMDMAX -1, "rmdir.exe /S /Q \"%s\"", path);
+  runcommand(cmd,NULL);
+  free(cmd);
+  return TRUE;
+}
+
 BOOL base16encode(LPBYTE   data,
                   DWORD    len,
                   char **  hexstr)

Modified: torvm/trunk/build/win32/src/torvm-w32/apicommon.h
===================================================================
--- torvm/trunk/build/win32/src/torvm-w32/apicommon.h	2009-05-04 12:19:04 UTC (rev 19425)
+++ torvm/trunk/build/win32/src/torvm-w32/apicommon.h	2009-05-04 12:44:12 UTC (rev 19426)
@@ -127,6 +127,8 @@
 BOOL tryconnect(const char * addr,
                 DWORD port);
 
+BOOL rmdirtree(LPSTR path);
+
 /* Caller is responsible for free'ing hexstr.  Note that it will be exactly
  * twice as long plus 1 (null terminated) as the input buffer.
  */

Modified: torvm/trunk/build/win32/src/torvm-w32/creds.c
===================================================================
--- torvm/trunk/build/win32/src/torvm-w32/creds.c	2009-05-04 12:19:04 UTC (rev 19425)
+++ torvm/trunk/build/win32/src/torvm-w32/creds.c	2009-05-04 12:44:12 UTC (rev 19426)
@@ -689,6 +689,7 @@
   if (s_advapi->LsaOpenPolicy &&
       s_advapi->LookupAccountName &&
       s_advapi->LsaAddAccountRights) {
+    /* XXX: Should check if use exists and if so, what groups. For now this causes no harm... */
     ldebug("Creating restricted user account: %s\\%s", hostname, username);
     snprintf(cmd, CMDMAX -1, "net.exe user %s \"\" /add", (*info)->name);
     runcommand(cmd,NULL);
@@ -697,6 +698,8 @@
     /* just to be sure in case someone did something stupid with local or domain policy ... */
     snprintf(cmd, CMDMAX -1, "net.exe localgroup Administrators %s /delete", (*info)->name);
     runcommand(cmd,NULL);
+    snprintf(cmd, CMDMAX -1, "net.exe user %s /ACTIVE:YES", (*info)->name);
+    runcommand(cmd,NULL);
 
     ntstatus = s_advapi->LsaOpenPolicy(&lsahostname,
                                        &policyattrs,
@@ -856,6 +859,80 @@
   return TRUE;
 }
 
+BOOL setupruserfollow(userinfo * info,
+                      LPTSTR     ctlip,
+                      LPTSTR     ctlport)
+{
+  LPTSTR relpath;
+  LPTSTR auppath;
+  LPTSTR binpath;
+  LPTSTR coff;
+  LPTSTR cmd;
+  HANDLE fh;
+  DWORD numwritten;
+  
+  ldebug ("Setting up restricted user Tor control port follower for %s on host %s.", info->name, info->host);
+  if (!buildsyspath(SYSDIR_ALLPROFILE, NULL, &auppath)) {
+    lerror ("Unable to build path for all users profile destination.");
+    return FALSE;
+  }
+  if (!buildfpath(PATH_FQ, VMDIR_BASE, NULL, "torvm.exe", &binpath)) {
+    free(auppath);
+    lerror ("Unable to build path to self (executing exe).");
+    return FALSE;
+  }
+  /* Trim off the "All Users" part as we just want Documents and Settings
+   * XXX: all of the path handling needs to be cleaned up, localized, collected.
+   */
+  coff = auppath + strlen(auppath) - 1;
+  while ( (coff > auppath) && (*coff != '\\') ) coff--;
+  if (coff > auppath)
+    *coff = 0;
+  relpath = malloc(CMDMAX);
+  snprintf(relpath, CMDMAX -1, "%s\\%s\\Start Menu\\Programs\\Startup\\torfollow.bat", auppath, info->name);
+  free(auppath);
+  ldebug ("Creating Tor follow script at %s using exe at %s", relpath, binpath); 
+
+  DeleteFile(relpath);
+  fh = CreateFile(relpath,
+                  GENERIC_WRITE,
+                  0,
+                  NULL,
+                  CREATE_ALWAYS,
+                  FILE_ATTRIBUTE_NORMAL,
+                  NULL);
+  if (fh == INVALID_HANDLE_VALUE) {
+    ldebug ("Unable to open Startup Tor follow script file. Error code: %d", GetLastError());
+    return FALSE;
+  }
+  cmd = "@echo off\r\n";
+  WriteFile(fh, cmd, strlen(cmd),  &numwritten, NULL);
+  cmd = "echo Tor VM is running!\r\n";
+  WriteFile(fh, cmd, strlen(cmd),  &numwritten, NULL);
+  cmd = "echo Press the Windows Key + \'L\' at the same time to change back to Admin user.\r\n";
+  WriteFile(fh, cmd, strlen(cmd),  &numwritten, NULL);
+  cmd = "echo Waiting for Tor VM to exit...\r\n";
+  WriteFile(fh, cmd, strlen(cmd),  &numwritten, NULL);
+  cmd = malloc(CMDMAX);
+  snprintf(cmd, CMDMAX -1, "\"%s\" --follow --ctlip %s --ctlport %s\r\n", binpath, ctlip, ctlport);
+  WriteFile(fh, cmd, strlen(cmd),  &numwritten, NULL);
+  CloseHandle(fh);
+  free(relpath);
+  free(cmd);
+  return TRUE;
+}
+
+BOOL disableuser (LPTSTR username)
+{
+  LPSTR cmd = NULL;
+  cmd = malloc(CMDMAX);
+  ldebug("Disabling user account: %s", username);
+  snprintf(cmd, CMDMAX -1, "net.exe user %s /ACTIVE:NO", username);
+  runcommand(cmd,NULL);
+  free(cmd);
+  return TRUE;
+}
+
 BOOL entropy (LPBYTE buf,
               DWORD  len)
 {

Modified: torvm/trunk/build/win32/src/torvm-w32/creds.h
===================================================================
--- torvm/trunk/build/win32/src/torvm-w32/creds.h	2009-05-04 12:19:04 UTC (rev 19425)
+++ torvm/trunk/build/win32/src/torvm-w32/creds.h	2009-05-04 12:44:12 UTC (rev 19426)
@@ -34,6 +34,7 @@
 BOOL createruser (LPTSTR  hostname,
                   LPTSTR  username,
                   userinfo **info);
+BOOL disableuser (LPTSTR  username);
 
 BOOL initruserprofile(userinfo *info);
                       

Modified: torvm/trunk/build/win32/src/torvm-w32/torvm.c
===================================================================
--- torvm/trunk/build/win32/src/torvm-w32/torvm.c	2009-05-04 12:19:04 UTC (rev 19425)
+++ torvm/trunk/build/win32/src/torvm-w32/torvm.c	2009-05-04 12:44:12 UTC (rev 19426)
@@ -15,6 +15,7 @@
 #define TOR_TAP_DNS2   "4.2.2.2"
 #define TOR_CAP_SYS    "tornpf.sys"
 #define TOR_HDD_FILE   "hdd.img"
+#define TOR_RESTRICTED_USER "Tor"
 #define QEMU_DEF_MEM   32
 #define CAP_MTU        1480
 
@@ -1360,7 +1361,6 @@
                    BOOL                  noinit,
                    char **               cmdline)
 {
-/* DHCPSVR DHCPNAME LEASE ISDHCP CTLSOCK HASHPW */
   const DWORD  cmdlen = CMDMAX;
   *cmdline = malloc(cmdlen);
   const char * basecmds = "quiet loglevel=0 clocksource=hpet";
@@ -1384,11 +1384,11 @@
   else {
     if (brif->isdhcp == FALSE) {
       snprintf (*cmdline, cmdlen -1,
-                "%s%s%s%s IP=%s MASK=%s GW=%s MAC=%s MTU=%d PRIVIP=%s CTLSOCK=%s:9051 HASHPW=%s",
+                "%s %s %s %s IP=%s MASK=%s GW=%s MAC=%s MTU=%d PRIVIP=%s CTLSOCK=%s:9051 CTLREADY=9052 HASHPW=%s",
                 usedebug ? dbgcmds : basecmds,
-                myhostname ? " USEHOSTNAME=" : "",
+                myhostname ? "USEHOSTNAME=" : "",
                 myhostname ? myhostname : "",
-                bundle ? " FOLLOWTOR=TRUE" : "",
+                bundle ? "FOLLOWTOR=TRUE" : "",
                 brif->ipaddr,
                 brif->netmask,
                 brif->gateway,
@@ -1404,11 +1404,11 @@
         myhostname = brif->dhcpname;
 
       snprintf (*cmdline, cmdlen -1,
-                "%s%s%s%s IP=%s MASK=%s GW=%s MAC=%s MTU=%d PRIVIP=%s ISDHCP DHCPSVR=%s DHCPNAME=%s CTLSOCK=%s:9051 HASHPW=%s",
+                "%s %s %s %s IP=%s MASK=%s GW=%s MAC=%s MTU=%d PRIVIP=%s ISDHCP DHCPSVR=%s DHCPNAME=%s CTLSOCK=%s:9051 CTLREADY=9052 HASHPW=%s",
                 usedebug ? dbgcmds : basecmds,
-                myhostname ? " USEHOSTNAME=" : "",
+                myhostname ? "USEHOSTNAME=" : "",
                 myhostname ? myhostname : "",
-                bundle ? " FOLLOWTOR=TRUE" : "",
+                bundle ? "FOLLOWTOR=TRUE" : "",
                 brif->ipaddr,
                 brif->netmask,
                 brif->gateway,
@@ -1540,7 +1540,7 @@
 
   cmd = malloc(CMDMAX);
   snprintf (cmd, CMDMAX -1,
-            "\"%s\" -tor-address %s%s",
+            "\"%s\" -tor-address %s %s",
             exe,
             TOR_TAP_VMIP,
             indebug ? " -loglevel debug -logfile debuglog.txt" :
@@ -1795,7 +1795,9 @@
   return TRUE;
 }
 
-BOOL setupuser (void)
+BOOL setupuser (LPTSTR username,
+                LPTSTR ctlip,
+                LPTSTR ctlport)
 {
   BOOL retval = FALSE;
   userinfo * ui;
@@ -1803,18 +1805,60 @@
   if (!myhostname)
     myhostname = getenv("HOSTNAME");
   if (createruser (myhostname,
-                   "Tor",
+                   username,
                    &ui)) {
     if (!initruserprofile(ui)) {
       ldebug ("Failed to initialize user profile data in setupuser.");
     }
     else {
-      retval = TRUE;
+      if (!setupruserfollow(ui, ctlip, ctlport)) {
+        ldebug ("Failed to setup Tor follow startup script for user %s.", username);
+      }
+      else {
+        ldebug ("All setup completed for restricted user %s.", username);
+        retval = TRUE;
+      }
     }
   }
   return retval;
 }
 
+/* XXX: This is a temporary method to clean out the usual culprits.
+ * Note that there are many other places to store data, particularly the registry.
+ */
+BOOL cleanruserfiles (LPTSTR username)
+{
+  LPTSTR dirpath;
+  LPTSTR auppath;
+  LPTSTR coff;
+  if (!buildsyspath(SYSDIR_ALLPROFILE, NULL, &auppath)) {
+    lerror ("Unable to build path for all users profile destination.");
+    return FALSE;
+  }
+  /* Trim off the "All Users" part as we just want Documents and Settings
+   * XXX: all of the path handling needs to be cleaned up, localized, collected.
+   */
+  coff = auppath + strlen(auppath) - 1;
+  while ( (coff > auppath) && (*coff != '\\') ) coff--;
+  if (coff > auppath)
+    *coff = 0;
+  dirpath = malloc(CMDMAX);
+  snprintf(dirpath, CMDMAX -1, "%s\\%s\\Local Settings\\Temporary Internet Files", auppath, username);
+  rmdirtree(dirpath);
+  snprintf(dirpath, CMDMAX -1, "%s\\%s\\Local Settings\\Temp", auppath, username);
+  rmdirtree(dirpath);
+  snprintf(dirpath, CMDMAX -1, "%s\\%s\\Local Settings\\SendTo", auppath, username);
+  rmdirtree(dirpath);
+  snprintf(dirpath, CMDMAX -1, "%s\\%s\\Local Settings\\Cookies", auppath, username);
+  rmdirtree(dirpath);
+  snprintf(dirpath, CMDMAX -1, "%s\\%s\\Local Settings\\History", auppath, username);
+  rmdirtree(dirpath);
+
+  free(auppath);
+  free(dirpath);  
+  return TRUE;
+}
+
 BOOL setupenv (void)
 {
 #define EBUFSZ 4096
@@ -1914,6 +1958,9 @@
   { "vmnop" , no_argument , NULL, 'X' },
   { "noinit" , no_argument , NULL, 'Z' },
   { "help" , no_argument , NULL, 'h' },
+  { "follow" , no_argument , NULL, 'F' },
+  { "ctlip" , required_argument, NULL, 'I' },
+  { "ctlport" , required_argument, NULL, 'P' },
   {0}
 };
 
@@ -1938,18 +1985,21 @@
 int main(int argc, char **argv)
 {
   const char *cmd;
-  int  numintf;
+  int numintf;
   struct s_rconnelem *connlist = NULL;
   struct s_rconnelem *ce = NULL;
   struct s_rconnelem *tapconn = NULL;
-  BOOL  vmaccel = FALSE;
-  BOOL  bundle = FALSE;
-  BOOL  indebug = FALSE;
-  BOOL  vmnop = FALSE;
-  BOOL  noinit = FALSE;
-  BOOL  foundit = FALSE;
-  char *  cmdline = NULL;
-  LPTSTR  logfile = NULL;
+  BOOL vmaccel = FALSE;
+  BOOL bundle = FALSE;
+  BOOL follow = FALSE;
+  BOOL indebug = FALSE;
+  BOOL vmnop = FALSE;
+  BOOL noinit = FALSE;
+  BOOL foundit = FALSE;
+  char *cmdline = NULL;
+  LPTSTR logfile = NULL;
+  LPTSTR ctliparg = NULL;
+  LPTSTR ctlportarg = NULL;
   DWORD taptimeout = 60; /* the tap device can't be configured until the VM connects it */
   int c, optidx = 0;
 
@@ -2009,6 +2059,24 @@
           noinit = TRUE;
           break;
 
+        case 'F':
+          follow = TRUE;
+          break;
+
+        case 'I':
+          if (optarg)
+            ctliparg = optarg;
+          else
+            ctliparg = TOR_TAP_VMIP;
+          break;
+
+        case 'P':
+          if (optarg)
+            ctlportarg = optarg;
+          else
+            ctlportarg = "9051";
+          break;
+
         case 'h':
           linfo ("Help for command usage invoked.");
           usage();
@@ -2017,12 +2085,25 @@
         case 0:  /* not used for flags currently. */
           break;
       default:
-        lerror ("Unrecognized command line argument or option passed.");
         usage();
         break;
     }
   }
-  
+ 
+  /* The Tor follow mode is a special case. All we do is loop until the control
+   * port is no longer accepting connections and then we issue a logoff request.
+   */ 
+  if (follow) {
+    while(tryconnect(ctliparg, atol(ctlportarg))) {
+      Sleep(1000);
+    }
+    /* At this point Tor in the Admin user desktop inside the VM has failed or exited.
+     * This is our cue to force the restricted user to log off.
+     */
+    runcommand("shutdown -l -f", NULL);
+    return 0;
+  }
+
   if (buildfpath(PATH_FQ, VMDIR_STATE, NULL, "vmlog.txt", &logfile)) {
     logto (logfile);
     free (logfile);
@@ -2061,8 +2142,11 @@
       fatal ("Unable to save current network configuration.");
     }
 
-    if (!setupuser()) {
-      lerror ("Unable to setup restricted user.");
+    if (bundle) {
+      /* XXX: note we're using the "all ready" alias for the control port. */
+      if (!setupuser(TOR_RESTRICTED_USER, TOR_TAP_VMIP, "9052")) {
+        lerror ("Unable to setup restricted user.");
+      }
     }
 
     ce = NULL;
@@ -2194,7 +2278,10 @@
   }
 
   /* XXX: temp hack - in bundle mode launch Vidalia with a custom config
-   * for the 10. tap control port and externally managed Tor instance.
+   * for the 10.x tap control port and externally managed Tor instance.
+   * The control port is used to signal both Tor starting correctly, and
+   * once Tor is stopped the no longer listening control port signals
+   * restricted user log off and clean shutdown.
    */
   if (bundle) {
     /* try to confirm control port is up before launching vidalia... */
@@ -2206,7 +2293,25 @@
     if (i > 0) {
       ldebug("Control port connected. Starting controller ...");
       runvidalia(indebug);
-      userswitcher();
+
+      /* XXX: Now we wait for the ALL READY socket to be listening before switching.
+       * If we don't get bootstrapped within this period of time something is broken/blocked.
+       */
+      ldebug("Waiting for Tor to bootstrap ...");
+      i = 60 * 5; 
+      while ( (!tryconnect(TOR_TAP_VMIP, 9052)) && (i > 0) ) {
+        Sleep(1000);
+        ldebug("Tor has not bootstrapped yet, checking again... [%d left]", i);
+        if (!isrunning(&pi)) 
+          i = 0;
+        else
+          i--;
+      }
+      if (i > 0) {
+        /* Once/if bootstrapped allow the user to run applications with restricted privs. */
+        cleanruserfiles(TOR_RESTRICTED_USER);
+        userswitcher();
+      }
     }
   }
 
@@ -2218,6 +2323,11 @@
 
   linfo ("Tor VM closed, restoring host network and services.");
 
+  if (bundle) {
+    disableuser(TOR_RESTRICTED_USER);
+    cleanruserfiles(TOR_RESTRICTED_USER);
+  }
+
  shutdown:
   if (getosversion() > OS_2000) {
     if (! enablefirewall()) {