Commit graph

90 commits

Author SHA1 Message Date
Pavel Šimerda
fed36d13b6 cleanup: remove unused header 2013-05-24 20:58:07 +02:00
Pavel Šimerda
5074898591 core: use nm-platform for link management 2013-05-24 19:14:50 +02:00
Martin Pitt
fd4709fa27 core: add option for running from the build tree
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
2013-05-22 16:17:23 +02:00
Dan Winship
a05941881e core: add single-letter command-line flags
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
2013-05-21 09:30:09 -03:00
Dan Winship
8d44136dce main: add --debug, fix logging under systemd
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
2013-05-21 09:30:09 -03:00
Dan Winship
7ff3d1500e main: make handling of --no-daemon saner by using G_OPTION_FLAG_REVERSED
https://bugzilla.gnome.org/show_bug.cgi?id=700550
2013-05-21 09:30:09 -03:00
Colin Walters
468c08511c core: add libgsystem as a git submodule
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.
2013-05-16 14:08:09 -05:00
Pavel Šimerda
15fd7cd75e platform: link management
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.
2013-04-10 16:40:58 +02:00
Dan Williams
c9335a497b core: add a root-only private D-Bus socket
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.
2013-04-08 10:55:37 -05:00
Dan Winship
b3e8361f0f settings: don't pass config_path to NMSettings and settings plugins
They can just call nm_config_get() now to get the config, and
nm_config_get_path() to get its path.
2013-04-03 10:23:48 -04:00
Dan Winship
26de9db14b core: remove some can't-happen checks
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.
2013-04-03 10:23:48 -04:00
Dan Winship
213a3a4d2e core: don't pass config data to NMDHCPManager and NMDnsManager
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.
2013-04-03 10:23:48 -04:00
Dan Winship
3407726758 config: move config-related command-line options into nm-config.c
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.
2013-04-03 10:23:47 -04:00
Pavel Šimerda
a290c5c3a6 Revert "trivial: remove nm-netlink-monitor.h from main"
This reverts commit 272335a2cf.

