9738
|
1 |
diff -urN -x'*~' gnome-session-2.18.0/gnome-session/Makefile.am ../SUNWtgnome-xagent-2.18.0.hacked/gnome-session-2.18.0/gnome-session/Makefile.am
|
|
2 |
--- gnome-session-2.18.0/gnome-session/Makefile.am 2007-04-12 17:59:16.954363000 +0000
|
|
3 |
+++ ../SUNWtgnome-xagent-2.18.0.hacked/gnome-session-2.18.0/gnome-session/Makefile.am 2007-04-12 18:04:53.249935000 +0000
|
9397
|
4 |
@@ -4,6 +4,7 @@
|
|
5 |
|
|
6 |
INCLUDES = \
|
|
7 |
$(GNOME_SESSION_CFLAGS) \
|
|
8 |
+ $(LIBWNCK_CFLAGS) \
|
|
9 |
$(STANDARD_PROPERTIES_CFLAGS) \
|
|
10 |
$(WARN_CFLAGS) \
|
|
11 |
$(DISABLE_DEPRECATED_CFLAGS) \
|
9738
|
12 |
@@ -33,6 +34,14 @@
|
9397
|
13 |
gnome_session_properties_LDADD = $(GNOME_SESSION_LIBS)
|
|
14 |
splash_test_LDADD = $(X_LIBS) $(GNOME_SESSION_LIBS)
|
|
15 |
logout_test_LDADD = $(X_LIBS) $(GNOME_SESSION_LIBS)
|
|
16 |
+if XTSOL_DEFINED
|
|
17 |
+tsoljds_xagent_LDADD = $(XTSOL_LIBS) $(GNOME_SESSION_LIBS)
|
|
18 |
+endif
|
|
19 |
+
|
|
20 |
+if XTSOL_DEFINED
|
|
21 |
+TSOLJDS_bin = \
|
|
22 |
+ tsoljds-xagent
|
|
23 |
+endif
|
|
24 |
|
|
25 |
if SESSION
|
|
26 |
noinst_PROGRAMS = \
|
9738
|
27 |
@@ -43,7 +52,8 @@
|
9397
|
28 |
gnome-session \
|
|
29 |
gnome-session-save \
|
|
30 |
gnome-session-remove \
|
|
31 |
- gnome-session-properties
|
|
32 |
+ gnome-session-properties\
|
|
33 |
+ $(TSOLJDS_bin)
|
|
34 |
endif
|
|
35 |
|
|
36 |
splash_test_SOURCES = \
|
10015
|
37 |
@@ -131,6 +131,45 @@
|
|
38 |
endif
|
10014
|
39 |
util.h
|
9397
|
40 |
|
|
41 |
+if XTSOL_DEFINED
|
|
42 |
+tsoljds_xagent_SOURCES = \
|
|
43 |
+ tsoljds-xagent.c \
|
|
44 |
+ save.c \
|
|
45 |
+ save.h \
|
|
46 |
+ manager.c \
|
|
47 |
+ manager.h \
|
|
48 |
+ remote.c \
|
|
49 |
+ remote.h \
|
|
50 |
+ ice.c \
|
|
51 |
+ ice.h \
|
9738
|
52 |
+ gsm-keyring.c \
|
|
53 |
+ gsm-keyring.h \
|
9397
|
54 |
+ splash-widget.c \
|
|
55 |
+ splash-widget.h \
|
|
56 |
+ logout.c \
|
|
57 |
+ logout.h \
|
|
58 |
+ prop.c \
|
|
59 |
+ command.c \
|
|
60 |
+ command.h \
|
|
61 |
+ gsm-protocol.c \
|
|
62 |
+ gsm-protocol.h \
|
|
63 |
+ gsm-typebuiltins.c \
|
|
64 |
+ gsm-typebuiltins.h \
|
|
65 |
+ headers.h \
|
|
66 |
+ util.c \
|
|
67 |
+ util.h \
|
|
68 |
+ gsm-multiscreen.c \
|
|
69 |
+ gsm-multiscreen.h \
|
|
70 |
+ gdm-logout-action.c \
|
|
71 |
+ gdm-logout-action.h \
|
10015
|
72 |
+ gsm-autostart.c \
|
|
73 |
+ gsm-autostart.h \
|
|
74 |
+ gsm-keyfile.c \
|
|
75 |
+ gsm-keyfile.h \
|
9397
|
76 |
+ tsoljds-misc.c \
|
|
77 |
+ tsoljds-misc.h
|
|
78 |
+endif
|
|
79 |
+
|
|
80 |
gnome_session_save_SOURCES = \
|
10014
|
81 |
gnome-session-save.c \
|
9397
|
82 |
gsm-typebuiltins.c \
|
9738
|
83 |
diff -urN -x'*~' gnome-session-2.18.0/gnome-session/tsoljds-xagent.c ../SUNWtgnome-xagent-2.18.0.hacked/gnome-session-2.18.0/gnome-session/tsoljds-xagent.c
|
|
84 |
--- gnome-session-2.18.0/gnome-session/tsoljds-xagent.c 1970-01-01 00:00:00.000000000 +0000
|
|
85 |
+++ ../SUNWtgnome-xagent-2.18.0.hacked/gnome-session-2.18.0/gnome-session/tsoljds-xagent.c 2007-04-12 18:03:20.518279000 +0000
|
|
86 |
@@ -0,0 +1,507 @@
|
9397
|
87 |
+#include <config.h>
|
|
88 |
+#ifdef HAVE_XTSOL
|
|
89 |
+
|
|
90 |
+#include <glib.h>
|
|
91 |
+#include <gtk/gtk.h>
|
|
92 |
+#include <gdk/gdkx.h>
|
|
93 |
+
|
|
94 |
+#include <sys/types.h>
|
|
95 |
+#include <sys/stat.h>
|
|
96 |
+#include <unistd.h>
|
|
97 |
+#include <stdlib.h>
|
|
98 |
+#include <pwd.h>
|
|
99 |
+
|
|
100 |
+#include <X11/Xlib.h>
|
|
101 |
+#include <X11/Xutil.h>
|
|
102 |
+#include <X11/Xos.h>
|
|
103 |
+#include <X11/Xatom.h>
|
|
104 |
+
|
|
105 |
+#include <stdio.h>
|
|
106 |
+#include <fcntl.h>
|
|
107 |
+#include <signal.h>
|
|
108 |
+#include <zone.h>
|
|
109 |
+
|
|
110 |
+#include <priv.h>
|
|
111 |
+#include <sys/tsol/priv.h>
|
|
112 |
+#include <tsol/label.h>
|
|
113 |
+#include <sys/tsol/label.h>
|
|
114 |
+#include <sys/tsol/label_macro.h>
|
|
115 |
+#include <X11/extensions/Xtsol.h>
|
|
116 |
+#include <prof_attr.h>
|
|
117 |
+#include <secdb.h>
|
|
118 |
+#include <libgnome/gnome-config.h>
|
|
119 |
+#include <libgnome/gnome-program.h>
|
|
120 |
+#include <libgnomeui/gnome-ui-init.h>
|
|
121 |
+#include <libgnomeui/gnome-client.h>
|
|
122 |
+
|
|
123 |
+#include "ice.h"
|
|
124 |
+#include "headers.h"
|
|
125 |
+#include "save.h"
|
9738
|
126 |
+#include "gsm-keyring.h"
|
9397
|
127 |
+
|
|
128 |
+gint purge_delay = 30000;
|
|
129 |
+gint warn_delay = 30000;
|
|
130 |
+gint suicide_delay = 10000;
|
|
131 |
+gboolean failsafe = FALSE;
|
|
132 |
+gboolean autosave = FALSE;
|
|
133 |
+gboolean save_selected = FALSE;
|
|
134 |
+gboolean logout_prompt = TRUE;
|
|
135 |
+gboolean session_save = FALSE;
|
|
136 |
+gchar *session_name = NULL;
|
|
137 |
+gboolean managesession = TRUE;
|
|
138 |
+gboolean trusted_session = FALSE;
|
|
139 |
+gboolean default_session = FALSE;
|
|
140 |
+
|
|
141 |
+typedef struct tcb_component {
|
|
142 |
+ char *name;
|
|
143 |
+} tcb_component;
|
|
144 |
+
|
|
145 |
+const tcb_component tcb[] = {
|
|
146 |
+ {"metacity" },
|
|
147 |
+ {"gnome-volcheck" }, /* This is not a tcb component, but it is not zone aware so remove */
|
|
148 |
+ {"gnome-panel"},
|
|
149 |
+ {"gnome-smproxy"},
|
|
150 |
+ {"gnome-wm"},
|
|
151 |
+ {"tsoljdsselmgr"},
|
|
152 |
+ {"tsoljds-tstripe"}
|
|
153 |
+};
|
|
154 |
+
|
|
155 |
+
|
|
156 |
+#define _XA_MOTIF_WINDOW "_MOTIF_DRAG_WINDOW"
|
|
157 |
+#define _XA_MOTIF_PROXY_WINDOW "_MOTIF_DRAG_PROXY_WINDOW"
|
|
158 |
+#define TSOLJDS_MIGRATION_SCRIPT "/usr/dt/config/tsoljds-migration"
|
|
159 |
+
|
|
160 |
+static void trim_tcb (Session* session);
|
|
161 |
+static Window GetPropertyWindow(Display *dpy, Window in_win, Atom atom);
|
|
162 |
+static Window CreateMotifDragWindow(Display *dpy);
|
|
163 |
+static void WriteMotifDragWindow(Display *dpy, Window *motifWindow);
|
|
164 |
+static void SetUpPolyprop (Display *x_dpy);
|
|
165 |
+static gboolean setPrivForTsol (void);
|
|
166 |
+int TsolErrorHandler(Display *dpy, XErrorEvent *error);
|
|
167 |
+
|
|
168 |
+struct passwd *pwent = NULL; /* Password entry for this user */
|
|
169 |
+int pipe_fd; /* Pipe read from dtwm */
|
|
170 |
+
|
|
171 |
+void trim_tcb (Session* session)
|
|
172 |
+{
|
|
173 |
+ GSList* list;
|
|
174 |
+ int i;
|
|
175 |
+ gboolean found = FALSE;
|
|
176 |
+ list = session->client_list;
|
|
177 |
+
|
|
178 |
+ for (; list; list = list->next)
|
|
179 |
+ {
|
|
180 |
+ Client* client = (Client*)list->data;
|
|
181 |
+ GSList* prop_list = client->properties;
|
|
182 |
+
|
|
183 |
+ found = FALSE;
|
|
184 |
+
|
|
185 |
+ for (; prop_list; prop_list = prop_list->next) {
|
|
186 |
+ SmProp* prop = (SmProp*)prop_list->data;
|
|
187 |
+
|
|
188 |
+ /* Go through the TCB list, if it is found, remove it */
|
|
189 |
+ for (i = 0; i < G_N_ELEMENTS(tcb); i++) {
|
|
190 |
+ if (strcmp (prop->vals->value, tcb[i].name)==0) {
|
|
191 |
+ REMOVE ( client->properties, prop);
|
|
192 |
+ found = TRUE;
|
|
193 |
+ break;
|
|
194 |
+ }
|
|
195 |
+ }
|
|
196 |
+ /* Since the prop for the client has been removed, go on to next */
|
|
197 |
+ if (found) break;
|
|
198 |
+ }
|
|
199 |
+ }
|
|
200 |
+}
|
|
201 |
+
|
|
202 |
+char *get_desktop_window_atom_name (void)
|
|
203 |
+{
|
|
204 |
+ static char *atom_name = NULL;
|
|
205 |
+ uid_t uid;
|
|
206 |
+ zoneid_t zid;
|
|
207 |
+
|
|
208 |
+ if (!atom_name) {
|
|
209 |
+ uid = geteuid ();
|
|
210 |
+ zid = getzoneid ();
|
|
211 |
+ atom_name = g_strdup_printf ("NAUTILUS_DESKTOP_WINDOW_%d_%d",
|
|
212 |
+ uid, zid);
|
|
213 |
+ }
|
|
214 |
+ return atom_name;
|
|
215 |
+}
|
|
216 |
+
|
|
217 |
+int
|
|
218 |
+get_screen_number (char *exec_cmd)
|
|
219 |
+{
|
|
220 |
+ gchar **token;
|
|
221 |
+ int scrnum;
|
|
222 |
+
|
|
223 |
+ token = g_strsplit (exec_cmd, ":", 2);
|
|
224 |
+ if (token[0]) {
|
|
225 |
+ scrnum = atoi (token[0]);
|
|
226 |
+ return scrnum;
|
|
227 |
+ }
|
|
228 |
+ else return 0;
|
|
229 |
+}
|
|
230 |
+
|
|
231 |
+gchar *
|
|
232 |
+get_real_command (char *exec_cmd)
|
|
233 |
+{
|
|
234 |
+ gchar **token;
|
|
235 |
+
|
|
236 |
+ token = g_strsplit (exec_cmd, ":", 2);
|
|
237 |
+ if (token[1])
|
|
238 |
+ return (token[1]);
|
|
239 |
+ else return exec_cmd;
|
|
240 |
+}
|
|
241 |
+
|
|
242 |
+static char * cond( GIOCondition condition)
|
|
243 |
+{
|
|
244 |
+ char value[50];
|
|
245 |
+
|
|
246 |
+ switch (condition)
|
|
247 |
+ {
|
|
248 |
+ case 1: strcpy (value, "GLIB_SYSDEF_POLLIN");
|
|
249 |
+ break;
|
|
250 |
+ case 2: strcpy (value, "GLIB_SYSDEF_POLLPRI");
|
|
251 |
+ break;
|
|
252 |
+ case 4: strcpy (value, "GLIB_SYSDEF_POLLOUT");
|
|
253 |
+ break;
|
|
254 |
+ case 8: strcpy (value, "GLIB_SYSDEF_POLLERR");
|
|
255 |
+ break;
|
|
256 |
+ case 16: strcpy (value, "GLIB_SYSDEF_POLLHUP");
|
|
257 |
+ break;
|
|
258 |
+ case 32: strcpy (value, "GLIB_SYSDEF_POLLNVAL");
|
|
259 |
+ break;
|
|
260 |
+ default: strcpy (value, "Unknown condition");
|
|
261 |
+ break;
|
|
262 |
+ }
|
|
263 |
+
|
|
264 |
+ return(value);
|
|
265 |
+}
|
|
266 |
+
|
|
267 |
+static void
|
|
268 |
+so_long_pipe (gpointer data)
|
|
269 |
+{
|
|
270 |
+ /*
|
|
271 |
+ * The pipe is bust which probably means the stripe
|
|
272 |
+ * has died. So there's nothing to do but die.
|
|
273 |
+ */
|
|
274 |
+ exit (2);
|
|
275 |
+}
|
|
276 |
+
|
|
277 |
+static gboolean handle_pipe_input (GIOChannel *source,
|
|
278 |
+ GIOCondition condition,
|
|
279 |
+ gpointer data)
|
|
280 |
+{
|
|
281 |
+#define BUFSIZE 1024
|
|
282 |
+ gsize byteread, pos;
|
|
283 |
+ gchar *str;
|
|
284 |
+ GError *error = NULL;
|
|
285 |
+ GIOStatus status=0;
|
|
286 |
+ int screen_num;
|
|
287 |
+ gchar *real_cmd;
|
|
288 |
+
|
|
289 |
+ if (condition & G_IO_ERR)
|
|
290 |
+ return FALSE;
|
|
291 |
+
|
|
292 |
+ if (condition & G_IO_HUP)
|
|
293 |
+ /* Seems like another good cue to get out of here */
|
|
294 |
+ return FALSE;
|
|
295 |
+
|
|
296 |
+ if (condition & G_IO_IN) {
|
|
297 |
+ status = g_io_channel_read_line (source, &str, &byteread, &pos, &error);
|
|
298 |
+
|
|
299 |
+ switch (status)
|
|
300 |
+ {
|
|
301 |
+ case G_IO_STATUS_NORMAL: str[pos] = '\0';
|
|
302 |
+ screen_num = get_screen_number (str);
|
|
303 |
+ real_cmd = get_real_command (str);
|
|
304 |
+ if ((strncmp (real_cmd, "save_yourself", 13) == 0) && (managesession == TRUE))
|
|
305 |
+ {
|
|
306 |
+ write_session ();
|
|
307 |
+ }
|
|
308 |
+ else {
|
|
309 |
+ GdkDisplay *gdk_dpy;
|
|
310 |
+ gdk_dpy = gdk_display_get_default ();
|
|
311 |
+ gdk_spawn_command_line_on_screen (gdk_display_get_screen (gdk_dpy, screen_num), real_cmd, &error);
|
|
312 |
+ }
|
|
313 |
+ return TRUE;
|
|
314 |
+
|
|
315 |
+ case G_IO_STATUS_AGAIN: fprintf (stderr, "G_IO_STATUS_AGAIN\n");
|
|
316 |
+ return FALSE;
|
|
317 |
+
|
|
318 |
+ case G_IO_STATUS_EOF:
|
|
319 |
+ fprintf (stderr, "G_IO_STATUS_EOF\n");
|
|
320 |
+ sleep(1);
|
|
321 |
+ return FALSE;
|
|
322 |
+
|
|
323 |
+ case G_IO_STATUS_ERROR:
|
|
324 |
+ fprintf (stderr, "G_IO_STATUS_ERROR: %s\n", error->message);
|
|
325 |
+ return FALSE;
|
|
326 |
+
|
|
327 |
+ default: g_assert_not_reached ();
|
|
328 |
+ return FALSE;
|
|
329 |
+ }
|
|
330 |
+ }
|
|
331 |
+}
|
|
332 |
+
|
|
333 |
+
|
|
334 |
+int main (int argc, char *argv[])
|
|
335 |
+{
|
|
336 |
+ GtkWidget *window, **windows;
|
|
337 |
+
|
|
338 |
+ GdkDisplay *gdk_dpy;
|
|
339 |
+ Display *x_dpy;
|
|
340 |
+ Window win;
|
|
341 |
+ gchar *displayname = NULL;
|
|
342 |
+ gint screen_count;
|
|
343 |
+ GdkScreen **screen_list;
|
|
344 |
+ gint i;
|
|
345 |
+ long myid;
|
|
346 |
+ GIOChannel *channel;
|
|
347 |
+ guint result;
|
|
348 |
+ Session *session;
|
|
349 |
+ static gboolean first_startup= TRUE;
|
|
350 |
+
|
|
351 |
+ /* redirect stdout and stderr to /dev/null */
|
|
352 |
+ int fd = open ("/dev/null", O_RDWR);
|
|
353 |
+ dup2 (fd, 1);
|
|
354 |
+ dup2 (fd, 2);
|
|
355 |
+
|
|
356 |
+ /* See if session management is needed */
|
|
357 |
+ if ((argc > 1) && !(strcmp (argv[1], "--nosession")))
|
|
358 |
+ managesession = FALSE;
|
|
359 |
+
|
|
360 |
+ if ((argc > 1) && !(strcmp (argv[1], "--defaultsession")))
|
|
361 |
+ default_session = TRUE;
|
|
362 |
+
|
9738
|
363 |
+ gsm_keyring_daemon_start ();
|
|
364 |
+
|
9397
|
365 |
+ /* This is required some that the ~/.gnome2 are setup */
|
|
366 |
+ if (managesession)
|
|
367 |
+ gnome_program_init ("tsoljds-xagent", "0.1", LIBGNOMEUI_MODULE,
|
|
368 |
+ argc, argv,
|
|
369 |
+ NULL);
|
|
370 |
+
|
|
371 |
+ /* Ignore all child deaths */
|
|
372 |
+ signal(SIGCHLD, SIG_IGN);
|
|
373 |
+
|
|
374 |
+ /* Get password entry to use the pw_shell entry later */
|
|
375 |
+ pwent = getpwuid(getuid());
|
|
376 |
+
|
|
377 |
+ if ((pipe_fd = dup(fileno(stdin))) != -1) {
|
|
378 |
+ int dummy_fd;
|
|
379 |
+
|
|
380 |
+ close(fileno(stdin));
|
|
381 |
+ /* Open /dev/null as stdin */
|
|
382 |
+ dummy_fd = open("/dev/null", O_RDONLY);
|
|
383 |
+ /* Set close_on_exec */
|
|
384 |
+ fcntl(pipe_fd, F_SETFD, 1);
|
|
385 |
+ } else
|
|
386 |
+ pipe_fd = fileno(stdin);
|
|
387 |
+
|
|
388 |
+ gtk_init (&argc, &argv);
|
|
389 |
+
|
|
390 |
+ /* Get GdkDisplay and number of screens */
|
|
391 |
+ gdk_dpy = gdk_display_get_default ();
|
|
392 |
+ x_dpy = GDK_DISPLAY_XDISPLAY (gdk_dpy);
|
|
393 |
+ screen_count = gdk_display_get_n_screens (gdk_dpy);
|
|
394 |
+
|
|
395 |
+ displayname = g_strdup (gdk_display_get_name (gdk_dpy));
|
|
396 |
+
|
|
397 |
+ if (screen_count <= 0) {
|
|
398 |
+ screen_count = 1; /* at least one screen */
|
|
399 |
+ }
|
|
400 |
+
|
|
401 |
+ /* allocation memory for the number of screens */
|
|
402 |
+ screen_list = g_new (GdkScreen *, screen_count);
|
|
403 |
+ windows = g_new (GtkWidget *, screen_count);
|
|
404 |
+
|
|
405 |
+ for (i = 0; i < screen_count; i++) {
|
|
406 |
+ windows[i] = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
|
407 |
+ gtk_widget_realize (windows[i]);
|
|
408 |
+ }
|
|
409 |
+
|
|
410 |
+ /* Trap the Xserver error as this is an essential hack to make the program
|
|
411 |
+ * to start up in the local zone.
|
|
412 |
+ */
|
|
413 |
+ XSetErrorHandler(TsolErrorHandler);
|
|
414 |
+
|
|
415 |
+ /* Set to Polyinstantiated properties for selection manager */
|
|
416 |
+ SetUpPolyprop (x_dpy);
|
|
417 |
+
|
|
418 |
+ if (managesession == TRUE) {
|
|
419 |
+ /*
|
|
420 |
+ * This script is needed to enable input method per zones and roles.
|
|
421 |
+ * start_session () is shared between gnome-session and tsoljds-xagent
|
|
422 |
+ * so putting this out of start_session () here.
|
|
423 |
+ */
|
|
424 |
+ if (g_file_test (TSOLJDS_MIGRATION_SCRIPT, G_FILE_TEST_IS_EXECUTABLE)) {
|
|
425 |
+ system (TSOLJDS_MIGRATION_SCRIPT);
|
|
426 |
+ }
|
|
427 |
+
|
|
428 |
+ initialize_ice ();
|
|
429 |
+
|
|
430 |
+ if (session_name == NULL &&
|
|
431 |
+ g_getenv ("GDM_GNOME_SESSION") != NULL) {
|
|
432 |
+ session_name = g_strdup (g_getenv ("GDM_GNOME_SESSION"));
|
|
433 |
+ }
|
|
434 |
+
|
|
435 |
+ /* If the session name hasn't been specified from the command line */
|
|
436 |
+ if(session_name == NULL) {
|
|
437 |
+ /* If there is no key specified, fall back to the default session */
|
|
438 |
+ session_name = gnome_config_get_string (CURRENT_SESSION_KEY "=" DEFAULT_SESSION);
|
|
439 |
+ /* if key was specified but is blank, just use the default */
|
|
440 |
+ if (!*session_name) {
|
|
441 |
+ g_free (session_name);
|
|
442 |
+ session_name = g_strdup (DEFAULT_SESSION);
|
|
443 |
+ }
|
|
444 |
+ }
|
|
445 |
+
|
|
446 |
+ session = read_session (session_name);
|
|
447 |
+ trim_tcb (session);
|
|
448 |
+ start_session (session);
|
|
449 |
+ }
|
|
450 |
+
|
|
451 |
+ if (first_startup) {
|
|
452 |
+ GError *err=NULL;
|
|
453 |
+ /* FIXME: need to get the screen info some how, but default to 0 for now */
|
|
454 |
+ gdk_spawn_command_line_on_screen (gdk_display_get_screen (gdk_dpy, 0), g_getenv("LABEL_EXEC_COMMAND"), &err);
|
|
455 |
+
|
|
456 |
+ if (err)
|
|
457 |
+ g_print ("error is %s\n", err->message);
|
|
458 |
+
|
|
459 |
+ first_startup = FALSE;
|
|
460 |
+ }
|
|
461 |
+
|
|
462 |
+ channel = g_io_channel_unix_new (pipe_fd);
|
|
463 |
+ result = g_io_add_watch_full (channel, G_PRIORITY_HIGH,
|
|
464 |
+ G_IO_IN | G_IO_PRI | G_IO_ERR | G_IO_HUP,
|
|
465 |
+ (GIOFunc)handle_pipe_input, NULL, so_long_pipe);
|
|
466 |
+ gtk_main ();
|
9738
|
467 |
+
|
|
468 |
+ gsm_keyring_daemon_stop ();
|
9397
|
469 |
+
|
|
470 |
+ return 0;
|
|
471 |
+}
|
|
472 |
+
|
|
473 |
+static void SetUpPolyprop (Display *x_dpy)
|
|
474 |
+{
|
|
475 |
+ /* copy motif_proxy_win from user's clearance to current label */
|
|
476 |
+#define ROOT_UID 0
|
|
477 |
+ XTsolResAttributes resattr;
|
|
478 |
+ Atom ATOM_MOTIF_DRAG_WIN;
|
|
479 |
+ Atom ATOM_MOTIF_PROXY_WIN;
|
|
480 |
+ m_label_t *slabel;
|
|
481 |
+ Window motif_drag_win = None;
|
|
482 |
+ Window proxy_win = None;
|
|
483 |
+ XWindowAttributes wattr;
|
|
484 |
+
|
|
485 |
+ /* Set up to look up the polyprop used by the sel_mgr */
|
|
486 |
+ slabel = blabel_alloc();
|
|
487 |
+ bsllow(slabel);
|
|
488 |
+ resattr.sl = slabel;
|
|
489 |
+ resattr.uid = ROOT_UID;
|
|
490 |
+ XTSOLsetPolyInstInfo(x_dpy, resattr.sl, (uid_t *)(&resattr.uid), True);
|
|
491 |
+ ATOM_MOTIF_DRAG_WIN = XInternAtom(x_dpy, _XA_MOTIF_WINDOW, False);
|
|
492 |
+ ATOM_MOTIF_PROXY_WIN = XInternAtom(x_dpy, _XA_MOTIF_PROXY_WINDOW, False);
|
|
493 |
+ motif_drag_win = GetPropertyWindow(x_dpy, DefaultRootWindow(x_dpy),
|
|
494 |
+ ATOM_MOTIF_DRAG_WIN);
|
|
495 |
+ if (motif_drag_win != None) {
|
|
496 |
+ proxy_win = GetPropertyWindow(x_dpy, motif_drag_win,
|
|
497 |
+ ATOM_MOTIF_PROXY_WIN);
|
|
498 |
+ }
|
|
499 |
+
|
|
500 |
+ /* put back our original polyprop settings */
|
|
501 |
+ getplabel(slabel);
|
|
502 |
+ resattr.uid = getuid();
|
|
503 |
+ XTSOLsetPolyInstInfo(x_dpy, resattr.sl, (uid_t *)(&resattr.uid), False);
|
|
504 |
+ blabel_free(slabel);
|
|
505 |
+
|
|
506 |
+ motif_drag_win = GetPropertyWindow(x_dpy, DefaultRootWindow(x_dpy),
|
|
507 |
+ ATOM_MOTIF_DRAG_WIN);
|
|
508 |
+
|
|
509 |
+ /* Validate motif_drag_win */
|
|
510 |
+ if (XGetWindowAttributes(x_dpy, motif_drag_win, &wattr) == 0) {
|
|
511 |
+ /* if window is invalid, create a new one */
|
|
512 |
+ motif_drag_win = CreateMotifDragWindow(x_dpy);
|
|
513 |
+ }
|
|
514 |
+
|
|
515 |
+ if (motif_drag_win != None) {
|
|
516 |
+ XChangeProperty(x_dpy, motif_drag_win, ATOM_MOTIF_PROXY_WIN,
|
|
517 |
+ XA_WINDOW, 32, PropModeReplace,
|
|
518 |
+ (unsigned char *) &proxy_win, 1);
|
|
519 |
+ }
|
|
520 |
+}
|
|
521 |
+
|
|
522 |
+Window
|
|
523 |
+GetPropertyWindow(Display *dpy, Window in_win, Atom atom)
|
|
524 |
+{
|
|
525 |
+ Atom type;
|
|
526 |
+ int format;
|
|
527 |
+ unsigned long lengthRtn;
|
|
528 |
+ unsigned long bytesafter;
|
|
529 |
+ Window *property = NULL;
|
|
530 |
+ Window win = None;
|
|
531 |
+
|
|
532 |
+ if ((XGetWindowProperty (dpy, in_win, atom, 0L, 1, False, AnyPropertyType,
|
|
533 |
+ &type, &format, &lengthRtn, &bytesafter,
|
|
534 |
+ (unsigned char **) &property) == Success) &&
|
|
535 |
+ (type == XA_WINDOW) && (format == 32) && (lengthRtn == 1)) {
|
|
536 |
+ win = *property;
|
|
537 |
+ }
|
|
538 |
+
|
|
539 |
+ if (property) {
|
|
540 |
+ XFree ((char *)property);
|
|
541 |
+ }
|
|
542 |
+
|
|
543 |
+ return (win);
|
|
544 |
+}
|
|
545 |
+
|
|
546 |
+
|
|
547 |
+static Window
|
|
548 |
+CreateMotifDragWindow(Display *dpy)
|
|
549 |
+{
|
|
550 |
+ XSetWindowAttributes sAttributes;
|
|
551 |
+ Window motifWindow;
|
|
552 |
+
|
|
553 |
+ XSetCloseDownMode (dpy, RetainPermanent);
|
|
554 |
+
|
|
555 |
+ sAttributes.override_redirect = True;
|
|
556 |
+ sAttributes.event_mask = PropertyChangeMask;
|
|
557 |
+ motifWindow = XCreateWindow (dpy, DefaultRootWindow (dpy), -100, -100,
|
|
558 |
+ 10, 10, 0, 0, InputOnly, CopyFromParent,
|
|
559 |
+ (CWOverrideRedirect |CWEventMask),
|
|
560 |
+ &sAttributes);
|
|
561 |
+ XMapWindow (dpy, motifWindow);
|
|
562 |
+ WriteMotifDragWindow (dpy, &motifWindow);
|
|
563 |
+
|
|
564 |
+ return (motifWindow);
|
|
565 |
+}
|
|
566 |
+
|
|
567 |
+static void
|
|
568 |
+WriteMotifDragWindow(Display *dpy, Window *motifWindow)
|
|
569 |
+{
|
|
570 |
+ Atom motifWindowAtom;
|
|
571 |
+
|
|
572 |
+ motifWindowAtom = XInternAtom (dpy, _XA_MOTIF_WINDOW, False);
|
|
573 |
+
|
|
574 |
+ XChangeProperty (dpy, RootWindow (dpy, 0), motifWindowAtom,
|
|
575 |
+ XA_WINDOW, 32, PropModeReplace,
|
|
576 |
+ (unsigned char *) motifWindow, 1);
|
|
577 |
+}
|
|
578 |
+
|
|
579 |
+/*
|
|
580 |
+ * Ignore X protocol errors
|
|
581 |
+ */
|
|
582 |
+int
|
|
583 |
+TsolErrorHandler(Display *dpy, XErrorEvent *error)
|
|
584 |
+{
|
|
585 |
+ char err_msg[132];
|
|
586 |
+
|
|
587 |
+ /* ignore all errors */
|
|
588 |
+
|
|
589 |
+ XGetErrorText(dpy, error->error_code, err_msg, sizeof(err_msg));
|
|
590 |
+
|
|
591 |
+ return 0;
|
|
592 |
+}
|
|
593 |
+#endif
|