[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [vidalia/alpha] Takes ownership of the tor process it controls
commit 44bf61439a737908292e7da8ee44cabb49cf7e09
Author: Tomás Touceda <chiiph@xxxxxxxxxxxxxx>
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 5d31023..081438d 100644
--- a/src/torcontrol/TorControl.cpp
+++ b/src/torcontrol/TorControl.cpp
@@ -1131,3 +1131,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 183e78f..bbf1478 100644
--- a/src/vidalia/MainWindow.cpp
+++ b/src/vidalia/MainWindow.cpp
@@ -605,6 +605,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()) {
@@ -833,6 +835,11 @@ void
MainWindow::connected()
{
authenticate();
+ if(!_torControl->isVidaliaRunningTor()) {
+ QString err;
+ if(!_torControl->takeOwnership(&err))
+ vWarn(err);
+ }
}
/** Called when the connection to the control socket fails. The reason will be
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits