Commit Graph

15047 Commits

Author SHA1 Message Date
Beniamino Galvani
d385a2a57a settings: remove hostname handling from plugins
Remove all hostname-related code from plugins since this functionality
has been moved to the core.
2015-06-12 15:59:39 +02:00
Beniamino Galvani
6c3d71c431 core: move handling of hostname from plugins to core
How to write and read the machine hostname is something that has been
handled until now by plugins; this is questionable since the method
using for storing the hostname should depend only on the distro used
and not on which plugins are enabled.

This commit moves all hostname-related functions from plugins to the
core and allows to specify the method used to load and store the
hostname at build time with the

  --with-hostname-persist=default|suse|gentoo

configure option.

'default' method stores the hostname to /etc/hostname and monitors it
to detect runtime changes.

When the selected method is 'suse', the hostname gets read from and
written to /etc/HOSTNAME; the file /etc/sysconfig/network/dhcp is also
read to detect if the hostname is dynamic and thus invalid. Both files
are monitored for changes.

'gentoo' method relies on /etc/conf.d/hostname for storing the
hostname.
2015-06-12 15:59:39 +02:00
Beniamino Galvani
fb304bc6b9 build: link core against SELinux
Some functions that rely on SELinux support are going to be moved from
plugins to core. Enable linking against the library.
2015-06-12 15:59:39 +02:00
Thomas Haller
ef4e017cfa libnm/utils: add _nm_utils_strv_find_first() function 2015-06-11 19:58:51 +02:00
Thomas Haller
176b13374a gitignore: ignore temporary files during build
If you type `git status` a certain times during build,
you see some temporary (untracked) files. Ignore them.
2015-06-11 13:45:37 +02:00
Jiří Klimeš
631f5b1e5c cli: use color names when TAB-completing "nmcli prompt-color" 2015-06-11 10:01:47 +02:00
Jiří Klimeš
3641ddb00a cli: take color name arguments for "nmcli prompt-color" in editor (bgo #744936)
Adjust nmcli prompt-color description and make it more friendly for
translators.

nmcli> nmcli prompt-color green

https://bugzilla.gnome.org/show_bug.cgi?id=744936
2015-06-11 10:00:54 +02:00
Thomas Haller
5eba53cd53 cli: fix metered to string property
nmc_property_connection_get_metered() must return non-localized strings
that can be parsed by nmc_property_connection_set_metered().

Fixes: f0aebfd746
2015-06-10 11:49:46 +02:00
Jiří Klimeš
94a393e9ed all: fix a compiler warning about function declarations
warning: function declaration isn’t a prototype [-Wstrict-prototypes]

In C function() and function(void) are two different prototypes (as opposed to
C++).
function()     accepts an arbitrary number of arguments
function(void) accepts zero arguments
2015-06-10 10:01:49 +02:00
Jiří Klimeš
036901b82e xml: (trivial) fix a typo 2015-06-10 09:34:58 +02:00
Beniamino Galvani
7d09debdf0 merge branch 'bg/metered-connections-bgo741725'
Expose information about whether a connection is metered and use some
heuristics to choose a reasonable default when the value is not
configured.

https://bugzilla.gnome.org/show_bug.cgi?id=741725
https://bugzilla.redhat.com/show_bug.cgi?id=1200452
2015-06-09 22:15:26 +02:00
Beniamino Galvani
04d5804dd5 nm-manager: add 'metered' property
This introduces a global metered property which makes easier for
clients to obtain the metered status of the current primary
connection.
2015-06-09 18:23:19 +02:00
Beniamino Galvani
bd4e1f37f8 cli: fix error message localization
Valid values must not be translated in error messages generated in
nmc_string_to_bool() and nmc_string_to_tristate().
2015-06-09 18:23:12 +02:00
Beniamino Galvani
7e5e624daf ifcfg-rh: add support for CONNECTION_METERED 2015-06-09 18:18:45 +02:00
Beniamino Galvani
862fd91df0 ifcfg-rh: change type of svTrueValue() return value and argument
Change type of return value and 'def' argument of svTrueValue() to
gint to make clear that it can be something different from TRUE and
FALSE.
2015-06-09 18:18:45 +02:00
Beniamino Galvani
a86255a043 core: update device 'metered' property on connection state change
The metered property of a NMDevice that reaches the activated state is
copied from the active connection and if its value is 'unknown' some
heuristics are used to guess the actual value.

When the connection is torn down the metered property is reset to
'unknown'.
2015-06-09 18:18:45 +02:00
Beniamino Galvani
1e39b2320d dhcp: detect NMIP4Config 'metered' flag based on ANDROID_METERED DHCP option
Some versions of Android's DHCP server send option 43 (Vendor specific
information) with value "ANDROID_METERED" in Wi-Fi hotspot mode.

