diff options
author | Adam Tkac <atkac@redhat.com> | 2010-04-23 14:02:43 +0000 |
---|---|---|
committer | Adam Tkac <atkac@redhat.com> | 2010-04-23 14:02:43 +0000 |
commit | 162ac3527dbdafdab9849f48a33726563d87b577 (patch) | |
tree | d85165d72630a09489bca30aa0ea1bd115dd2f6c | |
parent | 9c28a7b3b09eec9f7322222e18e5d1bbe917db60 (diff) | |
download | tigervnc-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
-rw-r--r-- | common/rfb/SSecurityFactoryStandard.cxx | 52 | ||||
-rw-r--r-- | common/rfb/SSecurityFactoryStandard.h | 10 | ||||
-rw-r--r-- | common/rfb/SSecurityVncAuth.cxx | 53 | ||||
-rw-r--r-- | common/rfb/SSecurityVncAuth.h | 13 | ||||
-rw-r--r-- | unix/xserver/hw/vnc/vncExtInit.cc | 2 | ||||
-rw-r--r-- | win/vncconfig/Authentication.h | 3 |
6 files changed, 66 insertions, 67 deletions
diff --git a/common/rfb/SSecurityFactoryStandard.cxx b/common/rfb/SSecurityFactoryStandard.cxx index 6056a19e..333d50bc 100644 --- a/common/rfb/SSecurityFactoryStandard.cxx +++ b/common/rfb/SSecurityFactoryStandard.cxx @@ -42,18 +42,11 @@ StringParameter SSecurityFactoryStandard::rev_sec_types "None"); -StringParameter SSecurityFactoryStandard::vncAuthPasswdFile -("PasswordFile", "Password file for VNC authentication", ""); -VncAuthPasswdParameter SSecurityFactoryStandard::vncAuthPasswd -("Password", "Obfuscated binary encoding of the password which clients must supply to " - "access the server", &SSecurityFactoryStandard::vncAuthPasswdFile); - - SSecurity* SSecurityFactoryStandard::getSSecurity(rdr::U8 secType, bool reverseConnection) { switch (secType) { case secTypeNone: return new SSecurityNone(); case secTypeVncAuth: - return new SSecurityVncAuth(&vncAuthPasswd); + return new SSecurityVncAuth(); default: throw Exception("Security type not supported"); } @@ -83,46 +76,3 @@ bool SSecurityFactoryStandard::isSecTypeSupported(rdr::U8 secType) { } } - -VncAuthPasswdParameter::VncAuthPasswdParameter(const char* name, - const char* desc, - StringParameter* passwdFile_) -: BinaryParameter(name, desc, 0, 0), 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; - } -} - - diff --git a/common/rfb/SSecurityFactoryStandard.h b/common/rfb/SSecurityFactoryStandard.h index 165881ec..f55894e3 100644 --- a/common/rfb/SSecurityFactoryStandard.h +++ b/common/rfb/SSecurityFactoryStandard.h @@ -44,22 +44,12 @@ namespace rfb { - class VncAuthPasswdParameter : public VncAuthPasswdGetter, BinaryParameter { - public: - VncAuthPasswdParameter(const char* name, const char* desc, StringParameter* passwdFile_); - virtual char* getVncAuthPasswd(); - protected: - StringParameter* passwdFile; - }; - class SSecurityFactoryStandard : public SSecurityFactory { public: virtual SSecurity* getSSecurity(rdr::U8 secType, bool reverse); virtual void getSecTypes(std::list<rdr::U8>* secTypes, bool reverse); static StringParameter sec_types; static StringParameter rev_sec_types; - static StringParameter vncAuthPasswdFile; - static VncAuthPasswdParameter vncAuthPasswd; protected: virtual bool isSecTypeSupported(rdr::U8 secType); }; 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; + } +} + diff --git a/common/rfb/SSecurityVncAuth.h b/common/rfb/SSecurityVncAuth.h index 1f7e6ece..8a2d0f62 100644 --- a/common/rfb/SSecurityVncAuth.h +++ b/common/rfb/SSecurityVncAuth.h @@ -24,6 +24,7 @@ #ifndef __RFB_SSECURITYVNCAUTH_H__ #define __RFB_SSECURITYVNCAUTH_H__ +#include <rfb/Configuration.h> #include <rfb/SSecurity.h> #include <rfb/Security.h> #include <rdr/types.h> @@ -37,12 +38,22 @@ namespace rfb { virtual char* getVncAuthPasswd()=0; }; + class VncAuthPasswdParameter : public VncAuthPasswdGetter, BinaryParameter { + public: + VncAuthPasswdParameter(const char* name, const char* desc, StringParameter* passwdFile_); + virtual char* getVncAuthPasswd(); + protected: + StringParameter* passwdFile; + }; + class SSecurityVncAuth : public SSecurity { public: - SSecurityVncAuth(VncAuthPasswdGetter* pg); + SSecurityVncAuth(void); virtual bool processMsg(SConnection* sc); virtual int getType() const {return secTypeVncAuth;} virtual const char* getUserName() const {return 0;} + static StringParameter vncAuthPasswdFile; + static VncAuthPasswdParameter vncAuthPasswd; private: enum {vncAuthChallengeSize = 16}; rdr::U8 challenge[vncAuthChallengeSize]; diff --git a/unix/xserver/hw/vnc/vncExtInit.cc b/unix/xserver/hw/vnc/vncExtInit.cc index 36948681..e7cb2a7a 100644 --- a/unix/xserver/hw/vnc/vncExtInit.cc +++ b/unix/xserver/hw/vnc/vncExtInit.cc @@ -110,8 +110,6 @@ static int vncErrorBase = 0; static int vncEventBase = 0; int vncInetdSock = -1; -rfb::AliasParameter rfbauth("rfbauth", "Alias for PasswordFile", - &SSecurityFactoryStandard::vncAuthPasswdFile); rfb::StringParameter httpDir("httpd", "Directory containing files to serve via HTTP", ""); diff --git a/win/vncconfig/Authentication.h b/win/vncconfig/Authentication.h index 24b71038..a59990b9 100644 --- a/win/vncconfig/Authentication.h +++ b/win/vncconfig/Authentication.h @@ -24,7 +24,8 @@ #include <rfb_win32/OSVersion.h> #include <rfb_win32/MsgBox.h> #include <rfb/ServerCore.h> -#include <rfb/secTypes.h> +#include <rfb/Security.h> +#include <rfb/SSecurityVncAuth.h> #include <rfb/Password.h> static rfb::BoolParameter queryOnlyIfLoggedOn("QueryOnlyIfLoggedOn", |