sync with TightVNC 1.2.3

pull/1/head
dscho 22 years ago
parent fd2931c0ed
commit e66eeecd62

@ -1,3 +1,4 @@
synced with TightVNC 1.2.3
solaris compile cleanups solaris compile cleanups
many x11vnc improvements many x11vnc improvements
added backchannel, an encoding which needs special clients to pass added backchannel, an encoding which needs special clients to pass

Binary file not shown.

@ -8,9 +8,10 @@
<TITLE> <TITLE>
$USER's $DESKTOP desktop ($DISPLAY) $USER's $DESKTOP desktop ($DISPLAY)
</TITLE> </TITLE>
<APPLET CODE=vncviewer.class ARCHIVE=vncviewer.jar <APPLET CODE=vncviewer.class ARCHIVE=VncViewer.jar
WIDTH=$APPLETWIDTH HEIGHT=$APPLETHEIGHT> WIDTH=$APPLETWIDTH HEIGHT=$APPLETHEIGHT>
<param name=PORT value=$PORT> <param name=PORT value=$PORT>
</APPLET> </APPLET>
<BR>
<A href="http://www.tightvnc.com/">www.TightVNC.com</A> <A href="http://www.tightvnc.com/">www.TightVNC.com</A>
</HTML> </HTML>

Binary file not shown.

