aboutsummaryrefslogtreecommitdiffstats
path: root/unix/xserver/hw
diff options
context:
space:
mode:
Diffstat (limited to 'unix/xserver/hw')
-rw-r--r--unix/xserver/hw/vnc/RFBGlue.cc33
-rw-r--r--unix/xserver/hw/vnc/RFBGlue.h3
-rw-r--r--unix/xserver/hw/vnc/XserverDesktop.cc40
-rw-r--r--unix/xserver/hw/vnc/vncExtInit.cc44
-rw-r--r--unix/xserver/hw/vnc/xvnc.c55
5 files changed, 76 insertions, 99 deletions
diff --git a/unix/xserver/hw/vnc/RFBGlue.cc b/unix/xserver/hw/vnc/RFBGlue.cc
index b7616298..f217906a 100644
--- a/unix/xserver/hw/vnc/RFBGlue.cc
+++ b/unix/xserver/hw/vnc/RFBGlue.cc
@@ -32,6 +32,8 @@
#include <network/TcpSocket.h>
+#include <rfb/UnixPasswordValidator.h>
+
#include "RFBGlue.h"
// Loggers used by C code must be created here
@@ -132,31 +134,9 @@ const char* vncGetParamDesc(const char *name)
return param->getDescription();
}
-int vncIsParamBool(const char *name)
-{
- core::VoidParameter* param;
- core::BoolParameter* bparam;
-
- param = core::Configuration::getParam(name);
- if (param == nullptr)
- return false;
-
- bparam = dynamic_cast<core::BoolParameter*>(param);
- if (bparam == nullptr)
- return false;
-
- return true;
-}
-
int vncGetParamCount(void)
{
- int count;
-
- count = 0;
- for (core::VoidParameter *param: *core::Configuration::global())
- count++;
-
- return count;
+ return core::Configuration::global()->size();
}
char *vncGetParamList(void)
@@ -256,3 +236,10 @@ int vncIsValidUTF8(const char* str, size_t bytes)
return 0;
}
}
+
+void vncSetDisplayName(const char *displayNumStr)
+{
+ std::string displayName(":");
+ displayName += displayNumStr;
+ rfb::UnixPasswordValidator::setDisplayName(displayName);
+}
diff --git a/unix/xserver/hw/vnc/RFBGlue.h b/unix/xserver/hw/vnc/RFBGlue.h
index 926f49c6..86304ad5 100644
--- a/unix/xserver/hw/vnc/RFBGlue.h
+++ b/unix/xserver/hw/vnc/RFBGlue.h
@@ -38,7 +38,6 @@ void vncLogDebug(const char *name, const char *format, ...)
int vncSetParam(const char *name, const char *value);
char* vncGetParam(const char *name);
const char* vncGetParamDesc(const char *name);
-int vncIsParamBool(const char *name);
int vncGetParamCount(void);
char *vncGetParamList(void);
@@ -56,6 +55,8 @@ char* vncUTF8ToLatin1(const char* src, size_t bytes);
int vncIsValidUTF8(const char* str, size_t bytes);
+void vncSetDisplayName(const char *displayNumStr);
+
#ifdef __cplusplus
}
#endif
diff --git a/unix/xserver/hw/vnc/XserverDesktop.cc b/unix/xserver/hw/vnc/XserverDesktop.cc
index d79c29b6..1a7a06db 100644
--- a/unix/xserver/hw/vnc/XserverDesktop.cc
+++ b/unix/xserver/hw/vnc/XserverDesktop.cc
@@ -40,6 +40,7 @@
#include <core/Configuration.h>
#include <core/LogWriter.h>
+#include <rdr/FdInStream.h>
#include <rdr/FdOutStream.h>
#include <network/Socket.h>
@@ -70,7 +71,7 @@ core::IntParameter
queryConnectTimeout("QueryConnectTimeout",
"Number of seconds to show the 'Accept "
"connection' dialog before rejecting the "
- "connection", 10);
+ "connection", 10, 0, INT_MAX);
XserverDesktop::XserverDesktop(int screenIndex_,
@@ -363,6 +364,31 @@ bool XserverDesktop::handleSocketEvent(int fd,
if (write)
sockserv->processSocketWriteEvent(*i);
+ // Do a graceful close by waiting for the peer to close their end
+ if ((*i)->isShutdown()) {
+ bool done;
+
+ done = false;
+ while (true) {
+ try {
+ (*i)->inStream().skip((*i)->inStream().avail());
+ if (!(*i)->inStream().hasData(1))
+ break;
+ } catch (std::exception&) {
+ done = true;
+ break;
+ }
+ }
+
+ if (done) {
+ vlog.debug("Client gone, sock %d",fd);
+ vncRemoveNotifyFd(fd);
+ sockserv->removeSocket(*i);
+ vncClientGone(fd);
+ delete (*i);
+ }
+ }
+
return true;
}
@@ -380,16 +406,8 @@ void XserverDesktop::blockHandler(int* timeout)
server->getSockets(&sockets);
for (i = sockets.begin(); i != sockets.end(); i++) {
int fd = (*i)->getFd();
- if ((*i)->isShutdown()) {
- vlog.debug("Client gone, sock %d",fd);
- vncRemoveNotifyFd(fd);
- server->removeSocket(*i);
- vncClientGone(fd);
- delete (*i);
- } else {
- /* Update existing NotifyFD to listen for write (or not) */
- vncSetNotifyFd(fd, screenIndex, true, (*i)->outStream().hasBufferedData());
- }
+ /* Update existing NotifyFD to listen for write (or not) */
+ vncSetNotifyFd(fd, screenIndex, true, (*i)->outStream().hasBufferedData());
}
// We are responsible for propagating mouse movement between clients
diff --git a/unix/xserver/hw/vnc/vncExtInit.cc b/unix/xserver/hw/vnc/vncExtInit.cc
index b64c14d3..e9924d70 100644
--- a/unix/xserver/hw/vnc/vncExtInit.cc
+++ b/unix/xserver/hw/vnc/vncExtInit.cc
@@ -27,7 +27,6 @@
#include <sys/types.h>
#include <pwd.h>
-#include <set>
#include <string>
#include <core/Configuration.h>
@@ -68,24 +67,17 @@ int vncFbstride[MAXSCREENS];
int vncInetdSock = -1;
-struct CaseInsensitiveCompare {
- bool operator() (const std::string &a, const std::string &b) const {
- return strcasecmp(a.c_str(), b.c_str()) < 0;
- }
-};
-
-typedef std::set<std::string, CaseInsensitiveCompare> ParamSet;
-static ParamSet allowOverrideSet;
-
static const char* defaultDesktopName();
core::IntParameter
- rfbport("rfbport", "TCP port to listen for RFB protocol", 0);
+ rfbport("rfbport",
+ "TCP port to listen for RFB protocol", 0, -1, 65535);
core::StringParameter
rfbunixpath("rfbunixpath",
"Unix socket to listen for RFB protocol", "");
core::IntParameter
- rfbunixmode("rfbunixmode", "Unix socket access mode", 0600);
+ rfbunixmode("rfbunixmode",
+ "Unix socket access mode", 0600, 0000, 0777);
core::StringParameter
desktopName("desktop", "Name of VNC desktop", defaultDesktopName());
core::BoolParameter
@@ -98,12 +90,12 @@ core::BoolParameter
avoidShiftNumLock("AvoidShiftNumLock",
"Avoid fake Shift presses for keys affected by "
"NumLock.", true);
-core::StringParameter
+core::StringListParameter
allowOverride("AllowOverride",
"Comma separated list of parameters that can be "
"modified using VNC extension.",
- "desktop,AcceptPointerEvents,SendCutText,AcceptCutText,"
- "SendPrimary,SetPrimary");
+ {"desktop", "AcceptPointerEvents", "SendCutText",
+ "AcceptCutText", "SendPrimary", "SetPrimary"});
core::BoolParameter
setPrimary("SetPrimary",
"Set the PRIMARY as well as the CLIPBOARD selection",
@@ -167,19 +159,6 @@ static rfb::PixelFormat vncGetPixelFormat(int scrIdx)
redShift, greenShift, blueShift);
}
-static void parseOverrideList(const char *text, ParamSet &out)
-{
- for (const char* iter = text; ; ++iter) {
- if (*iter == ',' || *iter == '\0') {
- out.insert(std::string(text, iter));
- text = iter + 1;
-
- if (*iter == '\0')
- break;
- }
- }
-}
-
void vncExtensionInit(void)
{
if (vncExtGeneration == vncGetServerGeneration()) {
@@ -201,7 +180,6 @@ void vncExtensionInit(void)
if (!initialised) {
core::initStdIOLoggers();
- parseOverrideList(allowOverride, allowOverrideSet);
allowOverride.setImmutable();
initialised = true;
@@ -523,8 +501,10 @@ void vncAbortMsc(int scrIdx, uint64_t id)
int vncOverrideParam(const char *param, const char *value)
{
- if (allowOverrideSet.find(param) == allowOverrideSet.end())
- return 0;
+ for (const char* allowed : allowOverride) {
+ if (strcasecmp(allowed, param) == 0)
+ return core::Configuration::setParam(param, value);
+ }
- return core::Configuration::setParam(param, value);
+ return 0;
}
diff --git a/unix/xserver/hw/vnc/xvnc.c b/unix/xserver/hw/vnc/xvnc.c
index 0b8e028f..5cf673aa 100644
--- a/unix/xserver/hw/vnc/xvnc.c
+++ b/unix/xserver/hw/vnc/xvnc.c
@@ -110,7 +110,6 @@ static VncScreenInfo vncScreenInfo = {
static Bool vncPixmapDepths[33];
static Bool Render = TRUE;
-static Bool displaySpecified = FALSE;
static char displayNumStr[16];
static int vncVerbose = 0;
@@ -176,15 +175,20 @@ ddxGiveUp(enum ExitCode error)
vncFreeFramebufferMemory(&vncScreenInfo.fb);
}
+#if XORG_OLDER_THAN(1, 21, 1)
void
AbortDDX(enum ExitCode error)
{
ddxGiveUp(error);
}
+#endif
void
OsVendorInit(void)
{
+ /* At this point, display has been set, so we can use it to
+ * initialize UnixPasswordValidator */
+ vncSetDisplayName(display);
}
void
@@ -276,14 +280,16 @@ ddxProcessArgument(int argc, char *argv[], int i)
}
if (argv[i][0] == ':')
- displaySpecified = TRUE;
+ return 0;
+#if XORG_OLDER_THAN(1, 21, 1)
#define CHECK_FOR_REQUIRED_ARGUMENTS(num) \
if (((i + num) >= argc) || (!argv[i + num])) { \
ErrorF("Required argument to %s not specified\n", argv[i]); \
UseMsg(); \
FatalError("Required argument to %s not specified\n", argv[i]); \
}
+#endif
if (strcmp(argv[i], "-pixdepths") == 0) { /* -pixdepths list-of-depth */
int depth, ret = 1;
@@ -382,7 +388,7 @@ ddxProcessArgument(int argc, char *argv[], int i)
dup2(nullfd, 2);
close(nullfd);
- if (!displaySpecified) {
+ if (!explicit_display) {
int port = vncGetSocketPort(vncInetdSock);
int displayNum = port - 5900;
@@ -396,9 +402,9 @@ ddxProcessArgument(int argc, char *argv[], int i)
FatalError
("Xvnc error: No free display number for -inetd\n");
}
-
- display = displayNumStr;
sprintf(displayNumStr, "%d", displayNum);
+ display = displayNumStr;
+ explicit_display = TRUE;
}
return 1;
@@ -442,30 +448,11 @@ ddxProcessArgument(int argc, char *argv[], int i)
}
if (!strcmp(argv[i], "-showconfig") || !strcmp(argv[i], "-version")) {
- /* Already shown at start */
+ vncPrintBanner();
exit(0);
}
- /* We need to resolve an ambiguity for booleans */
- if (argv[i][0] == '-' && i + 1 < argc && vncIsParamBool(&argv[i][1])) {
- if ((strcasecmp(argv[i + 1], "0") == 0) ||
- (strcasecmp(argv[i + 1], "1") == 0) ||
- (strcasecmp(argv[i + 1], "true") == 0) ||
- (strcasecmp(argv[i + 1], "false") == 0) ||
- (strcasecmp(argv[i + 1], "yes") == 0) ||
- (strcasecmp(argv[i + 1], "no") == 0)) {
- vncSetParam(&argv[i][1], argv[i + 1]);
- return 2;
- }
- }
-
- int ret;
-
- ret = vncHandleParamArg(argc, argv, i);
- if (ret != 0)
- return ret;
-
- return 0;
+ return vncHandleParamArg(argc, argv, i);
}
static Bool
@@ -761,12 +748,13 @@ vncRandRModeGet(int width, int height)
xRRModeInfo modeInfo;
char name[100];
RRModePtr mode;
+#ifdef HAVE_LIBXCVT
+ struct libxcvt_mode_info *cvtMode;
+#endif
memset(&modeInfo, 0, sizeof(modeInfo));
#ifdef HAVE_LIBXCVT
- struct libxcvt_mode_info *cvtMode;
-
cvtMode = libxcvt_gen_mode_info(width, height, 60.0, false, false);
modeInfo.width = cvtMode->hdisplay;
@@ -899,7 +887,7 @@ vncRandRCreateScreenOutputs(int scrIdx, int extraOutputs)
/* Creating and modifying modes, used by XserverDesktop and init here */
int
-vncRandRCanCreateModes()
+vncRandRCanCreateModes(void)
{
return 1;
}
@@ -1166,8 +1154,11 @@ InitOutput(ScreenInfo * scrInfo, int argc, char **argv)
int i;
int NumFormats = 0;
- if (serverGeneration == 1)
+ if (serverGeneration == 1) {
+ vncPrintBanner();
+
LoadExtensionList(vncExtensions, ARRAY_SIZE(vncExtensions), TRUE);
+ }
#if XORG_AT_LEAST(1, 20, 0)
xorgGlxCreateVendor();
@@ -1224,11 +1215,13 @@ DDXRingBell(int percent, int pitch, int duration)
vncBell();
}
+#if XORG_OLDER_THAN(1, 21, 1)
Bool
LegalModifier(unsigned int key, DeviceIntPtr pDev)
{
return TRUE;
}
+#endif
void
ProcessInputEvents(void)
@@ -1259,7 +1252,5 @@ vncClientGone(int fd)
int
main(int argc, char *argv[], char *envp[])
{
- vncPrintBanner();
-
return dix_main(argc, argv, envp);
}