~ubuntu-branches/ubuntu/trusty/gdm/trusty-proposed

« back to all changes in this revision

Viewing changes to .pc/ubuntu_dont_catch_sigsegv.patch/daemon/simple-slave-main.c

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha, Tim Lunn, Jeremy Bicha, Robert Ancell
  • Date: 2013-05-31 22:36:08 UTC
  • mfrom: (1.4.55)
  • Revision ID: package-import@ubuntu.com-20130531223608-33uo85niksee5460
Tags: 3.8.1.1-0ubuntu1
[ Tim Lunn ]
* New upstream release
* debian/patches/ubuntu_dont_catch_sigsegv.patch:
  - Dropped, obsolete
* debian/rules:
  - Don't rename gdm binary since that's already been
    done in the new version

[ Jeremy Bicha ]
* debian/control.in: Bump minimum glib
* debian/watch: Watch for unstable releases
* debian/patches/00git_logind_check.patch:
  - Dropped, applied in new release
* debian/patches/08_frequent-users_greeter.patch: Refreshed

[ Robert Ancell ]
* New upstream release
* debian/patches/ubuntu_daemon_autologin_tracking.patch:
* debian/patches/ubuntu_ensure_dirs.patch:
* debian/patches/ubuntu_slave-only-set-up-autologin.patch:
  - Applied upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
2
 
 *
3
 
 * Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
4
 
 *
5
 
 * This program is free software; you can redistribute it and/or modify
6
 
 * it under the terms of the GNU General Public License as published by
7
 
 * the Free Software Foundation; either version 2 of the License, or
8
 
 * (at your option) any later version.
9
 
 *
10
 
 * This program is distributed in the hope that it will be useful,
11
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
 * GNU General Public License for more details.
14
 
 *
15
 
 * You should have received a copy of the GNU General Public License
16
 
 * along with this program; if not, write to the Free Software
17
 
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18
 
 *
19
 
 */
20
 
 
21
 
#include "config.h"
22
 
 
23
 
#include <stdlib.h>
24
 
#include <stdio.h>
25
 
#include <unistd.h>
26
 
#include <errno.h>
27
 
#include <string.h>
28
 
#include <sys/types.h>
29
 
#include <sys/stat.h>
30
 
#include <fcntl.h>
31
 
#include <signal.h>
32
 
#include <locale.h>
33
 
 
34
 
#include <glib.h>
35
 
#include <glib/gi18n.h>
36
 
#include <glib-object.h>
37
 
#include <gio/gio.h>
38
 
 
39
 
#include "gdm-xerrors.h"
40
 
#include "gdm-signal-handler.h"
41
 
#include "gdm-log.h"
42
 
#include "gdm-common.h"
43
 
#include "gdm-simple-slave.h"
44
 
#include "gdm-settings.h"
45
 
#include "gdm-settings-direct.h"
46
 
#include "gdm-settings-keys.h"
47
 
#include "gdm-settings-client.h"
48
 
 
49
 
static GdmSettings     *settings        = NULL;
50
 
static int              gdm_return_code = 0;
51
 
 
52
 
static GDBusConnection *
53
 
get_system_bus (void)
54
 
{
55
 
        GError          *error;
56
 
        GDBusConnection *bus;
57
 
 
58
 
        error = NULL;
59
 
        bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
60
 
        if (bus == NULL) {
61
 
                g_warning ("Couldn't connect to system bus: %s",
62
 
                           error->message);
63
 
                g_error_free (error);
64
 
                goto out;
65
 
        }
66
 
 
67
 
        g_dbus_connection_set_exit_on_close (bus, FALSE);
68
 
 
69
 
 out:
70
 
        return bus;
71
 
}
72
 
 
73
 
static gboolean
74
 
signal_cb (int      signo,
75
 
           gpointer data)
76
 
{
77
 
        int ret;
78
 
 
79
 
        g_debug ("Got callback for signal %d", signo);
80
 
 
81
 
        ret = TRUE;
82
 
 
83
 
        switch (signo) {
84
 
        case SIGSEGV:
85
 
        case SIGBUS:
86
 
        case SIGILL:
87
 
        case SIGABRT:
88
 
                g_debug ("Caught signal %d.", signo);
89
 
 
90
 
                ret = FALSE;
91
 
                break;
92
 
 
93
 
        case SIGFPE:
94
 
        case SIGPIPE:
95
 
                /* let the fatal signals interrupt us */
96
 
                g_debug ("Caught signal %d, shutting down abnormally.", signo);
97
 
                ret = FALSE;
98
 
 
99
 
                break;
100
 
 
101
 
        case SIGINT:
102
 
        case SIGTERM:
103
 
                /* let the fatal signals interrupt us */
104
 
                g_debug ("Caught signal %d, shutting down normally.", signo);
105
 
                ret = FALSE;
106
 
 
107
 
                break;
108
 
 
109
 
        case SIGHUP:
110
 
                g_debug ("Got HUP signal");
111
 
                /* FIXME:
112
 
                 * Reread config stuff like system config files, VPN service files, etc
113
 
                 */
114
 
                ret = TRUE;
115
 
 
116
 
                break;
117
 
 
118
 
        case SIGUSR1:
119
 
                g_debug ("Got USR1 signal");
120
 
                /* we get this from xorg - can't use for anything else */
121
 
                ret = TRUE;
122
 
 
123
 
                break;
124
 
 
125
 
        case SIGUSR2:
126
 
                g_debug ("Got USR2 signal");
127
 
                ret = TRUE;
128
 
 
129
 
                gdm_log_toggle_debug ();
130
 
 
131
 
                break;
132
 
 
133
 
        default:
134
 
                g_debug ("Caught unhandled signal %d", signo);
135
 
                ret = TRUE;
136
 
 
137
 
                break;
138
 
        }
139
 
 
140
 
        return ret;
141
 
}
142
 
 
143
 
