Commit graph

12701 commits

Author SHA1 Message Date
Lubomir Rintel
b97560bc1f ifupdown: don't remove the object in its constructor
This is wrong an all the complexity of a property and associated bookkeeping is
completely unnecessary.

(cherry picked from commit 0cb45af977)
2016-03-14 16:36:53 +01:00
Lubomir Rintel
0a112e12ce ifupdown: drop a bogus warning
The key might be a wireless setting that has already been processed, not a
wireless-security setting.

(cherry picked from commit a5c204a69a)
2016-03-14 16:36:23 +01:00
Thomas Haller
1fe054d319 wifi: merge branch 'th/supplicant-manager-fix-ref-count-rh1298007'
https://bugzilla.redhat.com/show_bug.cgi?id=1298007
https://bugzilla.redhat.com/show_bug.cgi?id=1241198
https://mail.gnome.org/archives/networkmanager-list/2016-February/msg00094.html

(cherry picked from commit de19bc20d0)
2016-03-02 16:44:17 +01:00
Thomas Haller
3c612f9d54 wifi: fix crash due to wrong ownership handling in nm_supplicant_manager_iface_release()
nm_supplicant_manager_iface_get() would cache and reuse the supplicant
interface. But no ref-counting was in place so that the first user returning
the interface via nm_supplicant_manager_iface_release() would destroy the
instance for others.

This is broken for a very long time. Which shows that we hardly ever
have a cache-hit and usually create a new instance. So, instead of
letting nm_supplicant_manager_create_interface() check for existing
supplicant interface, always create a new instance. This also makes
sense, because we would expect that per ifname only one instance is
requested at a time. Also add an assertion that we don't return
multiple supplicant interface instances for the same ifname.

Drop nm_supplicant_manager_iface_release() in favor of requiring users
to unref the returned instance.

Also, use a GSList instead of a GHashTable for the cache.

Also, previously callers would pass @is_wireless to nm_supplicant_manager_iface_get(),
but the cache lookup did not consider that value. That doesn't matter
now as we always create a new instance.

https://bugzilla.redhat.com/show_bug.cgi?id=1298007
(cherry picked from commit f1fba3eb02)
2016-03-02 16:43:54 +01:00
Thomas Haller
dd6239bdf6 supplicant: don't pass start_now argument to nm_supplicant_interface_new()
Also, don't only consider the @die_count whether to start the supplicant,
but check for is_available() -- which already considers @die_count and
@running.

(cherry picked from commit 063f9185b9)
2016-03-02 16:43:54 +01:00
Thomas Haller
7944c5f8ac supplicant: drop is_wireless argument from NMSupplicantInterface's interface_add()
(cherry picked from commit 5d64da1da2)
2016-03-02 16:43:54 +01:00
Thomas Haller
b9ee515dc9 supplicant: remove check for iface instance after nm_supplicant_interface_new()
A plain constructor for a GObject cannot fail.

(cherry picked from commit a8165611a8)
2016-03-02 16:43:54 +01:00
Thomas Haller
213c20142c wifi/supplicant: take object reference during availability_changed()
If the list is expected to be modified, it also means that possibly
instances will be unrefed. Probably, not yet visited instances will
not be unrefed so there is no real problem.

Just be extra cautious and take a reference to all instances first.

(cherry picked from commit 004edecc81)
2016-03-02 16:43:54 +01:00
Thomas Haller
91bdabc808 device/wifi: remove unnecessary call to remove_supplicant_interface_error_handler()
remove_supplicant_interface_error_handler() is not needed as we later disconnect
all handlers for @self.

