Commit graph

13336 commits

Author SHA1 Message Date
Thomas Haller da0ded4927 config: drop global-dns.enable option in favor of .config.enable
No longer support disabling the global-dns configuration via the
"enable" option.

Instead, the user can put the entire dns-configuration in one separate
snippet, and disable it altogether with ".config.enable".
2015-10-05 17:12:50 +02:00
Thomas Haller 7182304684 config: allow to enable/disable configuration snippets
Support a new configuration option

  [.config]
  enable=<ENABLED>

for configuration snippets.

This new [.config] section is only relevant within the snippet itself
and it is not merged into the combined configuration.

Currently only the "enable" key is supported. If the "enable" key is
missing, it obviously defaults to being enabled. It allows snippets
to be skipped from loading. The main configuration "NetworkManager.conf"
cannot be skipped.

<ENABLED> can be a boolean value (false), to skip a configuration
snippet from loading.
It can also be a string to match against the NetworkManager version,
like "enable=nm-version-min:1.1,nm-version-min:1.0.6"

There are several motivations for this:

- the user can disable an entire configuration snippet by toggeling
  one entry.
  This generalizes  the functionality of the global-dns.enable
  setting, but in a way that applies to configuration on a per-file
  basis.

- for developing, we often switch between different versions of
  NetworkManager. Thus, we might want to use different configuration.
  E.g. before global-dns options, I want to use "dns=none" and manage
  resolv.conf myself. Now, I can use global-dns setting to do that.
  That can be achieved with something like the following (not exactly,
  it's an example only):

      [.config]
      enable=nm-version-min:1.1
      [main]
      dns=default
      [global-dns-domain-*]
      nameserver=127.0.0.1

  Arguably, this would be more awesome, if we would bump our micro devel
  version (1.1.0) more often while developing 1.2.0 (*hint*).

- in principle, packages could drop configuration snippets and enable
  them based on the NetworkManager version.

- with the "env:" spec, you can enable/disable snippets by configuring
  an environment variable. Again, useful for testing and developing.
2015-10-05 17:12:50 +02:00
Thomas Haller 72ff5e8cac core: add nm_utils_ascii_str_to_bool()
This is effectively the same as nm_config_parse_boolean(). The difference is,
that "nm-config.c" is not available to the interface-helper, thus any
code used by interface-helper (like "NetworkManager.c") cannot use this
function.

Still don't drop nm_config_parse_boolean() entirely, because it's better
to have the explicit notion of parsing a string in the config-context.

I ended up not using the function. But I'd still keep this patch.
2015-10-05 17:12:50 +02:00
Thomas Haller ced1dcabef config/trivial: rename nm_config_get_device_match_spec() to nm_config_get_match_spec()
We want to use the term match-spec more generally and not only
for "device-specs".
2015-10-05 17:12:50 +02:00
Thomas Haller d5bfe04dea core: merge branch 'th/more-asserts'
Change NM_MORE_ASSERTS to allow for different levels for which
asserts are enabled.
2015-10-05 16:02:38 +02:00
Thomas Haller 3b6c1aa1a3 device: add assertion to consistency of nm_device_check_connection_available() 2015-10-05 15:58:51 +02:00
Thomas Haller 6395c829bb build: make NM_MORE_ASSERTS define numeric for different levels of more-asserts
Allows to enable more-asserts more granularly.

Unfortunately, the old check was "${enable_more_asserts} == "yes", thus
we cannot extend "--enable-more-assert=level" because that would mean
that the same build script cannot set the option on both old and new
NetworkManager.
Thus, add a new option --with-more-asserts=level. If you put the
following in your build script, it will work as expected whether
you build a new or an old version of NetworkManager.
  ./configure --enable-more-asserts --with-more-asserts=5
2015-10-05 15:25:54 +02:00
Thomas Haller 0907f3c21e build: include "config.h" in nm*enum-types.c sources
Also include the "config.h" file in the generated sources
like "nm-enum-types.c".
2015-10-05 15:01:38 +02:00
Thomas Haller 82c37e643b config: add missing include to "config.h" header 2015-10-05 15:01:38 +02:00
Thomas Haller 9358588a2a build: drop generating empty nm-*-enum-types for device plugins
The device plugins adsl, team and wifi were generating empty
"nm-*-enum-types" header and source files.
2015-10-05 15:01:38 +02:00
Thomas Haller bb9d4b0ad1 device: use _LOG() logging macros for per-device logging 2015-10-05 13:05:05 +02:00
Thomas Haller 6b40108418 libnm: use nm_clear_g_source() in nm-object.c 2015-10-03 18:12:11 +02:00
Thomas Haller b74574fb0d wifi: align logging AP dumps
There are several places where we log the APs. It looks
nicer in the log, if all use the same length prefix.
2015-10-03 15:39:53 +02:00
Thomas Haller f1aece753d wifi: fix alignment of logging strength in nm_ap_dump() 2015-10-03 15:38:58 +02:00
Beniamino Galvani 7c5518ac8d bus-manager: fix handling of incoming signals
The 'new-connection' signal of a GDBusServer is emitted by default
through an idle source and the actual message processing starts only
after a signal handler returns TRUE.

Thus, before the signal handler has the chance to run, the GDBus
worker thread may detect that the connection is closed and schedule
the delivery of the 'closed' signal through another idle source.

After the termination of the 'new-connection' handler, the 'closed'
handler is executed, which cancels the subscription to GDBus signals
before any message has been processed.

This looks like a bug in GDBusServer; to work around it, just delay
the close of connection to let the signal dispatch run first.

https://bugzilla.gnome.org/show_bug.cgi?id=755170
2015-10-03 09:51:32 +02:00
Thomas Haller 18b20c4f6f code: merge branch 'th/enslave-team-rh1183444'
https://bugzilla.redhat.com/show_bug.cgi?id=1183444
2015-10-02 18:48:29 +02:00
Thomas Haller 85ac903bb8 device: fix activating slave device when stage1 delays action
When activating for example a team device which is to be enslaved to a
bridge, nm_device_activate_stage1_device_prepare() will postpone
stage 2.

In that case, we didn't register the "master-ready" of the team
device and thus never progressed the slave from stage2.

Reproduce:

  # nmcli connection delete t-br0
  # nmcli connection delete t-team0
  nmcli connection add type bridge con-name t-br0   autoconnect no ifname i-br0 ip4 192.168.177.100/24 gw4 192.168.177.1
  nmcli connection add type team   con-name t-team0 autoconnect no ifname i-team0
  nmcli connection modify id t-team0 connection.master i-br0 connection.slave-type bridge
  nmcli connection up t-team0
2015-10-02 18:45:39 +02:00
Thomas Haller e427d32ec3 device: use nm_clear_g_signal_handler() to clear master-ready signal handler 2015-10-02 16:42:44 +02:00
Thomas Haller c98c7a486c macros: add nm_clear_g_signal_handler() helper 2015-10-02 16:42:44 +02:00
Jiří Klimeš 6f9a7a8daa config: initialize gs_free marked variable
Otherwise I get the following error (iwhile building in Jenkins):

In file included from ../include/nm-default.h:45:0,
                 from nm-config.c:27:
nm-config.c: In function 'nm_config_set_global_dns':
../include/gsystem-local-alloc.h:31:10: error: 'group_name' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     func (*(Type*)v); \
          ^
nm-config.c:1483:17: note: 'group_name' was declared here
   gs_free char *group_name;
                 ^
2015-10-02 10:03:03 +02:00
Jiří Klimeš 956577a246 wifi: emit NEW_BSS on ScanDone to update APs in Wi-Fi device (rh #1267327)
When a Wi-Fi is switched to AP mode, NMDeviceWifi forgets the AP scan list.
Later, when the device goes back to normal managed mode, the device was not
able to acquire the AP list again (for a long time), because the list is only
populated when a new BSS is signalled. And that could take very long or never
happen as the supplicant would have to lost the BSS and announce it later.

Fix the problem by announcing known BSSs as a response to ScanDone signal.

Testcase:
$ nmcli con add type wifi ifname wlan0 con-name my-wifi-ap autoconnect off ssid MYSSID
$ nmcli con modify my-wifi-ap wifi.mode ap ipv4.method shared
$ nmcli con up my-wifi-ap
$ nmcli con down my-wifi-ap
$ nmcli device wifi list

https://bugzilla.redhat.com/show_bug.cgi?id=1267327
2015-10-02 09:45:15 +02:00
Jiří Klimeš 984714333f supplicant: fix BSSs property type
BSSs property is an array of object paths, not strings.
2015-10-02 09:36:09 +02:00
Lubomir Rintel b1512221bc nm-vpn-service-plugin: increase the quit timer
We now (since 3272ff6 libnm/libnm-glib: don't quit in the middle of asking for
secrets) always hook on the quit timer when NM asks the plugin if it needs
secrets. The timer is 20 seconds, which seems too short.

Let's make it three minutes. Don't bother adding another timer or using a
distinct timeout: it does no harm for the plugin to remain unused for three
minutes on a bus.

Another option would be to completely unhook it; however the plugin wouldn't
learn if the user cancelled the NM's secrets request and would remain unused
on the bus forever.
2015-10-01 17:17:52 +02:00
Lubomir Rintel d4a7645865 nm-config: drop a glib 2.40-ism
Fixes: ae9e82354a
2015-10-01 10:10:58 +02:00
Beniamino Galvani f04b27bd1f core: merge branch 'bg/global-dns-conf-bgo750458'
Add support for a global DNS configuration read from user
configuration file or set through D-Bus.

https://bugzilla.gnome.org/show_bug.cgi?id=750458
2015-10-01 09:21:32 +02:00
Beniamino Galvani c83ac1ed41 manager: export DNS global configuration D-Bus property 2015-10-01 09:05:08 +02:00
Beniamino Galvani dd6fbe7bfa man: document global DNS configuration sections 2015-10-01 09:05:08 +02:00
Beniamino Galvani ae9e82354a dns: add support for global configuration in DNS manager
Modify the DNS manager to use the static global DNS configuration when
available. In addition, change DNS plugins interface to accept a new
argument for global configuration and add support for this new
parameter to the dnsmasq plugin.
2015-10-01 09:05:08 +02:00
Beniamino Galvani 55c204b9a3 core: add support for reading global DNS configuration from keyfile
Add to the NMConfigData object information about global DNS
configuration, which is loaded from user or internal keyfile upon
object construction.
2015-10-01 09:05:08 +02:00
Beniamino Galvani bd27c110a3 glib-compat: add g_hash_table_get_keys_as_array() compat function 2015-10-01 09:05:08 +02:00
Thomas Haller 804ec6fbcd contrib/rpm: remove dbus-glib dependancy
Only libnm-glib still requires dbus-glib.
2015-09-30 23:10:56 +02:00
Thomas Haller 7bf10a75db build: extract version macros from "nm-version.h" to new header file "nm-version-macros.h"
For libnm library, "nm-dbus-interface.h" contains defines like the D-Bus
paths of NetworkManager. It is desirable to have this header usable without
having a dependency on "glib.h", for example for a QT application. For that,
commit c0852964a8 removed that dependancy.

For libnm-glib library, the analog to "nm-dbus-interface.h" is
"NetworkManager.h", and the same applies there. Commit
159e827a72 removed that include.
However, that broke build on PackageKit [1] which expected to get the
version macros by including "NetworkManager.h". So at least for libnm-glib,
we need to preserve old behavior so that a user including
"NetworkManager.h" gets the version macros, but not "glib.h".

Extract the version macros to a new header file "nm-version-macros.h".
This header doesn't include "glib.h" and can be included from
"NetworkManager.h". This gives as previous behavior and a glib-free
include.

For libnm we still don't include "nm-version-macros.h" to "nm-dbus-interface.h".
Very few users will actually need the version macros, but not using
libnm.
Users that use libnm, should just include (libnm's) "NetworkManager.h" to
get all headers.
As a special case, a user who doesn't want to use glib/libnm, but still
needs both "nm-dbus-interface.h" and "nm-version-macros.h", can include
them both separately.

[1] https://github.com/hughsie/PackageKit/issues/85

Fixes: 4545a7fe96
2015-09-30 23:10:29 +02:00
Thomas Haller b861900d45 tui: fix crash during activation when failed to create secret-agent
NetworkManager only allows one 'client:user-id' to register as secret
agent. Thus, when starting nmtui in two terminals, creating the secret
agent can fail.

This can lead to a crash.

https://bugzilla.gnome.org/show_bug.cgi?id=755883
2015-09-30 17:33:01 +02:00
Lubomir Rintel 4fe86b0031 dnsmasq-manager: forget the watch when the callback hits
It removes the source, we shouldn't try to remove it on dispose() then.
2015-09-30 16:35:33 +02:00
Lubomir Rintel bde246d30b bus-manager: only unregister skeletons if they were actually registered 2015-09-30 16:35:32 +02:00
Lubomir Rintel 30a0c3164c firewall-manager: handle bus connection failure 2015-09-30 16:02:48 +02:00
Thomas Haller a9b1869d63 all: use glib compatibility functions for g_hash_table_add() and g_hash_table_insert() 2015-09-30 14:12:25 +02:00
Thomas Haller 261dff429e glib-compat: add compatibility function for g_hash_table_insert() and g_hash_table_add()
They have a different name, because we don't want to do the
extra work unless explicitly requested.
2015-09-30 14:11:47 +02:00
Lubomir Rintel df27e6d5fd build: add .travis.yml 2015-09-30 13:43:03 +02:00
Lubomir Rintel 36e5c0a821 all: g_hash_table_add doesn't return a value before 2.40 2015-09-30 13:43:03 +02:00
Lubomir Rintel 3227778d89 manager: fix a reversed conditional
find_ac_for_connection() needs the uuid when the connection is not a
NMSettingConnection.

Fixes: 06da353242
2015-09-30 12:14:02 +02:00
Lubomir Rintel e0fa48f224 vpn-connection: set the MTU for the VPN IP interface
The 9b79e6c73 commit moved setting of the MTU from IP4Config to NMDevice, but
VPN connections don't have a NMDevice instance (yet). Set the MTU also from the
VPN connection. Also, copying of the MTU to the IP4Config is no longer needed
as the ip4_config_commit no longer sets the MTU.

Fixes: 9b79e6c732

https://bugzilla.gnome.org/show_bug.cgi?id=754781
2015-09-29 18:24:48 +02:00
Lubomir Rintel 8b0bb7a022 firewall-manager: avoid leaving dangling request if firewalld is not running
Unhook it prior to deallocation. Fixes an assertion on daemon shutdown:

  NetworkManager[30037]: <info>  exiting (success)
  **
  NetworkManager:ERROR:nm-firewall-manager.c:489:dispose: assertion failed: (g_hash_table_size (priv->pending_calls) == 0)
  Aborted (core dumped)

Fixes: 94f888a262
2015-09-29 14:10:47 +02:00
Lubomir Rintel b38bc15747 build: set -Werror when checking whether a -W<warning> option works
Otherwise the check is effectively a no-op and unknown options still get
turned on. This results in unknown warnings when build without
--with-extra-warnings=error:

  warning: unknown warning option '-Wno-unused-but-set-variable'; did you mean '-Wno-unused-const-variable'? [-Wunknown-warning-option]
2015-09-29 14:08:14 +02:00
Jiří Klimeš edec77fba4 merge: S390 subchannels improvements (bgo #755610)
- export device's S390 subchannels on D-Bus
- update 390 subchannels comparison for connection vs.device compatibility
- support s390 subchannels in libnm and nmcli

https://bugzilla.gnome.org/show_bug.cgi?id=755610
2015-09-29 09:41:45 +02:00
Jiří Klimeš 82e4364480 tests: add a test for connection_compatible() for wired devices
Allow setting MAC address and S390 subchannels for ethernet devices in
testing NM service.
2015-09-29 09:31:41 +02:00
Jiří Klimeš e7ed259fdc cli: print s390 subchannels for devices that have that 2015-09-29 09:31:41 +02:00
Jiří Klimeš 9abe74d98e libnm: match s390 subchannels and MAC blacklist in connection_compatible()
Basically, make it the same as check_connection_compatible()
in src/devices/nm-device-ethernet.c
2015-09-29 09:31:25 +02:00
Jiří Klimeš bbaca1b24e libnm: add 390-subchannels property to NMDeviceEthernet 2015-09-29 09:31:25 +02:00
Jiří Klimeš 4219aa9a56 device: export S390Subchannels property on Ethernet device
and update match_subchans() to compare number of subchannels too.
2015-09-29 09:30:01 +02:00