summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2016-10-24 18:27:57 +0200
committerSimon Rettberg2016-10-24 18:27:57 +0200
commit0fd908798e2dd06b41e2b7c9d1d4c2777dade0c0 (patch)
tree2c333f08be3790d7dba0deafb659d9f54a117fca
parent[client] Fix "toogle vm/manager" button (copy&paste error..) (diff)
downloadpvs2-0fd908798e2dd06b41e2b7c9d1d4c2777dade0c0.tar.gz
pvs2-0fd908798e2dd06b41e2b7c9d1d4c2777dade0c0.tar.xz
pvs2-0fd908798e2dd06b41e2b7c9d1d4c2777dade0c0.zip
[client] Create config dir before trying to create vnc password file inside
-rw-r--r--src/client/vnc/vncserver.cpp39
-rw-r--r--src/client/vnc/vncserver.h2
-rw-r--r--src/server/mainwindow/mainwindow.cpp1
3 files changed, 27 insertions, 15 deletions
diff --git a/src/client/vnc/vncserver.cpp b/src/client/vnc/vncserver.cpp
index 9d647f0..496a84d 100644
--- a/src/client/vnc/vncserver.cpp
+++ b/src/client/vnc/vncserver.cpp
@@ -55,6 +55,18 @@ VncServer::VncServer() : _process(NULL), _port(0), _timerId(0) {}
*/
VncServer::~VncServer() {}
+QSharedPointer<QFile> VncServer::createPwFile(const QDir& dir)
+{
+ QDir::root().mkpath(dir.absolutePath());
+ QString str(dir.absoluteFilePath("vncpass"));
+ QSharedPointer<QFile> file = QSharedPointer<QFile>(new QFile(str));
+ if (file->exists()) {
+ file->remove();
+ }
+ file->open(QIODevice::WriteOnly);
+ return file;
+}
+
/***************************************************************************//**
* @brief VncServer::start
*/
@@ -70,22 +82,21 @@ void VncServer::start()
_rwpass = makePassword();
_ropass = makePassword();
// Create new password file
- QDir path = Util::settingsDir();
- QString pwfile(path.absoluteFilePath("vncpass"));
- QFile pwhandle(pwfile);
- if (pwhandle.exists())
- pwhandle.remove();
- if (!pwhandle.open(QIODevice::WriteOnly)) {
- qDebug() << "Could not open " << pwfile << " for writing";
+ QSharedPointer<QFile> pwhandle = createPwFile(Util::settingsDir());
+ if (!pwhandle->isOpen()) {
+ pwhandle = createPwFile(QDir("/tmp"));
+ }
+ if (!pwhandle->isOpen()) {
+ qDebug() << "Could not open " << pwhandle->fileName() << " for writing";
emit started(0, _ropass, _rwpass);
return;
}
- pwhandle.setPermissions(QFile::ReadOwner | QFile::WriteOwner);
- pwhandle.write(_rwpass.toUtf8().constData());
- pwhandle.write("\n");
- pwhandle.write(_ropass.toUtf8().constData());
- pwhandle.write("\n");
- pwhandle.close();
+ pwhandle->setPermissions(QFile::ReadOwner | QFile::WriteOwner);
+ pwhandle->write(_rwpass.toUtf8().constData());
+ pwhandle->write("\n");
+ pwhandle->write(_ropass.toUtf8().constData());
+ pwhandle->write("\n");
+ pwhandle->close();
// Create new process
_process = new QProcess(this);
connect(_process, SIGNAL(readyReadStandardOutput()), this, SLOT(onStdOut()));
@@ -96,7 +107,7 @@ void VncServer::start()
QStringList args;
args << "-forever";
args << "-display" << ":0";
- args << "-passwdfile" << (QString("rm:" + pwfile));
+ args << "-passwdfile" << (QString("rm:" + pwhandle->fileName()));
args << "-shared";
args << "-repeat";
args << "-autoport" << QString::number(54112);
diff --git a/src/client/vnc/vncserver.h b/src/client/vnc/vncserver.h
index 61e6d21..4974946 100644
--- a/src/client/vnc/vncserver.h
+++ b/src/client/vnc/vncserver.h
@@ -9,6 +9,7 @@
#define VNCSERVER_H_
#include <QtCore>
+#include <QSharedPointer>
class VncServer;
@@ -25,6 +26,7 @@ private:
VncServer();
virtual ~VncServer();
+ QSharedPointer<QFile> createPwFile(const QDir& dir);
static VncServer *me;
diff --git a/src/server/mainwindow/mainwindow.cpp b/src/server/mainwindow/mainwindow.cpp
index c716849..6d9bdd3 100644
--- a/src/server/mainwindow/mainwindow.cpp
+++ b/src/server/mainwindow/mainwindow.cpp
@@ -806,7 +806,6 @@ void MainWindow::onButtonReloadRoomConfig()
{
connect(_reloadWindow->ui->buttonBox, SIGNAL(accepted()), this, SLOT(onReloadRoomOk()));
connect(_reloadWindow->ui->buttonBox, SIGNAL(rejected()), this, SLOT(onReloadRoomCancel()));
- qDebug() << "in onButtonReloadRoomConfig!" << "size of room: " << serverApp->getRooms().size();
QList<QString> keyList = serverApp->getRooms().keys();
for (QList<QString>::iterator it = keyList.begin(); it != keyList.end() ; it++) {
_reloadWindow->ui->roomList->addItem(*it);