Commit 05e1bc58 authored by Tomas Touceda's avatar Tomas Touceda
Browse files

Takes ownership of the tor process it controls

If Vidalia fails, tor won't be running in the background with a random
hashed password.
parent 4f0ebe51
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -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);
}
+3 −0
Original line number Diff line number Diff line
@@ -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. */
+7 −0
Original line number Diff line number Diff line
@@ -1083,6 +1083,8 @@ MainWindow::start()
    args << "ControlSocket" << path;
  }

  args << "__OwningControllerProcess" << QString::number(QCoreApplication::applicationPid());
  
  /* Add the control port authentication arguments */
  switch (settings.getAuthenticationMethod()) {
    case TorSettings::PasswordAuth:
@@ -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. */