aboutsummaryrefslogtreecommitdiffstats
path: root/unix/xserver/hw/vnc
diff options
context:
space:
mode:
Diffstat (limited to 'unix/xserver/hw/vnc')
-rw-r--r--unix/xserver/hw/vnc/Makefile.am21
-rw-r--r--unix/xserver/hw/vnc/RFBGlue.cc118
-rw-r--r--unix/xserver/hw/vnc/RFBGlue.h6
-rw-r--r--unix/xserver/hw/vnc/XserverDesktop.cc121
-rw-r--r--unix/xserver/hw/vnc/XserverDesktop.h23
-rw-r--r--unix/xserver/hw/vnc/Xvnc.man335
-rw-r--r--unix/xserver/hw/vnc/vncExt.c23
-rw-r--r--unix/xserver/hw/vnc/vncExtInit.cc143
-rw-r--r--unix/xserver/hw/vnc/vncExtInit.h2
-rw-r--r--unix/xserver/hw/vnc/vncInput.c2
-rw-r--r--unix/xserver/hw/vnc/vncModule.c2
-rw-r--r--unix/xserver/hw/vnc/xvnc.c65
12 files changed, 433 insertions, 428 deletions
diff --git a/unix/xserver/hw/vnc/Makefile.am b/unix/xserver/hw/vnc/Makefile.am
index 4049bafa..337d8f97 100644
--- a/unix/xserver/hw/vnc/Makefile.am
+++ b/unix/xserver/hw/vnc/Makefile.am
@@ -1,15 +1,12 @@
-TIGERVNC_SRCDIR=${top_srcdir}/../..
-TIGERVNC_BUILDDIR=${TIGERVNC_SRCDIR}
-
-# FIXME: We add an extra / to the paths to trick libtool in to adding
-# the libraries twice, to work around the dependency cycles we
-# have
-RFB_LIB=$(TIGERVNC_BUILDDIR)//common/rfb/librfb.la
-RDR_LIB=$(TIGERVNC_BUILDDIR)//common/rdr/librdr.la
-OS_LIB=$(TIGERVNC_BUILDDIR)//common/os/libos.la
-NETWORK_LIB=$(TIGERVNC_BUILDDIR)//common/network/libnetwork.la
-UNIXCOMMON_LIB=$(TIGERVNC_BUILDDIR)//unix/common/libunixcommon.la
-COMMON_LIBS=$(NETWORK_LIB) $(RFB_LIB) $(RDR_LIB) $(OS_LIB) $(UNIXCOMMON_LIB)
+TIGERVNC_SRCDIR=$(abspath ${top_srcdir}/../..)
+TIGERVNC_BUILDDIR=$(abspath ${top_builddir}/../..)
+
+RFB_LIB=$(TIGERVNC_BUILDDIR)/common/rfb/librfb.la
+RDR_LIB=$(TIGERVNC_BUILDDIR)/common/rdr/librdr.la
+OS_LIB=$(TIGERVNC_BUILDDIR)/common/os/libos.la
+NETWORK_LIB=$(TIGERVNC_BUILDDIR)/common/network/libnetwork.la
+UNIXCOMMON_LIB=$(TIGERVNC_BUILDDIR)/unix/common/libunixcommon.la
+COMMON_LIBS=$(UNIXCOMMON_LIB) $(RFB_LIB) $(NETWORK_LIB) $(RDR_LIB) $(CORE_LIB)
AM_CPPFLAGS = \
-I$(TIGERVNC_BUILDDIR) \
diff --git a/unix/xserver/hw/vnc/RFBGlue.cc b/unix/xserver/hw/vnc/RFBGlue.cc
index 2295bee8..f217906a 100644
--- a/unix/xserver/hw/vnc/RFBGlue.cc
+++ b/unix/xserver/hw/vnc/RFBGlue.cc
@@ -22,35 +22,36 @@
#endif
#include <stdlib.h>
+#include <string.h>
+
+#include <core/Configuration.h>
+#include <core/Logger_stdio.h>
+#include <core/Logger_syslog.h>
+#include <core/LogWriter.h>
+#include <core/string.h>
#include <network/TcpSocket.h>
-#include <rfb/Configuration.h>
-#include <rfb/LogWriter.h>
-#include <rfb/Logger_stdio.h>
-#include <rfb/Logger_syslog.h>
-#include <rfb/util.h>
-#include "RFBGlue.h"
+#include <rfb/UnixPasswordValidator.h>
-using namespace rfb;
+#include "RFBGlue.h"
// Loggers used by C code must be created here
-static LogWriter inputLog("Input");
-static LogWriter selectionLog("Selection");
+static core::LogWriter inputLog("Input");
+static core::LogWriter selectionLog("Selection");
void vncInitRFB(void)
{
- rfb::initStdIOLoggers();
- rfb::initSyslogLogger();
- rfb::LogWriter::setLogParams("*:stderr:30");
- rfb::Configuration::enableServerParams();
+ core::initStdIOLoggers();
+ core::initSyslogLogger();
+ core::LogWriter::setLogParams("*:stderr:30");
}
void vncLogError(const char *name, const char *format, ...)
{
- LogWriter *vlog;
+ core::LogWriter* vlog;
va_list ap;
- vlog = LogWriter::getLogWriter(name);
+ vlog = core::LogWriter::getLogWriter(name);
if (vlog == nullptr)
return;
va_start(ap, format);
@@ -60,9 +61,9 @@ void vncLogError(const char *name, const char *format, ...)
void vncLogStatus(const char *name, const char *format, ...)
{
- LogWriter *vlog;
+ core::LogWriter* vlog;
va_list ap;
- vlog = LogWriter::getLogWriter(name);
+ vlog = core::LogWriter::getLogWriter(name);
if (vlog == nullptr)
return;
va_start(ap, format);
@@ -72,9 +73,9 @@ void vncLogStatus(const char *name, const char *format, ...)
void vncLogInfo(const char *name, const char *format, ...)
{
- LogWriter *vlog;
+ core::LogWriter* vlog;
va_list ap;
- vlog = LogWriter::getLogWriter(name);
+ vlog = core::LogWriter::getLogWriter(name);
if (vlog == nullptr)
return;
va_start(ap, format);
@@ -84,9 +85,9 @@ void vncLogInfo(const char *name, const char *format, ...)
void vncLogDebug(const char *name, const char *format, ...)
{
- LogWriter *vlog;
+ core::LogWriter* vlog;
va_list ap;
- vlog = LogWriter::getLogWriter(name);
+ vlog = core::LogWriter::getLogWriter(name);
if (vlog == nullptr)
return;
va_start(ap, format);
@@ -97,30 +98,25 @@ void vncLogDebug(const char *name, const char *format, ...)
int vncSetParam(const char *name, const char *value)
{
if (value != nullptr)
- return rfb::Configuration::setParam(name, value);
+ return core::Configuration::setParam(name, value);
else {
- VoidParameter *param;
- param = rfb::Configuration::getParam(name);
+ core::VoidParameter* param;
+ param = core::Configuration::getParam(name);
if (param == nullptr)
return false;
return param->setParam();
}
}
-int vncSetParamSimple(const char *nameAndValue)
-{
- return rfb::Configuration::setParam(nameAndValue);
-}
-
char* vncGetParam(const char *name)
{
- VoidParameter *param;
+ core::VoidParameter* param;
// Hack to avoid exposing password!
if (strcasecmp(name, "Password") == 0)
return nullptr;
- param = rfb::Configuration::getParam(name);
+ param = core::Configuration::getParam(name);
if (param == nullptr)
return nullptr;
@@ -129,40 +125,18 @@ char* vncGetParam(const char *name)
const char* vncGetParamDesc(const char *name)
{
- rfb::VoidParameter *param;
+ core::VoidParameter* param;
- param = rfb::Configuration::getParam(name);
+ param = core::Configuration::getParam(name);
if (param == nullptr)
return nullptr;
return param->getDescription();
}
-int vncIsParamBool(const char *name)
-{
- VoidParameter *param;
- BoolParameter *bparam;
-
- param = rfb::Configuration::getParam(name);
- if (param == nullptr)
- return false;
-
- bparam = dynamic_cast<BoolParameter*>(param);
- if (bparam == nullptr)
- return false;
-
- return true;
-}
-
int vncGetParamCount(void)
{
- int count;
-
- count = 0;
- for (ParameterIterator i; i.param; i.next())
- count++;
-
- return count;
+ return core::Configuration::global()->size();
}
char *vncGetParamList(void)
@@ -172,8 +146,8 @@ char *vncGetParamList(void)
len = 0;
- for (ParameterIterator i; i.param; i.next()) {
- int l = strlen(i.param->getName());
+ for (core::VoidParameter *param: *core::Configuration::global()) {
+ int l = strlen(param->getName());
if (l <= 255)
len += l + 1;
}
@@ -183,11 +157,11 @@ char *vncGetParamList(void)
return nullptr;
ptr = data;
- for (ParameterIterator i; i.param; i.next()) {
- int l = strlen(i.param->getName());
+ for (core::VoidParameter *param: *core::Configuration::global()) {
+ int l = strlen(param->getName());
if (l <= 255) {
*ptr++ = l;
- memcpy(ptr, i.param->getName(), l);
+ memcpy(ptr, param->getName(), l);
ptr += l;
}
}
@@ -198,7 +172,12 @@ char *vncGetParamList(void)
void vncListParams(int width, int nameWidth)
{
- rfb::Configuration::listParams(width, nameWidth);
+ core::Configuration::listParams(width, nameWidth);
+}
+
+int vncHandleParamArg(int argc, char* argv[], int index)
+{
+ return core::Configuration::handleParamArg(argc, argv, index);
}
int vncGetSocketPort(int fd)
@@ -225,7 +204,7 @@ int vncIsTCPPortUsed(int port)
char* vncConvertLF(const char* src, size_t bytes)
{
try {
- return strdup(convertLF(src, bytes).c_str());
+ return strdup(core::convertLF(src, bytes).c_str());
} catch (...) {
return nullptr;
}
@@ -234,7 +213,7 @@ char* vncConvertLF(const char* src, size_t bytes)
char* vncLatin1ToUTF8(const char* src, size_t bytes)
{
try {
- return strdup(latin1ToUTF8(src, bytes).c_str());
+ return strdup(core::latin1ToUTF8(src, bytes).c_str());
} catch (...) {
return nullptr;
}
@@ -243,7 +222,7 @@ char* vncLatin1ToUTF8(const char* src, size_t bytes)
char* vncUTF8ToLatin1(const char* src, size_t bytes)
{
try {
- return strdup(utf8ToLatin1(src, bytes).c_str());
+ return strdup(core::utf8ToLatin1(src, bytes).c_str());
} catch (...) {
return nullptr;
}
@@ -252,8 +231,15 @@ char* vncUTF8ToLatin1(const char* src, size_t bytes)
int vncIsValidUTF8(const char* str, size_t bytes)
{
try {
- return isValidUTF8(str, bytes);
+ return core::isValidUTF8(str, bytes);
} catch (...) {
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 30c13bd2..86304ad5 100644
--- a/unix/xserver/hw/vnc/RFBGlue.h
+++ b/unix/xserver/hw/vnc/RFBGlue.h
@@ -36,15 +36,15 @@ void vncLogDebug(const char *name, const char *format, ...)
__attribute__((__format__ (__printf__, 2, 3)));
int vncSetParam(const char *name, const char *value);
-int vncSetParamSimple(const char *nameAndValue);
char* vncGetParam(const char *name);
const char* vncGetParamDesc(const char *name);
-int vncIsParamBool(const char *name);
int vncGetParamCount(void);
char *vncGetParamList(void);
void vncListParams(int width, int nameWidth);
+int vncHandleParamArg(int argc, char* argv[], int index);
+
int vncGetSocketPort(int fd);
int vncIsTCPPortUsed(int port);
@@ -55,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 260ed3a6..1a7a06db 100644
--- a/unix/xserver/hw/vnc/XserverDesktop.cc
+++ b/unix/xserver/hw/vnc/XserverDesktop.cc
@@ -37,10 +37,15 @@
#include <fcntl.h>
#include <sys/utsname.h>
+#include <core/Configuration.h>
+#include <core/LogWriter.h>
+
+#include <rdr/FdInStream.h>
+#include <rdr/FdOutStream.h>
+
#include <network/Socket.h>
+
#include <rfb/VNCServerST.h>
-#include <rfb/LogWriter.h>
-#include <rfb/Configuration.h>
#include <rfb/ServerCore.h>
#include "XserverDesktop.h"
@@ -56,20 +61,17 @@ void vncSetGlueContext(int screenIndex);
void vncPresentMscEvent(uint64_t id, uint64_t msc);
}
-using namespace rfb;
-using namespace network;
+static core::LogWriter vlog("XserverDesktop");
-static LogWriter vlog("XserverDesktop");
-
-BoolParameter rawKeyboard("RawKeyboard",
- "Send keyboard events straight through and "
- "avoid mapping them to the current keyboard "
- "layout", false);
-IntParameter queryConnectTimeout("QueryConnectTimeout",
- "Number of seconds to show the "
- "Accept connection dialog before "
- "rejecting the connection",
- 10);
+core::BoolParameter
+ rawKeyboard("RawKeyboard",
+ "Send keyboard events straight through and avoid mapping "
+ "them to the current keyboard layout", false);
+core::IntParameter
+ queryConnectTimeout("QueryConnectTimeout",
+ "Number of seconds to show the 'Accept "
+ "connection' dialog before rejecting the "
+ "connection", 10, 0, INT_MAX);
XserverDesktop::XserverDesktop(int screenIndex_,
@@ -84,10 +86,10 @@ XserverDesktop::XserverDesktop(int screenIndex_,
{
format = pf;
- server = new VNCServerST(name, this);
+ server = new rfb::VNCServerST(name, this);
setFramebuffer(width, height, fbptr, stride_);
- for (SocketListener* listener : listeners)
+ for (network::SocketListener* listener : listeners)
vncSetNotifyFd(listener->getFd(), screenIndex, true, false);
}
@@ -115,7 +117,7 @@ void XserverDesktop::unblockUpdates()
void XserverDesktop::setFramebuffer(int w, int h, void* fbptr, int stride_)
{
- ScreenSet layout;
+ rfb::ScreenSet layout;
if (shadowFramebuffer) {
delete [] shadowFramebuffer;
@@ -265,7 +267,7 @@ void XserverDesktop::setCursor(int width, int height, int hotX, int hotY,
}
try {
- server->setCursor(width, height, Point(hotX, hotY), cursorData);
+ server->setCursor(width, height, {hotX, hotY}, cursorData);
} catch (std::exception& e) {
vlog.error("XserverDesktop::setCursor: %s",e.what());
}
@@ -276,13 +278,13 @@ void XserverDesktop::setCursor(int width, int height, int hotX, int hotY,
void XserverDesktop::setCursorPos(int x, int y, bool warped)
{
try {
- server->setCursorPos(Point(x, y), warped);
+ server->setCursorPos({x, y}, warped);
} catch (std::exception& e) {
vlog.error("XserverDesktop::setCursorPos: %s",e.what());
}
}
-void XserverDesktop::add_changed(const rfb::Region &region)
+void XserverDesktop::add_changed(const core::Region& region)
{
try {
server->add_changed(region);
@@ -291,7 +293,8 @@ void XserverDesktop::add_changed(const rfb::Region &region)
}
}
-void XserverDesktop::add_copied(const rfb::Region &dest, const rfb::Point &delta)
+void XserverDesktop::add_copied(const core::Region& dest,
+ const core::Point& delta)
{
try {
server->add_copied(dest, delta);
@@ -318,10 +321,10 @@ void XserverDesktop::handleSocketEvent(int fd, bool read, bool write)
}
bool XserverDesktop::handleListenerEvent(int fd,
- std::list<SocketListener*>* sockets,
- VNCServer* sockserv)
+ std::list<network::SocketListener*>* sockets,
+ rfb::VNCServer* sockserv)
{
- std::list<SocketListener*>::iterator i;
+ std::list<network::SocketListener*>::iterator i;
for (i = sockets->begin(); i != sockets->end(); i++) {
if ((*i)->getFd() == fd)
@@ -331,7 +334,7 @@ bool XserverDesktop::handleListenerEvent(int fd,
if (i == sockets->end())
return false;
- Socket* sock = (*i)->accept();
+ network::Socket* sock = (*i)->accept();
vlog.debug("New client, sock %d", sock->getFd());
sockserv->addSocket(sock);
vncSetNotifyFd(sock->getFd(), screenIndex, true, false);
@@ -340,11 +343,11 @@ bool XserverDesktop::handleListenerEvent(int fd,
}
bool XserverDesktop::handleSocketEvent(int fd,
- VNCServer* sockserv,
+ rfb::VNCServer* sockserv,
bool read, bool write)
{
- std::list<Socket*> sockets;
- std::list<Socket*>::iterator i;
+ std::list<network::Socket*> sockets;
+ std::list<network::Socket*>::iterator i;
sockserv->getSockets(&sockets);
for (i = sockets.begin(); i != sockets.end(); i++) {
@@ -361,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;
}
@@ -373,21 +401,13 @@ void XserverDesktop::blockHandler(int* timeout)
vncInitInputDevice();
try {
- std::list<Socket*> sockets;
- std::list<Socket*>::iterator i;
+ std::list<network::Socket*> sockets;
+ std::list<network::Socket*>::iterator i;
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
@@ -402,7 +422,7 @@ void XserverDesktop::blockHandler(int* timeout)
}
// Trigger timers and check when the next will expire
- int nextTimeout = Timer::checkTimeouts();
+ int nextTimeout = core::Timer::checkTimeouts();
if (nextTimeout >= 0 && (*timeout == -1 || nextTimeout < *timeout))
*timeout = nextTimeout;
} catch (std::exception& e) {
@@ -410,10 +430,12 @@ void XserverDesktop::blockHandler(int* timeout)
}
}
-void XserverDesktop::addClient(Socket* sock, bool reverse, bool viewOnly)
+void XserverDesktop::addClient(network::Socket* sock,
+ bool reverse, bool viewOnly)
{
vlog.debug("New client, sock %d reverse %d",sock->getFd(),reverse);
- server->addSocket(sock, reverse, viewOnly ? AccessView : AccessDefault);
+ server->addSocket(sock, reverse,
+ viewOnly ? rfb::AccessView : rfb::AccessDefault);
vncSetNotifyFd(sock->getFd(), screenIndex, true, false);
}
@@ -462,7 +484,8 @@ void XserverDesktop::terminate()
kill(getpid(), SIGTERM);
}
-void XserverDesktop::pointerEvent(const Point& pos, uint16_t buttonMask)
+void XserverDesktop::pointerEvent(const core::Point& pos,
+ uint16_t buttonMask)
{
vncPointerMove(pos.x + vncGetScreenX(screenIndex),
pos.y + vncGetScreenY(screenIndex));
@@ -515,13 +538,13 @@ void XserverDesktop::handleClipboardData(const char* data_)
vncHandleClipboardData(data_);
}
-void XserverDesktop::grabRegion(const rfb::Region& region)
+void XserverDesktop::grabRegion(const core::Region& region)
{
if (shadowFramebuffer == nullptr)
return;
- std::vector<rfb::Rect> rects;
- std::vector<rfb::Rect>::iterator i;
+ std::vector<core::Rect> rects;
+ std::vector<core::Rect>::iterator i;
region.get_rects(&rects);
for (i = rects.begin(); i != rects.end(); i++) {
uint8_t *buffer;
@@ -542,7 +565,7 @@ void XserverDesktop::keyEvent(uint32_t keysym, uint32_t keycode, bool down)
vncKeyboardEvent(keysym, keycode, down);
}
-void XserverDesktop::handleTimeout(Timer* t)
+void XserverDesktop::handleTimeout(core::Timer* t)
{
if (t == &queryConnectTimer) {
server->approveConnection(queryConnectSocket, false,
diff --git a/unix/xserver/hw/vnc/XserverDesktop.h b/unix/xserver/hw/vnc/XserverDesktop.h
index 8c543db7..37f5b1b5 100644
--- a/unix/xserver/hw/vnc/XserverDesktop.h
+++ b/unix/xserver/hw/vnc/XserverDesktop.h
@@ -31,11 +31,13 @@
#include <stdint.h>
+#include <core/Timer.h>
+
#include <rfb/SDesktop.h>
#include <rfb/PixelBuffer.h>
-#include <rfb/Configuration.h>
-#include <rfb/Timer.h>
+
#include <unixcommon.h>
+
#include "vncInput.h"
namespace rfb {
@@ -45,7 +47,7 @@ namespace rfb {
namespace network { class SocketListener; class Socket; }
class XserverDesktop : public rfb::SDesktop, public rfb::FullFramePixelBuffer,
- public rfb::Timer::Callback {
+ public core::Timer::Callback {
public:
XserverDesktop(int screenIndex,
@@ -71,8 +73,8 @@ public:
void setCursor(int width, int height, int hotX, int hotY,
const unsigned char *rgbaData);
void setCursorPos(int x, int y, bool warped);
- void add_changed(const rfb::Region &region);
- void add_copied(const rfb::Region &dest, const rfb::Point &delta);
+ void add_changed(const core::Region& region);
+ void add_copied(const core::Region& dest, const core::Point& delta);
void handleSocketEvent(int fd, bool read, bool write);
void blockHandler(int* timeout);
void addClient(network::Socket* sock, bool reverse, bool viewOnly);
@@ -95,7 +97,8 @@ public:
void terminate() override;
void queryConnection(network::Socket* sock,
const char* userName) override;
- void pointerEvent(const rfb::Point& pos, uint16_t buttonMask) override;
+ void pointerEvent(const core::Point& pos,
+ uint16_t buttonMask) override;
void keyEvent(uint32_t keysym, uint32_t keycode, bool down) override;
unsigned int setScreenLayout(int fb_width, int fb_height,
const rfb::ScreenSet& layout) override;
@@ -105,7 +108,7 @@ public:
void handleClipboardData(const char* data) override;
// rfb::PixelBuffer callbacks
- void grabRegion(const rfb::Region& r) override;
+ void grabRegion(const core::Region& r) override;
protected:
bool handleListenerEvent(int fd,
@@ -115,7 +118,7 @@ protected:
rfb::VNCServer* sockserv,
bool read, bool write);
- void handleTimeout(rfb::Timer* t) override;
+ void handleTimeout(core::Timer* t) override;
private:
@@ -128,12 +131,12 @@ private:
network::Socket* queryConnectSocket;
std::string queryConnectAddress;
std::string queryConnectUsername;
- rfb::Timer queryConnectTimer;
+ core::Timer queryConnectTimer;
OutputIdMap outputIdMap;
std::map<uint64_t, uint64_t> pendingMsc;
- rfb::Point oldCursorPos;
+ core::Point oldCursorPos;
};
#endif
diff --git a/unix/xserver/hw/vnc/Xvnc.man b/unix/xserver/hw/vnc/Xvnc.man
index 49b1dc8a..d6b1664d 100644
--- a/unix/xserver/hw/vnc/Xvnc.man
+++ b/unix/xserver/hw/vnc/Xvnc.man
@@ -31,16 +31,25 @@ command-line, there are also "parameters" which can be set both via the
command-line and through the \fBvncconfig\fP(1) program.
.TP
-.B \-geometry \fIwidth\fPx\fIheight\fP
-Specify the size of the desktop to be created. Default is 1024x768.
-.
-.TP
.B \-depth \fIdepth\fP
Specify the pixel depth in bits of the desktop to be created. Default is 24,
other possible values are 16 and 32. Anything else is likely to cause strange
behaviour by applications and may prevent the server from starting at all.
.
.TP
+.B \-geometry \fIwidth\fPx\fIheight\fP
+Specify the size of the desktop to be created. Default is 1024x768.
+.
+.TP
+.B \-help
+List all the options and parameters
+.
+.TP
+.B \-inetd
+This significantly changes Xvnc's behaviour so that it can be launched from
+inetd. See the section below on usage with inetd.
+.
+.TP
.B \-pixelformat \fIformat\fP
Specify pixel format for server to use (BGRnnn or RGBnnn). The default for
depth 16 is RGB565 and for depth 24 and 32 is RGB888.
@@ -50,19 +59,6 @@ depth 16 is RGB565 and for depth 24 and 32 is RGB888.
DRM render node to use for DRI3 GPU acceleration. Specify an empty path to
disable DRI3. Default is \fBauto\fP which makes \fBXvnc\fP pick a suitable
available render node.
-.
-.TP
-.B \-interface \fIIP address\fP
-Listen on interface. By default Xvnc listens on all available interfaces.
-.
-.TP
-.B \-inetd
-This significantly changes Xvnc's behaviour so that it can be launched from
-inetd. See the section below on usage with inetd.
-.
-.TP
-.B \-help
-List all the options and parameters
.SH PARAMETERS
VNC parameters can be set both via the command-line and through the
@@ -76,70 +72,59 @@ Parameters can be turned on with -\fIparam\fP or off with
case-insensitive.
.TP
-.B \-desktop \fIdesktop-name\fP
-Each desktop has a name which may be displayed by the viewer. It defaults to
-"<user>@<hostname>".
-.
-.TP
-.B \-rfbport \fIport\fP
-Specifies the TCP port on which Xvnc listens for connections from viewers (the
-protocol used in VNC is called RFB - "remote framebuffer"). The default is
-5900 plus the display number. Specify \fB-1\fP to disable listening on a TCP
-port.
-.
-.TP
-.B \-UseIPv4
-Use IPv4 for incoming and outgoing connections. Default is on.
-.
-.TP
-.B \-UseIPv6
-Use IPv6 for incoming and outgoing connections. Default is on.
+.B \-AcceptCutText
+Accept clipboard updates from clients. Default is on.
.
.TP
-.B \-rfbunixpath \fIpath\fP
-Specifies the path of a Unix domain socket on which Xvnc listens for
-connections from viewers.
+.B \-AcceptKeyEvents
+Accept key press and release events from clients. Default is on.
.
.TP
-.B \-rfbunixmode \fImode\fP
-Specifies the mode of the Unix domain socket. The default is 0600.
+.B \-AcceptPointerEvents
+Accept pointer movement and button events from clients. Default is on.
.
.TP
-.B \-rfbauth \fIpasswd-file\fP, \-PasswordFile \fIpasswd-file\fP
-Password file for VNC authentication. There is no default, you should
-specify the password file explicitly. Password file should be created with
-the \fBvncpasswd\fP(1) utility. The file is accessed each time a connection
-comes in, so it can be changed on the fly.
+.B \-AcceptSetDesktopSize
+Accept requests to resize the size of the desktop. Default is on.
.
.TP
-.B \-AcceptCutText
-Accept clipboard updates from clients. Default is on.
+.B \-AllowOverride
+Comma separated list of parameters that can be modified using VNC extension.
+Parameters can be modified for example using \fBvncconfig\fP(1) program from
+inside a running session.
.
.TP
-.B \-MaxCutText \fIbytes\fP
-The maximum size of a clipboard update that will be accepted from a client.
-Default is \fB262144\fP.
+.B \-AlwaysShared
+Always treat incoming connections as shared, regardless of the client-specified
+setting. Default is off.
.
.TP
-.B \-SendCutText
-Send clipboard changes to clients. Default is on.
+.B \-AvoidShiftNumLock
+Key affected by NumLock often require a fake Shift to be inserted in order
+for the correct symbol to be generated. Turning on this option avoids these
+extra fake Shift events but may result in a slightly different symbol
+(e.g. a Return instead of a keypad Enter).
.
.TP
-.B \-SendPrimary
-Send the primary selection and cut buffer to the server as well as the
-clipboard selection. Default is on.
+.B \-BlacklistThreshold \fIcount\fP
+The number of unauthenticated connection attempts allowed from any individual
+host before that host is black-listed. Default is 5.
.
.TP
-.B \-AcceptPointerEvents
-Accept pointer movement and button events from clients. Default is on.
+.B \-BlacklistTimeout \fIseconds\fP
+The initial timeout applied when a host is first black-listed. The host
+cannot re-attempt a connection until the timeout expires. Default is 10.
.
.TP
-.B \-AcceptKeyEvents
-Accept key press and release events from clients. Default is on.
+.B \-CompareFB \fImode\fP
+Perform pixel comparison on framebuffer to reduce unnecessary updates. Can
+be either \fB0\fP (off), \fB1\fP (always) or \fB2\fP (auto). Default is
+\fB2\fP.
.
.TP
-.B \-AcceptSetDesktopSize
-Accept requests to resize the size of the desktop. Default is on.
+.B \-desktop \fIdesktop-name\fP
+Each desktop has a name which may be displayed by the viewer. It defaults to
+"<user>@<hostname>".
.
.TP
.B \-DisconnectClients
@@ -149,21 +134,6 @@ be refused while there is a client active. When combined with
\fBNeverShared\fP this means only one client is allowed at a time.
.
.TP
-.B \-NeverShared
-Never treat incoming connections as shared, regardless of the client-specified
-setting. Default is off.
-.
-.TP
-.B \-AlwaysShared
-Always treat incoming connections as shared, regardless of the client-specified
-setting. Default is off.
-.
-.TP
-.B \-Protocol3.3
-Always use protocol version 3.3 for backwards compatibility with badly-behaved
-clients. Default is off.
-.
-.TP
.B \-FrameRate \fIfps\fP
The maximum number of updates per second sent to each client. If the screen
updates any faster then those changes will be aggregated and sent in a single
@@ -171,10 +141,16 @@ update to the client. Note that this only controls the maximum rate and a
client may get a lower rate when resources are limited. Default is \fB60\fP.
.
.TP
-.B \-CompareFB \fImode\fP
-Perform pixel comparison on framebuffer to reduce unnecessary updates. Can
-be either \fB0\fP (off), \fB1\fP (always) or \fB2\fP (auto). Default is
-\fB2\fP.
+.B \-GnuTLSPriority \fIpriority\fP
+GnuTLS priority string that controls the TLS session’s handshake algorithms.
+See the GnuTLS manual for possible values. For GnuTLS < 3.6.3 the default
+value will be \fBNORMAL\fP to use upstream default. For newer versions
+of GnuTLS system-wide crypto policy will be used.
+.
+.TP
+.B \-IdleTimeout \fIseconds\fP
+The number of seconds after which an idle VNC connection will be dropped.
+Default is 0, which means that idle connections will never be dropped.
.
.TP
.B \-ImprovedHextile
@@ -183,90 +159,75 @@ compression ratios by the cost of using slightly more CPU time. Default is
on.
.
.TP
-.B \-SecurityTypes \fIsec-types\fP
-Specify which security scheme to use for incoming connections. Valid values
-are a comma separated list of \fBNone\fP, \fBVncAuth\fP, \fBPlain\fP,
-\fBTLSNone\fP, \fBTLSVnc\fP, \fBTLSPlain\fP, \fBX509None\fP, \fBX509Vnc\fP,
-\fBX509Plain\fP, \fBRA2\fP, \fBRA2ne\fP, \fBRA2_256\fP and \fBRA2ne_256\fP.
-Default is \fBTLSVnc,VncAuth\fP.
-.
-.TP
-.B \-Password \fIpassword\fP
-Obfuscated binary encoding of the password which clients must supply to
-access the server. Using this parameter is insecure, use \fBPasswordFile\fP
-parameter instead.
-.
-.TP
-.B \-PlainUsers \fIuser-list\fP
-A comma separated list of user names that are allowed to authenticate via
-any of the "Plain" security types (Plain, TLSPlain, etc.). Specify \fB*\fP
-to allow any user to authenticate using this security type. Specify \fB%u\fP
-to allow the user of the server process. Default is to deny all users.
-.
-.TP
-.B \-pam_service \fIname\fP, \-PAMService \fIname\fP
-PAM service name to use when authentication users using any of the "Plain"
-security types. Default is \fBvnc\fP.
+.B \-interface \fIIP address\fP
+Listen on interface. By default Xvnc listens on all available interfaces.
.
.TP
-.B \-X509Cert \fIpath\fP
-Path to a X509 certificate in PEM format to be used for all X509 based
-security types (X509None, X509Vnc, etc.).
+.B \-localhost
+Only allow connections from the same machine. Useful if you use SSH and want to
+stop non-SSH connections from any other hosts.
.
.TP
-.B \-X509Key \fIpath\fP
-Private key counter part to the certificate given in \fBX509Cert\fP. Must
-also be in PEM format.
+.B \-Log \fIlogname\fP:\fIdest\fP:\fIlevel\fP[, ...]
+Configures the debug log settings. \fIdest\fP can currently be \fBstderr\fP,
+\fBstdout\fP or \fBsyslog\fP, and \fIlevel\fP is between 0 and 100, 100 meaning
+most verbose output. \fIlogname\fP is usually \fB*\fP meaning all, but you can
+target a specific source file if you know the name of its "LogWriter". Default
+is \fB*:stderr:30\fP.
.
.TP
-.B \-GnuTLSPriority \fIpriority\fP
-GnuTLS priority string that controls the TLS session’s handshake algorithms.
-See the GnuTLS manual for possible values. For GnuTLS < 3.6.3 the default
-value will be \fBNORMAL\fP to use upstream default. For newer versions
-of GnuTLS system-wide crypto policy will be used.
+.B \-MaxConnectionTime \fIseconds\fP
+Terminate when a client has been connected for \fIN\fP seconds. Default is
+0.
.
.TP
-.B \-RSAKey \fIpath\fP
-Path to the RSA key for the RSA-AES security types (\fBRA2\fP, \fBRA2ne\fP,
-\fBRA2_256\fP and \fBRA2ne_256\fP) in PEM format.
+.B \-MaxCutText \fIbytes\fP
+The maximum size of a clipboard update that will be accepted from a client.
+Default is \fB262144\fP.
.
.TP
-.B \-RequireUsername
-Require username for the RSA-AES security types. Default is off.
+.B \-MaxDisconnectionTime \fIseconds\fP
+Terminate when no client has been connected for \fIN\fP seconds. Default is
+0.
.
.TP
-.B \-UseBlacklist
-Temporarily reject connections from a host if it repeatedly fails to
-authenticate. Default is on.
+.B \-MaxIdleTime \fIseconds\fP
+Terminate after \fIN\fP seconds of user inactivity. Default is 0.
.
.TP
-.B \-BlacklistThreshold \fIcount\fP
-The number of unauthenticated connection attempts allowed from any individual
-host before that host is black-listed. Default is 5.
+.B \-NeverShared
+Never treat incoming connections as shared, regardless of the client-specified
+setting. Default is off.
.
.TP
-.B \-BlacklistTimeout \fIseconds\fP
-The initial timeout applied when a host is first black-listed. The host
-cannot re-attempt a connection until the timeout expires. Default is 10.
+.B \-pam_service \fIname\fP, \-PAMService \fIname\fP
+PAM service name to use when authentication users using any of the "Plain"
+security types. Default is \fBvnc\fP.
.
.TP
-.B \-IdleTimeout \fIseconds\fP
-The number of seconds after which an idle VNC connection will be dropped.
-Default is 0, which means that idle connections will never be dropped.
+.B \-Password \fIpassword\fP
+Obfuscated binary encoding of the password which clients must supply to
+access the server. Using this parameter is insecure, use \fBPasswordFile\fP
+parameter instead.
.
.TP
-.B \-MaxDisconnectionTime \fIseconds\fP
-Terminate when no client has been connected for \fIN\fP seconds. Default is
-0.
+.B \-PasswordFile \fIpasswd-file\fP, \-rfbauth \fIpasswd-file\fP
+Password file for VNC authentication. There is no default, you should
+specify the password file explicitly. Password file should be created with
+the \fBvncpasswd\fP(1) utility. The file is accessed each time a connection
+comes in, so it can be changed on the fly.
.
.TP
-.B \-MaxConnectionTime \fIseconds\fP
-Terminate when a client has been connected for \fIN\fP seconds. Default is
-0.
+.B \-PlainUsers \fIuser-list\fP
+A comma separated list of user names that are allowed to authenticate via
+any of the "Plain" security types (Plain, TLSPlain, etc.). Specify \fB*\fP
+to allow any user to authenticate using this security type. Specify \fB%u\fP
+to allow the user of the server process. Default is to deny all users.
.
.TP
-.B \-MaxIdleTime \fIseconds\fP
-Terminate after \fIN\fP seconds of user inactivity. Default is 0.
+.B \-Protocol3.3
+Always use protocol version 3.3 for backwards compatibility with badly-behaved
+clients. Default is off.
.
.TP
.B \-QueryConnect
@@ -282,17 +243,11 @@ Number of seconds to show the Accept connection dialog before rejecting the
connection. Default is \fB10\fP.
.
.TP
-.B \-localhost
-Only allow connections from the same machine. Useful if you use SSH and want to
-stop non-SSH connections from any other hosts.
-.
-.TP
-.B \-Log \fIlogname\fP:\fIdest\fP:\fIlevel\fP
-Configures the debug log settings. \fIdest\fP can currently be \fBstderr\fP,
-\fBstdout\fP or \fBsyslog\fP, and \fIlevel\fP is between 0 and 100, 100 meaning
-most verbose output. \fIlogname\fP is usually \fB*\fP meaning all, but you can
-target a specific source file if you know the name of its "LogWriter". Default
-is \fB*:stderr:30\fP.
+.B \-RawKeyboard
+Send keyboard events straight through and avoid mapping them to the current
+keyboard layout. This effectively makes the keyboard behave according to the
+layout configured on the server instead of the layout configured on the
+client. Default is off.
.
.TP
.B \-RemapKeys \fImapping
@@ -311,24 +266,74 @@ RemapKeys=0x22<>0x40
.RE
.
.TP
-.B \-AvoidShiftNumLock
-Key affected by NumLock often require a fake Shift to be inserted in order
-for the correct symbol to be generated. Turning on this option avoids these
-extra fake Shift events but may result in a slightly different symbol
-(e.g. a Return instead of a keypad Enter).
+.B \-RequireUsername
+Require username for the RSA-AES security types. Default is off.
.
.TP
-.B \-RawKeyboard
-Send keyboard events straight through and avoid mapping them to the current
-keyboard layout. This effectively makes the keyboard behave according to the
-layout configured on the server instead of the layout configured on the
-client. Default is off.
+.B \-rfbport \fIport\fP
+Specifies the TCP port on which Xvnc listens for connections from viewers (the
+protocol used in VNC is called RFB - "remote framebuffer"). The default is
+5900 plus the display number. Specify \fB-1\fP to disable listening on a TCP
+port.
.
.TP
-.B \-AllowOverride
-Comma separated list of parameters that can be modified using VNC extension.
-Parameters can be modified for example using \fBvncconfig\fP(1) program from
-inside a running session.
+.B \-rfbunixmode \fImode\fP
+Specifies the mode of the Unix domain socket. The default is 0600.
+.
+.TP
+.B \-rfbunixpath \fIpath\fP
+Specifies the path of a Unix domain socket on which Xvnc listens for
+connections from viewers.
+.
+.TP
+.B \-RSAKey \fIpath\fP
+Path to the RSA key for the RSA-AES security types (\fBRA2\fP, \fBRA2ne\fP,
+\fBRA2_256\fP and \fBRA2ne_256\fP) in PEM format.
+.
+.TP
+.B \-SecurityTypes \fIsec-types\fP
+Specify which security scheme to use for incoming connections. Valid values
+are a comma separated list of \fBNone\fP, \fBVncAuth\fP, \fBPlain\fP,
+\fBTLSNone\fP, \fBTLSVnc\fP, \fBTLSPlain\fP, \fBX509None\fP, \fBX509Vnc\fP,
+\fBX509Plain\fP, \fBRA2\fP, \fBRA2ne\fP, \fBRA2_256\fP and \fBRA2ne_256\fP.
+Default is \fBTLSVnc,VncAuth\fP.
+.
+.TP
+.B \-SendCutText
+Send clipboard changes to clients. Default is on.
+.
+.TP
+.B \-SendPrimary
+Send the primary selection and cut buffer to the server as well as the
+clipboard selection. Default is on.
+.
+.TP
+.B \-SetPrimary
+Set the primary selection as well as the clipboard selection.
+Default is on.
+.
+.TP
+.B \-UseBlacklist
+Temporarily reject connections from a host if it repeatedly fails to
+authenticate. Default is on.
+.
+.TP
+.B \-UseIPv4
+Use IPv4 for incoming and outgoing connections. Default is on.
+.
+.TP
+.B \-UseIPv6
+Use IPv6 for incoming and outgoing connections. Default is on.
+.
+.TP
+.B \-X509Cert \fIpath\fP
+Path to a X509 certificate in PEM format to be used for all X509 based
+security types (X509None, X509Vnc, etc.).
+.
+.TP
+.B \-X509Key \fIpath\fP
+Private key counter part to the certificate given in \fBX509Cert\fP. Must
+also be in PEM format.
Allowing override of parameters such as \fBPAMService\fP or \fBPasswordFile\fP
can negatively impact security if Xvnc runs under different user than the
diff --git a/unix/xserver/hw/vnc/vncExt.c b/unix/xserver/hw/vnc/vncExt.c
index e98275c2..d664c744 100644
--- a/unix/xserver/hw/vnc/vncExt.c
+++ b/unix/xserver/hw/vnc/vncExt.c
@@ -103,11 +103,13 @@ int vncNotifyQueryConnect(void)
static int ProcVncExtSetParam(ClientPtr client)
{
- char *param;
+ char *param, *value;
xVncExtSetParamReply rep;
REQUEST(xVncExtSetParamReq);
- REQUEST_FIXED_SIZE(xVncExtSetParamReq, stuff->paramLen);
+ REQUEST_FIXED_SIZE(xVncExtSetParamReq,
+ ((stuff->paramLen + 3) & ~3) +
+ ((stuff->valueLen + 3) & ~3));
param = malloc(stuff->paramLen+1);
if (param == NULL)
@@ -115,6 +117,14 @@ static int ProcVncExtSetParam(ClientPtr client)
strncpy(param, (char*)&stuff[1], stuff->paramLen);
param[stuff->paramLen] = '\0';
+ value = malloc(stuff->valueLen+1);
+ if (value == NULL) {
+ free(param);
+ return BadAlloc;
+ }
+ strncpy(value, (char*)&stuff[1] + ((stuff->paramLen + 3) & ~3), stuff->valueLen);
+ value[stuff->valueLen] = '\0';
+
rep.type = X_Reply;
rep.length = 0;
rep.success = 0;
@@ -124,21 +134,22 @@ static int ProcVncExtSetParam(ClientPtr client)
* Prevent change of clipboard related parameters if clipboard is disabled.
*/
if (vncNoClipboard &&
- (strncasecmp(param, "SendCutText", 11) == 0 ||
- strncasecmp(param, "AcceptCutText", 13) == 0))
+ (strcasecmp(param, "SendCutText") == 0 ||
+ strcasecmp(param, "AcceptCutText") == 0))
goto deny;
- if (!vncOverrideParam(param))
+ if (!vncOverrideParam(param, value))
goto deny;
rep.success = 1;
// Send DesktopName update if desktop name has been changed
- if (strncasecmp(param, "desktop", 7) == 0)
+ if (strcasecmp(param, "desktop") == 0)
vncUpdateDesktopName();
deny:
free(param);
+ free(value);
if (client->swapped) {
swaps(&rep.sequenceNumber);
diff --git a/unix/xserver/hw/vnc/vncExtInit.cc b/unix/xserver/hw/vnc/vncExtInit.cc
index 367481ac..e9924d70 100644
--- a/unix/xserver/hw/vnc/vncExtInit.cc
+++ b/unix/xserver/hw/vnc/vncExtInit.cc
@@ -27,18 +27,17 @@
#include <sys/types.h>
#include <pwd.h>
-#include <set>
#include <string>
-#include <rfb/Configuration.h>
-#include <rfb/Logger_stdio.h>
-#include <rfb/LogWriter.h>
+#include <core/Configuration.h>
+#include <core/Logger_stdio.h>
+#include <core/LogWriter.h>
+#include <core/Region.h>
+
#include <rfb/ServerCore.h>
#include <rdr/HexOutStream.h>
-#include <rfb/LogWriter.h>
-#include <rfb/Hostname.h>
-#include <rfb/Region.h>
#include <rfb/ledStates.h>
+
#include <network/TcpSocket.h>
#include <network/UnixSocket.h>
@@ -55,9 +54,7 @@ extern "C" {
void vncSetGlueContext(int screenIndex);
}
-using namespace rfb;
-
-static rfb::LogWriter vlog("vncext");
+static core::LogWriter vlog("vncext");
// We can't safely get this from Xorg
#define MAXSCREENS 16
@@ -70,38 +67,43 @@ 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();
-rfb::IntParameter rfbport("rfbport", "TCP port to listen for RFB protocol",0);
-rfb::StringParameter rfbunixpath("rfbunixpath", "Unix socket to listen for RFB protocol", "");
-rfb::IntParameter rfbunixmode("rfbunixmode", "Unix socket access mode", 0600);
-rfb::StringParameter desktopName("desktop", "Name of VNC desktop", defaultDesktopName());
-rfb::BoolParameter localhostOnly("localhost",
- "Only allow connections from localhost",
- false);
-rfb::StringParameter interface("interface",
- "Listen on the specified network address",
- "all");
-rfb::BoolParameter avoidShiftNumLock("AvoidShiftNumLock",
- "Avoid fake Shift presses for keys affected by NumLock.",
- true);
-rfb::StringParameter allowOverride("AllowOverride",
- "Comma separated list of parameters that can be modified using VNC extension.",
- "desktop,AcceptPointerEvents,SendCutText,AcceptCutText,SendPrimary,SetPrimary");
-rfb::BoolParameter setPrimary("SetPrimary", "Set the PRIMARY as well "
- "as the CLIPBOARD selection", true);
-rfb::BoolParameter sendPrimary("SendPrimary",
- "Send the PRIMARY as well as the CLIPBOARD selection",
- true);
+core::IntParameter
+ 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, 0000, 0777);
+core::StringParameter
+ desktopName("desktop", "Name of VNC desktop", defaultDesktopName());
+core::BoolParameter
+ localhostOnly("localhost",
+ "Only allow connections from localhost", false);
+core::StringParameter
+ interface("interface",
+ "Listen on the specified network address", "all");
+core::BoolParameter
+ avoidShiftNumLock("AvoidShiftNumLock",
+ "Avoid fake Shift presses for keys affected by "
+ "NumLock.", true);
+core::StringListParameter
+ allowOverride("AllowOverride",
+ "Comma separated list of parameters that can be "
+ "modified using VNC extension.",
+ {"desktop", "AcceptPointerEvents", "SendCutText",
+ "AcceptCutText", "SendPrimary", "SetPrimary"});
+core::BoolParameter
+ setPrimary("SetPrimary",
+ "Set the PRIMARY as well as the CLIPBOARD selection",
+ true);
+core::BoolParameter
+ sendPrimary("SendPrimary",
+ "Send the PRIMARY as well as the CLIPBOARD selection",
+ true);
static const char* defaultDesktopName()
{
@@ -128,7 +130,7 @@ static const char* defaultDesktopName()
return name;
}
-static PixelFormat vncGetPixelFormat(int scrIdx)
+static rfb::PixelFormat vncGetPixelFormat(int scrIdx)
{
int depth, bpp;
int trueColour, bigEndian;
@@ -152,22 +154,9 @@ static PixelFormat vncGetPixelFormat(int scrIdx)
greenMax = greenMask >> greenShift;
blueMax = blueMask >> blueShift;
- return PixelFormat(bpp, depth, bigEndian, trueColour,
- redMax, greenMax, blueMax,
- 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;
- }
- }
+ return rfb::PixelFormat(bpp, depth, bigEndian, trueColour,
+ redMax, greenMax, blueMax,
+ redShift, greenShift, blueShift);
}
void vncExtensionInit(void)
@@ -189,9 +178,8 @@ void vncExtensionInit(void)
try {
if (!initialised) {
- rfb::initStdIOLoggers();
+ core::initStdIOLoggers();
- parseOverrideList(allowOverride, allowOverrideSet);
allowOverride.setImmutable();
initialised = true;
@@ -252,7 +240,7 @@ void vncExtensionInit(void)
if (!inetd && listeners.empty())
throw std::runtime_error("No path or port configured for incoming connections");
- PixelFormat pf = vncGetPixelFormat(scr);
+ rfb::PixelFormat pf = vncGetPixelFormat(scr);
vncSetGlueContext(scr);
desktop[scr] = new XserverDesktop(scr,
@@ -358,7 +346,7 @@ int vncConnectClient(const char *addr, int viewOnly)
std::string host;
int port;
- getHostAndPort(addr, &host, &port, 5500);
+ network::getHostAndPort(addr, &host, &port, 5500);
try {
network::Socket* sock = new network::TcpSocket(host.c_str(), port);
@@ -403,11 +391,11 @@ void vncSetLEDState(unsigned long leds)
state = 0;
if (leds & (1 << 0))
- state |= ledCapsLock;
+ state |= rfb::ledCapsLock;
if (leds & (1 << 1))
- state |= ledNumLock;
+ state |= rfb::ledNumLock;
if (leds & (1 << 2))
- state |= ledScrollLock;
+ state |= rfb::ledScrollLock;
for (int scr = 0; scr < vncGetScreenCount(); scr++)
desktop[scr]->setLEDState(state);
@@ -417,8 +405,8 @@ void vncAddChanged(int scrIdx, int nRects,
const struct UpdateRect *rects)
{
for (int i = 0;i < nRects;i++) {
- desktop[scrIdx]->add_changed(Region(Rect(rects[i].x1, rects[i].y1,
- rects[i].x2, rects[i].y2)));
+ desktop[scrIdx]->add_changed({{rects[i].x1, rects[i].y1,
+ rects[i].x2, rects[i].y2}});
}
}
@@ -427,9 +415,9 @@ void vncAddCopied(int scrIdx, int nRects,
int dx, int dy)
{
for (int i = 0;i < nRects;i++) {
- desktop[scrIdx]->add_copied(Region(Rect(rects[i].x1, rects[i].y1,
- rects[i].x2, rects[i].y2)),
- Point(dx, dy));
+ desktop[scrIdx]->add_copied({{rects[i].x1, rects[i].y1,
+ rects[i].x2, rects[i].y2}},
+ {dx, dy});
}
}
@@ -471,7 +459,7 @@ void vncPostScreenResize(int scrIdx, int success, int width, int height)
if (success) {
// Mark entire screen as changed
- desktop[scrIdx]->add_changed(Region(Rect(0, 0, width, height)));
+ desktop[scrIdx]->add_changed({{0, 0, width, height}});
}
}
@@ -511,15 +499,12 @@ void vncAbortMsc(int scrIdx, uint64_t id)
}
}
-int vncOverrideParam(const char *nameAndValue)
+int vncOverrideParam(const char *param, const char *value)
{
- const char* equalSign = strchr(nameAndValue, '=');
- if (!equalSign)
- return 0;
-
- std::string key(nameAndValue, equalSign);
- if (allowOverrideSet.find(key) == allowOverrideSet.end())
- return 0;
+ for (const char* allowed : allowOverride) {
+ if (strcasecmp(allowed, param) == 0)
+ return core::Configuration::setParam(param, value);
+ }
- return rfb::Configuration::setParam(nameAndValue);
+ return 0;
}
diff --git a/unix/xserver/hw/vnc/vncExtInit.h b/unix/xserver/hw/vnc/vncExtInit.h
index 6b37fe62..425aa9b7 100644
--- a/unix/xserver/hw/vnc/vncExtInit.h
+++ b/unix/xserver/hw/vnc/vncExtInit.h
@@ -91,7 +91,7 @@ uint64_t vncGetMsc(int scrIdx);
void vncQueueMsc(int scrIdx, uint64_t id, uint64_t msc);
void vncAbortMsc(int scrIdx, uint64_t id);
-int vncOverrideParam(const char *nameAndValue);
+int vncOverrideParam(const char *param, const char *value);
#ifdef __cplusplus
}
diff --git a/unix/xserver/hw/vnc/vncInput.c b/unix/xserver/hw/vnc/vncInput.c
index a705a85a..f83806ff 100644
--- a/unix/xserver/hw/vnc/vncInput.c
+++ b/unix/xserver/hw/vnc/vncInput.c
@@ -167,7 +167,7 @@ void vncPointerMove(int x, int y)
void vncGetPointerPos(int *x, int *y)
{
- if (vncPointerDev != NULL) {
+ if ((vncPointerDev != NULL) && (vncPointerDev->public.on)) {
ScreenPtr ptrScreen;
miPointerGetPosition(vncPointerDev, &cursorPosX, &cursorPosY);
diff --git a/unix/xserver/hw/vnc/vncModule.c b/unix/xserver/hw/vnc/vncModule.c
index 5f0886a3..bff317b5 100644
--- a/unix/xserver/hw/vnc/vncModule.c
+++ b/unix/xserver/hw/vnc/vncModule.c
@@ -50,7 +50,7 @@ ExtensionModule vncExt =
static XF86ModuleVersionInfo vncVersRec =
{
"vnc",
- "TigerVNC project",
+ "TigerVNC",
MODINFOSTRING1,
MODINFOSTRING2,
VENDOR_RELEASE,
diff --git a/unix/xserver/hw/vnc/xvnc.c b/unix/xserver/hw/vnc/xvnc.c
index 31301f6c..5cf673aa 100644
--- a/unix/xserver/hw/vnc/xvnc.c
+++ b/unix/xserver/hw/vnc/xvnc.c
@@ -73,8 +73,8 @@ extern char buildtime[];
#include "version-config.h"
-#define XVNCVERSION "TigerVNC 1.14.80"
-#define XVNCCOPYRIGHT ("Copyright (C) 1999-2024 TigerVNC Team and many others (see README.rst)\n" \
+#define XVNCVERSION "TigerVNC 1.15.80"
+#define XVNCCOPYRIGHT ("Copyright (C) 1999-2025 TigerVNC team and many others (see README.rst)\n" \
"See https://www.tigervnc.org for information on TigerVNC.\n")
#define VNC_DEFAULT_WIDTH 1024
@@ -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
@@ -214,8 +218,6 @@ ddxInputThreadInit(void)
void
ddxUseMsg(void)
{
- vncPrintBanner();
-
ErrorF("-pixdepths list-of-int support given pixmap depths\n");
ErrorF("+/-render turn on/off RENDER extension support"
"(default on)\n");
@@ -278,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;
@@ -384,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;
@@ -398,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;
@@ -448,28 +452,7 @@ ddxProcessArgument(int argc, char *argv[], int i)
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;
- }
- }
-
- if (vncSetParamSimple(argv[i]))
- return 1;
-
- if (argv[i][0] == '-' && i + 1 < argc) {
- if (vncSetParam(&argv[i][1], argv[i + 1]))
- return 2;
- }
-
- return 0;
+ return vncHandleParamArg(argc, argv, i);
}
static Bool
@@ -765,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;
@@ -903,7 +887,7 @@ vncRandRCreateScreenOutputs(int scrIdx, int extraOutputs)
/* Creating and modifying modes, used by XserverDesktop and init here */
int
-vncRandRCanCreateModes()
+vncRandRCanCreateModes(void)
{
return 1;
}
@@ -1170,10 +1154,11 @@ InitOutput(ScreenInfo * scrInfo, int argc, char **argv)
int i;
int NumFormats = 0;
- vncPrintBanner();
+ if (serverGeneration == 1) {
+ vncPrintBanner();
- if (serverGeneration == 1)
LoadExtensionList(vncExtensions, ARRAY_SIZE(vncExtensions), TRUE);
+ }
#if XORG_AT_LEAST(1, 20, 0)
xorgGlxCreateVendor();
@@ -1230,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)
@@ -1261,3 +1248,9 @@ vncClientGone(int fd)
GiveUp(0);
}
}
+
+int
+main(int argc, char *argv[], char *envp[])
+{
+ return dix_main(argc, argv, envp);
+}