diff options
-rw-r--r-- | common/rfb/Makefile.am | 8 | ||||
-rw-r--r-- | common/rfb/Security.cxx | 61 | ||||
-rw-r--r-- | common/rfb/Security.h | 29 | ||||
-rw-r--r-- | unix/vncviewer/vncviewer.cxx | 2 |
4 files changed, 94 insertions, 6 deletions
diff --git a/common/rfb/Makefile.am b/common/rfb/Makefile.am index 93189b99..a3b134fc 100644 --- a/common/rfb/Makefile.am +++ b/common/rfb/Makefile.am @@ -13,9 +13,9 @@ HDRS = Blacklist.h CapsContainer.h CapsList.h CConnection.h \ PixelFormat.h PixelFormat.inl Pixel.h RawDecoder.h RawEncoder.h \ Rect.h Region.h rreDecode.h RREDecoder.h rreEncode.h RREEncoder.h \ ScaledPixelBuffer.h ScaleFilters.h SConnection.h ScreenSet.h \ - screenTypes.h SDesktop.h Security.h ServerCore.h SMsgHandler.h \ + screenTypes.h SDesktop.h ServerCore.h SMsgHandler.h \ SMsgReader.h SMsgReaderV3.h SMsgWriter.h SMsgWriterV3.h \ - SSecurityFactoryStandard.h SSecurity.h SSecurityNone.h \ + Security.h SSecurityFactoryStandard.h SSecurityNone.h \ SSecurityVncAuth.h Threading.h tightDecode.h TightDecoder.h \ tightEncode.h TightEncoder.h TightPalette.h Timer.h \ TransImageGetter.h transInitTempl.h transTempl.h TrueColourMap.h \ @@ -34,12 +34,12 @@ librfb_la_SOURCES = $(HDRS) Blacklist.cxx CConnection.cxx CMsgHandler.cxx \ RREEncoder.cxx RREDecoder.cxx RawDecoder.cxx RawEncoder.cxx \ Region.cxx SConnection.cxx SMsgHandler.cxx \ SMsgReader.cxx SMsgReaderV3.cxx SMsgWriter.cxx SMsgWriterV3.cxx \ - ServerCore.cxx SSecurityFactoryStandard.cxx SSecurityVncAuth.cxx \ + ServerCore.cxx Security.cxx SSecurityFactoryStandard.cxx SSecurityVncAuth.cxx \ ScaledPixelBuffer.cxx ScaleFilters.cxx Timer.cxx TightDecoder.cxx \ TightEncoder.cxx TightPalette.cxx TransImageGetter.cxx \ UpdateTracker.cxx VNCSConnectionST.cxx \ VNCServerST.cxx ZRLEEncoder.cxx ZRLEDecoder.cxx encodings.cxx \ - Security.cxx util.cxx + util.cxx librfb_la_CPPFLAGS = -I$(top_srcdir)/common -I$(top_srcdir)/win librfb_la_LIBADD = diff --git a/common/rfb/Security.cxx b/common/rfb/Security.cxx index d6a9cac7..a38029a5 100644 --- a/common/rfb/Security.cxx +++ b/common/rfb/Security.cxx @@ -15,13 +15,74 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ +#include <assert.h> +#include <stdlib.h> #include <string.h> #ifdef _WIN32 #define strcasecmp _stricmp #endif +#include <rdr/Exception.h> +#include <rfb/LogWriter.h> #include <rfb/Security.h> +#include <rfb/SSecurityNone.h> +#include <rfb/SSecurityFactoryStandard.h> +#include <rfb/SSecurityVncAuth.h> #include <rfb/util.h> +using namespace rdr; +using namespace rfb; +using namespace std; + +static LogWriter vlog("Security"); + +Security::Security(void) +{ + char *secTypesStr = SSecurityFactoryStandard::sec_types.getData(); + + enabledSecTypes = parseSecTypes(secTypesStr); + + delete secTypesStr; +} + +void Security::EnableSecType(U8 secType) +{ + list<U8>::iterator i; + + for (i = enabledSecTypes.begin(); i != enabledSecTypes.end(); i++) + if (*i == secType) + return; + + enabledSecTypes.push_back(secType); +} + +bool Security::IsSupported(U8 secType) +{ + list<U8>::iterator i; + + for (i = enabledSecTypes.begin(); i != enabledSecTypes.end(); i++) + if (*i == secType) + return true; + + return false; +} + +SSecurity* Security::GetSSecurity(U8 secType) +{ + if (!IsSupported(secType)) + goto bail; + + switch (secType) { + case secTypeNone: return new SSecurityNone(); + case secTypeVncAuth: return new SSecurityVncAuth(); + default: + vlog.error("Undefined security type %d, aborting"); + abort(); + } + +bail: + throw Exception("Security type not supported"); +} + rdr::U8 rfb::secTypeNum(const char* name) { if (strcasecmp(name, "None") == 0) return secTypeNone; diff --git a/common/rfb/Security.h b/common/rfb/Security.h index 9ccfb56b..cb499110 100644 --- a/common/rfb/Security.h +++ b/common/rfb/Security.h @@ -23,6 +23,9 @@ #define __RFB_SECTYPES_H__ #include <rdr/types.h> +#include <rfb/Configuration.h> +#include <rfb/SSecurity.h> + #include <list> namespace rfb { @@ -34,7 +37,7 @@ namespace rfb { const rdr::U8 secTypeRA2ne = 6; const rdr::U8 secTypeSSPI = 7; - const rdr::U8 secTypeSSPIne = 8; + const rdr::U8 secTypeSSPIne = 8; const rdr::U8 secTypeTight = 16; const rdr::U8 secTypeUltra = 17; @@ -46,6 +49,30 @@ namespace rfb { const rdr::U32 secResultFailed = 1; const rdr::U32 secResultTooMany = 2; // deprecated + class Security { + public: + /* Create Security instance */ + Security(void); + + /* Enable/Disable certain security type */ + void EnableSecType(rdr::U8 secType); + void DisableSecType(rdr::U8 secType) { enabledSecTypes.remove(secType); } + + /* Check if certain type is supported */ + bool IsSupported(rdr::U8 secType); + + /* Get list of enabled security types */ + const std::list<rdr::U8>& GetEnabledSecTypes(void) + { return enabledSecTypes; } + + /* Create server side SSecurity class instance */ + SSecurity* GetSSecurity(rdr::U8 secType); + + static StringParameter secTypes; + private: + std::list<rdr::U8> enabledSecTypes; + }; + const char* secTypeName(rdr::U8 num); rdr::U8 secTypeNum(const char* name); std::list<rdr::U8> parseSecTypes(const char* types); diff --git a/unix/vncviewer/vncviewer.cxx b/unix/vncviewer/vncviewer.cxx index 720c8a16..80d65c55 100644 --- a/unix/vncviewer/vncviewer.cxx +++ b/unix/vncviewer/vncviewer.cxx @@ -58,7 +58,7 @@ IntParameter wmDecorationHeight("WMDecorationHeight", "Height of window " "manager decoration around a window", 24); StringParameter passwordFile("PasswordFile", "Password file for VNC authentication", ""); -AliasParameter rfbauth("passwd", "Alias for PasswordFile", &passwordFile); +AliasParameter passwd("passwd", "Alias for PasswordFile", &passwordFile); BoolParameter useLocalCursor("UseLocalCursor", "Render the mouse cursor locally", true); |