Done by mistake. Sorry.
2013-03-13 23:52:14 +01:00
Pavel Šimerda
272335a2cf trivial: remove nm-netlink-monitor.h from main
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
2013-03-13 23:08:06 +01:00
Pavel Šimerda
fa86a377a0 main: don't activate nm-netlink-monitor
It will be activated by the first module that needs it.
2013-03-13 22:15:37 +01:00
Dan Williams
875c1af2fd core: use Config object for connectivity checking parameters 2013-03-11 14:45:12 -05:00
Thomas Bechtold
c910a52241 config: convert NMConfig to object 2013-03-11 14:43:24 -05:00
Dan Winship
be89197214 core: remove remaining pre-2.32 GLib compat / deprecated usage 2013-02-26 13:07:33 +01:00
Dan Winship
d04f286327 all: remove pointless NULL checks
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
2013-02-13 13:38:13 -05:00
Dan Williams
4973da78e4 core: remove unused SIGUSR1 handling 2013-02-12 15:41:52 -06:00
Dan Williams
7491198138 build: clean up dbus-glib checks
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.
2013-01-30 11:19:15 -06:00
Colin Walters
ae627737d5 Remove SIGSEGV/SIGFPE etc. handling
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
2013-01-22 12:49:48 -05:00
Dan Williams
f8f1a131f5 policy: monitor connection activation/deactivation via the manager
Instead of through the VPN manager.
2012-12-17 17:01:10 -06:00
Jiří Klimeš
e7add58aad main: ensure NMSTATEDIR exists (bgo #689744)
For OSTree/gnome-ostree, the model chosen for /var is that services
are responsible for creating any data they need in /var at runtime.

Call g_mkdir_with_parents() to ensure NMSTATEDIR exists.

https://bugzilla.gnome.org/show_bug.cgi?id=689744

Based on Colin Walters' patch.
2012-12-06 16:51:17 +01:00
Pavel Šimerda
d82669d3fd build: unify NetworkManager path handling (some paths are changed)
Use autoconf/automake variables for NetworkManager paths. Use
NetworkManager subdirectory where appropriate.

Files in /var/run (or /run on some distros) are moved into a separate
directory as is usual with other daemons. It makes the filesystem
more readable and file prefixing unnecessary.

/var/run/NetworkManager.pid -> /var/run/NetworkManager/NetworkManager.pid
/var/run/nm-dns-dnsmasq.pid -> /var/run/NetworkManager/dnsmasq.pid
/var/run/nm-dns-dnsmasq.conf -> /var/run/NetworkManager/dnsmasq.conf

The /var/run/NetworkManager directory is created at runtime, if it doesn't
exist.

Note: Path-based security policies like SELinux and AppArmor may need to
be adapted.
2012-11-05 14:01:47 +01:00
Colin Walters
fed48417c3 Revert "core: import libgsystem, use it for local-allocations in main.c (bgo #685440)"
This reverts commit 89623b99c4 pending
further discussion.

See: https://mail.gnome.org/archives/networkmanager-list/2012-October/msg00065.html
2012-10-23 16:40:46 -05:00
Colin Walters
89623b99c4 core: import libgsystem, use it for local-allocations in main.c (bgo #685440)
See http://git.gnome.org/browse/libgsystem/tree/README
for a description of libgsystem.

What we specifically are using it for here is the local allocation
macros; this patch just modifies main.c as a demo.

Note this patch fixes a double-free in an error condition in
check_pidfile(); those sort of mistakes are basically impossible
to make when using these macros.
2012-10-16 12:08:03 -05:00
Pavel Šimerda
3efc2c4b9d distro: remove nm_backend_enable_loopback()
We don't need to use distribution-specific network scripts to just bring
up the loopback interface.

I'm not aware of any init dependency problems but even if there are some,
it is more practical to solve them in the respective configuration files.

This function also tried to add 127.0.0.1 to the list of addresses but
not ::1. We don't need to set the interfaces up as this is done by the
kernel.
2012-09-25 16:44:12 -05:00
Alexandre Rostovtsev
64342a313e core: wait until we daemonized before setting up signals (bgo #683932)
If we mask signals before daemonizing, the daemon process will not be
able to handle them, and thus would be unkillable with anything other
than SIGKILL.
2012-09-17 14:47:06 +02:00
Jiří Klimeš
173b458da9 core: describe arguments for --connectivity-* options 2012-07-09 16:21:11 +02:00
Jiří Klimeš
d73f11aefa core: mark cmd options for translation 2012-07-09 16:21:11 +02:00
Jiří Klimeš
78dda3b093 core: unblock signals for child processes we spawn out of NM (rh #739836)
Commit 217c5bf6ac fixed processing of unix
signals: signals are blocked in all threads and a dedicated thread handles the
signals using sigwait().
However, the commit forgot that child processes inherit signal mask as well.
That is why we have to unblock signals for child processes we spawn from NM, so
that they can receive signals.
2012-05-21 15:00:51 +02:00
Pantelis Koukousoulas
d125296eb1 adsl: initial PPPoE support for ADSL devices 2012-05-18 15:42:56 -05:00
Dan Williams
8ed02c3039 core: log whether WEXT is enabled or not (bgo #674650)
Now that we've encountered this twice with distros disabling WEXT
but apparently not realizing it kills staging and out-of-kernel
drivers like wl.o, make it a log message so we don't have to go
hunting for build-time logfiles.
2012-04-26 13:40:07 -05:00
Jiří Klimeš
217c5bf6ac core: improve handling of POSIX signals using sigwait() (rh #739836)
There are multiple ways how to handle standard unix signals. They work quite
well for a single-threaded application. However, signal handling in a multi-
threaded app becomes tricky. And, the most safe way is to use sigwait() function
in a dedicated thread, which allows us to process the signals synchronously and
thus avoid various nasty problems.

A few useful links:
http://pubs.opengroup.org/onlinepubs/007904975/functions/sigwait.html
http://pic.dhe.ibm.com/infocenter/aix/v6r1/index.jsp?topic=%2Fcom.ibm.aix.genprogc%2Fdoc%2Fgenprogc%2Fsignal_mgmt.htm
http://www.linuxjournal.com/article/2121?page=0,2
http://www.redwoodsoft.com/~dru/unixbook/book.chinaunix.net/special/ebook/addisonWesley/APUE2/0201433079/ch12lev1sec8.html
2012-04-17 15:29:10 +02:00
Thomas Bechtold
267bc993a7 core: add internet connectivity check
* use libsoup to compare a http response from a given
  uri with a given response (use g_str_has_prefix () to compare)
* do periodically check the connectivity. Check interval is configurable
* check connectivity when device state change
  from/to NM_DEVICE_STATE_ACTIVATED
2012-02-27 10:56:51 -06:00
Jiří Klimeš
f4da4f5523 trivial: fix spelling 2012-01-17 16:26:30 +01:00
Jiří Klimeš
87a2030a43 core: fix translations - use NULL instead of "" (else odd translation appears) 2012-01-17 16:18:43 +01:00
Gabor Kelemen
3b00919b7a core: mark strings for translation (bgo #666652) 2012-01-17 15:53:16 +01:00
Gabor Kelemen
d3c1383b4e core: fix domain for g_option_context_set_translation_domain() (bgo #666652) 2012-01-17 15:51:28 +01:00
Gabor Kelemen
48852e112e core: setlocale(), so that locale's env variables are honored (bgo #666516) 2012-01-17 15:17:06 +01:00
Dan Williams
b2eaf7228e firewall: add firewall log domain and use it in firewall code 2011-12-06 16:51:17 -06:00
Dan Williams
c1344ec097 trivial: small cleanup checking error 2011-12-05 12:14:40 -06:00
Dan Williams
2ade420479 netlink: consolidate netlink monitor error handling and initialization
The fact that any of this code was in main.c was a hangover from
a long time ago and it should really go with the rest of the
netlink monitor code.
2011-12-03 17:38:07 -06:00
Dan Williams
2ea0f3e9c2 backends: clean them up somewhat
Put the two functions they provide into their own header so
places that need them don't have to include nm-system.h.
2011-11-17 18:55:07 -06:00
Jiri Popelka
1c0aeb4575 firewall: add firewall manager
src/firewall-manager tracks whether firewall is on the bus or not.
In nm-device.c at stage5 (ip-config-commit) before we actually
apply the IP configuration to the interface, we send the
IP interface name and zone to firewall and asynchronously wait
for a D-Bus reply.  Then after we get the reply
(or if the firewall isn't running) we proceed with
applying the IP configuration to the interface.
2011-11-09 22:02:02 -06:00
Jiří Klimeš
4d1d3b9935 core: fix building for GLib thread API changes (GLib >= 2.31.0) (bgo #662695) 2011-10-31 15:30:02 +01:00
Jiří Klimeš
3e79f06566 trivial: remove unwanted exclamation mark to fix compilation 2011-10-03 15:54:25 +02:00
Thomas Bechtold
ab7a8fcf98 core: improve config error handling
* better error messages
  * fix memory leak in parse_state_file ()
  * create intermediate parent directories as needed for state file
2011-10-03 00:46:37 -05:00