Attached is an updated patch in two parts that applies to vnc4_4.1.1+X4.3.0-37.
Thanks, Jö. -- This message is protected by DoubleROT13 encryption Attempting to decode it violates the DMCA/WIPO acts
From 5d381de17eaf270422e3cb303c1b55c64e6fcba4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6=20Fahlke?= <jor...@jorrit.de> Date: Sat, 26 Mar 2011 20:15:13 +0100 Subject: [PATCH 1/2] [CCon] Use std::string instead of C-strings for brevety and safety. --- unix/vncviewer/CConn.cxx | 29 +++++++++++++---------------- 1 files changed, 13 insertions(+), 16 deletions(-) diff --git a/unix/vncviewer/CConn.cxx b/unix/vncviewer/CConn.cxx index 791d4fc..907340a 100644 --- a/unix/vncviewer/CConn.cxx +++ b/unix/vncviewer/CConn.cxx @@ -19,6 +19,10 @@ // CConn.cxx // +#include <iostream> +#include <ostream> +#include <string> + #include <termios.h> #include <stdio.h> #include <unistd.h> @@ -85,33 +89,26 @@ CConn::CConn(Display* dpy_, int argc_, char** argv_, network::Socket* sock_, vlog.info("Accepted connection from %s", name); if (name) free(name); } else { - if (vncServerName) { - getHostAndPort(vncServerName, &serverHost, &serverPort); - } else { + std::string serverName; + if (vncServerName) + serverName = vncServerName; + else { int popup = popupXDialog; if (!popup) { /* Get server */ - fprintf(stderr, "Server: "); - vncServerName = new char[128]; - if(fgets(vncServerName, 128, stdin)) { - size_t len = strlen(vncServerName); - /* remove \n at the end */ - if(vncServerName[len-1] == '\n') - vncServerName[len-1] = '\0'; - } else { - /* fgets failed, probably eof -- assume empty string as input */ - vncServerName[0] = '\0'; - } - getHostAndPort(vncServerName, &serverHost, &serverPort); + std::cerr << "Server: " << std::flush; + if(!getline(std::cin, serverName)) + serverName.clear(); } else { ServerDialog dlg(dpy, &options, &about); if (!dlg.show() || dlg.entry.getText()[0] == 0) { exit(1); } - getHostAndPort(dlg.entry.getText(), &serverHost, &serverPort); + serverName = dlg.entry.getText(); } } + getHostAndPort(serverName.c_str(), &serverHost, &serverPort); sock = new network::TcpSocket(serverHost, serverPort, ipVersion); vlog.info("connected to host %s port %d", serverHost, serverPort); } -- 1.7.2.5
From df3691b0b7eca1af91b3e7352d1985935c8e798b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6=20Fahlke?= <jor...@jorrit.de> Date: Sat, 26 Mar 2011 21:08:34 +0100 Subject: [PATCH 2/2] [CCon] Make it possible to use unix domain sockets --- unix/vncviewer/CConn.cxx | 30 +++++++++++++++++++++++++++--- unix/vncviewer/vncviewer.man | 8 ++++++++ 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/unix/vncviewer/CConn.cxx b/unix/vncviewer/CConn.cxx index 907340a..58e07e4 100644 --- a/unix/vncviewer/CConn.cxx +++ b/unix/vncviewer/CConn.cxx @@ -22,10 +22,13 @@ #include <iostream> #include <ostream> #include <string> +#include <vector> #include <termios.h> #include <stdio.h> #include <unistd.h> +#include <sys/socket.h> +#include <sys/un.h> #include "CConn.h" #include <rfb/CMsgWriter.h> #include <rfb/encodings.h> @@ -108,9 +111,30 @@ CConn::CConn(Display* dpy_, int argc_, char** argv_, network::Socket* sock_, } } - getHostAndPort(serverName.c_str(), &serverHost, &serverPort); - sock = new network::TcpSocket(serverHost, serverPort, ipVersion); - vlog.info("connected to host %s port %d", serverHost, serverPort); + /* assume it's a unix domain socket if it contains a '/' */ + if(serverName.find('/') != std::string::npos) { + int unix_sock = socket(PF_LOCAL, SOCK_STREAM, 0); + size_t sock_addr_size = offsetof(sockaddr_un, sun_path) + + serverName.size() + 1; + // buffer for the sockaddr structure that gets deallocated automatically + std::vector<char> name_buf(sock_addr_size); + sockaddr_un *name = (sockaddr_un *)&name_buf.front(); + name->sun_family = AF_LOCAL; + strcpy(name->sun_path, serverName.c_str()); + int result = connect(unix_sock, (const sockaddr *)name, sock_addr_size); + if(result == -1) { + /* connecting socket failed */ + vlog.error("Can't connect to unix domain socket %s", vncServerName); + exit(1); + } + + sock = new network::TcpSocket(unix_sock); + vlog.info("connected to unix domain socket %s", serverName.c_str()); + } else { + getHostAndPort(serverName.c_str(), &serverHost, &serverPort); + sock = new network::TcpSocket(serverHost, serverPort, ipVersion); + vlog.info("connected to host %s port %d", serverHost, serverPort); + } } sameMachine = sock->sameMachine(); diff --git a/unix/vncviewer/vncviewer.man b/unix/vncviewer/vncviewer.man index 9ce75e4..9ff1db5 100644 --- a/unix/vncviewer/vncviewer.man +++ b/unix/vncviewer/vncviewer.man @@ -8,6 +8,10 @@ vncviewer \- VNC viewer for X .br .B vncviewer .RI [ options ] +.RI [ unix_domain_socket ] +.br +.B vncviewer +.RI [ options ] .B \-listen .RI [ port ] .SH DESCRIPTION @@ -27,6 +31,10 @@ VNC server on that machine. Either the machine name or display number can be omitted. So for example ":1" means display number 1 on the same machine, and "snoopy" means "snoopy:0" i.e. display 0 on machine "snoopy". +A server specification containing a '/' is recognised as a path to an unix +domain socket. The viewer will then connect to a server listening on that +socket, for example a QEMU virtual machine. + If the VNC server is successfully contacted, you will be prompted for a password to authenticate you. If the password is correct, a window will appear showing the desktop of the VNC server. -- 1.7.2.5
signature.asc
Description: Digital signature