Skip to content

Commit 06bb023

Browse files
committed
The configured VNC security method should apply only to VNC clients. The web interface, going through WebSocket, should not be affected.
1 parent 21a63eb commit 06bb023

File tree

3 files changed

+137
-0
lines changed

3 files changed

+137
-0
lines changed

rootfs/etc/services.d/xvnc/params

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ if [ -n "$PASSWORD_FILE" ]; then
7373
else
7474
echo "-SecurityTypes=X509Vnc,TLSVnc"
7575
fi
76+
echo "-InternalConnectionSecurityTypes=VncAuth"
7677
echo "-rfbauth=$PASSWORD_FILE"
7778
else
7879
# Without password.
@@ -81,6 +82,7 @@ else
8182
else
8283
echo "-SecurityTypes=X509None,TLSNone"
8384
fi
85+
echo "-InternalConnectionSecurityTypes=None"
8486
fi
8587

8688
if is-bool-val-true "${SECURE_CONNECTION:-0}" && [ "${SECURE_CONNECTION_VNC_METHOD:-SSL}" != "SSL" ]; then

src/tigervnc/build.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,8 @@ patch -p1 -d /tmp/tigervnc < "$SCRIPT_DIR"/vncpasswd-static.patch
364364
patch -p1 -d /tmp/tigervnc < "$SCRIPT_DIR"/disable-pam.patch
365365
# Fix static build.
366366
patch -p1 -d /tmp/tigervnc < "$SCRIPT_DIR"/static-build.patch
367+
# Support for internal connection security types.
368+
patch -p1 -d /tmp/tigervnc < "$SCRIPT_DIR"/internal-conn-sec-types.patch
367369

368370
log "Configuring TigerVNC..."
369371
(
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
#
2+
# This patch adds the ability to configure a different of security types for
3+
# internal connection (e.g. Unix domain socket).
4+
#
5+
--- a/common/rfb/SConnection.cxx
6+
+++ b/common/rfb/SConnection.cxx
7+
@@ -45,6 +45,7 @@ static LogWriter vlog("SConnection");
8+
9+
SConnection::SConnection(AccessRights accessRights)
10+
: readyForSetColourMapEntries(false),
11+
+ isInternal(false),
12+
is(0), os(0), reader_(0), writer_(0), ssecurity(0),
13+
authFailureTimer(this, &SConnection::handleAuthFailureTimeout),
14+
state_(RFBSTATE_UNINITIALISED), preferredEncoding(encodingRaw),
15+
@@ -71,6 +76,17 @@ void SConnection::setStreams(rdr::InStream* is_, rdr::OutStream* os_)
16+
os = os_;
17+
}
18+
19+
+void SConnection::setInternal(bool internal)
20+
+{
21+
+ isInternal = internal;
22+
+ security.UpdateSecTypes(this);
23+
+}
24+
+
25+
+bool SConnection::getInternal()
26+
+{
27+
+ return isInternal;
28+
+}
29+
+
30+
void SConnection::initialiseProtocol()
31+
{
32+
char str[13];
33+
--- a/common/rfb/SConnection.h
34+
+++ b/common/rfb/SConnection.h
35+
@@ -56,6 +56,11 @@ namespace rfb {
36+
// (i.e. SConnection will not delete them).
37+
void setStreams(rdr::InStream* is, rdr::OutStream* os);
38+
39+
+ // setInternal() is used to indicate if this is an internal connection, like
40+
+ // from a Unix Domain Socket.
41+
+ void setInternal(bool internal);
42+
+ bool getInternal();
43+
+
44+
// initialiseProtocol() should be called once the streams and security
45+
// types are set. Subsequently, processMsg() should be called whenever
46+
// there is data to read on the InStream.
47+
@@ -242,6 +248,8 @@ namespace rfb {
48+
49+
int defaultMajorVersion, defaultMinorVersion;
50+
51+
+ bool isInternal;
52+
+
53+
rdr::InStream* is;
54+
rdr::OutStream* os;
55+
56+
--- a/common/rfb/SecurityServer.cxx
57+
+++ b/common/rfb/SecurityServer.cxx
58+
@@ -54,6 +54,19 @@ StringParameter SecurityServer::secTypes
59+
"VncAuth",
60+
ConfServer);
61+
62+
+StringParameter SecurityServer::internalConnectionSecTypes
63+
+("InternalConnectionSecurityTypes",
64+
+ "Specify which security scheme to use for internal connections (None, VncAuth, Plain"
65+
+#ifdef HAVE_GNUTLS
66+
+ ", TLSNone, TLSVnc, TLSPlain, X509None, X509Vnc, X509Plain"
67+
+#endif
68+
+#ifdef HAVE_NETTLE
69+
+ ", RA2, RA2ne, RA2_256, RA2ne_256"
70+
+#endif
71+
+ ")",
72+
+ "",
73+
+ConfServer);
74+
+
75+
SSecurity* SecurityServer::GetSSecurity(SConnection* sc, uint32_t secType)
76+
{
77+
if (!IsSupported(secType))
78+
@@ -94,3 +107,13 @@ bail:
79+
throw Exception("Security type not supported");
80+
}
81+
82+
+void SecurityServer::UpdateSecTypes(SConnection *sc)
83+
+{
84+
+ std::list<uint32_t> newSecTypes;
85+
+ if (sc->getInternal())
86+
+ newSecTypes = parseSecTypes(internalConnectionSecTypes);
87+
+ if (newSecTypes.size() == 0)
88+
+ newSecTypes = parseSecTypes(secTypes);
89+
+ SetSecTypes(newSecTypes);
90+
+}
91+
+
92+
--- a/common/rfb/SecurityServer.h
93+
+++ b/common/rfb/SecurityServer.h
94+
@@ -35,7 +35,10 @@ namespace rfb {
95+
/* Create server side SSecurity class instance */
96+
SSecurity* GetSSecurity(SConnection* sc, uint32_t secType);
97+
98+
+ void UpdateSecTypes(SConnection* sc);
99+
+
100+
static StringParameter secTypes;
101+
+ static StringParameter internalConnectionSecTypes;
102+
};
103+
104+
}
105+
--- a/common/rfb/VNCSConnectionST.cxx
106+
+++ b/common/rfb/VNCSConnectionST.cxx
107+
@@ -22,6 +22,8 @@
108+
#include <config.h>
109+
#endif
110+
111+
+#include <sys/socket.h>
112+
+
113+
#include <network/TcpSocket.h>
114+
115+
#include <rfb/ComparingUpdateTracker.h>
116+
@@ -73,6 +75,17 @@ VNCSConnectionST::VNCSConnectionST(VNCServerST* server_, network::Socket *s,
117+
else
118+
idleTimer.start(secsToMillis(rfb::Server::idleTimeout));
119+
}
120+
+
121+
+ // Determine is this is an internal connection
122+
+ {
123+
+ struct sockaddr addr;
124+
+ socklen_t salen = sizeof(addr);
125+
+ if (getsockname(sock->getFd(), &addr, &salen) == 0) {
126+
+ if (addr.sa_family == AF_UNIX) {
127+
+ setInternal(true);
128+
+ }
129+
+ }
130+
+ }
131+
}
132+
133+

0 commit comments

Comments
 (0)