(cherry picked from commit 8dcf4d32e9)
2016-03-02 16:43:54 +01:00
Thomas Haller
9345900f28 device/wifi: replace cancel_pending_scan() with nm_clear_g_source()
(cherry picked from commit 84828960ff)
2016-03-02 16:43:54 +01:00
Thomas Haller
2c007671c9 device/ethernet: cleanup clearing handlers registered to supplicant interface
(cherry picked from commit 0a2ff1d16d)
2016-03-02 16:43:54 +01:00
Thomas Haller
83bf1a7c86 device/ethernet: use nm_clear_g*() function in remove_supplicant_interface_error_handler()
(cherry picked from commit 30f72c2753)
2016-03-02 16:43:54 +01:00
Thomas Haller
3822c7d6cc supplicant: remove unused function nm_supplicant_interface_get_device()
(cherry picked from commit 2505911ad5)
2016-03-02 16:43:54 +01:00
Beniamino Galvani
236d23c9a2 build: fix travis file syntax
Fixes: 46819838e7
2016-03-02 15:39:42 +01:00
Dan Williams
ba7359441b libnm-glib/libnm/vpn: fix handling of ConnectInteractive() failure (rh #1298732)
If the plugin supports interactive mode, but the VPN binary (like vpnc
or openvpn) doesn't support it, then the plugin should return
NM_VPN_PLUGIN_ERROR_INTERACTIVE_NOT_SUPPORTED from its connect_interactive()
hook.  This lets NetworkManager know to fall back to plain Connect().

Since this notification is done through an error return, the VPN service
plugin code sees the failure and moves the plugin state back to
STOPPED.  NetworkManager sees that state change, and terminates the
connection attempt while waiting for a reply to the Connect() method.

(VPN service plugins that don't support interactive mode at all don't
have this problem because that error is returned before the plugin's
state is moved to STARTING.)

To fix this, do two things:

1) if the connect_interactive() hook fails and returns the error
NM_VPN_PLUGIN_ERROR_INTERACTIVE_NOT_SUPPORTED, postpone the STOPPED
state change for a few seconds to allow NM time to fall back to
plain Connect().  We still want to move the plugin state back to
STOPPED eventually, because otherwise it could stay in STARTING
forever.

2) change state to STARTING only if the connect/connect_interactive
plugin hooks were successful.  Otherwise the plugin would still be
in STARTING state, and it's not valid to call Connect()/ConnectInteractive()
during the STARTING state.

https://mail.gnome.org/archives/networkmanager-list/2016-February/msg00091.html
https://bugzilla.redhat.com/show_bug.cgi?id=1298732
(cherry picked from commit abc700c5c7)
2016-03-02 11:28:27 +01:00
Thomas Haller
cd6ee5786a platform/tests: workaround test failure for kernel bug
Unenslaving from a bridge can cause a spurious RTM_DELLINK signal.
NMPlatform does raise those signals, but fixes the state of the
cache afterwards. Workaround the test failure.

Related: https://bugzilla.redhat.com/show_bug.cgi?id=1285719
(cherry picked from commit dec682f6d1)
2016-02-25 15:18:06 +01:00
Thomas Haller
46819838e7 travis: update .travis.yml not to run tests when build fails
When building fails, we should not run the tests. They clutter
the output.

(cherry picked from commit ad45d232fe)
2016-02-25 15:18:06 +01:00
Thomas Haller
625033a285 travis: fix setting NMTST_DEBUG for travis-check.sh script
(cherry picked from commit 7ec5acdc66)
2016-02-25 15:18:06 +01:00
Thomas Haller
ccee81f0d5 travis: fix bug in .travis.yml
Fixes: 1408b8c0a2
(cherry picked from commit c94a9372fa)
2016-02-25 15:18:06 +01:00
Lubomir Rintel
873e6564a0 travis: decouple the build from the test run
It looks better in the .yml file as well as in the travis UI.

(cherry picked from commit 1408b8c0a2)
[bgalvani: dropped the coverity part]
2016-02-25 15:17:55 +01:00
Thomas Haller
0907ad6cd8 travis: move build script to a separate script and improve debugging for failed tests
(cherry picked from commit 34050e9c0b)
2016-02-25 15:09:51 +01:00
Dan Williams
a3c0166a20 wifi: ignore monitor interfaces
If a monitor interface is created, NM will grab that interface
and change it to station mode.  That's not very nice.

