~ubuntu-core-dev/update-notifier/ubuntu

« back to all changes in this revision

Viewing changes to src/update-notifier.c

  • Committer: Brian Murray
  • Date: 2013-06-03 22:40:21 UTC
  • mfrom: (781.2.12 distro-cd-detected)
  • Revision ID: brian@canonical.com-20130603224021-17l6xslzhzss1ji9
* Move update-notifier checking for CDs with packages into a new binary
  distro-cd-updater
* Add an upstart user session job that runs upon CD insertion
* Remove sections of uevent related to hp firmware and replace them with an
  upstart user session job
* Modified avahi disabled notification to run as an upstart user session
* Modified new release check to run as an upstart user session
* Added in a weekly cron job to check for a new release of ubuntu
* Added an upstart user session job to check for crashes
* Ensure we ask before launching a pkexec dialog for an apport crash

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
#include "update-notifier.h"
42
42
#include "update.h"
43
43
#include "hooks.h"
44
 
#include "cdroms.h"
45
44
#include "uevent.h"
46
45
#include "crash.h"
47
 
#include "avahi.h"
48
 
#include "release.h"
49
46
#include "trayappletui.h"
50
47
 
51
48
/* some prototypes */
68
65
// delay on startup (to make session startup faster)
69
66
static int STARTUP_DELAY=1;
70
67
 
71
 
// make the release upgrader check for a devel release
72
 
gboolean DEVEL_RELEASE=FALSE;
73
 
 
74
 
// force release check
75
 
static gboolean FORCE_RELEASE_CHECK=FALSE;
76
 
 
77
68
// global debug options
78
69
static gboolean HOOK_DEBUG = FALSE;
79
70
static gboolean UPDATE_DEBUG = FALSE;
80
71
static gboolean INOTIFY_DEBUG = FALSE;
81
72
static gboolean UEVENT_DEBUG = FALSE;
82
 
static gboolean RELEASE_DEBUG = FALSE;
83
73
static gboolean MISC_DEBUG = FALSE;
84
74
 
85
75
// logging stuff
97
87
         g_log_default_handler (log_domain, log_level, message, user_data);
98
88
   }
99
89
   else if (log_domain && strcmp(log_domain, "inotify") == 0) {
100
 
      if (INOTIFY_DEBUG) 
 
90
      if (INOTIFY_DEBUG)
101
91
          g_log_default_handler (log_domain, log_level, message, user_data);
102
92
   }
103
93
   else if (log_domain && strcmp(log_domain, "uevent") == 0) {
104
94
      if (UEVENT_DEBUG)
105
95
         g_log_default_handler (log_domain, log_level, message, user_data);
106
96
   }
107
 
   else if (log_domain && strcmp(log_domain, "release") == 0) {
108
 
      if (RELEASE_DEBUG)
109
 
         g_log_default_handler (log_domain, log_level, message, user_data);
110
 
   }
111
97
   else if (MISC_DEBUG)
112
98
      g_log_default_handler (log_domain, log_level, message, user_data);
113
99
}
256
242
      g_debug_inotify("crashreport found");
257
243
      un->crashreport_pending = TRUE;
258
244
   }
259
 
   if(strstr(info_uri, UNICAST_LOCAL_AVAHI_FILE)) {
260
 
      g_debug_inotify("avahi disabled due to unicast .local domain");
261
 
      un->unicast_local_avahi_pending = TRUE;
262
 
   }
263
245
}
264
246
 
