-
-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The configured VNC security method should apply only to VNC clients. …
…The web interface, going through WebSocket, should not be affected.
- Loading branch information
Showing
3 changed files
with
137 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
# | ||
# This patch adds the ability to configure a different of security types for | ||
# internal connection (e.g. Unix domain socket). | ||
# | ||
--- a/common/rfb/SConnection.cxx | ||
+++ b/common/rfb/SConnection.cxx | ||
@@ -45,6 +45,7 @@ static LogWriter vlog("SConnection"); | ||
|
||
SConnection::SConnection(AccessRights accessRights) | ||
: readyForSetColourMapEntries(false), | ||
+ isInternal(false), | ||
is(0), os(0), reader_(0), writer_(0), ssecurity(0), | ||
authFailureTimer(this, &SConnection::handleAuthFailureTimeout), | ||
state_(RFBSTATE_UNINITIALISED), preferredEncoding(encodingRaw), | ||
@@ -71,6 +76,17 @@ void SConnection::setStreams(rdr::InStream* is_, rdr::OutStream* os_) | ||
os = os_; | ||
} | ||
|
||
+void SConnection::setInternal(bool internal) | ||
+{ | ||
+ isInternal = internal; | ||
+ security.UpdateSecTypes(this); | ||
+} | ||
+ | ||
+bool SConnection::getInternal() | ||
+{ | ||
+ return isInternal; | ||
+} | ||
+ | ||
void SConnection::initialiseProtocol() | ||
{ | ||
char str[13]; | ||
--- a/common/rfb/SConnection.h | ||
+++ b/common/rfb/SConnection.h | ||
@@ -56,6 +56,11 @@ namespace rfb { | ||
// (i.e. SConnection will not delete them). | ||
void setStreams(rdr::InStream* is, rdr::OutStream* os); | ||
|
||
+ // setInternal() is used to indicate if this is an internal connection, like | ||
+ // from a Unix Domain Socket. | ||
+ void setInternal(bool internal); | ||
+ bool getInternal(); | ||
+ | ||
// initialiseProtocol() should be called once the streams and security | ||
// types are set. Subsequently, processMsg() should be called whenever | ||
// there is data to read on the InStream. | ||
@@ -242,6 +248,8 @@ namespace rfb { | ||
|
||
int defaultMajorVersion, defaultMinorVersion; | ||
|
||
+ bool isInternal; | ||
+ | ||
rdr::InStream* is; | ||
rdr::OutStream* os; | ||
|
||
--- a/common/rfb/SecurityServer.cxx | ||
+++ b/common/rfb/SecurityServer.cxx | ||
@@ -54,6 +54,19 @@ StringParameter SecurityServer::secTypes | ||
"VncAuth", | ||
ConfServer); | ||
|
||
+StringParameter SecurityServer::internalConnectionSecTypes | ||
+("InternalConnectionSecurityTypes", | ||
+ "Specify which security scheme to use for internal connections (None, VncAuth, Plain" | ||
+#ifdef HAVE_GNUTLS | ||
+ ", TLSNone, TLSVnc, TLSPlain, X509None, X509Vnc, X509Plain" | ||
+#endif | ||
+#ifdef HAVE_NETTLE | ||
+ ", RA2, RA2ne, RA2_256, RA2ne_256" | ||
+#endif | ||
+ ")", | ||
+ "", | ||
+ConfServer); | ||
+ | ||
SSecurity* SecurityServer::GetSSecurity(SConnection* sc, uint32_t secType) | ||
{ | ||
if (!IsSupported(secType)) | ||
@@ -94,3 +107,13 @@ bail: | ||
throw Exception("Security type not supported"); | ||
} | ||
|
||
+void SecurityServer::UpdateSecTypes(SConnection *sc) | ||
+{ | ||
+ std::list<uint32_t> newSecTypes; | ||
+ if (sc->getInternal()) | ||
+ newSecTypes = parseSecTypes(internalConnectionSecTypes); | ||
+ if (newSecTypes.size() == 0) | ||
+ newSecTypes = parseSecTypes(secTypes); | ||
+ SetSecTypes(newSecTypes); | ||
+} | ||
+ | ||
--- a/common/rfb/SecurityServer.h | ||
+++ b/common/rfb/SecurityServer.h | ||
@@ -35,7 +35,10 @@ namespace rfb { | ||
/* Create server side SSecurity class instance */ | ||
SSecurity* GetSSecurity(SConnection* sc, uint32_t secType); | ||
|
||
+ void UpdateSecTypes(SConnection* sc); | ||
+ | ||
static StringParameter secTypes; | ||
+ static StringParameter internalConnectionSecTypes; | ||
}; | ||
|
||
} | ||
--- a/common/rfb/VNCSConnectionST.cxx | ||
+++ b/common/rfb/VNCSConnectionST.cxx | ||
@@ -22,6 +22,8 @@ | ||
#include <config.h> | ||
#endif | ||
|
||
+#include <sys/socket.h> | ||
+ | ||
#include <network/TcpSocket.h> | ||
|
||
#include <rfb/ComparingUpdateTracker.h> | ||
@@ -73,6 +75,17 @@ VNCSConnectionST::VNCSConnectionST(VNCServerST* server_, network::Socket *s, | ||
else | ||
idleTimer.start(secsToMillis(rfb::Server::idleTimeout)); | ||
} | ||
+ | ||
+ // Determine is this is an internal connection | ||
+ { | ||
+ struct sockaddr addr; | ||
+ socklen_t salen = sizeof(addr); | ||
+ if (getsockname(sock->getFd(), &addr, &salen) == 0) { | ||
+ if (addr.sa_family == AF_UNIX) { | ||
+ setInternal(true); | ||
+ } | ||
+ } | ||
+ } | ||
} | ||
|
||
|