Mark the NMIP4Config as metered when such option is received.
2015-06-09 18:18:45 +02:00
Beniamino Galvani
3c2f4a17f9 systemd/dhcp: add support for vendor specific DHCP option
This adds support for DHCP option 43 (Vendor Specific Information) to
the internal DHCP client. The option carries an opaque object of n
octets, interpreted by vendor-specific code on the clients and
servers.
2015-06-09 18:18:45 +02:00
Beniamino Galvani
68db65b727 core: add 'metered' flag to NMIP4Config
Some DHCP servers send specific options to give a hint that clients
should avoid unneeded data usage.

Add a metered flag to NMIP4Config to keep track of this information.
2015-06-09 18:18:45 +02:00
Beniamino Galvani
f0aebfd746 cli: add support for 'metered' connection property 2015-06-09 18:15:20 +02:00
Beniamino Galvani
609f4f37c0 cli: add nmc_string_to_tristate() 2015-06-09 18:11:25 +02:00
Beniamino Galvani
6f647fe689 libnm-core: add 'metered' property to NMSettingConnection
Add a 'metered' enum property to NMSettingConnection with possible
values: unknown,yes,no. The value indicates the presence of limitations
in the amount of traffic flowing through the connection.
2015-06-09 18:11:25 +02:00
Beniamino Galvani
f208e7030f cli: add 'metered' property to device 2015-06-09 18:11:25 +02:00
Beniamino Galvani
bbbf522941 core,libnm: add 'metered' property to NMDevice 2015-06-09 18:11:25 +02:00
Thomas Haller
acef8c6a1b contrib/rpm: let NetworkManager package own '/etc/NetworkManager/' directory 2015-06-08 17:48:33 +02:00
Thomas Haller
d38c3851f8 platform: merge branch 'th/platform_refact_caching-bgo747981' (early part)
- add new file 'nm-platform-utils.c' and moves some independent utility
  functions there (ethtool, udev).
- some refactoring of platform code, including initialization of
  NMPlatform instance.
- run platform tests in a separate user namespace, which allow
  us to run root-tests as non-root.

https://bugzilla.gnome.org/show_bug.cgi?id=747981
2015-06-05 16:54:06 +02:00
Thomas Haller
d4f828c887 platform: expose nm_platform_signal_change_type_to_string() 2015-06-05 16:52:50 +02:00
Thomas Haller
2f3fd86dc5 platform: refactor support_kernel_extended_ifa_flags to static variable
Whether we have support depends on the kernel, and is not
per NMLinuxPlatform instance.
2015-06-05 16:52:50 +02:00
Thomas Haller
95333d84bc platform: move ethtool_get_link_speed() to nm-platform-utils 2015-06-05 16:52:50 +02:00
Thomas Haller
299af02e40 platform: move supports_mii_carrier_detect() to nmp_utils_mii_supports_carrier_detect() 2015-06-05 16:52:50 +02:00
Thomas Haller
ac84b22fc7 platform: move ethtool_*() to nmp_utils_ethtool_*() 2015-06-05 16:52:50 +02:00
Thomas Haller
398819c3ac platform: factor out ethtool_get_wake_on_lan() function 2015-06-05 16:52:50 +02:00
Thomas Haller
ba084b5b90 platform: factor out ethtool_get_peer_ifindex() function 2015-06-05 16:52:50 +02:00
Thomas Haller
4be9394864 platform: factor out ethtool_supports_vlans() function 2015-06-05 16:52:50 +02:00
Thomas Haller
2b8f3331d7 platform/trivial: move ethtool_supports_carrier_detect() code 2015-06-05 16:52:50 +02:00
Thomas Haller
77a3767d1e platform: move code udev_get_driver() to nmp_utils_udev_get_driver() 2015-06-05 16:52:50 +02:00
Thomas Haller
ce700d94f5 platform: add nm-platform-utils.[ch] files
There is no general purpose file for platform utilities.
We only have nm-platform.h, which contains (mostly) functions
that operate on a NMPlatform instance (and that can be mocked
using NMFakePlatform).

Add a new file for independent utility functions. nm-platform-utils.c
should not call into functions having a NMPlatform instance, to
have them independent from platform caching and the platform
singleton.
2015-06-05 16:52:50 +02:00
Thomas Haller
d7a312d17a platform: move nm_platform_query_devices() to nm-manager
nm_platform_query_devices() would raise an 'added' signal
for all its links. That is bad style because it could
confuse other listeners for platform signals which don't
expect such artificial change signals.

The public API of NMPlatform already gives NMManager the ability
to 'pull' all the links and iterate them itself.

