1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
|
--- ./nx-X11/programs/Xserver/os/utils.c.X.original 2015-02-13 14:03:44.792440567 +0100
+++ ./nx-X11/programs/Xserver/os/utils.c 2015-02-13 14:03:44.788440645 +0100
@@ -52,6 +52,23 @@
*/
/* $XFree86: xc/programs/Xserver/os/utils.c,v 3.96 2004/01/07 04:16:37 dawes Exp $ */
+/**************************************************************************/
+/* */
+/* Copyright (c) 2001, 2011 NoMachine, http://www.nomachine.com/. */
+/* */
+/* NX-X11, NX protocol compression and NX extensions to this software */
+/* are copyright of NoMachine. Redistribution and use of the present */
+/* software is allowed according to terms specified in the file LICENSE */
+/* which comes in the source distribution. */
+/* */
+/* Check http://www.nomachine.com/licensing.html for applicability. */
+/* */
+/* NX and NoMachine are trademarks of Medialogic S.p.A. */
+/* */
+/* All rights reserved. */
+/* */
+/**************************************************************************/
+
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
@@ -246,6 +263,20 @@
#include <errno.h>
+#ifdef NX_TRANS_SOCKET
+
+#include "NX.h"
+#include "NXvars.h"
+
+#endif
+
+#ifdef NX_TRANS_EXIT
+
+void (*OsVendorStartRedirectErrorFProc)() = NULL;
+void (*OsVendorEndRedirectErrorFProc)() = NULL;
+
+#endif
+
Bool CoreDump;
#ifdef PANORAMIX
@@ -543,6 +574,10 @@
{
int olderrno = errno;
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST)
+ fprintf(stderr, "GiveUp: Called with signal [%d].\n", sig);
+#endif
+
dispatchException |= DE_TERMINATE;
isItTimeToYield = TRUE;
#if defined(SYSV) && defined(X_NOT_POSIX)
@@ -1548,12 +1583,21 @@
#define SMART_SCHEDULE_TIMER ITIMER_REAL
#endif
+#ifdef NX_TRANS_SOCKET
+void
+SmartScheduleStopTimer (void)
+#else
static void
SmartScheduleStopTimer (void)
+#endif
{
#ifdef SMART_SCHEDULE_POSSIBLE
struct itimerval timer;
-
+
+ #ifdef NX_TRANS_TEST
+ fprintf(stderr, "SmartScheduleStopTimer: Stopping timer.\n");
+ #endif
+
timer.it_interval.tv_sec = 0;
timer.it_interval.tv_usec = 0;
timer.it_value.tv_sec = 0;
@@ -1568,7 +1612,21 @@
{
#ifdef SMART_SCHEDULE_POSSIBLE
struct itimerval timer;
-
+
+ #ifdef NX_TRANS_SOCKET
+
+ if (SmartScheduleDisable)
+ {
+ return FALSE;
+ }
+
+ #endif
+
+ #ifdef NX_TRANS_TEST
+ fprintf(stderr, "SmartScheduleStartTimer: Starting timer with [%ld] ms.\n",
+ SmartScheduleInterval);
+ #endif
+
SmartScheduleTimerStopped = FALSE;
timer.it_interval.tv_sec = 0;
timer.it_interval.tv_usec = SmartScheduleInterval * 1000;
@@ -1586,6 +1644,12 @@
int olderrno = errno;
SmartScheduleTime += SmartScheduleInterval;
+
+ #ifdef NX_TRANS_TEST
+ fprintf(stderr, "SmartScheduleTimer: Got timer with time [%ld] ms.\n",
+ SmartScheduleTime);
+ #endif
+
if (SmartScheduleIdle)
{
SmartScheduleStopTimer ();
@@ -1603,6 +1667,10 @@
if (SmartScheduleDisable)
return TRUE;
+ #ifdef NX_TRANS_TEST
+ fprintf(stderr, "SmartScheduleInit: Initializing the smart scheduler.\n");
+ #endif
+
bzero ((char *) &act, sizeof(struct sigaction));
/* Set up the timer signal function */
@@ -1714,6 +1782,11 @@
ErrorF("System: `%s'\n", command);
#endif
+#ifdef NX_TRANS_EXIT
+ if (OsVendorStartRedirectErrorFProc != NULL) {
+ OsVendorStartRedirectErrorFProc();
+ }
+#endif
switch (pid = fork()) {
case -1: /* error */
p = -1;
@@ -1730,6 +1803,11 @@
} while (p == -1 && errno == EINTR);
}
+#ifdef NX_TRANS_EXIT
+ if (OsVendorEndRedirectErrorFProc != NULL) {
+ OsVendorEndRedirectErrorFProc();
+ }
+#endif
#ifdef SIGCHLD
signal(SIGCHLD, csig);
@@ -1765,11 +1843,23 @@
return NULL;
}
+#ifdef NX_TRANS_EXIT
+ if (OsVendorStartRedirectErrorFProc != NULL) {
+ OsVendorStartRedirectErrorFProc();
+ }
+ OsBlockSignals ();
+#endif
switch (pid = fork()) {
case -1: /* error */
close(pdes[0]);
close(pdes[1]);
xfree(cur);
+#ifdef NX_TRANS_EXIT
+ if (OsVendorEndRedirectErrorFProc != NULL) {
+ OsVendorEndRedirectErrorFProc();
+ }
+ OsReleaseSignals ();
+#endif
return NULL;
case 0: /* child */
if (setgid(getgid()) == -1)
@@ -1791,12 +1881,61 @@
}
close(pdes[1]);
}
+
+ #ifdef NX_TRANS_SOCKET
+
+ /*
+ * Check if the child process should not
+ * use the parent's libraries.
+ */
+
+ if (_NXUnsetLibraryPath)
+ {
+ #ifndef __sun
+
+ unsetenv ("LD_LIBRARY_PATH");
+
+ #else
+
+ extern char **environ;
+
+ char **ep = environ;
+
+ ep = environ;
+
+ while (*ep)
+ {
+ if (!strncmp("LD_LIBRARY_PATH=", *ep, strlen("LD_LIBRARY_PATH=")))
+ {
+ break;
+ }
+
+ *ep++;
+ }
+
+ while (*ep)
+ {
+ *ep = *(ep + 1);
+ ep++;
+ }
+
+ #endif
+ }
+
+ #endif
+
+ #ifdef NX_TRANS_EXIT
+ OsReleaseSignals ();
+ #endif
+
execl("/bin/sh", "sh", "-c", command, (char *)NULL);
_exit(127);
}
+#ifndef NX_TRANS_EXIT
/* Avoid EINTR during stdio calls */
OsBlockSignals ();
+#endif
/* parent */
if (*type == 'r') {
@@ -1945,6 +2084,11 @@
/* allow EINTR again */
OsReleaseSignals ();
+#ifdef NX_TRANS_EXIT
+ if (OsVendorEndRedirectErrorFProc != NULL) {
+ OsVendorEndRedirectErrorFProc();
+ }
+#endif
return pid == -1 ? -1 : pstat;
}
|