summaryrefslogtreecommitdiff
path: root/src/main.c
Commit message (Collapse)AuthorAgeFilesLines
* core: ignore SIGPIPEThomas Haller2014-10-271-0/+4
| | | | | | | | | | | | | | | | | | | Ignoring SIGPIPE signal, otherwise it causes problems. For example, running `NetworkManager --debug 2>&1 | tee log.txt` in a terminal and killing it with CTRL+C (SIGINT), will abruplty terminate NetworkManager without clean shutdown. Note, that with this patch and above example, NetworkManager will both receive SIGINT and SIGPIPE. Since we now ignore SIGPIPE, NetworkManager will shut down cleanly. Any logging output after killing `tee` is of lost however. Also, there might be other cases where NM reads/writes to a pipe/socket and unexpectedly received SIGPIPE. For example nm-dns-manager.c spawns netconfig (run_netconfig()) and writes the configuration to its stdin. If netconfig dies, the write might fail with EPIPE. Signed-off-by: Thomas Haller <thaller@redhat.com>
* auth: rework polkit autorization to use DBUS interface directlyThomas Haller2014-09-291-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | This makes NetworkManager independent of <polkit/polkit.h> development headers and libpolkit-gobject-1.so library. Instead communicate directly with polkit using its DBUS interface. PolicyKit support is now always compiled in. You can control polkit authorization with the configuration option [main] auth-polkit=yes|no If the configure option is omitted, a build time default value is used. This default value can be set with the configure option --enable-polkit. This commit adds a new class NMAuthManager that reimplements the relevant DBUS client parts. It takes source code from the polkit library. https://bugzilla.gnome.org/show_bug.cgi?id=734146 Signed-off-by: Thomas Haller <thaller@redhat.com>
* libnm: rename NetworkManager.h and NetworkManagerVPN.hDan Winship2014-08-011-1/+1
| | | | | | | "NetworkManager.h"'s name (and non-standard capitalization) suggest that it's some sort of high-level super-important header, but it's really just low-level D-Bus stuff. Rename it to "nm-dbus-interface.h" and likewise "NetworkManagerVPN.h" to "nm-vpn-dbus-interface.h"
* libnm, core, cli, tui: fix the capitalization of various typesDan Winship2014-08-011-2/+2
| | | | | | | | | | | | GLib/Gtk have mostly settled on the convention that two-letter acronyms in type names remain all-caps (eg, "IO"), but longer acronyms become initial-caps-only (eg, "Tcp"). NM was inconsistent, with most long acronyms using initial caps only (Adsl, Cdma, Dcb, Gsm, Olpc, Vlan), but others using all caps (DHCP, PPP, PPPOE, VPN). Fix libnm and src/ to use initial-caps only for all three-or-more-letter-long acronyms (and update nmcli and nmtui for the libnm changes).
* core: fill in nm-types.h, clean out other headersDan Winship2014-07-231-0/+1
| | | | | | | | | | | | | | Clean up some of the cross-includes between headers (which made it so that, eg, if you included NetworkManagerUtils.h in a test program, you would need to build the test with -I$(top_srcdir)/src/platform, and if you included nm-device.h you'd need $(POLKIT_CFLAGS)) by moving all GObject struct definitions for src/ and src/settings/ into nm-types.h (which already existed to solve the NMDevice/NMActRequest circular references). Update various .c files to explicitly include the headers they used to get implicitly, and remove some now-unnecessary -I options from Makefiles.
* core: #include gsystem-local-alloc.h instead of libgsystem.hThomas Haller2014-07-151-1/+1
| | | | Signed-off-by: Thomas Haller <thaller@redhat.com>
* dispatcher: only dispatch if scripts existDan Williams2014-06-061-0/+3
| | | | | | If there are no dispatcher scripts, don't bother dispatching any events. This saves some time configuring networking if the event would have no effect anyway.
* all: g_type_init() has been deprecated in GLib 2.35.0Jiří Klimeš2014-05-271-0/+3
| | | | | g_type_init() deprecation: https://bugzilla.gnome.org/show_bug.cgi?id=686161
* core: remove the HostnameProvider interfaceDan Williams2014-05-091-2/+0
| | | | | | It's only used to keep the DHCPManager up-to-date with hostname changes, and that can be accomplished in much less code by just having NMManager set a hostname on the DHCPManager itself.
* core: don't ref/unref the DHCP managerDan Williams2014-05-091-5/+5
| | | | It's a singleton anyway, so no need to ref/unref it. Just use it.
* policy: remove old /etc/hosts cleaning code (bgo #729689)Dan Williams2014-05-081-4/+0
| | | | | | | | | | | | | | | | | | | | NetworkManager stopped touching /etc/hosts in late 2010 before the NetworkManager 0.8.1 release. The code in nm-policy-hosts.c's only purpose is to remove any of the entries that NetworkManager added long ago. I think we're at the point where people have already upgraded to NetworkManager 0.8.1 or later and thus this code would be a NOP. The only risk is that some stale /etc/hosts entries will be left if you upgrade from NM 0.8 or lower to anything higher than that. FWIW, Ubuntu Lucid (10.04) ships NM 0.8.0 and SLES11 ships NM 0.7.0, so if users of these distros upgraded to a later NetworkManager they might run into the stale entries issue if we remove this code from NM. But given how old these distros are, it seems unlikely that users will do a direct upgrade to something 4+ years newer... https://bugzilla.gnome.org/show_bug.cgi?id=729689
* core: add configuration main.debug and interpret environment variable NM_DEBUGThomas Haller2014-05-021-0/+34
| | | | | | | | | | | Interpret the configuration option main.debug and the environment variable NM_DEBUG as a comma separated list of debugging options (parsed with g_parse_debug_string()). Currently only the option "RLIMIT_CORE" is supported, to set the core dump size to unlimited. Signed-off-by: Thomas Haller <thaller@redhat.com>
* core: don't ref the Manager singletonDan Williams2014-03-031-1/+1
| | | | | | | | | The OLPC mesh code did rely on nm_manager_get() referencing the singleton when returning it, but all other callers of nm_manager_get() did not. Thus the manager's refcount would always increase and almost never decrease. Fix the refcounting so that the manager always has only one ref, and it's lifetime is controlled by main() and nothing else.
* replace snprintf by g_snprintfThomas Haller2014-02-241-1/+1
| | | | | | Use the glib wrapper for snprintf. Signed-off-by: Thomas Haller <thaller@redhat.com>
* core: report which option is unknownGuido Günther2014-02-151-2/+4
| | | | | | | | | | | | | | | So far NetworkManager didn't tell which option it didn't know about: Invalid option. Please use --help to see a list of valid options. Now it is a bit more informative: Unknown option --asdf. Please use --help to see a list of valid options. The "Unknown option" string is marked as translatable in glib so i18n doesn't suffer. Signed-off-by: Thomas Haller <thaller@redhat.com>
* logging: ignore unrecognized domains on startupDan Winship2013-12-201-1/+14
| | | | | | If the command line or NetworkManager.conf mentions a non-existent domain, just print a warning and ignore it. That way if you switch to using an older NM that doesn't have that domain, it will still work.
* core: make NMSessionMonitor non-refcountedDan Winship2013-12-031-0/+6
| | | | and ensure that main() frees the singleton before exiting
* trivial: consistently #include "libgsystem.h" rather than just ↵Colin Walters2013-08-291-1/+1
| | | | | | | | gsystem-local-alloc.h libgsystem contains more than just the local allocation macros; in the future we will likely want to make use of some of this such as the structured logging support.
* core: make NMPolicy a GObjectDan Winship2013-08-281-8/+0
| | | | | And make it owned by NMManager, rather than being a separate top-level object.
* trivial: remove unused system.h includeslPavel Šimerda2013-07-051-1/+0
|
* config: Include overrides in parsed config file messageColin Walters2013-06-241-1/+1
| | | | Useful to see which files are being read.
* main+logging: Allow early logging before config filesColin Walters2013-06-241-13/+42
| | | | | | | | | | | | | | | The new setup phase goes like this: - main() - parse command line options - logging is configured, targeting stdout/stderr - ...other stuff... - do or do not daemonize, depending on commandline option and config files - Call openlog() - further log messages go to syslog (and potentially stderr as well, if the -d option was specified so we use LOG_PERROR). Basically, this allows us to log messages about config file parsing and such, which *greatly* helps with debugging.
* main: Move static assertions after setlocale(), but before option processingColin Walters2013-06-241-10/+10
| | | | | | These assertions (such as getuid() == 0) don't need to access the config files or commandline arguments, but *do* output localized error messages, so they should be after setlocale().
* main: Set umask earlierColin Walters2013-06-241-7/+7
| | | | | Since we may be creating e.g. pid files before this, we need to set the umask as early as possible.
* main: setenv(GIO_USE_VFS=local) *very* earlyColin Walters2013-06-241-6/+6
| | | | | See https://bugzilla.gnome.org/show_bug.cgi?id=701322 for why we should order calls to setenv() as early as possible.
* main: allow daemonizing again - initialize become_daemon to TRUE (bgo #701383)Jiří Klimeš2013-06-031-1/+1
| | | | | | | | 7ff3d1500e8a9dcce4d12b7b879bf1d178b94bf8 reversed become_daemon for "--no-daemon" with G_OPTION_FLAG_REVERSE, but missed to reverse initialization into become_daemon=TRUE and thus NM couldn't be daemonized. https://bugzilla.gnome.org/show_bug.cgi?id=701383
* cleanup: remove unused headerPavel Šimerda2013-05-241-1/+0
|
* core: use nm-platform for link managementPavel Šimerda2013-05-241-1/+1
|
* core: add option for running from the build treeMartin Pitt2013-05-221-1/+26
| | | | | | | | | | | | Add hidden command line option --run-from-build-dir; with that, helpers like nm-avahi-autoipd.action and nm-dhcp-helper will be called from the build tree instead of libexecdir, which allows testing without having to install first. Helper paths are now stored in global variables instead of macros, and get modified with that new option. https://bugzilla.gnome.org/show_bug.cgi?id=698752
* core: add single-letter command-line flagsDan Winship2013-05-211-4/+4
| | | | | | | | Add single-letter options for --version, --no-daemon, --debug, and --pid-file (and document them, as well as the existing single-letter option for --help). https://bugzilla.gnome.org/show_bug.cgi?id=700550
* main: add --debug, fix logging under systemdDan Winship2013-05-211-2/+4
| | | | | | | | | | | | | | | When run with --no-daemon, NM used to duplicate all syslog output to stderr, for ease of debugging. But this meant it had to tell systemd to ignore stderr, so you wouldn't get duplicated log entries. But that meant we lost error messages that didn't go through nm_log. (eg, g_warning()s and g_return_if_fail()s). Fix this by making --no-daemon no longer duplicate syslog output to stderr, and removing the "StandardError=null" from the systemd service file. To get the old behavior, you can use --debug instead of --no-daemon. https://bugzilla.gnome.org/show_bug.cgi?id=700550
* main: make handling of --no-daemon saner by using G_OPTION_FLAG_REVERSEDDan Winship2013-05-211-5/+1
| | | | https://bugzilla.gnome.org/show_bug.cgi?id=700550
* core: add libgsystem as a git submoduleColin Walters2013-05-161-38/+12
| | | | | | | | | And change src/main.c to use the local allocation macros. This results in much cleaner code, as one can see from the diff. Because libgsystem is designed for nonrecursive make, it fits best in the current recursive setup if we build . first. This will be a lot nicer when we switch NM to a nonrecursive setup.
* platform: link managementPavel Šimerda2013-04-101-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Create the new nm-platform framework and implement link (or interface) management. The nm-platform serves as the point of contact between the rest of NetworkManager and the operating system. There are two backends for nm-platform: * NMFakePlatform: Fake kernel backend for testing purposes * NMLinuxPlatform: Linux kernel backend for actual use A comprehensive testsuite is included and will be extended with new feature additions. To enable the Linux part of the testsuite, use --enable-tests=root configure options and run 'make check' as root. Use --enable-code-coverage for code coverage support. ./autogen.sh --enable-tests=root --enable-code-coverage make make -C src/platform check-code-coverage Link features: * Retrieve the list of links * Translate between indexes and names * Discover device type * Add/remove dummy interfaces (for testing) Thanks to Thomas Graf for helping with libnl3 synchronization issues.
* core: add a root-only private D-Bus socketDan Williams2013-04-081-3/+12
| | | | | | | | | | | | | | For cases where NM may run without a bus daemon in root-only environments, like an initramfs. For disconnection, since private connection just get a disconnect message instead of NameOwnerChanged signals broadcast by a bus daemon, just synthesize the NameOwnerChanged signals using our fake owner name. It's just easier to do this rather than modify any code that cares about disconnects. Note that the new private socket is only enabled if built with dbus-glib >= 0.100 as there are bugs in previous versions in the implementation of dbus_g_proxy_new_for_peer() which clients must use to talk to the private socket.
* settings: don't pass config_path to NMSettings and settings pluginsDan Winship2013-04-031-3/+1
| | | | | They can just call nm_config_get() now to get the config, and nm_config_get_path() to get its path.
* core: remove some can't-happen checksDan Winship2013-04-031-25/+7
| | | | | | Most of the various nm_foo_manager_get/new() calls never return NULL, so just g_assert() that fact rather than logging a separate error message for each one.
* core: don't pass config data to NMDHCPManager and NMDnsManagerDan Winship2013-04-031-2/+2
| | | | | | | | | | | Rather than passing specific bits of data to NMDHCPManager and NMDnsManager, just let them call nm_config_get() and then get the data themselves. Also, remove the GError argument from nm_dhcp_manager_new(), since the function never returned NULL. This in turn means there is no longer any need for a distinction between nm_dhcp_manager_new() and nm_dhcp_manager_get(), so remove the former.
* config: move config-related command-line options into nm-config.cDan Winship2013-04-031-28/+2
| | | | | | Rather than having main.c parse them and then hand them all to nm_config_new(), just let nm-config provide its own GOptionEntry array to merge in with main's.
* Revert "trivial: remove nm-netlink-monitor.h from main"Pavel Šimerda2013-03-131-0/+1
| | | | | | This reverts commit 272335a2cf86f0c5dc4399960de528fcbe4d0547. Done by mistake. Sorry.
* trivial: remove nm-netlink-monitor.h from mainPavel Šimerda2013-03-131-1/+0
| | | | | | | | nm-netlink-monitor is deprecated and the only consumer that still uses it is nm-ip6-manager, which will start it on its own. Conflicts: src/main.c
* main: don't activate nm-netlink-monitorPavel Šimerda2013-03-131-4/+0
| | | | It will be activated by the first module that needs it.
* core: use Config object for connectivity checking parametersDan Williams2013-03-111-3/+0
|
* config: convert NMConfig to objectThomas Bechtold2013-03-111-1/+1
|
* core: remove remaining pre-2.32 GLib compat / deprecated usageDan Winship2013-02-261-11/+0
|
* all: remove pointless NULL checksDan Winship2013-02-131-6/+0
| | | | | | | | | | | g_malloc(), etc, never return NULL, by API contract. Likewise, by extension, no other glib function ever returns NULL due to lack of memory. So remove lots of unnecessary checks (the vast majority of which would have immediately crashed had they ever run anyway, since g_set_error(), g_warning(), and nm_log_*() all need to allocate memory). https://bugzilla.gnome.org/show_bug.cgi?id=693678
* core: remove unused SIGUSR1 handlingDan Williams2013-02-121-5/+0
|
* build: clean up dbus-glib checksDan Williams2013-01-301-6/+0
| | | | | dbus_glib_global_set_disable_legacy_property_access() was added in dbus-glib 0.88, and since we require 0.94 we can remove this check.
* Remove SIGSEGV/SIGFPE etc. handlingColin Walters2013-01-221-23/+0
| | | | | | | | | | | | | | | | | | | | | Modern operating systems come with systemwide "crash catching" facilities; for example, the Linux kernel can now pipe core dumps out to userspace, and programs like "systemd-coredump" and "abrt" record these. In this model, it's actively counterproductive for individual processes to catch SIGSEGV because: 1) Trying to unwind from inside the process after arbitrary corruption is destined to fail. 2) It hides the fact that a crash happened at all - my OS test framework wants to know if any process crashed, and I don't want to guess by running regexps against /var/log/Xorg.0.log or whatever. Signed-off-by: Colin Walters <walters@verbum.org> https://bugzilla.gnome.org/show_bug.cgi?id=692032
* policy: monitor connection activation/deactivation via the managerDan Williams2012-12-171-1/+1
| | | | Instead of through the VPN manager.