vnc: Don't enable auth without an authfile
diff --git a/src/VNCFlinger.cpp b/src/VNCFlinger.cpp
index b9b5da4..b910453 100644
--- a/src/VNCFlinger.cpp
+++ b/src/VNCFlinger.cpp
@@ -18,6 +18,8 @@
#define LOG_TAG "VNCFlinger"
#include <utils/Log.h>
+#include <fstream>
+
#include <binder/IPCThreadState.h>
#include <binder/IServiceManager.h>
#include <binder/ProcessState.h>
@@ -86,6 +88,7 @@
status_t VNCFlinger::clearPassword() {
std::remove(VNC_AUTH_FILE);
ALOGW("Password authentication disabled");
+ mVNCScreen->authPasswdData = NULL;
return OK;
}
@@ -97,6 +100,7 @@
return BAD_VALUE;
}
ALOGI("Password has been set");
+ mVNCScreen->authPasswdData = (void *)VNC_AUTH_FILE;
return OK;
}
@@ -238,7 +242,6 @@
mVNCScreen->desktopName = "VNCFlinger";
mVNCScreen->alwaysShared = TRUE;
mVNCScreen->httpDir = NULL;
- mVNCScreen->authPasswdData = (void *)VNC_AUTH_FILE;
mVNCScreen->newClientHook = (rfbNewClientHookPtr)VNCFlinger::onNewClient;
mVNCScreen->kbdAddEvent = InputDevice::onKeyEvent;
mVNCScreen->ptrAddEvent = InputDevice::onPointerEvent;
@@ -251,6 +254,11 @@
mVNCScreen->deferUpdateTime = 0;
mVNCScreen->screenData = this;
+ std::ifstream authFile(VNC_AUTH_FILE);
+ if ((bool)authFile) {
+ mVNCScreen->authPasswdData = (void *)VNC_AUTH_FILE;
+ }
+
return err;
}