@ -39,6 +39,10 @@
#include <fcntl.h> #include <fcntl.h>
#include <errno.h> #include <errno.h>
#ifdef USE_LIBWRAP
#include <tcpd.h>
#endif
#include "rfb.h" #include "rfb.h"
#define NOT_FOUND_STR "HTTP/1.0 404 Not found\n\n" \ #define NOT_FOUND_STR "HTTP/1.0 404 Not found\n\n" \
@ -62,6 +66,7 @@ FILE* httpFP = NULL;
#define BUF_SIZE 32768 #define BUF_SIZE 32768
static char buf[BUF_SIZE]; static char buf[BUF_SIZE];
static size_t buf_filled=0;
/* /*
@ -137,6 +142,7 @@ httpCheckFds(rfbScreenInfoPtr rfbScreen)
} }
if (FD_ISSET(rfbScreen->httpListenSock, &fds)) { if (FD_ISSET(rfbScreen->httpListenSock, &fds)) {
int flags;
if (rfbScreen->httpSock >= 0) close(rfbScreen->httpSock); if (rfbScreen->httpSock >= 0) close(rfbScreen->httpSock);
if ((rfbScreen->httpSock = accept(rfbScreen->httpListenSock, if ((rfbScreen->httpSock = accept(rfbScreen->httpListenSock,
@ -144,12 +150,27 @@ httpCheckFds(rfbScreenInfoPtr rfbScreen)
rfbLogPerror("httpCheckFds: accept"); rfbLogPerror("httpCheckFds: accept");
return; return;
} }
#ifdef USE_LIBWRAP
if(!hosts_ctl("vnc",STRING_UNKNOWN,inet_ntoa(addr.sin_addr),
STRING_UNKNOWN)) {
rfbLog("Rejected connection from client %s\n",
inet_ntoa(addr.sin_addr));
#else
if ((rfbScreen->httpFP = fdopen(rfbScreen->httpSock, "r+")) == NULL) { if ((rfbScreen->httpFP = fdopen(rfbScreen->httpSock, "r+")) == NULL) {
rfbLogPerror("httpCheckFds: fdopen"); rfbLogPerror("httpCheckFds: fdopen");
#endif
close(rfbScreen->httpSock); close(rfbScreen->httpSock);
rfbScreen->httpSock = -1; rfbScreen->httpSock = -1;
return; return;
} }
flags=fcntl(rfbScreen->httpSock,F_GETFL);
if(flags==-1 ||
fcntl(rfbScreen->httpSock,F_SETFL,flags|O_NONBLOCK)==-1) {
rfbLogPerror("httpCheckFds: fcntl");
close(rfbScreen->httpSock);
rfbScreen->httpSock=-1;
return;
}
/*AddEnabledDevice(httpSock);*/ /*AddEnabledDevice(httpSock);*/
} }
@ -180,11 +201,10 @@ httpProcessInput(rfbScreenInfoPtr rfbScreen)
char *fname; char *fname;
unsigned int maxFnameLen; unsigned int maxFnameLen;
FILE* fd; FILE* fd;
Bool gotGet = FALSE;
Bool performSubstitutions = FALSE; Bool performSubstitutions = FALSE;
char str[256]; char str[256];
#ifndef WIN32 #ifndef WIN32
struct passwd *user = getpwuid(getuid());; struct passwd *user = getpwuid(getuid());
#endif #endif
cl.sock=rfbScreen->httpSock; cl.sock=rfbScreen->httpSock;
@ -198,66 +218,74 @@ httpProcessInput(rfbScreenInfoPtr rfbScreen)
fname = &fullFname[strlen(fullFname)]; fname = &fullFname[strlen(fullFname)];
maxFnameLen = 255 - strlen(fullFname); maxFnameLen = 255 - strlen(fullFname);
buf[0] = '\0'; /* Read data from the HTTP client until we get a complete request. */
while (1) { while (1) {
ssize_t got = read (rfbScreen->httpSock, buf + buf_filled,
/* Read lines from the HTTP client until a blank line. The only sizeof (buf) - buf_filled - 1);
line we need to parse is the line "GET <filename> ..." */
if (got <= 0) {
if (!fgets(buf, BUF_SIZE, rfbScreen->httpFP)) { if (got == 0) {
rfbLogPerror("httpProcessInput: fgets"); rfbLog("httpd: premature connection close\n");
} else {
if (errno == EAGAIN) {
return;
}
rfbLogPerror("httpProcessInput: read");
}
httpCloseSock(rfbScreen); httpCloseSock(rfbScreen);
return; return;
} }
if ((strcmp(buf,"\n") == 0) || (strcmp(buf,"\r\n") == 0) buf_filled += got;
|| (strcmp(buf,"\r") == 0) || (strcmp(buf,"\n\r") == 0)) buf[buf_filled] = '\0';
/* end of client request */
/* Is it complete yet (is there a blank line)? */
if (strstr (buf, "\r\r") || strstr (buf, "\n\n") ||
strstr (buf, "\r\n\r\n") || strstr (buf, "\n\r\n\r"))
break; break;
}
if (strncmp(buf, "GET ", 4) == 0) {
gotGet = TRUE;
if (strlen(buf) > maxFnameLen) { /* Process the request. */
rfbLog("GET line too long\n"); if (strncmp(buf, "GET ", 4)) {
httpCloseSock(rfbScreen); rfbLog("no GET line\n");
return; httpCloseSock(rfbScreen);
} return;
} else {
if (sscanf(buf, "GET %s HTTP/1.0", fname) != 1) { /* Only use the first line. */
rfbLog("couldn't parse GET line\n"); buf[strcspn(buf, "\n\r")] = '\0';
httpCloseSock(rfbScreen); }
return;
}
if (fname[0] != '/') { if (strlen(buf) > maxFnameLen) {
rfbLog("filename didn't begin with '/'\n"); rfbLog("GET line too long\n");
WriteExact(&cl, NOT_FOUND_STR, strlen(NOT_FOUND_STR)); httpCloseSock(rfbScreen);
httpCloseSock(rfbScreen); return;
return; }
}
if (strchr(fname+1, '/') != NULL) { if (sscanf(buf, "GET %s HTTP/1.0", fname) != 1) {
rfbLog("asking for file in other directory\n"); rfbLog("couldn't parse GET line\n");
WriteExact(&cl, NOT_FOUND_STR, strlen(NOT_FOUND_STR)); httpCloseSock(rfbScreen);
httpCloseSock(rfbScreen); return;
return; }
}
getpeername(rfbScreen->httpSock, (struct sockaddr *)&addr, &addrlen); if (fname[0] != '/') {
rfbLog("httpd: get '%s' for %s\n", fname+1, rfbLog("filename didn't begin with '/'\n");
inet_ntoa(addr.sin_addr)); WriteExact(&cl, NOT_FOUND_STR, strlen(NOT_FOUND_STR));
continue; httpCloseSock(rfbScreen);
} return;
} }
if (!gotGet) { if (strchr(fname+1, '/') != NULL) {
rfbLog("no GET line\n"); rfbLog("asking for file in other directory\n");
WriteExact(&cl, NOT_FOUND_STR, strlen(NOT_FOUND_STR));
httpCloseSock(rfbScreen); httpCloseSock(rfbScreen);
return; return;
} }
getpeername(rfbScreen->httpSock, (struct sockaddr *)&addr, &addrlen);
rfbLog("httpd: get '%s' for %s\n", fname+1,
inet_ntoa(addr.sin_addr));
/* If we were asked for '/', actually read the file index.vnc */ /* If we were asked for '/', actually read the file index.vnc */
if (strcmp(fname, "/") == 0) { if (strcmp(fname, "/") == 0) {
@ -274,10 +302,10 @@ httpProcessInput(rfbScreenInfoPtr rfbScreen)
/* Open the file */ /* Open the file */
if ((fd = fopen(fullFname, "r")) <= 0) { if ((fd = fopen(fullFname, "r")) <= 0) {
rfbLogPerror("httpProcessInput: open"); rfbLogPerror("httpProcessInput: open");
WriteExact(&cl, NOT_FOUND_STR, strlen(NOT_FOUND_STR)); WriteExact(&cl, NOT_FOUND_STR, strlen(NOT_FOUND_STR));
httpCloseSock(rfbScreen); httpCloseSock(rfbScreen);
return; return;
} }
WriteExact(&cl, OK_STR, strlen(OK_STR)); WriteExact(&cl, OK_STR, strlen(OK_STR));

@ -1208,7 +1208,8 @@ rfbSendRectEncodingRaw(cl, x, y, w, h)
char *fbptr = (cl->screen->frameBuffer + (cl->screen->paddedWidthInBytes * y) char *fbptr = (cl->screen->frameBuffer + (cl->screen->paddedWidthInBytes * y)
+ (x * (cl->screen->bitsPerPixel / 8))); + (x * (cl->screen->bitsPerPixel / 8)));
if (cl->ublen + sz_rfbFramebufferUpdateRectHeader > UPDATE_BUF_SIZE) { /* Flush the buffer to guarantee correct alignment for translateFn(). */
if (cl->ublen > 0) {
if (!rfbSendUpdateBuf(cl)) if (!rfbSendUpdateBuf(cl))
return FALSE; return FALSE;
} }

@ -67,6 +67,13 @@ struct timeval
#include <fcntl.h> #include <fcntl.h>
#include <errno.h> #include <errno.h>
#ifdef USE_LIBWRAP
#include <syslog.h>
#include <tcpd.h>
int allow_severity=LOG_INFO;
int deny_severity=LOG_WARNING;
#endif
#include "rfb.h" #include "rfb.h"
/*#ifndef WIN32 /*#ifndef WIN32
@ -223,6 +230,16 @@ rfbCheckFds(rfbScreenInfoPtr rfbScreen,long usec)
return; return;
} }
#ifdef USE_LIBWRAP
if(!hosts_ctl("vnc",STRING_UNKNOWN,inet_ntoa(addr.sin_addr),
STRING_UNKNOWN)) {
rfbLog("Rejected connection from client %s\n",
inet_ntoa(addr.sin_addr));
close(sock);
return;
}
#endif
rfbLog("Got connection from client %s\n", inet_ntoa(addr.sin_addr)); rfbLog("Got connection from client %s\n", inet_ntoa(addr.sin_addr));
rfbNewClient(rfbScreen,sock); rfbNewClient(rfbScreen,sock);

Loading…
Cancel
Save