Before, nm_platform_query_devices() would also initialize udev
devices, so there was a more compelling reason for this function.
2015-06-05 16:52:50 +02:00
Thomas Haller
d6ce01f115 platform: merge setup_devices() function into constructed()
We already populate the netlink cache in constructed(). No need
to wait with udev devices until nm_platform_query_devices(). Just
do it right away.

Add a hack to keep 'lo' default-unmanaged. Now that we load
udev devices earlier, we end up clearing the default-unmanged
flag on 'lo', which has bad consequences.
2015-06-05 16:52:49 +02:00
Lubomir Rintel
ed01c975d8 tests: use a user ns to fake root 2015-06-05 16:52:49 +02:00
Lubomir Rintel
f9dd7f0d84 tests: allow running the link test without a writeable sysfs
This fixes the test run in a container/our NETNS/NEWUSER test jail.
2015-06-05 16:52:49 +02:00
Thomas Haller
39f2b51abb core: add option to suppress error logging if nm_utils_modprobe() fails
We don't want error logging for nm_platform_link_add() which
tries to load the bonding module. Later we will run tests as non-root,
where modprobe will fail. Logging an error would break the tests.
2015-06-05 16:52:49 +02:00
Thomas Haller
57958b93b6 utils: add NM_FLAGS_SET(), NM_FLAGS_UNSET() and NM_FLAGS_ASSIGN() macros 2015-06-05 16:52:49 +02:00
Thomas Haller
fe3e1849b7 core: make nm_assert() always compile condition
Even if asserts are not enabled, still let the compiler see what we would
assert. Otherwise, we get warnings about unused variables or we migth miss
compile errors inside nm_assert().
2015-06-05 16:52:49 +02:00
Lubomir Rintel
ce2ea51ed0 Revert "core: avoid loading GIO modules"
This reverts commit 6a841c0cd1.

We do actually need the modules for connectivity checking.
2015-06-05 16:04:27 +02:00
Thomas Haller
18ecf48d7a merge branch 'th/connection-defaults-bgo695383'
- support new [connection] section in NetworkManager.conf
- allow configuring a default value for ipvx.route-metric
- allow configuring a default value for ipv6.ip6-privacy
  and read the fallback configuration from sysctl.

https://bugzilla.gnome.org/show_bug.cgi?id=695383
https://bugzilla.gnome.org/show_bug.cgi?id=721200
https://bugzilla.redhat.com/show_bug.cgi?id=1187525
2015-06-05 12:52:52 +02:00
Thomas Haller
f3c61f8141 device: remove reading ipv6 privacy setting from sysctl
Since introduction for support of ip6-privacy (use_tempaddr,
RFC4941) with commit d376270bfe,
the sysctl value from /etc was always read first.

This is problematic, because an explicit setting in the
connection should not be ignored over a global configuration.

Drop that old behavior. It was also problematic, because we did
not read any files under /etc/sysctl.d (except for sysctl.conf).
Also, we did not honor per-interface configurations.

Now we also use as last fallback the value from
/proc/sys/net/ipv6/conf/default/use_tempaddr
That has the advantage of falling back to the system default value
so that NM doesn't need to have it's own default policy
(Related: https://bugzilla.redhat.com/show_bug.cgi?id=1187525).

This is a change in behavior.
2015-06-05 12:38:30 +02:00
Thomas Haller
e729dd70ae device: add global configuration default for ip6-privacy (use_tempaddr, RFC4941)
Support default value for setting 'ipv6.ip6-privacy' in
NetworkManager.conf.

If the global value is unset, preserve old behavior of looking into
/etc/sycctl.conf first. That behavior was introduced with commit
d376270bfe, since we support ip6-privacy
setting.

If the global value is set to "unknown", add a new fallback
that instead reads the runtime value from
  "/proc/sys/net/ipv6/conf/default/use_tempaddr"
This seems more sensible behavior because we fallback to sysctl,
but instead of looking at static files in /etc, read /proc.
But to preserve the old behavior, we only do that when a global
value is configured at all.

https://bugzilla.gnome.org/show_bug.cgi?id=721200
2015-06-05 12:38:30 +02:00
Thomas Haller
e4293788fc libnm/doc: document behavior of setting ip6-privacy in /etc/sysctl.conf
https://bugzilla.gnome.org/show_bug.cgi?id=721200
2015-06-05 12:38:30 +02:00
Thomas Haller
59a991725a device: make route-metric configurable per-device
The route-metric can be configured per connection via the
ipv4.route-metric and ipv6.route-metric fields. When the
value is left at -1 (the default), we would determine the
route-metric based on the device type (nm_device_get_priority()).

Extend that scheme by making the default value overwritable in
NetworkManager.conf.
2015-06-05 12:38:30 +02:00