https://mail.gnome.org/archives/networkmanager-list/2016-February/msg00068.html
(cherry picked from commit 751a37bf43)
2016-02-24 09:25:35 -06:00
Thomas Haller
ab667dd885 platform: fix detection of link-type for netlink event
Often a netlink event doesn't contain enough information to determine
the link type. Then we consult sysctl or ethtool. However, if we already
have the same object cached, we want to reused the (once detected) link-type.

There was a bug in lookup of the cached object.

(cherry picked from commit 9c0cfbbae6)
2016-02-15 17:26:28 +01:00
Beniamino Galvani
afb2447789 platform: always try to refetch new ethernet links
Due to a kernel bug [1], we sometimes receive spurious NEWLINK
messages after a wifi interface has disappeared. Since the link is not
present anymore we can't determine its type and thus it will show up
as a Ethernet one, with no address specified.  Request the link again
to check if it really exists.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1302037

https://bugzilla.gnome.org/show_bug.cgi?id=761151
(cherry picked from commit 97be12b662)
2016-02-12 14:45:30 +01:00
Dan Williams
05a14d0818 wifi: allow autoconnect on AP/AdHoc mode connections with manual IP configuration
The existing checks assumed that all AP/AdHoc connections would use the
shared IP method.  But what we really want to check for here is whether the
connection is AP/AdHoc.  Leave the existing 'shared' check for backwards
compatibility.

Also move the check above the timestamp check, since the user shouldn't need
to manually set a timestamp just to get an AP-mode connection to autoconnect.

(cherry picked from commit e2637760f1)
2016-02-11 14:38:05 -06:00
Thomas Haller
b81e8ca537 contrib/rpm: add rpm_version in spec file
and rename realversion to real_version to follow the pattern.

(cherry picked from commit 6490dc154c)
2016-02-03 15:49:04 +01:00
Thomas Haller
3d15ab9616 contrib/rpm: update comment for patches in spec file
We don't want to create backups of original files when
patching. Update the comment in the spec file to indicate
that.

(cherry picked from commit 455b981215)
2016-02-03 15:43:24 +01:00
Thomas Haller
261bd53e65 contrib/rpm: merge branch 'th/contrib-rpm-backports' 2016-02-02 19:44:52 +01:00
Thomas Haller
6807fcc5be contrib/rpm: remove dbus-glib dependancy
Only libnm-glib still requires dbus-glib.

(cherry picked from commit 804ec6fbcd)
2016-02-02 19:02:40 +01:00
Dan Williams
b880c9040b contrib: remove dbus/dbus-glib requires from libnm sub-package
libnm doesn't use dbus-glib or dbus at all.

(cherry picked from commit 5e892819fc)
2016-02-02 19:02:40 +01:00
Thomas Haller
6d342fb4c7 contrib/rpm: make build more configurable by using conditionals
Also add a new conditional "debug" to enable more assertions and
more logging, which is disabled by default.

Also add a conditional "test" to disable running the unit tests
(make check) while building the package.

http://rpm.org/wiki/PackagerDocs/ConditionalBuilds
(cherry picked from commit 87dc14476b)
2016-02-02 19:02:40 +01:00
Dan Winship
4037b6c8bb contrib: sync fedora/rpm/NetworkManager.spec
We're building the plugins on s390 these days

(cherry picked from commit 20a56fa9a2)
2016-02-02 19:02:40 +01:00
Thomas Haller
d6f2e6b0dd contrib/rpm: remove NetworkManager-devel package
NetworkManager-devel package contained development headers that
are useful without libnm-glib and without glib. But it is also
based on the legacy libnm-glib library as it has headers like
"/usr/include/NetworkManager/NetworkManager.h".

A glib-free devel package based on the new libnm library would
be needed to provide "/usr/include/libnm/nm-dbus-interface.h".

