~ubuntu-branches/ubuntu/precise/network-manager/precise

« back to all changes in this revision

Viewing changes to .pc/70_lp145653_no_sigaction_for_crashes.patch/src/main.c

  • Committer: Package Import Robot
  • Author(s): Mathieu Trudel-Lapierre
  • Date: 2012-02-09 16:45:41 UTC
  • mfrom: (1.1.53)
  • Revision ID: package-import@ubuntu.com-20120209164541-4h90zknlsfdb7x35
Tags: 0.9.2.0+git201202091925.c721477-0ubuntu1
* upstream snapshot 2012-02-09 19:25:59 (GMT)
  + c721477d11d4fe144111d6d2eec8f93f2e9186c9
* debian/patches/avoid-periodic-disk-wakeups.patch: refreshed.
* debian/patches/nl3-default-ip6-route.patch: refreshed.
* debian/libnm-glib4.symbols: add symbols:
  + nm_active_connection_get_master@Base
  + nm_client_new_async@Base
  + nm_client_new_finish@Base
  + nm_remote_settings_new_async@Base
  + nm_remote_settings_new_finish@Base
  + nm_device_get_state_reason@Base
* debian/libnm-util2.symbols: add symbols:
  + nm_setting_802_1x_get_pac_file@Base
  + nm_setting_infiniband_get_transport_mode@Base

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 * with this program; if not, write to the Free Software Foundation, Inc.,
16
16
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
17
 *
18
 
 * Copyright (C) 2004 - 2011 Red Hat, Inc.
 
18
 * Copyright (C) 2004 - 2012 Red Hat, Inc.
19
19
 * Copyright (C) 2005 - 2008 Novell, Inc.
20
20
 */
21
21
 
25
25
#include <dbus/dbus-glib-lowlevel.h>
26
26
#include <dbus/dbus-glib.h>
27
27
#include <getopt.h>
 
28
#include <locale.h>
28
29
#include <errno.h>
29
30
#include <stdlib.h>
30
31
#include <signal.h>
139
140
 
140
141
        /* Set up our quit pipe */
141
142
        if (pipe (quit_pipe) < 0) {
142
 
                fprintf (stderr, "Failed to initialze SIGTERM pipe: %d", errno);
 
143
                fprintf (stderr, _("Failed to initialize SIGTERM pipe: %d"), errno);
143
144
                exit (1);
144
145
        }
145
146
        fcntl (quit_pipe[1], F_SETFL, O_NONBLOCK | fcntl (quit_pipe[1], F_GETFL));
170
171
        gboolean success = FALSE;
171
172
 
172
173
        if ((fd = open (pidfile, O_CREAT|O_WRONLY|O_TRUNC, 00644)) < 0) {
173
 
                fprintf (stderr, "Opening %s failed: %s\n", pidfile, strerror (errno));
 
174
                fprintf (stderr, _("Opening %s failed: %s\n"), pidfile, strerror (errno));
174
175
                return FALSE;
175
176
        }
176
177
 
177
178
        snprintf (pid, sizeof (pid), "%d", getpid ());
178
179
        if (write (fd, pid, strlen (pid)) < 0)
179
 
                fprintf (stderr, "Writing to %s failed: %s\n", pidfile, strerror (errno));
 
180
                fprintf (stderr, _("Writing to %s failed: %s\n"), pidfile, strerror (errno));
180
181
        else
181
182
                success = TRUE;
182
183
 
183
184
        if (close (fd))
184
 
                fprintf (stderr, "Closing %s failed: %s\n", pidfile, strerror (errno));
 
185
                fprintf (stderr, _("Closing %s failed: %s\n"), pidfile, strerror (errno));
185
186
 
186
187
        return success;
187
188
}
224
225
        if (strcmp (process_name, "NetworkManager") == 0) {
225
226
                /* Check that the process exists */
226
227
                if (kill (pid, 0) == 0) {
227
 
                        fprintf (stderr, "NetworkManager is already running (pid %ld)\n", pid);
 
228
                        fprintf (stderr, _("NetworkManager is already running (pid %ld)\n"), pid);
228
229
                        nm_running = TRUE;
229
230
                }
230
231
        }
361
362
        gboolean wrote_pidfile = FALSE;
362
363
 
