]> git.proxmox.com Git - vncterm.git/blob - vncpatches/remove-systemd-socket-activation.patch
bound check utf8 characters
[vncterm.git] / vncpatches / remove-systemd-socket-activation.patch
1 commit 25e3dfeab75b6febdb6c1157e991c3bcbeb3eb86
2 Author: Fabian Grünbichler <f.gruenbichler@proxmox.com>
3 AuthorDate: Thu Feb 2 11:22:35 2017 +0100
4 Commit: Fabian Grünbichler <f.gruenbichler@proxmox.com>
5 CommitDate: Thu Feb 2 11:22:35 2017 +0100
6
7 Revert "Support systemd socket activation"
8
9 unneeded extra build dep
10
11 diff --git a/CMakeLists.txt b/CMakeLists.txt
12 index 9424d8d..4c56635 100644
13 --- a/CMakeLists.txt
14 +++ b/CMakeLists.txt
15 @@ -36,7 +36,6 @@ find_package(GnuTLS)
16 find_package(Threads)
17 find_package(X11)
18 find_package(OpenSSL)
19 -find_package(PkgConfig)
20 find_library(LIBGCRYPT_LIBRARIES gcrypt)
21
22 # Check whether the version of libjpeg we found was libjpeg-turbo and print a
23 @@ -103,17 +102,6 @@ if(PNG_FOUND)
24 endif(PNG_FOUND)
25 option(LIBVNCSERVER_ALLOW24BPP "Allow 24 bpp" ON)
26
27 -pkg_check_modules(SYSTEMD "libsystemd")
28 -if(SYSTEMD_FOUND)
29 - option(LIBVNCSERVER_WITH_SYSTEMD "Build with systemd socket activation support" ON)
30 -endif(SYSTEMD_FOUND)
31 -
32 -if(LIBVNCSERVER_WITH_SYSTEMD)
33 - add_definitions(-DLIBVNCSERVER_WITH_SYSTEMD)
34 - include_directories(${SYSTEMD_INCLUDE_DIRS})
35 - set(ADDITIONAL_LIBS ${ADDITIONAL_LIBS} ${SYSTEMD_LIBRARIES})
36 -endif(LIBVNCSERVER_WITH_SYSTEMD)
37 -
38 if(GNUTLS_FOUND)
39 set(LIBVNCSERVER_WITH_CLIENT_TLS 1)
40 option(LIBVNCSERVER_WITH_WEBSOCKETS "Build with websockets support (gnutls)" ON)
41 diff --git a/configure.ac b/configure.ac
42 index f13edb4..3f4b29a 100644
43 --- a/configure.ac
44 +++ b/configure.ac
45 @@ -68,9 +68,6 @@ if test ! -z "$with_ffmpeg"; then
46 fi
47 AM_CONDITIONAL(HAVE_MP3LAME, test "$HAVE_MP3LAME" = "true")
48
49 -PKG_CHECK_MODULES([LIBSYSTEMD], [libsystemd], [with_systemd=1], [with_systemd=0])
50 -AM_CONDITIONAL([WITH_SYSTEMD], [test $with_systemd -eq 1])
51 -
52 # Seem to need this dummy here to induce the 'checking for egrep... grep -E', etc.
53 # before it seemed to be inside the with_jpeg conditional.
54 AC_CHECK_HEADER(thenonexistentheader.h, HAVE_THENONEXISTENTHEADER_H="true")
55 diff --git a/libvncserver/Makefile.am b/libvncserver/Makefile.am
56 index e25784b..2f23e31 100644
57 --- a/libvncserver/Makefile.am
58 +++ b/libvncserver/Makefile.am
59 @@ -59,12 +59,6 @@ LIB_SRCS = main.c rfbserver.c rfbregion.c auth.c sockets.c $(WEBSOCKETSSRCS) \
60 libvncserver_la_SOURCES=$(LIB_SRCS)
61 libvncserver_la_LIBADD=$(WEBSOCKETSSSLLIBS)
62
63 -if WITH_SYSTEMD
64 -AM_CPPFLAGS += -DLIBVNCSERVER_WITH_SYSTEMD
65 -libvncserver_la_CFLAGS = $(LIBSYSTEMD_CFLAGS)
66 -libvncserver_la_LIBADD += $(LIBSYSTEMD_LIBS)
67 -endif
68 -
69 lib_LTLIBRARIES=libvncserver.la
70 libvncserver_la_LDFLAGS = -version-info 1:0:0
71
72 diff --git a/libvncserver/sockets.c b/libvncserver/sockets.c
73 index bbc3d90..6467b1c 100644
74 --- a/libvncserver/sockets.c
75 +++ b/libvncserver/sockets.c
76 @@ -77,10 +77,6 @@
77 #include "rfbssl.h"
78 #endif
79
80 -#ifdef LIBVNCSERVER_WITH_SYSTEMD
81 -#include <systemd/sd-daemon.h>
82 -#endif
83 -
84 #if defined(__linux__) && defined(NEED_TIMEVAL)
85 struct timeval
86 {
87 @@ -126,54 +122,6 @@ int deny_severity=LOG_WARNING;
88 int rfbMaxClientWait = 20000; /* time (ms) after which we decide client has
89 gone away - needed to stop us hanging */
90
91 -static rfbBool
92 -rfbNewConnectionFromSock(rfbScreenInfoPtr rfbScreen, int sock)
93 -{
94 - const int one = 1;
95 -#ifdef LIBVNCSERVER_IPv6
96 - struct sockaddr_storage addr;
97 -#else
98 - struct sockaddr_in addr;
99 -#endif
100 - socklen_t addrlen = sizeof(addr);
101 -
102 - getpeername(sock, (struct sockaddr *)&addr, &addrlen);
103 -
104 - if(!rfbSetNonBlocking(sock)) {
105 - rfbLogPerror("rfbCheckFds: setnonblock");
106 - closesocket(sock);
107 - return FALSE;
108 - }
109 -
110 - if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY,
111 - (char *)&one, sizeof(one)) < 0) {
112 - rfbLogPerror("rfbCheckFds: setsockopt failed: can't set TCP_NODELAY flag, non TCP socket?");
113 - }
114 -
115 -#ifdef USE_LIBWRAP
116 - if(!hosts_ctl("vnc",STRING_UNKNOWN,inet_ntoa(addr.sin_addr),
117 - STRING_UNKNOWN)) {
118 - rfbLog("Rejected connection from client %s\n",
119 - inet_ntoa(addr.sin_addr));
120 - closesocket(sock);
121 - return FALSE;
122 - }
123 -#endif
124 -
125 -#ifdef LIBVNCSERVER_IPv6
126 - char host[1024];
127 - if(getnameinfo((struct sockaddr*)&addr, addrlen, host, sizeof(host), NULL, 0, NI_NUMERICHOST) != 0) {
128 - rfbLogPerror("rfbProcessNewConnection: error in getnameinfo");
129 - }
130 - rfbLog("Got connection from client %s\n", host);
131 -#else
132 - rfbLog("Got connection from client %s\n", inet_ntoa(addr.sin_addr));
133 -#endif
134 -
135 - rfbNewClient(rfbScreen,sock);
136 - return TRUE;
137 -}
138 -
139 /*
140 * rfbInitSockets sets up the TCP and UDP sockets to listen for RFB
141 * connections. It does nothing if called again.
142 @@ -190,20 +138,6 @@ rfbInitSockets(rfbScreenInfoPtr rfbScreen)
143
144 rfbScreen->socketState = RFB_SOCKET_READY;
145
146 -#ifdef LIBVNCSERVER_WITH_SYSTEMD
147 - if (sd_listen_fds(0) == 1)
148 - {
149 - int sock = SD_LISTEN_FDS_START + 0;
150 - if (sd_is_socket(sock, AF_UNSPEC, 0, 0))
151 - rfbNewConnectionFromSock(rfbScreen, sock);
152 - else if (sd_is_socket(sock, AF_UNSPEC, 0, 1))
153 - rfbProcessNewConnection(rfbScreen);
154 - return;
155 - }
156 - else
157 - rfbLog("Unable to establish connection with systemd socket\n");
158 -#endif
159 -
160 if (rfbScreen->inetdSock != -1) {
161 const int one = 1;
162
163 @@ -479,7 +413,14 @@ rfbCheckFds(rfbScreenInfoPtr rfbScreen,long usec)
164 rfbBool
165 rfbProcessNewConnection(rfbScreenInfoPtr rfbScreen)
166 {
167 + const int one = 1;
168 int sock = -1;
169 +#ifdef LIBVNCSERVER_IPv6
170 + struct sockaddr_storage addr;
171 +#else
172 + struct sockaddr_in addr;
173 +#endif
174 + socklen_t addrlen = sizeof(addr);
175 fd_set listen_fds;
176 int chosen_listen_sock = -1;
177
178 @@ -500,12 +441,47 @@ rfbProcessNewConnection(rfbScreenInfoPtr rfbScreen)
179 if (rfbScreen->listen6Sock >= 0 && FD_ISSET(rfbScreen->listen6Sock, &listen_fds))
180 chosen_listen_sock = rfbScreen->listen6Sock;
181
182 - if ((sock = accept(chosen_listen_sock, NULL, NULL)) < 0) {
183 + if ((sock = accept(chosen_listen_sock,
184 + (struct sockaddr *)&addr, &addrlen)) < 0) {
185 rfbLogPerror("rfbCheckFds: accept");
186 return FALSE;
187 }
188
189 - return rfbNewConnectionFromSock(rfbScreen, sock);
190 + if(!rfbSetNonBlocking(sock)) {
191 + closesocket(sock);
192 + return FALSE;
193 + }
194 +
195 + if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY,
196 + (char *)&one, sizeof(one)) < 0) {
197 + rfbLogPerror("rfbCheckFds: setsockopt failed: can't set TCP_NODELAY flag, non TCP socket?");
198 + }
199 +
200 +#ifdef USE_LIBWRAP
201 + if(!hosts_ctl("vnc",STRING_UNKNOWN,inet_ntoa(addr.sin_addr),
202 + STRING_UNKNOWN)) {
203 + rfbLog("Rejected connection from client %s\n",
204 + inet_ntoa(addr.sin_addr));
205 + closesocket(sock);
206 + return FALSE;
207 + }
208 +#endif
209 +
210 +#ifdef LIBVNCSERVER_IPv6
211 + {
212 + char host[1024];
213 + if(getnameinfo((struct sockaddr*)&addr, addrlen, host, sizeof(host), NULL, 0, NI_NUMERICHOST) != 0) {
214 + rfbLogPerror("rfbProcessNewConnection: error in getnameinfo");
215 + }
216 + rfbLog("Got connection from client %s\n", host);
217 + }
218 +#else
219 + rfbLog("Got connection from client %s\n", inet_ntoa(addr.sin_addr));
220 +#endif
221 +
222 + rfbNewClient(rfbScreen,sock);
223 +
224 + return TRUE;
225 }
226
227