But that would amount to 4 devel packages. Instead, just move
the content of NetworkManager-devel into NetworkManager-glib-devel
package.

Note that NetworkManager-devel already contained several truely
libnm-glib dependent files, like the vala bindings (which require
libnm-glib). So that was another bug in the packaging and is fixed
by moving it all to NetworkManager-glib-devel.

https://bugzilla.gnome.org/show_bug.cgi?id=755938
(cherry picked from commit e01c17523a)
2016-02-02 19:02:40 +01:00
Lubomir Rintel
1a0850934b contrib/rpm: sync from Fedora git
(cherry picked from commit de5d98197f)
2016-02-02 19:02:40 +01:00
Thomas Haller
162dd7874f contrib/rpm: add comment to NetworkManager.conf about debug logfiles
(cherry picked from commit bb78d14467)
2016-02-02 18:21:08 +01:00
Thomas Haller
fb8ede6525 contrib/rpm: add --no-build option to build_clean.sh
Option to skip building the source package. Useful if you already
have a source tarball from a previous run.

(cherry picked from commit 3b01d25561)
2016-02-02 18:19:48 +01:00
Beniamino Galvani
b0d84e84fa device/team: fix tiny memory leak
Fixes: 10f9b6c58b
(cherry picked from commit dc4d0a4200)
2016-02-01 22:32:20 +01:00
Thomas Haller
5d4d0fd7e6 connectivity: fix calling parent dispose()
(cherry picked from commit 2bf4960ec1)
2016-02-01 13:26:04 +01:00
Dan Williams
cb54c14cd5 platform: ignore permanent MAC addresses of all ones (FF:FF:FF:FF:FF:FF)
Drivers are stupid, and just like the platform ignores an all zeros
permanent address, so should it ignore all ones.

NetworkManager[509]: <debug> [1453743778.854919] [devices/nm-device.c:8885] nm_device_update_hw_address(): [0x190370] (eth0): hardware address now 86:18:52:xx:xx:xx
NetworkManager[509]: <debug> [1453743778.855438] [devices/nm-device.c:9138] constructed(): [0x190370] (eth0): read initial MAC address 86:18:52:xx:xx:xx
NetworkManager[509]: <debug> [1453743778.861602] [devices/nm-device.c:9148] constructed(): [0x190370] (eth0): read permanent MAC address FF:FF:FF:FF:FF:FF

(cherry picked from commit d442dcd174)
2016-01-29 17:41:16 -06:00
Lubomir Rintel
38ad5c9f3a ifcfg,keyfile: fix temporary file races (CVE-2016-0764)
Two of these raised Coverity's eyebrows.