363
364
        GOptionEntry options[] = {
364
 
                { "version", 0, 0, G_OPTION_ARG_NONE, &show_version, "Print NetworkManager version and exit", NULL },
365
 
                { "no-daemon", 0, 0, G_OPTION_ARG_NONE, &become_daemon, "Don't become a daemon", NULL },
366
 
                { "g-fatal-warnings", 0, 0, G_OPTION_ARG_NONE, &g_fatal_warnings, "Make all warnings fatal", NULL },
367
 
                { "pid-file", 0, 0, G_OPTION_ARG_FILENAME, &pidfile, "Specify the location of a PID file", "filename" },
368
 
                { "state-file", 0, 0, G_OPTION_ARG_FILENAME, &state_file, "State file location", "/path/to/state.file" },
369
 
                { "config", 0, 0, G_OPTION_ARG_FILENAME, &config_path, "Config file location", "/path/to/config.file" },
370
 
                { "plugins", 0, 0, G_OPTION_ARG_STRING, &plugins, "List of plugins separated by ','", "plugin1,plugin2" },
371
 
                { "log-level", 0, 0, G_OPTION_ARG_STRING, &log_level, "Log level: one of [ERR, WARN, INFO, DEBUG]", "INFO" },
 
365
                { "version", 0, 0, G_OPTION_ARG_NONE, &show_version, N_("Print NetworkManager version and exit"), NULL },
 
366
                { "no-daemon", 0, 0, G_OPTION_ARG_NONE, &become_daemon, N_("Don't become a daemon"), NULL },
 
367
                { "g-fatal-warnings", 0, 0, G_OPTION_ARG_NONE, &g_fatal_warnings, N_("Make all warnings fatal"), NULL },
 
368
                { "pid-file", 0, 0, G_OPTION_ARG_FILENAME, &pidfile, N_("Specify the location of a PID file"), N_("filename") },
 
369
                { "state-file", 0, 0, G_OPTION_ARG_FILENAME, &state_file, N_("State file location"), N_("/path/to/state.file") },
 
370
                { "config", 0, 0, G_OPTION_ARG_FILENAME, &config_path, N_("Config file location"), N_("/path/to/config.file") },
 
371
                { "plugins", 0, 0, G_OPTION_ARG_STRING, &plugins, N_("List of plugins separated by ','"), N_("plugin1,plugin2") },
 
372
                /* Translators: Do not translate the values in the square brackets */
 
373
                { "log-level", 0, 0, G_OPTION_ARG_STRING, &log_level, N_("Log level: one of [ERR, WARN, INFO, DEBUG]"), "INFO" },
372
374
                { "log-domains", 0, 0, G_OPTION_ARG_STRING, &log_domains,
373
 
                        "Log domains separated by ',': any combination of\n"
 
375
                        /* Translators: Do not translate the values in the square brackets */
 
376
                        N_("Log domains separated by ',': any combination of\n"
374
377
                        "                                          [NONE,HW,RFKILL,ETHER,WIFI,BT,MB,DHCP4,DHCP6,PPP,\n"
375
378
                        "                                           WIFI_SCAN,IP4,IP6,AUTOIP4,DNS,VPN,SHARING,SUPPLICANT,\n"
376
379
                        "                                           AGENTS,SETTINGS,SUSPEND,CORE,DEVICE,OLPC,WIMAX,\n"
377
 
                        "                                           INFINIBAND,FIREWALL]",
 
380
                        "                                           INFINIBAND,FIREWALL]"),
378
381
                        "HW,RFKILL,WIFI" },
379
382
                {NULL}
380
383
        };
381
384
 
382
385
        if (!g_module_supported ()) {
383
 
                fprintf (stderr, "GModules are not supported on your platform!\n");
 
386
                fprintf (stderr, _("GModules are not supported on your platform!\n"));
384
387
                exit (1);
385
388
        }
386
389
 
 
390
        /* Set locale to be able to use environment variables */
 
391
        setlocale (LC_ALL, "");
 
392
 
387
393
        bindtextdomain (GETTEXT_PACKAGE, NMLOCALEDIR);
388
394
        bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
389
395
        textdomain (GETTEXT_PACKAGE);
390
396
 
391
397
        /* Parse options */
392
 
        opt_ctx = g_option_context_new ("");
393
 
        g_option_context_set_translation_domain (opt_ctx, "UTF-8");
 
398
        opt_ctx = g_option_context_new (NULL);
 
399
        g_option_context_set_translation_domain (opt_ctx, GETTEXT_PACKAGE);
394
400
        g_option_context_set_ignore_unknown_options (opt_ctx, FALSE);
395
401
        g_option_context_set_help_enabled (opt_ctx, TRUE);
396
402
        g_option_context_add_main_entries (opt_ctx, options, NULL);
397
403
 
398
404
        g_option_context_set_summary (opt_ctx,
399
 
                "NetworkManager monitors all network connections and automatically\nchooses the best connection to use.  It also allows the user to\nspecify wireless access points which wireless cards in the computer\nshould associate with.");
 
405
                _("NetworkManager monitors all network connections and automatically\nchooses the best connection to use.  It also allows the user to\nspecify wireless access points which wireless cards in the computer\nshould associate with."));
400
406
 
401
407
        success = g_option_context_parse (opt_ctx, &argc, &argv, NULL);
402
408
        g_option_context_free (opt_ctx);
412
418
        }
413
419
 
414
420
        if (getuid () != 0) {
415
 
                fprintf (stderr, "You must be root to run NetworkManager!\n");
 
421
                fprintf (stderr, _("You must be root to run NetworkManager!\n"));
416
422
                exit (1);
417
423
        }
418
424
 
432
438
        /* Read the config file and CLI overrides */
433
439
        config = nm_config_new (config_path, plugins, log_level, log_domains, &error);
434
440
        if (config == NULL) {
435
 
                fprintf (stderr, "Failed to read configuration: (%d) %s\n",
 
441
                fprintf (stderr, _("Failed to read configuration: (%d) %s\n"),
436
442
                         error ? error->code : -1,
437
 
                         (error && error->message) ? error->message : "unknown");
 
443
                         (error && error->message) ? error->message : _("unknown"));
438
444
                exit (1);
439
445
        }
440
446
 
450
456
 
451
457
        /* Parse the state file */
452
458
        if (!parse_state_file (state_file, &net_enabled, &wifi_enabled, &wwan_enabled, &wimax_enabled, &error)) {
453
 
                fprintf (stderr, "State file %s parsing failed: (%d) %s\n",
 
459
                fprintf (stderr, _("State file %s parsing failed: (%d) %s\n"),
454
460
                         state_file,
455
461
                         error ? error->code : -1,
456
 
                         (error && error->message) ? error->message : "unknown");
 
462
                         (error && error->message) ? error->message : _("unknown"));
457
463
                /* Not a hard failure */
458
464
        }
459
465
        g_clear_error (&error);
467
473
                        int saved_errno;
468
474
 
469
475
                        saved_errno = errno;
470
 
                        fprintf (stderr, "Could not daemonize: %s [error %u]\n",
 
476
                        fprintf (stderr, _("Could not daemonize: %s [error %u]\n"),
471
477
                                 g_strerror (saved_errno),
472
478
                                 saved_errno);
473
479
                        exit (1);