[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[vidalia-svn] r3382: Implement coderman's read-password-from-stdin option. Resolv (vidalia/trunk/src/vidalia)
Author: edmanm
Date: 2008-12-10 23:58:55 -0500 (Wed, 10 Dec 2008)
New Revision: 3382
Modified:
vidalia/trunk/src/vidalia/mainwindow.cpp
vidalia/trunk/src/vidalia/vidalia.cpp
vidalia/trunk/src/vidalia/vidalia.h
Log:
Implement coderman's read-password-from-stdin option. Resolves ticket #428.
Modified: vidalia/trunk/src/vidalia/mainwindow.cpp
===================================================================
--- vidalia/trunk/src/vidalia/mainwindow.cpp 2008-12-11 04:49:46 UTC (rev 3381)
+++ vidalia/trunk/src/vidalia/mainwindow.cpp 2008-12-11 04:58:55 UTC (rev 3382)
@@ -20,6 +20,7 @@
#include <QtGui>
#include <QTimer>
+#include <QTextStream>
#include <vidalia.h>
#include <file.h>
#include <html.h>
@@ -258,12 +259,18 @@
{
VidaliaSettings settings;
- /* Initialize _useSavedPassword to true. If Tor is already running when
- * Vidalia starts, then there is no point in generating a random password.
- * If Tor is not already running, then this will be set according to the
- * current configuration in the start() method.
- */
- _useSavedPassword = true;
+ if (vApp->readPasswordFromStdin()) {
+ QTextStream in(stdin);
+ in >> _controlPassword;
+ _useSavedPassword = false;
+ } else {
+ /* Initialize _useSavedPassword to true. If Tor is already running when
+ * Vidalia starts, then there is no point in generating a random password.
+ * If Tor is not already running, then this will be set according to the
+ * current configuration in the start() method.
+ */
+ _useSavedPassword = true;
+ }
if (settings.runTorAtStart()) {
/* If we're supposed to start Tor when Vidalia starts, then do it now */
@@ -819,12 +826,14 @@
/* Add the control port authentication arguments */
switch (settings.getAuthenticationMethod()) {
case TorSettings::PasswordAuth:
- if (settings.useRandomPassword()) {
- _controlPassword = TorSettings::randomPassword();
- _useSavedPassword = false;
- } else {
- _controlPassword = settings.getControlPassword();
- _useSavedPassword = true;
+ if (! vApp->readPasswordFromStdin()) {
+ if (settings.useRandomPassword()) {
+ _controlPassword = TorSettings::randomPassword();
+ _useSavedPassword = false;
+ } else {
+ _controlPassword = settings.getControlPassword();
+ _useSavedPassword = true;
+ }
}
args << "HashedControlPassword"
<< TorSettings::hashPassword(_controlPassword);
Modified: vidalia/trunk/src/vidalia/vidalia.cpp
===================================================================
--- vidalia/trunk/src/vidalia/vidalia.cpp 2008-12-11 04:49:46 UTC (rev 3381)
+++ vidalia/trunk/src/vidalia/vidalia.cpp 2008-12-11 04:58:55 UTC (rev 3382)
@@ -38,8 +38,9 @@
#define ARG_PIDFILE "pidfile" /**< Location and name of our pidfile.*/
#define ARG_LOGFILE "logfile" /**< Location of our logfile. */
#define ARG_LOGLEVEL "loglevel" /**< Log verbosity. */
+#define ARG_READ_PASSWORD_FROM_STDIN \
+ "read-password-from-stdin" /**< Read password from stdin. */
-
/* Static member variables */
QMap<QString, QString> Vidalia::_args; /**< List of command-line arguments. */
QString Vidalia::_style; /**< The current GUI style. */
@@ -334,6 +335,12 @@
return QDir::convertSeparators(dataDirectory() + "/vidalia.pid");
}
+bool
+Vidalia::readPasswordFromStdin()
+{
+ return _args.contains(ARG_READ_PASSWORD_FROM_STDIN);
+}
+
/** Writes <b>msg</b> with severity <b>level</b> to Vidalia's log. */
Log::LogMessage
Vidalia::log(Log::LogLevel level, QString msg)
Modified: vidalia/trunk/src/vidalia/vidalia.h
===================================================================
--- vidalia/trunk/src/vidalia/vidalia.h 2008-12-11 04:49:46 UTC (rev 3381)
+++ vidalia/trunk/src/vidalia/vidalia.h 2008-12-11 04:58:55 UTC (rev 3382)
@@ -86,6 +86,10 @@
/** Returns the location of Vidalia's pid file. */
static QString pidFile();
+ /** Returns true if Vidalia should read the control password from stdin.
+ */
+ static bool readPasswordFromStdin();
+
/** Writes <b>msg</b> with severity <b>level</b> to Vidalia's log. */
static Log::LogMessage log(Log::LogLevel level, QString msg);