CID 59389 (#1 of 1): Insecure temporary file (SECURE_TEMP)
5.  secure_temp: Calling mkstemp without securely setting umask first.

CID 59388 (#1 of 1): Insecure temporary file (SECURE_TEMP)
1.  secure_temp: Calling mkstemp without securely setting umask first.

Last one raised mine.

When a connection is edited and saved, there's a small window during which and
unprivileged authenticated local user can read out connection secrets (e.g. a
VPN or Wi-Fi password). The security impact is perhaps of low severity as
there's no way to force another user to save their connection.

(cherry picked from commit 60b7ed3bdc)
2016-01-29 20:36:18 +01:00
Dan Williams
f2773e525c wwan: retry connect on some errors and save them for log messages
First, cb751012a2 mistakenly converted the
act_stage_context_step() in connect_ready() to connect_context_clear()
instead of connect_context_step().  This would cause the IP Type retry
logic to fail and no further types to be tried.  It also throws
away the ctx->first_error and causes all errors that MM returns on the
connect attempt to be dropped on the floor.

Second, not all errors should cause an advance to the next IP Type,
since some errors aren't related to it.  Specifically, MM_CORE_ERROR_RETRY
when using Simple.Connect() means that a timeout was reached
in the internal connect logic, not a modem or network error.  In
that case, try the connect again with the same IP Type before advancing
to the next type.

Fixes: cb751012a2

Tested-by: Ladislav Michl <ladis@linux-mips.org>
Tested-by: Tore Anderson <tore@fud.no>
(cherry picked from commit 1cf4727766)
2016-01-28 12:28:21 -06:00
Thomas Haller
30bedd0b39 bluez: own reference to connection provider in NMBluezDevice
(cherry picked from commit 53233bb04c)
2016-01-27 14:23:34 +01:00
Thomas Haller
81a9d84d60 bluez: own reference to connection provider in NMBluezManager
(cherry picked from commit 94dcffc475)
2016-01-27 14:23:33 +01:00
Thomas Haller
c354f30f57 bluez: fix invoking parent dispose() function in NMBluezManager
Fixes: bf5a6ad443
(cherry picked from commit 7cc54d5bb9)
2016-01-27 14:23:32 +01:00
Thomas Haller
5ab7e899aa libnm-glib: fix another memory leak around update_permissions()
This time in init_async_got_permissions().

Thereby, just use gs_unref_hash and gs_free_error for cleanup.

(cherry picked from commit 8029f59e4f)
2016-01-26 12:35:16 +01:00
Thomas Haller
1deae2a284 libnm-glib: fix crash due to uninitalized pointer in get_permissions_reply()
If the D-Bus call failed with error, @permissions would stay uninitialized.

Fixes: f2399a6976
Fixes: 808f012603

(cherry picked from commit e0601d501a)
2016-01-26 12:08:19 +01:00
Dan Williams
808f012603 libnm-glib: fix leak in get_permissions_reply()
(cherry picked from commit f2399a6976)
2016-01-26 12:07:55 +01:00
Dan Williams
d4b15684f3 wwan: rework connection flow to send PIN earlier and fix autoconnect
Modems often don't expose all the required properties until they have
been unlocked, and that includes the IP types supported by the modem.

With an autoconnect WWAN connection where the SIM requires a PIN, there
were two problems:

1) the PIN is a secret and we don't have it until it's explicitly requested
during the activation process, so we cannot gate GSM connection availability
on whether a PIN is present since this happens long before we request secrets

2) when the modem is locked it may not report the supported IP types, which
caused an auto-activation to fail early becuase IP compatibility is checked
before the PIN is sent to the modem

Rework connection activation flow into a series of concrete steps, where the
PIN is sent to the modem if required, and only after the modem is actually
unlocked does the connection proceed.  This does mean that any connection
marked 'autoconnect' can theoretically enable a PIN-locked modem even if
the connection has no PIN defined, but there's no good way around that.
NetworkManager would activate the connection

(cherry picked from commit cb751012a2)
2016-01-25 12:40:08 -06:00
Dan Williams
7878e91b77 core: only run availability recheck transition if required
Device subclasses can call nm_device_recheck_available() at any time,
and the function would change the device's state to UNKNOWN in cases
where the device was available already.  For WWAN devices, availability
is rechecked every time the modem state changes, resulting in:

NetworkManager[28919]: <info>  (ttyUSB4): modem state changed, 'disabled' --> 'enabling' (reason: user-requested)
NetworkManager[28919]: <debug> [1445538582.116727] [devices/nm-device.c:2769] recheck_available(): [0x23bd710] (ttyUSB4): device is available, will transition to unknown
NetworkManager[28919]: <info>  (ttyUSB4): modem state changed, 'enabling' --> 'searching' (reason: user-requested)
NetworkManager[28919]: <debug> [1445538582.776317] [devices/nm-device.c:2769] recheck_available(): [0x23bd710] (ttyUSB4): device is available, will transition to unknown

(cherry picked from commit d9c6b9f3dd)
2016-01-25 12:40:08 -06:00
Thomas Haller
859099f353 systemd: order NetworkManager.serivce after network-pre.target
https://bugzilla.gnome.org/show_bug.cgi?id=761001
(cherry picked from commit 9c3187027c)
2016-01-23 16:57:56 +01:00