Commit graph

7630 commits

Author SHA1 Message Date
Thomas Haller
7991298c51 core: be strict about connection argument in D-Bus methods
There is no excuse for clients to send connections to NetworkManager
that have invalid/unknown fields. Just reject them.

This is a dangerous change, because we might now reject connections
that we were accepting previously. Who know what clients were sending
and it used to work.
2016-03-29 11:56:26 +02:00
Thomas Haller
0c5b98b464 core: be strict when parsing connection in AddAndActivateConnection
AddAndActivateConnection is allowed to provide an incomplete connection
that will be completed by NetworkManager. That is, a connection that
does not verify.

But we still want to catch invalid properties or unknown setting types.
Thus, we want to reject invalid partial connections.

This possibly rejects invalid requests from clients that were accepted
before. Thus this change has the potential to break misbehaving clients.
2016-03-29 11:55:24 +02:00
Thomas Haller
d4c201272e core: be strict about connection argument for Reapply() D-Bus method
There is no excuse for clients to send connections to NetworkManager
that have invalid/unknown fields. Just reject them.

As Reapply() is new API in nm-1-1, there is no problem with backward
compatibility.
2016-03-26 12:10:54 +01:00
Thomas Haller
3d8776108c libnm-core: add _nm_simple_connection_new_from_dbus() function
Contary to nm_simple_connection_new_from_dbus(), this internal
function allows to specify parse-flags.
2016-03-26 12:10:54 +01:00
Thomas Haller
72216f7359 shared: move NM_UTILS_ERROR to shared-utils
NM_UTILS_ERROR is our way to say, that we don't care about
the GError domain and code. nmcli sometimes passes domain "1"
and code "0" to g_set_error(), which could be considered
a bug.

We usually don't care about the error but only about the error
message, so let's have a universally available error quark around.
2016-03-26 12:10:53 +01:00
Lubomir Rintel
b26159b149 manager: allow delaying the device activation when the parent is not real
Don't try to realize our device when the parent device is not real.
Instead, enqueue the activation and wait until it is active before
realizing our device and progressing the device to DISCONNECTED so that
it can get connected.
2016-03-26 11:31:21 +01:00
Lubomir Rintel
da226ae137 manager: separate the traversal to disconected to a separate routine
Will be useful when we'll be able to defer the realization of the
device.
2016-03-26 11:31:20 +01:00
Lubomir Rintel
6e382ea91d active-connection: add parent active connection tracking
Make it possible to let active connection know about an active
connection it depends on and emit a signal when the parent is active.
2016-03-26 11:31:18 +01:00
Lubomir Rintel
ce745e098a device: delay the activation if the backing device is not yet there 2016-03-26 11:29:41 +01:00
Lubomir Rintel
2a45d30cc5 device: only clear the activate request when the device disconnects
If it's traversing from unavailable to disconnected (e.g. realizing
of the device was delayed because it was awaiting the parent connection),
then we just want to progress the activation.
2016-03-26 11:29:41 +01:00
Lubomir Rintel
6219759490 device: _get_available_connections() with _get_best_connection()
We'll need to share the best conneciton logic and it's the only caller
of nm_device_get_available_connections(). Let's just move it all to
NMDevice and provide the best connection from there instead.
2016-03-26 11:29:41 +01:00
Lubomir Rintel
618373a14f dbus: use the annotations for documentation
gdbus only understands those (and gtk docstrings, which we should eventually
use) when generating the documentation.
2016-03-26 11:28:19 +01:00
Thomas Haller
12e6984b87 platform/tests: fix bug in netns test which can cause mounting tmpfs over /run
The root-test "/general/netns/bind-to-path" mounts a tmpfs
over /var/run for the duration of the test and unmounts it at
the end.

Due to a bug, we first mount the tmpfs, then switch to another
namespace, and finally unmount /var/run on that other namespace.

That means, when you run the tests as root, it will bork /run
on your system.

