~noskcaj/ubuntu/vivid/gdm/3.14.1

« back to all changes in this revision

Viewing changes to daemon/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:
43
43
#include "gdm-manager.h"
44
44
#include "gdm-log.h"
45
45
#include "gdm-common.h"
46
 
#include "gdm-signal-handler.h"
47
46
 
48
47
#include "gdm-settings.h"
49
48
#include "gdm-settings-direct.h"
185
184
        GError *error = NULL;
186
185
 
187
186
        /* Set up /var/run/gdm */
188
 
        if (!ensure_dir_with_perms (GDM_RAN_ONCE_MARKER_DIR, 0, gid, (S_IRWXU | S_IRWXG), &error)) {
 
187
        if (!ensure_dir_with_perms (GDM_RAN_ONCE_MARKER_DIR, 0, gid, 0711, &error)) {
189
188
                gdm_fail (_("Failed to create ran once marker dir %s: %s"),
190
189
                          GDM_RAN_ONCE_MARKER_DIR, error->message);
191
190
        }
192
191
 
193
192
        /* Set up /var/gdm */
194
 
        if (!ensure_dir_with_perms (AUTHDIR, uid, gid, (S_IRWXU | S_IRWXG | S_ISVTX), &error)) {
 
193
        if (!ensure_dir_with_perms (AUTHDIR, uid, gid, 0711, &error)) {
195
194
                gdm_fail (_("Failed to create AuthDir %s: %s"),
196
195
                          AUTHDIR, error->message);
197
196
        }
198
197
 
199
198
        /* Set up /var/log/gdm */
200
 
        if (!ensure_dir_with_perms (LOGDIR, 0, gid, (S_IRWXU | S_IRWXG | S_ISVTX), &error)) {
 
199
        if (!ensure_dir_with_perms (LOGDIR, 0, gid, 0711, &error)) {
201
200
                gdm_fail (_("Failed to create LogDir %s: %s"),
202
201
                          LOGDIR, error->message);
203
202
        }
267
266
}
268
267
 
269
268
static gboolean
270
 
signal_cb (int      signo,
271
 
           gpointer data)
272
 
{
273
 
        int ret;
274
 
 
275
 
        g_debug ("Got callback for signal %d", signo);
276
 
 
277
 
        ret = TRUE;
278
 
 
279
 
        switch (signo) {
280
 
        case SIGFPE:
281
 
        case SIGPIPE:
282
 
                /* let the fatal signals interrupt us */
283
 
                g_debug ("Caught signal %d, shutting down abnormally.", signo);
284
 
                ret = FALSE;
285
 
 
286
 
                break;
287
 
 
288
 
        case SIGINT:
289
 
        case SIGTERM:
290
 
                /* let the fatal signals interrupt us */
291
 
                g_debug ("Caught signal %d, shutting down normally.", signo);
292
 
                ret = FALSE;
293
 
 
294
 
                break;
295
 
 
296
 
        case SIGHUP:
297
 
                g_debug ("Got HUP signal");
298
 
                /* Reread config stuff like system config files, VPN service
299
 
                 * files, etc
300
 
                 */
301
 
                g_object_unref (settings);
302
 
                settings = gdm_settings_new ();
303
 
                if (settings != NULL) {
304
 
                        if (! gdm_settings_direct_init (settings, DATADIR "/gdm/gdm.schemas", "/")) {
305
 
                                g_warning ("Unable to initialize settings");
306
 
                        }
 
269
on_shutdown_signal_cb (gpointer user_data)
 
270
{
 
271
        GMainLoop *mainloop = user_data;
 
272
 
 
273
        g_main_loop_quit (mainloop);
 
274
 
 
275
        return FALSE;
 
276
}
 
277
 
 
278
static gboolean
 
279
on_sighup_cb (gpointer user_data)
 
280
{
 
281
        g_debug ("Got HUP signal");
 
282
        /* Reread config stuff like system config files, VPN service
 
283
         * files, etc
 
284
         */
 
285
        g_object_unref (settings);
 
286
        settings = gdm_settings_new ();
 
287
        if (settings != NULL) {
 
288
                if (! gdm_settings_direct_init (settings, DATADIR "/gdm/gdm.schemas", "/")) {
 
289
                        g_warning ("Unable to initialize settings");
307
290
                }
308
 
 
309
 
                ret = TRUE;
310
 
 
311
 
                break;
312
 
 
313
 
        case SIGUSR1:
314
 
                g_debug ("Got USR1 signal");
315
 
                /* FIXME:
316
 
                 * Play with log levels or something
317
 
                 */
318
 
                ret = TRUE;
319
 
 
320
 
                gdm_log_toggle_debug ();
321
 
 
322
 
                break;
323
 
 
324
 
        default:
325
 
                g_debug ("Caught unhandled signal %d", signo);
326
 
                ret = TRUE;
327
 
 
328
 
                break;
329
291
        }
330
292
 
331
 
        return ret;
 
293
        return TRUE;
 
294
}
 
295
 
 
296
static gboolean
 
297
on_sigusr1_cb (gpointer user_data)
 
298
{
 
299
        g_debug ("Got USR1 signal");
 
300
 
 
301
        gdm_log_toggle_debug ();
 
302
 
 
303
        return TRUE;
332
304
}
333
305
 
334
306
static gboolean
354
326
        GError             *error = NULL;
355
327
        int                 ret;
356
328
        gboolean            res;
357
 
        GdmSignalHandler   *signal_handler;
358
329
        static gboolean     do_timed_exit    = FALSE;
359
330
        static gboolean     print_version    = FALSE;
360
331
        static gboolean     fatal_warnings   = FALSE;
372
343
 
373
344
        ret = 1;
374
345
 
375
 
        g_type_init ();
376
 
 
377
346
        context = g_option_context_new (_("GNOME Display Manager"));
378
347
        g_option_context_add_main_entries (context, entries, NULL);
379
348
        g_option_context_set_ignore_unknown_options (context, TRUE);
440
409
 
441
410
        main_loop = g_main_loop_new (NULL, FALSE);
442
411
 
443
 
        signal_handler = gdm_signal_handler_new ();
444
 
        gdm_signal_handler_set_fatal_func (signal_handler,
445
 
                                           (GDestroyNotify)g_main_loop_quit,
446
 
                                           main_loop);
447
 
        gdm_signal_handler_add_fatal (signal_handler);
448
 
        gdm_signal_handler_add (signal_handler, SIGTERM, signal_cb, NULL);
449
 
        gdm_signal_handler_add (signal_handler, SIGINT, signal_cb, NULL);
450
 
        gdm_signal_handler_add (signal_handler, SIGFPE, signal_cb, NULL);
451
 
        gdm_signal_handler_add (signal_handler, SIGHUP, signal_cb, NULL);
452
 
        gdm_signal_handler_add (signal_handler, SIGUSR1, signal_cb, NULL);
 
412
        g_unix_signal_add (SIGTERM, on_shutdown_signal_cb, main_loop);
 
413
        g_unix_signal_add (SIGINT, on_shutdown_signal_cb, main_loop);
 
414
        g_unix_signal_add (SIGHUP, on_sighup_cb, NULL);
 
415
        g_unix_signal_add (SIGUSR1, on_sigusr1_cb, NULL);
453
416
 
454
417
        if (do_timed_exit) {
455
418
                g_timeout_add_seconds (30, (GSourceFunc) timed_exit_cb, main_loop);
461
424
 
462
425
        g_clear_object (&manager);
463
426
        g_clear_object (&settings);
464
 
        g_clear_object (&signal_handler);
465
427
 
466
428
        gdm_settings_direct_shutdown ();
467
429
        gdm_log_shutdown ();