summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--vncviewer/CViewOptions.cxx4
-rw-r--r--vncviewer/CViewOptions.h1
-rw-r--r--vncviewer/cview.cxx13
3 files changed, 17 insertions, 1 deletions
diff --git a/vncviewer/CViewOptions.cxx b/vncviewer/CViewOptions.cxx
index 1f551296..13ad7cdd 100644
--- a/vncviewer/CViewOptions.cxx
+++ b/vncviewer/CViewOptions.cxx
@@ -30,6 +30,8 @@
using namespace rfb;
using namespace rfb::win32;
+static StringParameter passwordFile("PasswordFile",
+ "Password file for VNC authentication", "");
static BoolParameter useLocalCursor("UseLocalCursor", "Render the mouse cursor locally", true);
static BoolParameter useDesktopResize("UseDesktopResize", "Support dynamic desktop resizing", true);
@@ -113,7 +115,7 @@ preferredEncoding(encodingZRLE), clientCutText(::clientCutText), serverCutText(:
protocol3_3(::protocol3_3), acceptBell(::acceptBell), lowColourLevel(::lowColourLevel),
pointerEventInterval(ptrEventInterval), emulate3(::emulate3), monitor(::monitor.getData()),
customCompressLevel(::customCompressLevel), compressLevel(::compressLevel),
-noJpeg(::noJpeg), qualityLevel(::qualityLevel)
+noJpeg(::noJpeg), qualityLevel(::qualityLevel), passwordFile(::passwordFile.getData())
{
CharArray encodingName(::preferredEncoding.getData());
preferredEncoding = encodingNum(encodingName.buf);
diff --git a/vncviewer/CViewOptions.h b/vncviewer/CViewOptions.h
index e45612c3..d49cab14 100644
--- a/vncviewer/CViewOptions.h
+++ b/vncviewer/CViewOptions.h
@@ -83,6 +83,7 @@ namespace rfb {
bool noJpeg;
int qualityLevel;
+ CharArray passwordFile;
};
diff --git a/vncviewer/cview.cxx b/vncviewer/cview.cxx
index 5d1ee5d2..78fc4be6 100644
--- a/vncviewer/cview.cxx
+++ b/vncviewer/cview.cxx
@@ -1484,6 +1484,19 @@ void CView::invertRect(const Rect& r) {
}
bool CView::getUserPasswd(char** user, char** password) {
+ if (!user && options.passwordFile.buf[0]) {
+ FILE* fp = fopen(options.passwordFile.buf, "r");
+ if (!fp) return false;
+ char data[256];
+ int datalen = fread(data, 1, 256, fp);
+ fclose(fp);
+ if (datalen != 8) return false;
+ vncAuthUnobfuscatePasswd(data);
+ *password = strDup(data);
+ memset(data, 0, strlen(data));
+ return true;
+ }
+
if (user && options.userName.buf)
*user = strDup(options.userName.buf);
if (password && options.password.buf)