summaryrefslogtreecommitdiffstats
path: root/common/rfb/SSecurityVncAuth.cxx
diff options
context:
space:
mode:
authorAdam Tkac <atkac@redhat.com>2010-04-23 14:02:43 +0000
committerAdam Tkac <atkac@redhat.com>2010-04-23 14:02:43 +0000
commit162ac3527dbdafdab9849f48a33726563d87b577 (patch)
treed85165d72630a09489bca30aa0ea1bd115dd2f6c /common/rfb/SSecurityVncAuth.cxx
parent9c28a7b3b09eec9f7322222e18e5d1bbe917db60 (diff)
downloadtigervnc-162ac3527dbdafdab9849f48a33726563d87b577.tar.gz
tigervnc-162ac3527dbdafdab9849f48a33726563d87b577.zip
[Development] Move all VncAuth code from SSecurityFactoryStandard class to
SSecurityVncAuth class. git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4036 3789f03b-4d11-0410-bbf8-ca57d06f2519
Diffstat (limited to 'common/rfb/SSecurityVncAuth.cxx')
-rw-r--r--common/rfb/SSecurityVncAuth.cxx53
1 files changed, 51 insertions, 2 deletions
diff --git a/common/rfb/SSecurityVncAuth.cxx b/common/rfb/SSecurityVncAuth.cxx
index 29a3b964..ca81bf33 100644
--- a/common/rfb/SSecurityVncAuth.cxx
+++ b/common/rfb/SSecurityVncAuth.cxx
@@ -40,9 +40,16 @@ using namespace rfb;
static LogWriter vlog("SVncAuth");
+StringParameter SSecurityVncAuth::vncAuthPasswdFile
+("PasswordFile", "Password file for VNC authentication", "", ConfServer);
+AliasParameter rfbauth("rfbauth", "Alias for PasswordFile",
+ &SSecurityVncAuth::vncAuthPasswdFile, ConfServer);
+VncAuthPasswdParameter SSecurityVncAuth::vncAuthPasswd
+("Password", "Obfuscated binary encoding of the password which clients must supply to "
+ "access the server", &SSecurityVncAuth::vncAuthPasswdFile);
-SSecurityVncAuth::SSecurityVncAuth(VncAuthPasswdGetter* pg_)
- : sentChallenge(false), responsePos(0), pg(pg_)
+SSecurityVncAuth::SSecurityVncAuth(void)
+ : sentChallenge(false), responsePos(0), pg(&vncAuthPasswd)
{
}
@@ -85,3 +92,45 @@ bool SSecurityVncAuth::processMsg(SConnection* sc)
return true;
}
+
+VncAuthPasswdParameter::VncAuthPasswdParameter(const char* name,
+ const char* desc,
+ StringParameter* passwdFile_)
+: BinaryParameter(name, desc, 0, 0, ConfServer), passwdFile(passwdFile_) {
+}
+
+char* VncAuthPasswdParameter::getVncAuthPasswd() {
+ ObfuscatedPasswd obfuscated;
+ getData((void**)&obfuscated.buf, &obfuscated.length);
+
+ if (obfuscated.length == 0) {
+ if (passwdFile) {
+ CharArray fname(passwdFile->getData());
+ if (!fname.buf[0]) {
+ vlog.info("neither %s nor %s params set", getName(), passwdFile->getName());
+ return 0;
+ }
+
+ FILE* fp = fopen(fname.buf, "r");
+ if (!fp) {
+ vlog.error("opening password file '%s' failed",fname.buf);
+ return 0;
+ }
+
+ vlog.debug("reading password file");
+ obfuscated.buf = new char[128];
+ obfuscated.length = fread(obfuscated.buf, 1, 128, fp);
+ fclose(fp);
+ } else {
+ vlog.info("%s parameter not set", getName());
+ }
+ }
+
+ try {
+ PlainPasswd password(obfuscated);
+ return password.takeBuf();
+ } catch (...) {
+ return 0;
+ }
+}
+