Fixes: 46f5c07643
2016-03-24 17:49:15 +01:00
Beniamino Galvani
76b79df155 dhcp: don't fail assertions when a DHCP client is not available
If no configured client is available, gracefully fail the activation
without throwing runtime errors.
2016-03-24 15:03:04 +01:00
Beniamino Galvani
fd971567b9 dhcp: fall back to other clients when an invalid one is specified
If the user specifies an invalid 'dhcp' option in configuration,
currently we disable DHCP. Instead, fall back to other available
clients, as we do for other options.
2016-03-24 15:03:04 +01:00
Beniamino Galvani
519787e1e4 core: accept zero @wait_before_kill_msec in nm_utils_kill_process_sync()
A zero @wait_before_kill_msec argument should disable the generation
of a SIGKILL signal (after a different signal has been sent).
2016-03-24 15:03:04 +01:00
Beniamino Galvani
3b3a4e1c8b dns: fix error cleanup in kill_existing()
Fixes: 3e66813db2
2016-03-24 10:21:53 +01:00
Thomas Haller
a0f7967386 dns: always reload the dns configuration mode on SIGHUP 2016-03-23 09:09:06 +01:00
Thomas Haller
0c4b2d8c89 dns: enable dns plugins also with immutable resolv.conf
We check whether /etc/resolv.conf is set as immutable. But even then
we still want to support our dns plugins like dnsmasq and unbound.
2016-03-23 09:09:06 +01:00
Thomas Haller
288799713d dns: add new "rc-manager=file" 2016-03-23 09:09:06 +01:00
Thomas Haller
22df466ed3 dns: split create_resolv_conf() out of write_resolv_conf() 2016-03-23 09:09:06 +01:00
Thomas Haller
f73621a545 dns: refactor NMDnsManagerResolvConfMode to string conversion 2016-03-23 09:09:06 +01:00
Thomas Haller
4faaa3eb0b dns: fix _NMLOG() macro
The buffer was too small to contain _NMLOG_PREFIX_NAME and the pointer,
resulting in truncated messages like:

  dns-mgr[0x561d1183d: set resolv-conf-mode: none
2016-03-23 09:08:35 +01:00
Thomas Haller
3bcc0e5cea dnsmasq: use _LOG() macros
The _LOG*() macros based on _NMLOG() prefix each line with a
context. Since we no longer log the location of the logging line,
this is the more important.
2016-03-22 16:50:50 +01:00
Thomas Haller
3e66813db2 dns: refactor kill_existing() to always unlink pidfile
When a pidfile exists, it is always stale after this point
and kill_existing() should always unlink it.

Also, refactor kill_existing() to use nm_utils_kill_process_sync()
which waits for the process to be gone.
2016-03-22 16:45:00 +01:00
Thomas Haller
ca733526e6 dns: cleanup disposing of NMDnsPlugin 2016-03-22 16:45:00 +01:00
Thomas Haller
6673d3ad7a dns: refactor cleanup and unlink of pidfile 2016-03-22 16:45:00 +01:00
Mathieu Trudel-Lapierre
2bb769cf10 dns: cleanup pid file when dnsmasq process terminated
[thaller@redhat.com: extracted the patch from a larger one]

https://mail.gnome.org/archives/networkmanager-list/2016-March/msg00144.html

Signed-off-by: Mathieu Trudel-Lapierre <mathieu.trudel-lapierre@canonical.com>
2016-03-22 16:44:33 +01:00
Thomas Haller
99ef0d26e2 dns/trivial: fix indention 2016-03-22 16:30:38 +01:00
Thomas Haller
8c3295f447 systemd: merge branch systemd into master
Update systemd code from upstream. In the meantime, two
patches that we applied early in NetworkManager core were
applied in upstream systemd too. So, resync.
2016-03-22 14:03:39 +01:00
Thomas Haller
a558dc99d6 systemd: update code from upstream
This is a direct dump from systemd git on 2016-03-22, git commit
99d91109a6ed7f8bcdeef164fe9497112128944a.

======

SYSTEMD_DIR=../systemd
COMMIT=99d91109a6ed7f8bcdeef164fe9497112128944a

(
  cd "$SYSTEMD_DIR"
  git checkout "$COMMIT"
  git reset --hard
  git clean -fdx
)

git ls-files :/src/systemd/src/ | xargs -d '\n' rm -f

nm_copy_sd() {
    mkdir -p "./src/systemd/$(dirname "$1")"
    cp "$SYSTEMD_DIR/$1" "./src/systemd/$1"
}

nm_copy_sd "src/basic/alloc-util.c"
nm_copy_sd "src/basic/alloc-util.h"
nm_copy_sd "src/basic/async.h"
nm_copy_sd "src/basic/escape.c"
nm_copy_sd "src/basic/escape.h"
nm_copy_sd "src/basic/ether-addr-util.c"
nm_copy_sd "src/basic/ether-addr-util.h"
nm_copy_sd "src/basic/fileio.c"
nm_copy_sd "src/basic/fileio.h"
nm_copy_sd "src/basic/fd-util.c"
nm_copy_sd "src/basic/fd-util.h"
nm_copy_sd "src/basic/fs-util.c"
nm_copy_sd "src/basic/fs-util.h"
nm_copy_sd "src/basic/hash-funcs.c"
nm_copy_sd "src/basic/hash-funcs.h"
nm_copy_sd "src/basic/hashmap.c"
nm_copy_sd "src/basic/hashmap.h"
nm_copy_sd "src/basic/hexdecoct.c"
nm_copy_sd "src/basic/hexdecoct.h"
nm_copy_sd "src/basic/hostname-util.c"
nm_copy_sd "src/basic/hostname-util.h"
nm_copy_sd "src/basic/in-addr-util.c"
nm_copy_sd "src/basic/in-addr-util.h"
nm_copy_sd "src/basic/io-util.c"
nm_copy_sd "src/basic/io-util.h"
nm_copy_sd "src/basic/list.h"
nm_copy_sd "src/basic/log.h"
nm_copy_sd "src/basic/macro.h"
nm_copy_sd "src/basic/mempool.h"
nm_copy_sd "src/basic/mempool.c"
nm_copy_sd "src/basic/parse-util.c"
nm_copy_sd "src/basic/parse-util.h"
nm_copy_sd "src/basic/path-util.c"
nm_copy_sd "src/basic/path-util.h"
nm_copy_sd "src/basic/prioq.h"
nm_copy_sd "src/basic/prioq.c"
nm_copy_sd "src/basic/random-util.c"
nm_copy_sd "src/basic/random-util.h"
nm_copy_sd "src/basic/refcnt.h"
nm_copy_sd "src/basic/set.h"
nm_copy_sd "src/basic/siphash24.c"
nm_copy_sd "src/basic/siphash24.h"
nm_copy_sd "src/basic/socket-util.c"
nm_copy_sd "src/basic/socket-util.h"
nm_copy_sd "src/basic/sparse-endian.h"
nm_copy_sd "src/basic/stdio-util.h"
nm_copy_sd "src/basic/string-table.c"
nm_copy_sd "src/basic/string-table.h"
nm_copy_sd "src/basic/string-util.c"
nm_copy_sd "src/basic/string-util.h"
nm_copy_sd "src/basic/strv.c"
nm_copy_sd "src/basic/strv.h"
nm_copy_sd "src/basic/time-util.c"
nm_copy_sd "src/basic/time-util.h"
nm_copy_sd "src/basic/umask-util.h"
nm_copy_sd "src/basic/unaligned.h"
nm_copy_sd "src/basic/utf8.c"
nm_copy_sd "src/basic/utf8.h"
nm_copy_sd "src/basic/util.c"
nm_copy_sd "src/basic/util.h"
nm_copy_sd "src/libsystemd-network/arp-util.c"
nm_copy_sd "src/libsystemd-network/arp-util.h"
nm_copy_sd "src/libsystemd-network/dhcp6-internal.h"
nm_copy_sd "src/libsystemd-network/dhcp6-lease-internal.h"
nm_copy_sd "src/libsystemd-network/dhcp6-network.c"
nm_copy_sd "src/libsystemd-network/dhcp6-option.c"
nm_copy_sd "src/libsystemd-network/dhcp6-protocol.h"
nm_copy_sd "src/libsystemd-network/dhcp-identifier.c"
nm_copy_sd "src/libsystemd-network/dhcp-identifier.h"
nm_copy_sd "src/libsystemd-network/dhcp-internal.h"
nm_copy_sd "src/libsystemd-network/dhcp-lease-internal.h"
nm_copy_sd "src/libsystemd-network/dhcp-network.c"
nm_copy_sd "src/libsystemd-network/dhcp-option.c"
nm_copy_sd "src/libsystemd-network/dhcp-packet.c"
nm_copy_sd "src/libsystemd-network/dhcp-protocol.h"
nm_copy_sd "src/libsystemd-network/lldp.h"
nm_copy_sd "src/libsystemd-network/lldp-internal.h"
nm_copy_sd "src/libsystemd-network/lldp-neighbor.c"
nm_copy_sd "src/libsystemd-network/lldp-neighbor.h"
nm_copy_sd "src/libsystemd-network/lldp-network.c"
nm_copy_sd "src/libsystemd-network/lldp-network.h"
nm_copy_sd "src/libsystemd-network/network-internal.c"
nm_copy_sd "src/libsystemd-network/network-internal.h"
nm_copy_sd "src/libsystemd-network/sd-dhcp6-client.c"
nm_copy_sd "src/libsystemd-network/sd-dhcp6-lease.c"
nm_copy_sd "src/libsystemd-network/sd-dhcp-client.c"
nm_copy_sd "src/libsystemd-network/sd-dhcp-lease.c"
nm_copy_sd "src/libsystemd-network/sd-ipv4ll.c"
nm_copy_sd "src/libsystemd-network/sd-ipv4acd.c"
nm_copy_sd "src/libsystemd-network/sd-lldp.c"
nm_copy_sd "src/libsystemd/sd-event/sd-event.c"
nm_copy_sd "src/libsystemd/sd-id128/sd-id128.c"
nm_copy_sd "src/shared/dns-domain.c"
nm_copy_sd "src/shared/dns-domain.h"
nm_copy_sd "src/systemd/_sd-common.h"
nm_copy_sd "src/systemd/sd-dhcp6-client.h"
nm_copy_sd "src/systemd/sd-dhcp6-lease.h"
nm_copy_sd "src/systemd/sd-dhcp-client.h"
nm_copy_sd "src/systemd/sd-dhcp-lease.h"
nm_copy_sd "src/systemd/sd-event.h"
nm_copy_sd "src/systemd/sd-ndisc.h"
nm_copy_sd "src/systemd/sd-id128.h"
nm_copy_sd "src/systemd/sd-ipv4acd.h"
nm_copy_sd "src/systemd/sd-ipv4ll.h"
nm_copy_sd "src/systemd/sd-lldp.h"
2016-03-22 13:57:06 +01:00
Lubomir Rintel
f29d90115f dbus: fix a typo in the comment 2016-03-21 14:05:54 +01:00
Thomas Haller
acf9496ccf main: create parent directories of NMSTATEDIR with permissions 755
In case, "$PREFIX/var/lib" does not exist, we want to create those
directories with permissions 755, not 700.
2016-03-21 13:31:40 +01:00
Thomas Haller
8297683605 main: create NMSTATEDIR with permissions 700
"NMSTATEDIR" is "nmstatedir" is "'${localstatedir}'/lib/$PACKAGE" is
usually "/var/lib/NetworkManager".

The "install-data-hook" in "src/Makefile.am" properly installs the
directory with permissions 700. When creating the directory at startup,
we must also use those permissions.
2016-03-21 11:41:51 +01:00
Robby Workman
b907d90f61 src/Makefile.am: create $rundir mode 0755 instead of 0700
Otherwise, $NMRUNDIR/resolv.conf isn't readable by unprivileged
users.

https://mail.gnome.org/archives/networkmanager-list/2016-March/msg00124.html
2016-03-21 11:33:15 +01:00
Lubomir Rintel
357a1c61a0 supplicant-config: fix misleading indentation 2016-03-20 17:05:35 +01:00
Lubomir Rintel
53029e321d dbus: don't do <deny send_interface="..." /> in dbus service file
It does more than intended; apart from denying messages to that particular
interface it also denies all messages non-qualified with an
interface globally.
This blocks messages completely unrelated to wpa_supplicant, such as
NetworkManager communication with the VPN plugins.

From the dbus-daemon manual:

  Be careful with send_interface/receive_interface, because the
  interface field in messages is optional. In particular, do NOT
  specify <deny send_interface="org.foo.Bar"/>! This will cause
  no-interface messages to be blocked for all services, which is
  almost certainly not what you intended. Always use rules of the form:
  <deny send_interface="org.foo.Bar" send_destination="org.foo.Service"/>

We can just safely remove those rules, since we're sufficiently protected
by the send_destination matches and method calls are disallowed by default
anyway.

https://bugzilla.gnome.org/show_bug.cgi?id=763880
2016-03-20 12:22:32 +01:00
Thomas Haller
60cc501a66 device: optimize hashtable usage for shared_ips
No point ins storing "TRUE" as value in the @shared_ips hash
table. That forces glib to allocate a separate storage for the
value. Just use g_hash_table_add() instead.
2016-03-20 10:59:46 +01:00
Lubomir Rintel
6c12f04e87 vpn-connection: do not leak the connection if there's no timeout 2016-03-18 18:04:55 +01:00
Lubomir Rintel
d568eb0e6c vpn-connection: don't dispose the proxy before we get the disconnect response
The return_method would be rejected by the dbus-daemon when the NM drops
its match, resulting in an ugly message in the log:

  method call time=1458301860.187048 sender=:1.267 -> destination=:1.276
    serial=5302 path=/org/freedesktop/NetworkManager/VPN/Plugin;
    interface=org.freedesktop.NetworkManager.VPN.Plugin; member=Disconnect
  method call time=1458301860.187054 sender=:1.267 -> destination=org.freedesktop.DBus
    serial=5303 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus;
    member=RemoveMatch
     string "type='signal',sender='org.freedesktop.DBus',
                                   interface='org.freedesktop.DBus',
                                   member='NameOwnerChanged',
                                   path='/org/freedesktop/DBus',
                                   arg0='org.freedesktop.NetworkManager.libreswan.Connection_10'"
  method return time=1458301860.187061 sender=org.freedesktop.DBus -> destination=:1.267
    serial=1835 reply_serial=5303
  ...
  method return time=1458301860.195351 sender=:1.276 -> destination=:1.267
    serial=19 reply_serial=5302
  error time=1458301860.195361 sender=org.freedesktop.DBus -> destination=:1.276
    error_name=org.freedesktop.DBus.Error.AccessDenied reply_serial=19
     string "Rejected send message, 7 matched rules; type="method_return",
             sender=":1.276" (uid=0 pid=26915
             comm="/usr/libexec/nm-libreswan-service --bus-name org.f")
             interface="(unset)" member="(unset)" error name="(unset)"
             requested_reply="0" destination=":1.267" (uid=0 pid=25724
             comm="/usr/sbin/NetworkManager --no-daemon ")"

Also, refcount the connection instance. While the proxy is alive, it
invokes singal callbacks that get the object as a parameter.
2016-03-18 18:04:55 +01:00
Francesco Giudici
99ad9df342 dhcp: fix GBytes leak in nm_dhcp_client_start_ip4() 2016-03-18 10:46:16 +01:00
Thomas Haller
e3d2fc861b dhcp: support _LOGx_ENABLED() macro in dhcp-client
The macro _LOGx_ENABLED() is defined with a default implementation
that depends on _NMLOG_DOMAIN. Although that default does not
check for LOGD_DHCP4 vs. LOGD_DHCP6, still provide it.
Determining the correct domain might involve a larger performance
impact that what we would safe.
2016-03-17 18:00:53 +01:00
Thomas Haller
01732b87f6 rdisc: fix setting netns during consturction of NMRDisc
We obtain the netns from the platform instance that is passed
in. It's wrong to set the current netns in nm_rdisc_init().

Fixes: 3ba9444728
2016-03-17 16:19:09 +01:00
Thomas Haller
3363d8fd4e lldp: refactor keeping tlv data and order entries in neighbor GVariant
The fields in the neighbor variant should have a defined order.

Instead of sorting the hash table entries while constructing the
variant in lldp_neighbor_to_variant(), refactor the management of
the TLV attributes.
As we only support known attributes, we can
store them in an array at a known index instead of putting them
in a hash table.
An alternative would be to have explict fields for every known
attribute. That would be even more efficient, but requires more
work when adding new attributes.
2016-03-17 15:04:37 +01:00
Thomas Haller
191e5ae8a7 lldp: ensure stable order of variants in LLDP neighbor list 2016-03-17 15:00:49 +01:00
Thomas Haller
121e790bda lldp: drop process_lldp_neighbors()
We register the callback early on, so we get notified about
every single neighbor as they show up. No need to iterate over
them explicitly -- and probably, at that early state, there are
no neighbors yet.
2016-03-17 15:00:49 +01:00
Thomas Haller
4cd6ac3a7b lldp: process one neighbor at a time
The systemd event tells which neighbor changed. Make use
of this information and don't rebuild all the neighbors
all the time.

That means, we must also change our rate limiting. Instead of
rate limiting the processing of all neighbors, we process neighbors
right away but limit the notification that gobject property changed.
2016-03-17 15:00:49 +01:00
Thomas Haller
e1f1e07a3d lldp: implement properties via NM_GOBJECT_PROPERTIES_DEFINE() 2016-03-17 15:00:48 +01:00
Thomas Haller
c68dd4a202 lldp: improve logging 2016-03-17 15:00:48 +01:00
Thomas Haller
9c5265621c lldp: let lldp_neighbor_new() also create invalid objects
When we receive an update for a certain neighbor, the update
might be invalid and we want to reject it. However, we still
must create an invalid object to compare whether the update
causes a remove of a previously valid neighbor.

Let lldp_neighbor_new() create an instance as long as the
id fields are present.
2016-03-17 15:00:48 +01:00