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.cc4
-rw-r--r--unix/xserver/hw/vnc/XserverDesktop.cc14
-rw-r--r--unix/xserver/hw/vnc/XserverDesktop.h12
-rw-r--r--unix/xserver/hw/vnc/Xvnc.man9
-rw-r--r--unix/xserver/hw/vnc/vncExt.c1
-rw-r--r--unix/xserver/hw/vnc/vncExtInit.cc36
-rw-r--r--unix/xserver/hw/vnc/vncExtInit.h1
7 files changed, 59 insertions, 18 deletions
diff --git a/unix/xserver/hw/vnc/RFBGlue.cc b/unix/xserver/hw/vnc/RFBGlue.cc
index c9153364..160177bd 100644
--- a/unix/xserver/hw/vnc/RFBGlue.cc
+++ b/unix/xserver/hw/vnc/RFBGlue.cc
@@ -192,14 +192,14 @@ void vncListParams(int width, int nameWidth)
int vncGetSocketPort(int fd)
{
- return network::TcpSocket::getSockPort(fd);
+ return network::getSockPort(fd);
}
int vncIsTCPPortUsed(int port)
{
try {
// Attempt to create TCPListeners on that port.
- std::list<network::TcpListener*> dummy;
+ std::list<network::SocketListener*> dummy;
network::createTcpListeners (&dummy, 0, port);
while (!dummy.empty()) {
delete dummy.back();
diff --git a/unix/xserver/hw/vnc/XserverDesktop.cc b/unix/xserver/hw/vnc/XserverDesktop.cc
index 080943d0..4aac7655 100644
--- a/unix/xserver/hw/vnc/XserverDesktop.cc
+++ b/unix/xserver/hw/vnc/XserverDesktop.cc
@@ -32,7 +32,7 @@
#include <fcntl.h>
#include <sys/utsname.h>
-#include <network/TcpSocket.h>
+#include <network/Socket.h>
#include <rfb/Exception.h>
#include <rfb/VNCServerST.h>
#include <rfb/HTTPServer.h>
@@ -107,8 +107,8 @@ public:
XserverDesktop::XserverDesktop(int screenIndex_,
- std::list<network::TcpListener*> listeners_,
- std::list<network::TcpListener*> httpListeners_,
+ std::list<network::SocketListener*> listeners_,
+ std::list<network::SocketListener*> httpListeners_,
const char* name, const rfb::PixelFormat &pf,
int width, int height,
void* fbptr, int stride)
@@ -127,13 +127,13 @@ XserverDesktop::XserverDesktop(int screenIndex_,
if (!httpListeners.empty ())
httpServer = new FileHTTPServer(this);
- for (std::list<TcpListener*>::iterator i = listeners.begin();
+ for (std::list<SocketListener*>::iterator i = listeners.begin();
i != listeners.end();
i++) {
vncSetNotifyFd((*i)->getFd(), screenIndex, true, false);
}
- for (std::list<TcpListener*>::iterator i = httpListeners.begin();
+ for (std::list<SocketListener*>::iterator i = httpListeners.begin();
i != httpListeners.end();
i++) {
vncSetNotifyFd((*i)->getFd(), screenIndex, true, false);
@@ -386,10 +386,10 @@ void XserverDesktop::handleSocketEvent(int fd, bool read, bool write)
}
bool XserverDesktop::handleListenerEvent(int fd,
- std::list<TcpListener*>* sockets,
+ std::list<SocketListener*>* sockets,
SocketServer* sockserv)
{
- std::list<TcpListener*>::iterator i;
+ std::list<SocketListener*>::iterator i;
for (i = sockets->begin(); i != sockets->end(); i++) {
if ((*i)->getFd() == fd)
diff --git a/unix/xserver/hw/vnc/XserverDesktop.h b/unix/xserver/hw/vnc/XserverDesktop.h
index f1c3e3e7..f866a4cc 100644
--- a/unix/xserver/hw/vnc/XserverDesktop.h
+++ b/unix/xserver/hw/vnc/XserverDesktop.h
@@ -44,7 +44,7 @@ namespace rfb {
class VNCServerST;
}
-namespace network { class TcpListener; class Socket; class SocketServer; }
+namespace network { class SocketListener; class Socket; class SocketServer; }
class XserverDesktop : public rfb::SDesktop, public rfb::FullFramePixelBuffer,
public rdr::Substitutor,
@@ -53,8 +53,8 @@ class XserverDesktop : public rfb::SDesktop, public rfb::FullFramePixelBuffer,
public:
XserverDesktop(int screenIndex,
- std::list<network::TcpListener*> listeners_,
- std::list<network::TcpListener*> httpListeners_,
+ std::list<network::SocketListener*> listeners_,
+ std::list<network::SocketListener*> httpListeners_,
const char* name, const rfb::PixelFormat &pf,
int width, int height, void* fbptr, int stride);
virtual ~XserverDesktop();
@@ -109,7 +109,7 @@ public:
protected:
bool handleListenerEvent(int fd,
- std::list<network::TcpListener*>* sockets,
+ std::list<network::SocketListener*>* sockets,
network::SocketServer* sockserv);
bool handleSocketEvent(int fd,
network::SocketServer* sockserv,
@@ -122,8 +122,8 @@ private:
int screenIndex;
rfb::VNCServerST* server;
rfb::HTTPServer* httpServer;
- std::list<network::TcpListener*> listeners;
- std::list<network::TcpListener*> httpListeners;
+ std::list<network::SocketListener*> listeners;
+ std::list<network::SocketListener*> httpListeners;
bool directFbptr;
uint32_t queryConnectId;
diff --git a/unix/xserver/hw/vnc/Xvnc.man b/unix/xserver/hw/vnc/Xvnc.man
index 80b78781..269be9af 100644
--- a/unix/xserver/hw/vnc/Xvnc.man
+++ b/unix/xserver/hw/vnc/Xvnc.man
@@ -91,6 +91,15 @@ Use IPv4 for incoming and outgoing connections. Default is on.
Use IPv6 for incoming and outgoing connections. Default is on.
.
.TP
+.B \-rfbunixpath \fIpath\fP
+Specifies the path of a Unix domain socket on which Xvnc listens for
+connections from viewers, instead of listening on a TCP port.
+.
+.TP
+.B \-rfbunixmode \fImode\fP
+Specifies the mode of the Unix domain socket. The default is 0600.
+.
+.TP
.B \-rfbwait \fItime\fP, \-ClientWaitTimeMillis \fItime\fP
Time in milliseconds to wait for a viewer which is blocking the server. This is
necessary because the server is single-threaded and sometimes blocks until the
diff --git a/unix/xserver/hw/vnc/vncExt.c b/unix/xserver/hw/vnc/vncExt.c
index f7ba9fa8..fd65eab6 100644
--- a/unix/xserver/hw/vnc/vncExt.c
+++ b/unix/xserver/hw/vnc/vncExt.c
@@ -585,6 +585,7 @@ static int SProcVncExtDispatch(ClientPtr client)
static void vncResetProc(ExtensionEntry* extEntry)
{
+ vncExtensionClose();
}
static void vncClientStateChange(CallbackListPtr * l, void * d, void * p)
diff --git a/unix/xserver/hw/vnc/vncExtInit.cc b/unix/xserver/hw/vnc/vncExtInit.cc
index 54cca953..d6f6b742 100644
--- a/unix/xserver/hw/vnc/vncExtInit.cc
+++ b/unix/xserver/hw/vnc/vncExtInit.cc
@@ -34,6 +34,7 @@
#include <rfb/Region.h>
#include <rfb/ledStates.h>
#include <network/TcpSocket.h>
+#include <network/UnixSocket.h>
#include "XserverDesktop.h"
#include "vncExtInit.h"
@@ -79,6 +80,8 @@ rfb::IntParameter httpPort("httpPort", "TCP port to listen for HTTP",0);
rfb::AliasParameter rfbwait("rfbwait", "Alias for ClientWaitTimeMillis",
&rfb::Server::clientWaitTimeMillis);
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","x11");
rfb::BoolParameter localhostOnly("localhost",
"Only allow connections from localhost",
@@ -173,14 +176,29 @@ void vncExtensionInit(void)
for (int scr = 0; scr < vncGetScreenCount(); scr++) {
if (!desktop[scr]) {
- std::list<network::TcpListener*> listeners;
- std::list<network::TcpListener*> httpListeners;
+ std::list<network::SocketListener*> listeners;
+ std::list<network::SocketListener*> httpListeners;
if (scr == 0 && vncInetdSock != -1) {
- if (network::TcpSocket::isListening(vncInetdSock))
+ if (network::isSocketListening(vncInetdSock))
{
listeners.push_back(new network::TcpListener(vncInetdSock));
vlog.info("inetd wait");
}
+ } else if (rfbunixpath.getValueStr()[0] != '\0') {
+ char path[PATH_MAX];
+ int mode = (int)rfbunixmode;
+
+ if (scr == 0)
+ strncpy(path, rfbunixpath, sizeof(path));
+ else
+ snprintf(path, sizeof(path), "%s.%d",
+ rfbunixpath.getValueStr(), scr);
+ path[sizeof(path)-1] = '\0';
+
+ listeners.push_back(new network::UnixListener(path, mode));
+
+ vlog.info("Listening for VNC connections on %s (mode %04o)",
+ path, mode);
} else {
const char *addr = interface;
int port = rfbport;
@@ -244,6 +262,18 @@ void vncExtensionInit(void)
vncRegisterBlockHandlers();
}
+void vncExtensionClose(void)
+{
+ try {
+ for (int scr = 0; scr < vncGetScreenCount(); scr++) {
+ delete desktop[scr];
+ desktop[scr] = NULL;
+ }
+ } catch (rdr::Exception& e) {
+ vncFatalError("vncExtInit: %s",e.str());
+ }
+}
+
void vncHandleSocketEvent(int fd, int scrIdx, int read, int write)
{
desktop[scrIdx]->handleSocketEvent(fd, read, write);
diff --git a/unix/xserver/hw/vnc/vncExtInit.h b/unix/xserver/hw/vnc/vncExtInit.h
index e8294340..9414723f 100644
--- a/unix/xserver/hw/vnc/vncExtInit.h
+++ b/unix/xserver/hw/vnc/vncExtInit.h
@@ -48,6 +48,7 @@ extern int vncFbstride[];
extern int vncInetdSock;
void vncExtensionInit(void);
+void vncExtensionClose(void);
void vncHandleSocketEvent(int fd, int scrIdx, int read, int write);
void vncCallBlockHandlers(int* timeout);