commit 05e1bc589237ef9bf3a36cba08c1928b4da8889a Author: Tomás Touceda chiiph@torproject.org Date: Fri Jan 20 12:03:53 2012 -0300
Takes ownership of the tor process it controls
If Vidalia fails, tor won't be running in the background with a random hashed password. --- src/torcontrol/TorControl.cpp | 7 +++++++ src/torcontrol/TorControl.h | 3 +++ src/vidalia/MainWindow.cpp | 7 +++++++ 3 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/src/torcontrol/TorControl.cpp b/src/torcontrol/TorControl.cpp index af925a7..730e821 100644 --- a/src/torcontrol/TorControl.cpp +++ b/src/torcontrol/TorControl.cpp @@ -1127,3 +1127,10 @@ TorControl::ipToCountry(const QHostAddress &ip, QString *errmsg) return QString(); }
+/** Takes ownership of the tor process it's communicating to */ +bool +TorControl::takeOwnership(QString *errmsg) +{ + ControlCommand cmd("TAKEOWNERSHIP"); + return send(cmd, errmsg); +} diff --git a/src/torcontrol/TorControl.h b/src/torcontrol/TorControl.h index f3504f5..c16758c 100644 --- a/src/torcontrol/TorControl.h +++ b/src/torcontrol/TorControl.h @@ -209,6 +209,9 @@ public: * it's not NULL. */ QString ipToCountry(const QHostAddress &ip, QString *errmsg = 0);
+ /** Takes ownership of the tor process it's communicating to */ + bool takeOwnership(QString *errmsg); + public slots: /** Closes the circuit specified by <b>circId</b>. If <b>ifUnused</b> is * true, then the circuit will not be closed unless it is unused. */ diff --git a/src/vidalia/MainWindow.cpp b/src/vidalia/MainWindow.cpp index a60509f..3148078 100644 --- a/src/vidalia/MainWindow.cpp +++ b/src/vidalia/MainWindow.cpp @@ -1082,6 +1082,8 @@ MainWindow::start() QString path = settings.getSocketPath(); args << "ControlSocket" << path; } + + args << "__OwningControllerProcess" << QString::number(QCoreApplication::applicationPid());
/* Add the control port authentication arguments */ switch (settings.getAuthenticationMethod()) { @@ -1346,6 +1348,11 @@ void MainWindow::connected() { authenticate(); + if(!_torControl->isVidaliaRunningTor()) { + QString err; + if(!_torControl->takeOwnership(&err)) + vWarn(err); + } }
/** Called when Vidalia wants to disconnect from a Tor it did not start. */
tor-commits@lists.torproject.org