diff options
Diffstat (limited to 'unix')
-rw-r--r-- | unix/x0vncserver/x0vncserver.cxx | 20 | ||||
-rw-r--r-- | unix/x0vncserver/x0vncserver.man | 9 | ||||
-rw-r--r-- | unix/xserver/hw/vnc/RFBGlue.cc | 4 | ||||
-rw-r--r-- | unix/xserver/hw/vnc/XserverDesktop.cc | 14 | ||||
-rw-r--r-- | unix/xserver/hw/vnc/XserverDesktop.h | 12 | ||||
-rw-r--r-- | unix/xserver/hw/vnc/Xvnc.man | 9 | ||||
-rw-r--r-- | unix/xserver/hw/vnc/vncExt.c | 1 | ||||
-rw-r--r-- | unix/xserver/hw/vnc/vncExtInit.cc | 36 | ||||
-rw-r--r-- | unix/xserver/hw/vnc/vncExtInit.h | 1 |
9 files changed, 82 insertions, 24 deletions
diff --git a/unix/x0vncserver/x0vncserver.cxx b/unix/x0vncserver/x0vncserver.cxx index c8098f70..c08572be 100644 --- a/unix/x0vncserver/x0vncserver.cxx +++ b/unix/x0vncserver/x0vncserver.cxx @@ -31,6 +31,7 @@ #include <rfb/Configuration.h> #include <rfb/Timer.h> #include <network/TcpSocket.h> +#include <network/UnixSocket.h> #include <vncconfig/QueryConnectDialog.h> @@ -58,6 +59,8 @@ IntParameter maxProcessorUsage("MaxProcessorUsage", "Maximum percentage of " "CPU time to be consumed", 35); StringParameter displayname("display", "The X display", ""); IntParameter rfbport("rfbport", "TCP port to listen for RFB protocol",5900); +StringParameter rfbunixpath("rfbunixpath", "Unix socket to listen for RFB protocol", ""); +IntParameter rfbunixmode("rfbunixmode", "Unix socket access mode", 0600); IntParameter queryConnectTimeout("QueryConnectTimeout", "Number of seconds to show the Accept Connection dialog before " "rejecting the connection", @@ -291,7 +294,7 @@ int main(int argc, char** argv) signal(SIGINT, CleanupSignalHandler); signal(SIGTERM, CleanupSignalHandler); - std::list<TcpListener*> listeners; + std::list<SocketListener*> listeners; try { TXWindow::init(dpy,"x0vncserver"); @@ -307,13 +310,18 @@ int main(int argc, char** argv) QueryConnHandler qcHandler(dpy, &server); server.setQueryConnectionHandler(&qcHandler); - createTcpListeners(&listeners, 0, (int)rfbport); - vlog.info("Listening on port %d", (int)rfbport); + if (rfbunixpath.getValueStr()[0] != '\0') { + listeners.push_back(new network::UnixListener(rfbunixpath, rfbunixmode)); + vlog.info("Listening on %s (mode %04o)", (const char*)rfbunixpath, (int)rfbunixmode); + } else { + createTcpListeners(&listeners, 0, (int)rfbport); + vlog.info("Listening on port %d", (int)rfbport); + } const char *hostsData = hostsFile.getData(); FileTcpFilter fileTcpFilter(hostsData); if (strlen(hostsData) != 0) - for (std::list<TcpListener*>::iterator i = listeners.begin(); + for (std::list<SocketListener*>::iterator i = listeners.begin(); i != listeners.end(); i++) (*i)->setFilter(&fileTcpFilter); @@ -335,7 +343,7 @@ int main(int argc, char** argv) FD_ZERO(&wfds); FD_SET(ConnectionNumber(dpy), &rfds); - for (std::list<TcpListener*>::iterator i = listeners.begin(); + for (std::list<SocketListener*>::iterator i = listeners.begin(); i != listeners.end(); i++) FD_SET((*i)->getFd(), &rfds); @@ -387,7 +395,7 @@ int main(int argc, char** argv) } // Accept new VNC connections - for (std::list<TcpListener*>::iterator i = listeners.begin(); + for (std::list<SocketListener*>::iterator i = listeners.begin(); i != listeners.end(); i++) { if (FD_ISSET((*i)->getFd(), &rfds)) { diff --git a/unix/x0vncserver/x0vncserver.man b/unix/x0vncserver/x0vncserver.man index 5c8729e2..5dc0b052 100644 --- a/unix/x0vncserver/x0vncserver.man +++ b/unix/x0vncserver/x0vncserver.man @@ -66,6 +66,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 x0vncserver 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 \-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 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); |