author | gheet |
Thu, 17 Sep 2009 10:59:21 +0000 | |
changeset 16577 | 3d25f7c9cb60 |
parent 16227 | 215acc7b5592 |
child 22462 | e8b2379726ad |
permissions | -rw-r--r-- |
16577 | 1 |
diff -urN -x '*.orig' gnome-session-2.27.92/gnome-session/Makefile.am ../SUNWtgnome-xagent-2.27.92.hacked/gnome-session-2.27.92/gnome-session/Makefile.am |
2 |
--- gnome-session-2.27.92/gnome-session/Makefile.am 2009-09-17 11:40:52.971520127 +0100 |
|
3 |
+++ ../SUNWtgnome-xagent-2.27.92.hacked/gnome-session-2.27.92/gnome-session/Makefile.am 2009-09-17 11:41:50.458212056 +0100 |
|
4 |
@@ -1,6 +1,6 @@ |
|
5 |
NULL = |
|
6 |
||
7 |
-bin_PROGRAMS = gnome-session |
|
8 |
+bin_PROGRAMS = tsoljds-xagent |
|
9 |
||
10 |
noinst_LTLIBRARIES = libgsmutil.la |
|
11 |
||
12 |
@@ -42,7 +42,7 @@ |
|
13 |
$(DBUS_GLIB_LIBS) \ |
|
14 |
$(NULL) |
|
15 |
||
16 |
-gnome_session_LDADD = \ |
|
17 |
+tsoljds_xagent_LDADD = \ |
|
18 |
libgsmutil.la \ |
|
19 |
$(top_builddir)/egg/libeggdesktopfile.la \ |
|
20 |
$(SM_LIBS) \ |
|
21 |
@@ -55,7 +55,7 @@ |
|
22 |
$(EXECINFO_LIBS) \ |
|
23 |
$(NULL) |
|
24 |
||
25 |
-gnome_session_SOURCES = \ |
|
26 |
+tsoljds_xagent_SOURCES = \ |
|
27 |
gsm-app.h \ |
|
28 |
gsm-app.c \ |
|
29 |
gsm-autostart-app.h \ |
|
30 |
@@ -88,7 +88,7 @@ |
|
31 |
gdm-signal-handler.c \ |
|
32 |
gdm-log.h \ |
|
33 |
gdm-log.c \ |
|
34 |
- main.c \ |
|
35 |
+ xagent.c \ |
|
36 |
gsm-store.h \ |
|
37 |
gsm-store.c \ |
|
38 |
gsm-inhibitor.h \ |
|
39 |
@@ -99,8 +99,6 @@ |
|
40 |
gsm-session-save.h \ |
|
41 |
gsm-xsmp-server.c \ |
|
42 |
gsm-xsmp-server.h \ |
|
43 |
- trusted.h \ |
|
44 |
- trusted.c \ |
|
45 |
$(NULL) |
|
46 |
||
47 |
libgsmutil_la_LIBADD = \ |
|
48 |
diff -urN -x '*.orig' gnome-session-2.27.92/gnome-session/xagent.c ../SUNWtgnome-xagent-2.27.92.hacked/gnome-session-2.27.92/gnome-session/xagent.c |
|
49 |
--- gnome-session-2.27.92/gnome-session/xagent.c 1970-01-01 01:00:00.000000000 +0100 |
|
50 |
+++ ../SUNWtgnome-xagent-2.27.92.hacked/gnome-session-2.27.92/gnome-session/xagent.c 2009-09-17 11:41:50.457672613 +0100 |
|
14405 | 51 |
@@ -0,0 +1,384 @@ |
13200 | 52 |
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- |
53 |
+ * |
|
54 |
+ * Copyright (C) 2006 Novell, Inc. |
|
55 |
+ * Copyright (C) 2008 Red Hat, Inc. |
|
56 |
+ * Copyright (C) 2008 Sun Microsystems, Inc. |
|
12871 | 57 |
+ * |
13200 | 58 |
+ * This program is free software; you can redistribute it and/or |
59 |
+ * modify it under the terms of the GNU General Public License as |
|
60 |
+ * published by the Free Software Foundation; either version 2 of the |
|
61 |
+ * License, or (at your option) any later version. |
|
62 |
+ * |
|
63 |
+ * This program is distributed in the hope that it will be useful, but |
|
64 |
+ * WITHOUT ANY WARRANTY; without even the implied warranty of |
|
65 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
66 |
+ * Lesser General Public License for more details. |
|
67 |
+ * |
|
68 |
+ * You should have received a copy of the GNU General Public License |
|
69 |
+ * along with this program; if not, write to the Free Software |
|
70 |
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
|
71 |
+ * 02111-1307, USA. |
|
12871 | 72 |
+ */ |
73 |
+ |
|
74 |
+#ifdef HAVE_CONFIG_H |
|
9397 | 75 |
+#include <config.h> |
12871 | 76 |
+#endif |
9397 | 77 |
+ |
12871 | 78 |
+#include <libintl.h> |
79 |
+#include <signal.h> |
|
80 |
+#include <stdlib.h> |
|
9397 | 81 |
+ |
12871 | 82 |
+#include <glib/gi18n.h> |
83 |
+#include <glib/goption.h> |
|
84 |
+#include <gdk/gdkx.h> |
|
85 |
+#include <gtk/gtklabel.h> |
|
86 |
+#include <gtk/gtkvbox.h> |
|
87 |
+#include <gtk/gtkprogressbar.h> |
|
13200 | 88 |
+#include <gtk/gtk.h> |
89 |
+ |
|
90 |
+#include <dbus/dbus.h> |
|
91 |
+#include <dbus/dbus-glib.h> |
|
92 |
+#include <dbus/dbus-glib-bindings.h> |
|
93 |
+#include <dbus/dbus-glib-lowlevel.h> |
|
9397 | 94 |
+ |
13200 | 95 |
+#include <unistd.h> |
96 |
+#include <sys/types.h> |
|
97 |
+#include <sys/stat.h> |
|
98 |
+#include <fcntl.h> |
|
99 |
+ |
|
13233 | 100 |
+#include <string.h> |
101 |
+ |
|
13200 | 102 |
+#include "gsm-gconf.h" |
103 |
+#include "gsm-util.h" |
|
104 |
+#include "gsm-manager.h" |
|
105 |
+#include "gsm-xsmp-server.h" |
|
106 |
+#include "gsm-store.h" |
|
107 |
+#include "trusted.h" |
|
12871 | 108 |
+ |
109 |
+#define TSOLJDS_MIGRATION_SCRIPT "/usr/dt/config/tsoljds-migration" |
|
13233 | 110 |
+ |
13200 | 111 |
+#define GSM_DBUS_NAME "org.gnome.SessionManager" |
9397 | 112 |
+ |
13233 | 113 |
+ |
14405 | 114 |
+gboolean defaultsession = FALSE; |
115 |
+gboolean nosession = FALSE; |
|
9397 | 116 |
+ |
12871 | 117 |
+static GOptionEntry entries[] = { |
118 |
+ { "defaultsession", '\0', 0, G_OPTION_ARG_NONE, &defaultsession, |
|
119 |
+ N_("Do not load user-specified applications"), |
|
120 |
+ NULL }, |
|
121 |
+ { "nosession", '\0', 0, G_OPTION_ARG_NONE, &nosession, |
|
122 |
+ N_("Do not startup any applications"), |
|
123 |
+ NULL }, |
|
124 |
+ { NULL, 0, 0, 0, NULL, NULL, NULL } |
|
9397 | 125 |
+}; |
126 |
+ |
|
127 |
+int |
|
12871 | 128 |
+XAgentXErrorHandler (Display *dpy, XErrorEvent *error) |
9397 | 129 |
+{ |
12871 | 130 |
+ char err_msg[132]; |
13200 | 131 |
+ |
12871 | 132 |
+ XGetErrorText (dpy, error->error_code, err_msg, sizeof (err_msg)); |
9397 | 133 |
+ |
12871 | 134 |
+ return 0; |
9397 | 135 |
+} |
136 |
+ |
|
137 |
+static void |
|
138 |
+so_long_pipe (gpointer data) |
|
139 |
+{ |
|
12871 | 140 |
+ /* |
141 |
+ * The pipe is bust which probably means the stripe |
|
142 |
+ * has died. So there's nothing to do but die. |
|
143 |
+ */ |
|
144 |
+ exit (2); |
|
9397 | 145 |
+} |
146 |
+ |
|
13200 | 147 |
+static void |
12871 | 148 |
+parse_exec_string (char *exec, int *screen, char **command) |
149 |
+{ |
|
150 |
+ gchar **tokens = g_strsplit (exec, ":", 2); |
|
151 |
+ |
|
152 |
+ if (tokens[0]) { |
|
153 |
+ *screen = atoi (tokens[0]); |
|
154 |
+ } else { |
|
155 |
+ *screen = 0; |
|
156 |
+ } |
|
157 |
+ |
|
158 |
+ if (tokens[1]) { |
|
159 |
+ *command = g_strdup (tokens[1]); |
|
160 |
+ } else { |
|
161 |
+ *command = g_strdup (exec); |
|
162 |
+ } |
|
163 |
+ |
|
164 |
+ g_strfreev (tokens); |
|
165 |
+ |
|
166 |
+} |
|
167 |
+ |
|
168 |
+static gboolean |
|
169 |
+handle_pipe_input (GIOChannel *source, |
|
170 |
+ GIOCondition condition, |
|
171 |
+ gpointer data) |
|
9397 | 172 |
+{ |
173 |
+#define BUFSIZE 1024 |
|
174 |
+ gsize byteread, pos; |
|
175 |
+ gchar *str; |
|
176 |
+ GError *error = NULL; |
|
177 |
+ GIOStatus status=0; |
|
178 |
+ int screen_num; |
|
179 |
+ gchar *real_cmd; |
|
12871 | 180 |
+ GdkDisplay *gdk_dpy; |
9397 | 181 |
+ |
12871 | 182 |
+ if (condition & G_IO_ERR) return FALSE; |
9397 | 183 |
+ |
12871 | 184 |
+ if (condition & G_IO_HUP) return FALSE; |
9397 | 185 |
+ |
12871 | 186 |
+ if (condition & G_IO_IN) { |
187 |
+ status = g_io_channel_read_line (source, &str, &byteread, &pos, &error); |
|
9397 | 188 |
+ |
189 |
+ switch (status) |
|
12871 | 190 |
+ { |
13200 | 191 |
+ case G_IO_STATUS_NORMAL: |
12871 | 192 |
+ str[pos] = '\0'; |
13200 | 193 |
+ parse_exec_string (str, &screen_num, &real_cmd); |
12871 | 194 |
+ gdk_dpy = gdk_display_get_default (); |
13200 | 195 |
+ gdk_spawn_command_line_on_screen (gdk_display_get_screen (gdk_dpy, |
196 |
+ screen_num), real_cmd, &error); |
|
197 |
+ g_free (real_cmd); |
|
12871 | 198 |
+ return TRUE; |
13200 | 199 |
+ case G_IO_STATUS_AGAIN: |
200 |
+ return FALSE; |
|
9397 | 201 |
+ |
13200 | 202 |
+ case G_IO_STATUS_EOF: |
203 |
+ sleep(1); |
|
204 |
+ return FALSE; |
|
9397 | 205 |
+ |
13200 | 206 |
+ case G_IO_STATUS_ERROR: |
207 |
+ return FALSE; |
|
9397 | 208 |
+ |
13200 | 209 |
+ default: |
210 |
+ g_assert_not_reached (); |
|
211 |
+ return FALSE; |
|
9397 | 212 |
+ } |
213 |
+ } |
|
214 |
+} |
|
215 |
+ |
|
13200 | 216 |
+static void |
217 |
+on_bus_name_lost (DBusGProxy *bus_proxy, |
|
218 |
+ const char *name, |
|
219 |
+ gpointer data) |
|
220 |
+{ |
|
221 |
+ g_warning ("Lost name on bus: %s, exiting", name); |
|
222 |
+ exit (1); |
|
223 |
+} |
|
224 |
+ |
|
225 |
+static gboolean |
|
226 |
+acquire_name_on_proxy (DBusGProxy *bus_proxy, |
|
227 |
+ const char *name) |
|
228 |
+{ |
|
229 |
+ GError *error; |
|
230 |
+ guint result; |
|
231 |
+ gboolean res; |
|
232 |
+ gboolean ret; |
|
233 |
+ |
|
234 |
+ ret = FALSE; |
|
235 |
+ |
|
236 |
+ if (bus_proxy == NULL) { |
|
237 |
+ goto out; |
|
238 |
+ } |
|
239 |
+ |
|
240 |
+ error = NULL; |
|
241 |
+ res = dbus_g_proxy_call (bus_proxy, |
|
242 |
+ "RequestName", |
|
243 |
+ &error, |
|
244 |
+ G_TYPE_STRING, name, |
|
245 |
+ G_TYPE_UINT, 0, |
|
246 |
+ G_TYPE_INVALID, |
|
247 |
+ G_TYPE_UINT, &result, |
|
248 |
+ G_TYPE_INVALID); |
|
249 |
+ if (! res) { |
|
250 |
+ if (error != NULL) { |
|
251 |
+ g_warning ("Failed to acquire %s: %s", name, error->message); |
|
252 |
+ g_error_free (error); |
|
253 |
+ } else { |
|
254 |
+ g_warning ("Failed to acquire %s", name); |
|
255 |
+ } |
|
256 |
+ goto out; |
|
257 |
+ } |
|
258 |
+ |
|
259 |
+ if (result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) { |
|
260 |
+ if (error != NULL) { |
|
261 |
+ g_warning ("Failed to acquire %s: %s", name, error->message); |
|
262 |
+ g_error_free (error); |
|
263 |
+ } else { |
|
264 |
+ g_warning ("Failed to acquire %s", name); |
|
265 |
+ } |
|
266 |
+ goto out; |
|
267 |
+ } |
|
268 |
+ |
|
269 |
+ /* register for name lost */ |
|
270 |
+ dbus_g_proxy_add_signal (bus_proxy, |
|
271 |
+ "NameLost", |
|
272 |
+ G_TYPE_STRING, |
|
273 |
+ G_TYPE_INVALID); |
|
274 |
+ dbus_g_proxy_connect_signal (bus_proxy, |
|
275 |
+ "NameLost", |
|
276 |
+ G_CALLBACK (on_bus_name_lost), |
|
277 |
+ NULL, |
|
278 |
+ NULL); |
|
279 |
+ |
|
280 |
+ |
|
281 |
+ ret = TRUE; |
|
282 |
+ |
|
283 |
+ out: |
|
284 |
+ return ret; |
|
285 |
+} |
|
286 |
+ |
|
287 |
+static gboolean |
|
288 |
+acquire_name (void) |
|
289 |
+{ |
|
290 |
+ DBusGProxy *bus_proxy; |
|
291 |
+ GError *error; |
|
292 |
+ DBusGConnection *connection; |
|
293 |
+ |
|
294 |
+ error = NULL; |
|
295 |
+ connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error); |
|
296 |
+ if (connection == NULL) { |
|
297 |
+ gsm_util_init_error (TRUE, |
|
298 |
+ "Could not connect to session bus: %s", |
|
299 |
+ error->message); |
|
300 |
+ /* not reached */ |
|
301 |
+ } |
|
302 |
+ |
|
303 |
+ bus_proxy = dbus_g_proxy_new_for_name (connection, |
|
304 |
+ DBUS_SERVICE_DBUS, |
|
305 |
+ DBUS_PATH_DBUS, |
|
306 |
+ DBUS_INTERFACE_DBUS); |
|
307 |
+ |
|
308 |
+ if (! acquire_name_on_proxy (bus_proxy, GSM_DBUS_NAME) ) { |
|
309 |
+ gsm_util_init_error (TRUE, |
|
310 |
+ "Could not acquire name on session bus: %s", |
|
311 |
+ error->message); |
|
312 |
+ /* not reached */ |
|
313 |
+ } |
|
314 |
+ |
|
315 |
+ g_object_unref (bus_proxy); |
|
316 |
+ |
|
317 |
+ return TRUE; |
|
318 |
+} |
|
319 |
+ |
|
14405 | 320 |
+static void |
321 |
+xagent_start_dbus (void) { |
|
322 |
+ |
|
323 |
+ gchar *out, *err, *chr; |
|
324 |
+ gint status; |
|
325 |
+ GError *error; |
|
326 |
+ |
|
327 |
+ g_spawn_command_line_sync ("/usr/bin/dbus-launch --exit-with-session", |
|
328 |
+ &out, &err, &status, &error); |
|
329 |
+ |
|
330 |
+ chr = strchr (out, '\n'); |
|
331 |
+ *chr = '\0'; |
|
332 |
+ |
|
333 |
+ putenv (out); |
|
334 |
+} |
|
335 |
+ |
|
336 |
+static void |
|
337 |
+xagent_start_default_clients (void) { |
|
338 |
+ |
|
339 |
+ char **app_path = NULL; |
|
340 |
+ |
|
341 |
+ char *default_apps[] = {"/usr/bin/nautilus --no-default-window", |
|
342 |
+ NULL }; |
|
343 |
+ |
|
344 |
+ for (app_path = default_apps; *app_path != NULL; app_path++) { |
|
345 |
+ g_spawn_command_line_async (*app_path, NULL); |
|
346 |
+ } |
|
347 |
+} |
|
348 |
+ |
|
12871 | 349 |
+int |
350 |
+main (int argc, char **argv) |
|
9397 | 351 |
+{ |
13200 | 352 |
+ struct sigaction sa; |
353 |
+ GError *error; |
|
354 |
+ char *display_str; |
|
355 |
+ Display *xdisp; |
|
356 |
+ GdkDisplay *gdisp; |
|
357 |
+ GsmManager *manager; |
|
358 |
+ GsmStore *client_store; |
|
359 |
+ GsmXsmpServer *xsmp_server; |
|
360 |
+ int dummy_fd, pipe_fd; |
|
361 |
+ GIOChannel *channel; |
|
362 |
+ guint result; |
|
9397 | 363 |
+ |
13200 | 364 |
+ bindtextdomain (GETTEXT_PACKAGE, LOCALE_DIR); |
365 |
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); |
|
366 |
+ textdomain (GETTEXT_PACKAGE); |
|
9397 | 367 |
+ |
13200 | 368 |
+ int fd = open ("/dev/null", O_RDWR); |
369 |
+ dup2 (fd, 1); |
|
370 |
+ dup2 (fd, 2); |
|
9397 | 371 |
+ |
13200 | 372 |
+ sa.sa_handler = SIG_IGN; |
373 |
+ sa.sa_flags = 0; |
|
374 |
+ sigemptyset (&sa.sa_mask); |
|
375 |
+ sigaction (SIGPIPE, &sa, 0); |
|
376 |
+ |
|
377 |
+ if ((pipe_fd = dup (fileno(stdin))) != -1) { |
|
378 |
+ close (fileno(stdin)); |
|
379 |
+ dummy_fd = open ("/dev/null", O_RDONLY); |
|
380 |
+ fcntl (pipe_fd, F_SETFD, 1); |
|
381 |
+ } else { |
|
382 |
+ pipe_fd = fileno (stdin); |
|
383 |
+ } |
|
9397 | 384 |
+ |
13200 | 385 |
+ error = NULL; |
386 |
+ gtk_init_with_args (&argc, &argv, |
|
387 |
+ (char *) _(" - the GNOME session manager"), |
|
388 |
+ entries, GETTEXT_PACKAGE, |
|
389 |
+ &error); |
|
390 |
+ if (error != NULL) { |
|
391 |
+ gsm_util_init_error (TRUE, "%s", error->message); |
|
392 |
+ } |
|
9397 | 393 |
+ |
13200 | 394 |
+ /* Set DISPLAY explicitly for all our children, in case --display |
395 |
+ * was specified on the command line. |
|
396 |
+ */ |
|
397 |
+ display_str = gdk_get_display (); |
|
398 |
+ gsm_util_setenv ("DISPLAY", display_str); |
|
399 |
+ g_free (display_str); |
|
9397 | 400 |
+ |
13200 | 401 |
+ gdisp = gdk_display_get_default (); |
402 |
+ xdisp = gdk_x11_display_get_xdisplay (gdisp); |
|
403 |
+ XInternAtom (xdisp, "GNOME_SM_DESKTOP", FALSE); |
|
9397 | 404 |
+ |
13200 | 405 |
+ XSetErrorHandler (XAgentXErrorHandler); |
9397 | 406 |
+ |
13200 | 407 |
+ if (!nosession) { |
14405 | 408 |
+ xagent_start_dbus (); /* Start up gconfd if not already running. */ |
13200 | 409 |
+ gsm_gconf_init (); |
9397 | 410 |
+ |
13200 | 411 |
+ gsm_gconf_check (); |
13235
18437e8f6a57
2008-08-21 Stephen Browne <set EMAIL_ADDRESS environment variable>
stephen
parents:
13233
diff
changeset
|
412 |
+ } |
13200 | 413 |
+ |
13235
18437e8f6a57
2008-08-21 Stephen Browne <set EMAIL_ADDRESS environment variable>
stephen
parents:
13233
diff
changeset
|
414 |
+ if (g_file_test (TSOLJDS_MIGRATION_SCRIPT, G_FILE_TEST_IS_EXECUTABLE)) { |
18437e8f6a57
2008-08-21 Stephen Browne <set EMAIL_ADDRESS environment variable>
stephen
parents:
13233
diff
changeset
|
415 |
+ system (TSOLJDS_MIGRATION_SCRIPT); |
13200 | 416 |
+ } |
13235
18437e8f6a57
2008-08-21 Stephen Browne <set EMAIL_ADDRESS environment variable>
stephen
parents:
13233
diff
changeset
|
417 |
+ /*start the session*/ |
14405 | 418 |
+ xagent_start_default_clients (); |
9397 | 419 |
+ |
13200 | 420 |
+ /* we may have to spawn an exec immediately */ |
421 |
+ gdk_spawn_command_line_on_screen (gdk_display_get_screen (gdisp, 0), |
|
422 |
+ g_getenv("LABEL_EXEC_COMMAND"), &error); |
|
423 |
+ |
|
424 |
+ channel = g_io_channel_unix_new (pipe_fd); |
|
425 |
+ result = g_io_add_watch_full (channel, G_PRIORITY_HIGH, |
|
426 |
+ G_IO_IN | G_IO_PRI | G_IO_ERR | G_IO_HUP, |
|
427 |
+ (GIOFunc)handle_pipe_input, NULL, |
|
428 |
+ so_long_pipe); |
|
429 |
+ |
|
430 |
+ gtk_main (); |
|
9397 | 431 |
+ |
13200 | 432 |
+ gsm_gconf_shutdown (); |
9397 | 433 |
+ |
13200 | 434 |
+ return 0; |
9397 | 435 |
+} |