Commit graph

15675 commits

Author SHA1 Message Date
Jiří Klimeš
ebfa947e83 cli: enable bash completion for some more properties of add/modify
connection.interface-name
mavclan.tap
mavclan.parent
ip-tunnel.parent
vxlan.parent

(cherry picked from commit c2ef397867)
2016-09-19 17:05:11 +02:00
Jiří Klimeš
68be811f81 cli: fix completion/add missing functions for '--complete-args' (rh #1375933)
This makes bash completion work again for 'nmcli connection add'.

Fixes: 8b39090597

https://bugzilla.redhat.com/show_bug.cgi?id=1375933
(cherry picked from commit 61a56aa3db)
2016-09-19 17:05:10 +02:00
Jiří Klimeš
9d88543617 cli: (trivial) move gen_func_ifnames() from devices.c to common.c
and rename it to nmc_rl_gen_func()

(cherry picked from commit 1f0ba2e487)
2016-09-19 17:05:08 +02:00
Jiří Klimeš
5984bdd895 cli: (trivial): remove stray %s
(cherry picked from commit 4b90b7b774)
2016-09-19 17:05:07 +02:00
Beniamino Galvani
b0463880fc manager: emit device-removed signal when a device unrealizes
The 'device-added' and 'device-removed' signals indicate when the
value of the 'Devices' property changes. The property only returns
realized devices and so if a device unrealizes we should emit the
removed signal for it.

Fixes: 5da37a129c

https://bugzilla.gnome.org/show_bug.cgi?id=771324
(cherry picked from commit cdedd2b53e)
2016-09-16 16:29:05 +02:00
Beniamino Galvani
dbb67694cb device: fix crash reapplying connection to slave devices
Slave devices don't have IPv4 and IPv6 configuration and so special
care must be taken when comparing their methods.

https://bugzilla.redhat.com/show_bug.cgi?id=1376446
(cherry picked from commit 8f92ead6e2)
2016-09-16 14:23:11 +02:00
Beniamino Galvani
5dfb3ec72c clients: fix check on secret request path
priv->path is NULL when the agent handles all requests (for example
when executing "nmcli agent").

Fixes: f3099db28e
(cherry picked from commit 2a391348b6)
2016-09-15 10:27:52 +02:00
Beniamino Galvani
1064dcafbe clients: merge branch 'bg/clients-agent-message-rh1351272'
https://bugzilla.redhat.com/show_bug.cgi?id=1351272
(cherry picked from commit 73c649f365)
2016-09-15 08:33:20 +02:00
Beniamino Galvani
b7b3f54f98 clients: fix matching of connection path
Since we use g_str_has_prefix() to match a request_id with the
connection path, there can be wrong matches. For example:

 request_id: /org/freedesktop/NetworkManager/Settings/10/802-1x
 connection: /org/freedesktop/NetworkManager/Settings/1

would match. Add a trailing slash to the connection path stored in the
agent to prevent this.

(cherry picked from commit f666efed0d)
2016-09-15 08:32:58 +02:00
Beniamino Galvani
9b443db451 clients: handle secret requests only for current connection
The path was checked only when serving the enqueued requests but not
for new ones. Fix this by moving the check to
request_secrets_from_ui().

Fixes: 991df80408

https://bugzilla.redhat.com/show_bug.cgi?id=1351272
(cherry picked from commit f3099db28e)
2016-09-15 08:32:54 +02:00
Beniamino Galvani
b632f2984b clients: add secrets request message for wired and DSL connections
(cherry picked from commit 2c1adaae5e)
2016-09-15 08:32:52 +02:00
Beniamino Galvani
b8e34bcdb3 clients: don't show "(null)" prompt for secrets
If the caller doesn't provide a message, simply don't show it.

(cherry picked from commit a80af27fc9)
2016-09-15 08:32:51 +02:00
Beniamino Galvani
ce3e2152bc clients: add define for NMSecretAgentSimple signal name
(cherry picked from commit b28b2ba8a9)
2016-09-15 08:32:49 +02:00
Thomas Haller
06946bf2ce build: move detection of NM_GIT_SHA to separate "m4/git-sha-record.m4"
We want to embed the current commit-id in the ./configure script.
That way the generated ./configure file in the source tarball
references the commit-id from which the tarball was created.

Then, in a second step, a script can check ./configure to find
the parent commit. This is for example done by the 'makerepo.sh'
script.

This is generally useful, and also done by network-manager-applet
and libnl3 projects. Move the function to a separate m4 macro
to reuse it. It should also be re-used in NetworkManager's VPN plugins.

(cherry picked from commit b33aacbc91)
2016-09-14 14:13:16 +02:00
Francesco Giudici
96b31cdd82 tests/ifupdown: add missing source-stanza files reference from makefile
Fixes: ada6b96de9
(cherry picked from commit b50fc0d47e)
2016-09-13 16:55:10 +02:00
Thomas Haller
66c665808f device: cleanup _hw_addr_set()
No change in behavior, just reorganize.

Fixes: 32f7c1d4b9
(cherry picked from commit e7a1008b4b)
2016-09-13 11:21:26 +02:00
Thomas Haller
cd8f2ecc61 device: wait for MAC address change to complete before setting interface up
Some drivers (brcmfmac) don't change the MAC address right away.
NetworkManager works around that by waiting synchronously until
the address changes (commit 1a85103765).

wpa_supplicant on the other hand, only re-reads the MAC address
when changing state from DISABLED to ENABLED, which happens when
the interface comes up.

That is a bug in wpa_supplicant and the driver, but we can work-around by
waiting until the MAC address actually changed before setting the interface
IFF_UP. Also note, that there is still a race in wpa_supplicant which might
miss a change to DISABLED state altogether.

https://bugzilla.gnome.org/show_bug.cgi?id=770504
https://bugzilla.redhat.com/show_bug.cgi?id=1374023
(cherry picked from commit 32f7c1d4b9)
2016-09-13 10:35:13 +02:00
Beniamino Galvani
ee3d814f11 ifcfg-rh: fill 'auth-alg' with the original value for WPA-PSK
Restore the original value of auth-alg, which can be NULL or 'open'
for WPA-PSK.

https://bugzilla.gnome.org/show_bug.cgi?id=770907
(cherry picked from commit b519b96c4e)
2016-09-12 16:15:42 +02:00
Beniamino Galvani
3bb3afbbe1 ifcfg-rh: add wifi protocols only if present in connection file
An empty 802-11-wireless-security.proto is equivalent to
'wpa,rsn'. Previously we added the two protocols when reading the
connection and the variables were missing, with the result that an
empty value would be read as 'wpa,rsn' at the next restart. This is
harmless but makes the two connections appear as different, with bad
effects when 'monitor-connection-files' is enabled.

Ensure that the original value persists after a write/read cycle.

https://bugzilla.gnome.org/show_bug.cgi?id=770907
(cherry picked from commit 00c4e7e73a)
2016-09-12 16:15:40 +02:00
Thomas Haller
27986f402c build: disable type checks in G_TYPE_CHECK_INSTANCE_CAST() macros (bgo#771120)
Avoid the pointless overhead. Even glib disables them unless you build
with --enable-debug.

https://bugzilla.gnome.org/show_bug.cgi?id=771120
(cherry picked from commit eb8da4c282)
2016-09-12 13:55:23 +02:00
Thomas Haller
4a535e6213 libnm-core: fix crash in nm_vpn_plugin_info_list_get_service_types()
Coverity says, "Dereference after null check". Indeed, @aliases
is usually NULL.

Fixes: 46665898bb
(cherry picked from commit 9cf9c3a88e)
2016-09-09 01:23:40 +02:00
Thomas Haller
0536525d98 ifcfg-rh: remove dead code from write_ip4_setting()
s_ip4 cannot be NULL and fake_ip4 is never TRUE.

Found by Coverity.

Fixes: cf7b8866ce
(cherry picked from commit 8bae6e588f)
2016-09-09 01:01:58 +02:00
Thomas Haller
8d57540368 device: workaround driver issue with delayed change of MAC address
brcmfmac and possibly other drivers don't change the MAC address
right away, but instead the result is delayed. That is problematic
because we cannot continue activation before the MAC address is
settled.

Add a hack to workaround the issue by waiting until the MAC address
changed.

The previous attempt to workaround this was less intrusive: we would
just refresh the link once and check the result. But that turns out
not to be sufficent for all cases. Now, wait and poll.

https://bugzilla.gnome.org/show_bug.cgi?id=770456
https://bugzilla.redhat.com/show_bug.cgi?id=1374023
(cherry picked from commit 1a85103765)
2016-09-08 21:04:44 +02:00
Thomas Haller
0b182d0f45 dhcp: merge branch 'th/dhcp-helper-sync-notify-rh1372854'
https://bugzilla.redhat.com/show_bug.cgi?id=1372854

(cherry picked from commit 42519abdbf)
2016-09-08 00:26:31 +02:00
Thomas Haller
e678bd29a4 dhcp: call synchronous Notify D-Bus method from nm-dhcp-helper
A D-Bus signal is asynchronous and it can happen that nm-dhcp-helper
emits the "Event" signal before the server is able to register a handler:

   NM_DHCP_HELPER=/usr/libexec/nm-dhcp-helper
   nmcli general logging level TRACE
   for i in `seq 1 500`; do $NM_DHCP_HELPER & done
   journalctl -u NetworkManager --since '1 min ago' | grep "didn't have associated interface" | wc -l
    499

Avoid that, by calling the synchronous D-Bus method "Notify".

Interestingly, this race seem to exist since 2007.

Actually, we called g_dbus_connection_signal_subscribe() from inside
GDBusServer:new-connection signal. So it is not clear how such a race
could exist. I was not able to reproduce it by putting a sleep
before g_dbus_connection_signal_subscribe(). On the other hand, there
is bug rh#1372854 and above reproducer which strongly indicates that
events can be lost under certain circumstances.
Now we instead g_dbus_connection_register_object() from the
new-connection signal. According to my tests there was no more race
as also backed by glib's documentation. Still, keep a simple retry-loop
in nm-dhcp-helper just to be sure.

https://bugzilla.redhat.com/show_bug.cgi?id=1372854
https://bugzilla.redhat.com/show_bug.cgi?id=1373276
(cherry picked from commit 2856a658b3)
2016-09-08 00:26:14 +02:00
Thomas Haller
3ac3125aff dhcp: add new header "nm-dhcp-helper-api.h"
(cherry picked from commit 7684b68c49)
2016-09-08 00:26:14 +02:00
Thomas Haller
9d44dafc3c dhcp-helper: refactor logging to use logging macros
(cherry picked from commit cc89996c9e)
2016-09-08 00:26:14 +02:00
Thomas Haller
a8d87ef87f dhcp-helper: refactor error handling
Don't exit(1) from fatal_error() because that skips destroying
local variables in main(). Just return regularly.

(cherry picked from commit bb489163db)
2016-09-08 00:26:14 +02:00
Thomas Haller
0ebdfd6cf1 dhcp-listener/trivial: rename field to track connections in NMDhcpListener
It's not "signal-handles", as it currently tracks the registration ID of
type int. Rename it, it is effectively the list of connections that we
track.

(cherry picked from commit 2dd3a5245f)
2016-09-08 00:26:14 +02:00
Thomas Haller
3920a90e4a dhcp-listener: add logging macros to nm-dhcp-listener.c
(cherry picked from commit d37cd04fe0)
2016-09-08 00:26:14 +02:00
Thomas Haller
75e13f0e15 dhcp-listener: refactor type definition and embed private data in @self
(cherry picked from commit 822f01a8fd)
2016-09-08 00:26:14 +02:00
Thomas Haller
3940d63a7e core: use _NM_GET_PRIVATE() macros
(cherry picked from commit cdf6ad4057)
2016-09-08 00:26:14 +02:00
Thomas Haller
5bac57496c shared: add _NM_GET_PRIVATE() macro
(cherry picked from commit 2cae9ba348)
2016-09-08 00:26:14 +02:00
Thomas Haller
811aaead4c shared: add NM_MIN()/NM_MAX() macros to replace glib's MIN()/MAX()
(cherry picked from commit b2016fd2a5)
2016-09-08 00:26:14 +02:00
Thomas Haller
99e30bdf70 logging: don't round subsecond part in logging timestamp
tv.tv_usec is guaranteed to have less then 6 digits, however rounding it up
we might reach 1000000 and thus the value becomes mis-aligned. To round
correctly, we would have to carry over a potential overflow to the seconds.
But that seems too much effort for little gain. Just truncate the value.

(cherry picked from commit c1b4b99a3c)
2016-09-08 00:26:14 +02:00
Thomas Haller
e9a0ce84a1 ifupdown: add curly braces to for loop
(cherry picked from commit 0ef8e98e73)
2016-09-07 13:22:16 +02:00
Scott Sweeny
1dd66ed623 plugins: ifupdown: support source-directory stanza
Enable the ifupdown settings plugin to read interface
definitions from the source directory:

/etc/network/interfaces.d/

https://mail.gnome.org/archives/networkmanager-list/2016-September/msg00014.html
(cherry picked from commit ada6b96de9)
2016-09-07 13:22:15 +02:00
Thomas Haller
fe0e507617 libnm: merge branch 'th/empty-cloned-mac-address-rh1372799'
https://bugzilla.redhat.com/show_bug.cgi?id=1372799

(cherry picked from commit ad3c8a0d4e)
2016-09-06 16:17:45 +02:00
Thomas Haller
742bf5671f libnm: fix regression serializing empty "cloned-mac-address"
For "cloned-mac-address", the empty string "" is an invalid
value that is rejected by verify().

Commit 8eed671 changed how the property is serialized to D-Bus.
Before, it was serialized using _nm_utils_hwaddr_to_dbus().
For invalid or empty addresses, this would not serialize the
value on D-Bus (or before commit 76aa6f8e0, it would create
a bogus value with no array elements).

With commit 8eed671, the cloned-mac-address gets also serialized
as "assigned-mac-address" via _nm_utils_hwaddr_cloned_data_synth(),
which would pass on invalid strings that the server would then reject.

That breaks for example nmtui. Try editing a connection with
"cloned-mac-address" set to NULL. Note, as long as you don't edit
the cloned MAC address in nmtui, you can save the modification.
Once you start modifying the entry, you can no longer set an empty
MAC address as the server now receives the invalid empty string.
Thus, the "OK" button fails with
   Unable to save connection:
   802-3-ethernet.cloned-mac-address:
   is not a valid MAC address
It also means, nmtui cannot modify the "cloned-mac-address" field to
become empty.

Fix that problem at various places by coercing "" to NULL.

Fixes: 8eed67122c

https://bugzilla.redhat.com/show_bug.cgi?id=1372799
(cherry picked from commit 814784aa46)
2016-09-06 16:16:19 +02:00
Thomas Haller
1fdf026e2d libnm-core: replace local helper with nm_stdup_not_empty()
(cherry picked from commit f4d7db964e)
2016-09-06 16:16:19 +02:00
Thomas Haller
4aad70a61d shared: add helper macros nm_str_not_empty() and nm_strdup_not_empty()
(cherry picked from commit 3227b9017b)
2016-09-06 16:16:19 +02:00
Lubomir Rintel
bcc9a7eacf po: add translations from Red Hat
https://bugzilla.redhat.com/show_bug.cgi?id=887771
(cherry picked from commit 2724ec53b7)
2016-09-06 15:43:00 +02:00
Thomas Haller
c87b89bf8f core: merge branch 'th/dbus-property-changed-source-iface-bgo770629-v2'
https://bugzilla.gnome.org/show_bug.cgi?id=770629
https://bugzilla.redhat.com/show_bug.cgi?id=1371920

(cherry picked from commit 673282ece6)
2016-09-02 20:28:40 +02:00
Thomas Haller
e0eca5cec9 NEWS: update file with changes to PropertiesChanged signal
(cherry picked from commit 56bd86fd0c)
2016-09-02 20:28:21 +02:00
Thomas Haller
db4375277c exported-object: use _NMLOG2() macro for logging property-changed signal
(cherry picked from commit ba713e8381)
2016-09-02 20:17:42 +02:00
Thomas Haller
7220d469be exported-object: use @self variable instead of @object
(cherry picked from commit b9c1868b45)
2016-09-02 20:17:42 +02:00
Thomas Haller
98773bff54 dbus: deprecated NM specific PropertiesChanged signals
Nowadays, users should use the standard "PropertiesChanged" signal
on "org.freedesktop.DBus.Properties" interface.

(cherry picked from commit 6fb917178a)
2016-09-02 20:17:42 +02:00
Thomas Haller
c29ca9b876 dbus: fix emitting D-Bus NetworkManager's old-style PropertiesChange signal
Before switching to gdbus (before 1.2.0), NetworkManager used dbus-glib.
Most objects in the D-Bus API with properties had a signal
NetworkManager-specific "PropertiesChanged" signal. Nowadays, this way of
handling of property changes is deprecated for the common "PropertiesChanged"
signal on the "org.freedesktop.DBus.Properties" interface.

There were a few pecularities in 1.0.0 and earlier:

  (1) Due to the implementation with dbus-glib, a property-changed
    signal was emitted on *all* interfaces. For example:
      - a change on a NMDeviceVeth of "NMDeviceEthernet.HwAddress" would be
        emitted both for the interfaces "fdo.NM.Device.Ethernet" and
        "fdo.NM.Device.Veth". Note that NMDeviceVeth is derived from
        NMDeviceEthernet and there is no "HwAddress" on veth device.
      - a change of "NMVpnConnection.VpnState" was emitted on both
        interfaces "fdo.NM.VPN.Connection" and "fdo.NM.Connecion.Active".
        Note that NMActiveConnection is the parent type of NMVpnConnection and
        only the latter has a property "VpnState".
  (2) NMDevice's "fdo.NM.Device" interface  doesn't have a "PropertiesChanged"
    signal. From (1) follows that all property-changes for this type were instead
    invoked with an interface like "fdo.NM.Device.Ethernet" (or multiple
    interfaces in case of NMDeviceVeth).

1.2.0 introduced gdbus, which gives us the standard "fdo.DBus.Properties"
signal. However, it made the mistake of not realizing (1), thus instead
of emitting the signal once for each interface, it would pick the first
one in the inheritance tree.

With 1.4.0, a bug from merge commit 844345e caused signals for devices
to be only emitted for the interface "fdo.NM.Device.Statistics", instead
of "fdo.NM.Device.Ethernet" or "fdo.NM.Device.Veth" (or both).

The latter is what bgo#770629 is about and what commit 82e9439 tried to fix.
However, the fix was wrong because it tried to do the theoretically correct
thing of emitting the property-changed signal exactly once for the
interface that actually ontains the property. In addition, it missed that
NMDevice doesn't have a PropertiesChanged signal, which caused signals for
"fdo.NM.Device" to get lost *sigh*.

Now, restore the (broken) behavior of 1.0.0. These old-style property changed
signals are anyway considered deprecated and exist solely to satisfy old clients
and preserve the old API.

Fixes: 63fbfad3705db5901e6a2a6a2fc332da0f0ae4be

https://bugzilla.gnome.org/show_bug.cgi?id=770629
https://bugzilla.redhat.com/show_bug.cgi?id=1371920
(cherry picked from commit bef26a2e69)
2016-09-02 20:17:42 +02:00
Thomas Haller
268ae4a359 man: fix wording in NetworkManager.conf for "rc-manager"
(cherry picked from commit e284651f4c)
2016-09-02 17:05:17 +02:00
Thomas Haller
c66cbe9375 doc: add comment to systemd's NetworkManager.service about ibft requiring CAP_SYS_ADMIN
We don't want to enable this upstream, but make the requirement
more discoverable by documenting it and put a comment to
NetworkManager.service.

https://bugzilla.redhat.com/show_bug.cgi?id=1371201
(cherry picked from commit 9aee7b493e)
2016-09-02 15:39:42 +02:00