265
247
/*
349
331
      un->crashreport_pending = FALSE;
350
332
   }
351
333
 
352
 
   if(un->unicast_local_avahi_pending) {
353
 
      g_debug("checking for disabled avahi due to unicast .local domain now");
354
 
      avahi_disabled_check ();
355
 
      un->unicast_local_avahi_pending = FALSE;
356
 
   }
357
 
 
358
334
   // reset the bitfields (for the next "time-slice")
359
335
   un->dpkg_was_run = FALSE;
360
336
   un->apt_get_running = FALSE;
379
355
      HOOKS_DIR, 
380
356
      CRASHREPORT_DIR,
381
357
      NULL};
 
358
   gboolean autolaunch = g_settings_get_boolean(un->settings,
 
359
                                                SETTINGS_KEY_AUTO_LAUNCH);
382
360
   for(i=0;monitor_dirs[i] != NULL;i++) {
 
361
      if (getenv("UPSTART_SESSION") && monitor_dirs[i] == CRASHREPORT_DIR && autolaunch) {
 
362
         continue;
 
363
      }
383
364
      GError *error = NULL;
384
365
      GFile *gf = g_file_new_for_path(monitor_dirs[i]);
385
366
      monitor_handle = g_file_monitor_directory(gf, 0, NULL, &error);
394
375
      "/var/lib/dpkg/status", 
395
376
      "/var/lib/update-notifier/dpkg-run-stamp", 
396
377
      "/var/lib/apt/periodic/update-success-stamp",
397
 
      UNICAST_LOCAL_AVAHI_FILE,
398
378
      NULL};
399
379
   for(i=0;monitor_files[i] != NULL;i++) {
400
380
      GError *error = NULL;
522
502
   { "debug-updates", 0, 0, G_OPTION_ARG_NONE, &UPDATE_DEBUG, "Enable updates/autolaunch debugging"},
523
503
   { "debug-inotify", 0, 0, G_OPTION_ARG_NONE, &INOTIFY_DEBUG, "Enable inotify debugging"},
524
504
   { "debug-uevent", 0, 0, G_OPTION_ARG_NONE, &UEVENT_DEBUG, "Enable uevent debugging"},
525
 
   { "debug-new-release-check", 0, 0, G_OPTION_ARG_NONE, &RELEASE_DEBUG, "Enable new release check debugging"},
526
505
   { "debug-misc", 0, 0, G_OPTION_ARG_NONE, &MISC_DEBUG, "Enable uncategorized debug prints"},
527
506
   { "force", 0, 0, G_OPTION_ARG_NONE, &FORCE_START, "Force start even if the user is not in the admin group"},
528
507
   { "force-use-pkexec", 0, 0, G_OPTION_ARG_NONE, &FORCE_PKEXEC, "Force running all commands (update-manager, synaptic) with pkexec" },
529
508
   { "startup-delay", 0, 0, G_OPTION_ARG_INT, &STARTUP_DELAY, "Delay startup by given amount of seconds" },
530
 
   { "devel-release", 0, 0, G_OPTION_ARG_NONE, &DEVEL_RELEASE, "Make the release checker check for a new development release" },
531
 
   { "force-release-check", 0, 0, G_OPTION_ARG_NONE, &FORCE_RELEASE_CHECK, "Force release check" },
532
509
   { NULL }
533
510
};
534
511
 
553
530
        textdomain(PACKAGE);
554
531
 
555
532
        if (HOOK_DEBUG || UPDATE_DEBUG || INOTIFY_DEBUG ||
556
 
            UEVENT_DEBUG || RELEASE_DEBUG || MISC_DEBUG)
 
533
            UEVENT_DEBUG || MISC_DEBUG)
557
534
                g_setenv ("G_MESSAGES_DEBUG", "all", TRUE);
558
535
 
559
536
        // setup a custom debug log handler
565
542
                           debug_log_handler, NULL);
566
543
        g_log_set_handler ("uevent", G_LOG_LEVEL_DEBUG,
567
544
                           debug_log_handler, NULL);
568
 
        g_log_set_handler ("release", G_LOG_LEVEL_DEBUG,
569
 
                           debug_log_handler, NULL);
570
545
        g_log_set_handler (NULL, G_LOG_LEVEL_DEBUG,
571
546
                           debug_log_handler, NULL);
572
547
 
585
560
           exit(0);
586
561
        }
587
562
 
588
 
        // do not run as system user (e.g. guest user)
589
 
        if (FORCE_RELEASE_CHECK)
590
 
           g_settings_reset(un->settings, SETTINGS_KEY_LAST_RELEASE_CHECK);
591
 
 
592
563
        // check if it is running already
593
564
        if (!up_get_clipboard ()) {
594
565
           g_warning ("already running?");
607
578
        g_timeout_add_seconds(STARTUP_DELAY, 
608
579
                              (GSourceFunc)(tray_icons_init), un);
609
580
 
610
 
        // initial check for avahi
611
 
        avahi_disabled_check();
612
 
 
613
 
        /* setup inserted-cdroms checker */
614
 
        if(!cdroms_init(un)) {
615
 
           g_warning("initializing cdroms failed");
616
 
        }
617
 
 
618
 
        // init release checker
619
 
        release_checker_init(un);
620
 
 
621
 
        // init uevent monitoring (missing firmware, etc.)
 
581
        // init uevent monitoring (printer support, etc.)
 
582
#ifdef ENABLE_SCP
622
583
        uevent_init();
623
 
 
 
584
#endif
624
585
        // init gio file monitoring
625
586
        monitor_init (un);
626
587