static void
144
 
on_slave_stopped (GdmSlave   *slave,
145
 
                  GMainLoop  *main_loop)
146
 
{
147
 
        g_debug ("slave finished");
148
 
        gdm_return_code = 0;
149
 
        g_main_loop_quit (main_loop);
150
 
}
151
 
 
152
 
static gboolean
153
 
is_debug_set (void)
154
 
{
155
 
        gboolean debug = FALSE;
156
 
 
157
 
        /* enable debugging for unstable builds */
158
 
        if (gdm_is_version_unstable ()) {
159
 
                return TRUE;
160
 
        }
161
 
 
162
 
        gdm_settings_direct_get_boolean (GDM_KEY_DEBUG, &debug);
163
 
        return debug;
164
 
}
165
 
 
166
 
int
167
 
main (int    argc,
168
 
      char **argv)
169
 
{
170
 
        GMainLoop        *main_loop;
171
 
        GOptionContext   *context;
172
 
        GDBusConnection  *connection;
173
 
        GdmSlave         *slave;
174
 
        static char      *display_id = NULL;
175
 
        GdmSignalHandler *signal_handler;
176
 
        static GOptionEntry entries []   = {
177
 
                { "display-id", 0, 0, G_OPTION_ARG_STRING, &display_id, N_("Display ID"), N_("ID") },
178
 
                { NULL }
179
 
        };
180
 
 
181
 
        bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
182
 
        textdomain (GETTEXT_PACKAGE);
183
 
        setlocale (LC_ALL, "");
184
 
 
185
 
        g_type_init ();
186
 
 
187
 
        context = g_option_context_new (_("GNOME Display Manager Slave"));
188
 
        g_option_context_add_main_entries (context, entries, NULL);
189
 
 
190
 
        g_option_context_parse (context, &argc, &argv, NULL);
191
 
        g_option_context_free (context);
192
 
 
193
 
        /* For debugging */
194
 
        /*sleep (10);*/
195
 
 
196
 
        connection = get_system_bus ();
197
 
        if (connection == NULL) {
198
 
                goto out;
199
 
        }
200
 
 
201
 
        gdm_xerrors_init ();
202
 
        gdm_log_init ();
203
 
 
204
 
        settings = gdm_settings_new ();
205
 
        if (settings == NULL) {
206
 
                g_warning ("Unable to initialize settings");
207
 
                goto out;
208
 
        }
209
 
 
210
 
        if (! gdm_settings_direct_init (settings, DATADIR "/gdm/gdm.schemas", "/")) {
211
 
                g_warning ("Unable to initialize settings");
212
 
                goto out;
213
 
        }
214
 
 
215
 
        gdm_log_set_debug (is_debug_set ());
216
 
 
217
 
        if (display_id == NULL) {
218
 
                g_critical ("No display ID set");
219
 
                exit (1);
220
 
        }
221
 
 
222
 
        if (! gdm_settings_client_init (DATADIR "/gdm/gdm.schemas", "/")) {
223
 
                g_critical ("Unable to initialize settings client");
224
 
                exit (1);
225
 
        }
226
 
 
227
 
        main_loop = g_main_loop_new (NULL, FALSE);
228
 
 
229
 
        signal_handler = gdm_signal_handler_new ();
230
 
        gdm_signal_handler_set_fatal_func (signal_handler,
231
 
                                           (GDestroyNotify)g_main_loop_quit,
232
 
                                           main_loop);
233
 
        gdm_signal_handler_add (signal_handler, SIGTERM, signal_cb, NULL);
234
 
        gdm_signal_handler_add (signal_handler, SIGINT, signal_cb, NULL);
235
 
        gdm_signal_handler_add (signal_handler, SIGILL, signal_cb, NULL);
236
 
        gdm_signal_handler_add (signal_handler, SIGBUS, signal_cb, NULL);
237
 
        gdm_signal_handler_add (signal_handler, SIGFPE, signal_cb, NULL);
238
 
        gdm_signal_handler_add (signal_handler, SIGHUP, signal_cb, NULL);
239
 
        gdm_signal_handler_add (signal_handler, SIGSEGV, signal_cb, NULL);
240
 
        gdm_signal_handler_add (signal_handler, SIGABRT, signal_cb, NULL);
241
 
        gdm_signal_handler_add (signal_handler, SIGUSR1, signal_cb, NULL);
242
 
        gdm_signal_handler_add (signal_handler, SIGUSR2, signal_cb, NULL);
243
 
 
244
 
        slave = gdm_simple_slave_new (display_id);
245
 
        if (slave == NULL) {
246
 
                goto out;
247
 
        }
248
 
        g_signal_connect (slave,
249
 
                          "stopped",
250
 
                          G_CALLBACK (on_slave_stopped),
251
 
                          main_loop);
252
 
        gdm_slave_start (slave);
253
 
 
254
 
        g_main_loop_run (main_loop);
255
 
 
256
 
        if (slave != NULL) {
257
 
                g_object_unref (slave);
258
 
        }
259
 
 
260
 
        if (signal_handler != NULL) {
261
 
                g_object_unref (signal_handler);
262
 
        }
263
 
 
264
 
        g_main_loop_unref (main_loop);
265
 
 
266
 
 out:
267
 
        g_debug ("Slave finished");
268
 
 
269
 
        g_object_unref (connection);
270
 
 
271
 
        return gdm_return_code;
272
 
}