summaryrefslogtreecommitdiffstats
path: root/x11vnc/inet.c
diff options
context:
space:
mode:
authorrunge <runge>2006-02-20 19:19:30 +0000
committerrunge <runge>2006-02-20 19:19:30 +0000
commit603b5667b64aa5aaea0aa7e575fb4cb2c2b6d7c7 (patch)
tree582b98055d3f8edf42fff571a3443ff0dfaa1256 /x11vnc/inet.c
parent4b8cc33e39e1d2f4eb459312659eff873a41e4db (diff)
downloadlibtdevnc-603b5667b64aa5aaea0aa7e575fb4cb2c2b6d7c7.tar.gz
libtdevnc-603b5667b64aa5aaea0aa7e575fb4cb2c2b6d7c7.zip
fix some non-gcc compiler warnings and signals in x11vnc
Diffstat (limited to 'x11vnc/inet.c')
-rw-r--r--x11vnc/inet.c43
1 files changed, 41 insertions, 2 deletions
diff --git a/x11vnc/inet.c b/x11vnc/inet.c
index 29f4992..12f4fee 100644
--- a/x11vnc/inet.c
+++ b/x11vnc/inet.c
@@ -177,8 +177,47 @@ char *ident_username(rfbClientPtr client) {
if (!user || *user == '\0') {
char msg[128];
int n, sock, ok = 0;
-
- if ((sock = rfbConnectToTcpAddr(client->host, 113)) < 0) {
+ int block = 0;
+
+ /*
+ * need to check to see if the operation will block for
+ * a long time: a firewall may just ignore our packets.
+ */
+#if LIBVNCSERVER_HAVE_FORK
+ { pid_t pid, pidw;
+ int rc;
+ if ((pid = fork()) > 0) {
+ usleep(100 * 1000); /* 0.1 sec */
+ pidw = waitpid(pid, &rc, WNOHANG);
+ if (pidw <= 0) {
+ usleep(1000 * 1000); /* 1.0 sec */
+ pidw = waitpid(pid, &rc, WNOHANG);
+ if (pidw <= 0) {
+ block = 1;
+ kill(pid, SIGTERM);
+ }
+ }
+ } else if (pid == -1) {
+ ;
+ } else {
+ /* child */
+ signal(SIGHUP, SIG_DFL);
+ signal(SIGINT, SIG_DFL);
+ signal(SIGQUIT, SIG_DFL);
+ signal(SIGTERM, SIG_DFL);
+
+ if ((sock = rfbConnectToTcpAddr(client->host, 113)) < 0) {
+ exit(1);
+ } else {
+ close(sock);
+ exit(0);
+ }
+ }
+ }
+#endif
+ if (block) {
+ ;
+ } else if ((sock = rfbConnectToTcpAddr(client->host, 113)) < 0) {
rfbLog("could not connect to ident: %s:%d\n",
client->host, 113);
} else {