Commit Graph

173 Commits

Author SHA1 Message Date
Thomas Haller
e65639bde9 util: add nm_utils_array_remove_at_indexes() function 2015-04-08 14:39:17 +02:00
Dan Winship
8da83a2ba3 core: port the daemon side of the dispatcher to gdbus 2015-04-03 16:58:40 -04:00
Dan Williams
06f25a3ec7 dns: ensure that update_dns() always returns a GError on failure
Callers may expect this, so make sure we do it.
2015-03-27 16:19:13 -05:00
Dan Williams
99a6201264 core: use dev_id when calculating the interface IPv6 IID (rh #1101809)
Some device types (s390 OSA and ipvlan) can use the same link-layer address
for multiple virtual interfaces, and the kernel used the dev_id property
to differentiate these devices when constructing the IID.  NM should do
this too to prevent IID clashes.

https://bugzilla.redhat.com/show_bug.cgi?id=1101809
2015-03-27 15:11:34 -05:00
Thomas Haller
e82293ebf6 libnm: move _nm_utils_uuid_generate_from_strings() from src/ to libnm-core/ 2015-03-12 18:12:26 +01:00
Thomas Haller
67510e323a trivial: rename nm_utils_uuid_generate_from_strings() to _nm_utils_uuid_generate_from_strings() 2015-03-12 18:12:26 +01:00
Thomas Haller
c5d23737fd libnm: move _nm_utils_ascii_str_to_int64() from src/ to libnm-core/ 2015-03-12 18:12:26 +01:00
Thomas Haller
093f6d477b trivial: rename nm_utils_ascii_str_to_int64() to _nm_utils_ascii_str_to_int64() 2015-03-12 18:12:26 +01:00
Dan Williams
231b0390a5 vpn: convert NMVpnConnection <-> VPN service communication to GDBus (bgo #745307)
Of special note is the new D-Bus rule to allow root to talk to
org.freedesktop.NetworkManager.VPN.Plugin, without which NetworkManager
would not hear signals from the VPN plugins.  Oddly, this worked
fine with dbus-glib...

https://bugzilla.gnome.org/show_bug.cgi?id=745307
2015-03-03 15:04:46 -06:00
Thomas Haller
3bcc5e4bd0 core: add nm_match_spec_split() function
There are currently three device spec properties: 'main.ignore-carrier',
'main.no-auto-default' and 'keyfile.unmanaged-devices'.

The first two, called g_key_file_parse_value_as_string() to split
the string into individual device specs. This uses ',' as separator
and supports escaping using '\\'.

'keyfile.unmanaged-devices' is split using ',' or ';' as separator
without supporting escaping.

Add a new function nm_match_spec_split(), to unify these two behaviors
and support both formats. That is, both previous formats are mostly
supported, but obviously there are some behavioral changes if the string
contains one of '\\', ',', or ';'.

nm_match_spec_split() is copied from glibs g_key_file_parse_value_as_string()
and adjusted.
2015-02-24 10:35:24 +01:00
Thomas Haller
5c2e1afd1b core: support "except:" spec to negate match
Extend nm_match_spec_*() to support an "except:" prefix to negate
the result of a match. "except:" only works when followed by
an exact match type, for example "except:interface-name:vboxnet0",
but not "except:vboxnet0".

A matching "except:" spec always wins, regardless of other positive
matchings.
2015-02-24 10:35:24 +01:00
Thomas Haller
2051944333 core: remove nm_match_spec_string()
It was only used to match against "*", in a case-insensitive
way.
2015-02-24 10:35:24 +01:00
Lubomir Rintel
0d59984ce8 core: Add NMUtilsIPv6IfaceId to nm-types.h
We'd like to use it in nm-platform.h, but it's included by
NetworkManagerUtils.h before the declaration occurs.
2015-01-26 13:05:06 +01:00
Thomas Haller
4ad6099b01 utils: add nm_utils_modprobe()
https://bugzilla.gnome.org/show_bug.cgi?id=740651
2015-01-19 12:07:27 -06:00
Dan Winship
fb792af7cb core: add nm_utils_setpgid(), and use it
Add nm_utils_setpgid() as a g_spawn*() child setup function for
calling setpgid(), and use it where appropriate rather than
reimplementing it every time.
2015-01-19 11:29:13 -05:00
Thomas Haller
422fbf48b9 all: move STRLEN() macro to global header nm-utils-internal.h
https://bugzilla.gnome.org/show_bug.cgi?id=741651
2014-12-18 17:36:57 +01:00
Thomas Haller
9a08d8602c core: add nm_utils_uuid_generate_from_strings()
Add function to create variant3 UUIDs based on a set
of concatenated strings.
2014-12-04 17:02:22 +01:00
Thomas Haller
ae2b8d6353 core: rename NM_PLATFORM_ROUTE_METRIC_DEFAULT to NM_PLATFORM_ROUTE_METRIC_DEFAULT_IP6
For IPv4, iproute for example defaults to a metric of 0.
Hence, the name NM_PLATFORM_ROUTE_METRIC_DEFAULT was misleading.

Also add a NM_PLATFORM_ROUTE_METRIC_DEFAULT_IP4 define for completeness.

https://bugzilla.gnome.org/show_bug.cgi?id=740780
2014-12-01 16:38:05 +01:00
Dan Williams
7df18cba5b core: add nm_utils_ip4_property_path() 2014-11-07 12:18:33 -06:00
Thomas Haller
c52e331014 core: move definition of NMLinkType to nm-types.h
As we use NMLinkType in NetworkManagerUtils.h, we cannot use
the utils header without nm-platform.h. That is clearly wrong.
Apparently NMLinkType has a wider use outside of platform (and
its name is not prefixed with 'platform' either).

Move the enum definition to nm-types.h.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-07 15:19:05 +01:00
Thomas Haller
f892ac4f45 core/trivial: remove semicolon from macro
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-07 15:19:05 +01:00
Thomas Haller
ff145486d1 core: add nm_ipX_config_get_direct_route_for_host() functions
add two functions nm_ip4_config_get_direct_route_for_host()
and nm_ip6_config_get_direct_route_for_host() to check if we have
a direct (non-gw) route to a certain host.

Signed-off-by: Thomas Haller <thaller@redhat.com>

https://bugzilla.gnome.org/show_bug.cgi?id=738590
2014-10-31 18:35:31 +01:00
Thomas Haller
22911696f4 core: add nm_utils_ip6_route_metric_normalize() function
Kernel treats IPv6 route metrics with value zero (0) special.
Add a utility function that helps accounting for that.

Signed-off-by: Thomas Haller <thaller@redhat.com>

https://bugzilla.gnome.org/show_bug.cgi?id=738590
2014-10-31 18:31:19 +01:00
Thomas Haller
41e0d5b9ce core: add nm_utils_log_connection_diff
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-10-12 21:17:17 +02:00
Thomas Haller
f87e876f79 core: prefer connections with higher priority for autoconnect
https://bugzilla.gnome.org/show_bug.cgi?id=580018

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-10-12 20:13:18 +02:00
Thomas Haller
efd8be04f1 core: add nm_utils_kill_process_sync() function
This utility function is for killing other processes.
Contrary to nm_utils_kill_child_*() which is for killing
and reaping child processes.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-10-10 12:28:59 +02:00
Thomas Haller
99c5edbacd core: add nm_utils_get_start_time_for_pid() function
Move the code from nm-auth-subject.c over to NetworkManagerUtils.c

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-10-10 11:51:40 +02:00
Thomas Haller
bda076bb3c core: add macros NM_FLAGS_HAS(), NM_FLAGS_ANY() and NM_FLAGS_ALL()
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-09-24 16:12:45 +02:00
Dan Winship
6793a32a8c libnm: port to GDBus
Port libnm-core/libnm to GDBus.

The NetworkManager daemon continues to use dbus-glib; the
previously-added connection hash/variant conversion methods are now
moved to NetworkManagerUtils (along with a few other utilities that
are now only needed by the daemon code).
2014-09-18 11:51:09 -04:00
Dan Williams
544fc82aa7 core: consolidate helper progam searching (bgo #734131)
Instead of having basically the same code in a bunch of different
place to find helper programs, just have one place do it.  Yes, this
does mean that the same sequence of paths is searched for all helpers
(so for example, dnsmasq will no longer be found first in /usr/local)
but I think consistency is the better option here.

https://bugzilla.gnome.org/show_bug.cgi?id=734131
2014-09-11 12:11:56 -05:00
Jiří Klimeš
5d982b3810 utils: use gssize (signed) 'len' parameter in nm_ethernet_address_is_valid()
Fix copyright statement too.
2014-09-05 11:11:01 +02:00
Dan Winship
3a54d05098 libnm-core: change all mac-address properties to G_TYPE_STRING
Make all mac-address properties (including NMSettingBluetooth:bdaddr,
NMSettingOlpcMesh:dhcp-anycast-addr, and NMSettingWireless:bssid) be
strings, using _nm_setting_class_transform_property() to handle
translating to/from binary form when dealing with D-Bus.

Update everything accordingly for the change, and also add a test for
transformed setting properties to test-general.
2014-09-04 09:20:10 -04:00
Dan Winship
7d233cc956 core: abstract out the duplicated default-ifname-generating code
NMDeviceBond, NMDeviceBridge, and NMDeviceTeam all used basically the
same code to generate a default interface name. Move it into
nm_utils_complete_generic().
2014-09-04 09:18:44 -04:00
Thomas Haller
ed20177d27 core: refactor nm_utils_complete_generic() not to use a dynamic format string
For NMDeviceWifi and NMDeviceWimax, the printf format string for
nm_utils_complete_generic() was created based on ssid/nsp. Since
these input strings are untrusted, this is a serious bug.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-25 16:46:14 +02:00
Dan Winship
c81fb49aa5 all: fix up multiple-include-guard defines
Previously, src/nm-ip4-config.h, libnm/nm-ip4-config.h, and
libnm-glib/nm-ip4-config.h all used "NM_IP4_CONFIG_H" as an include
guard, which meant that nm-test-utils.h could not tell which of them
was being included (and so, eg, if you tried to include
nm-ip4-config.h in a libnm test, it would fail to compile because
nm-test-utils.h was referring to symbols in src/nm-ip4-config.h).

Fix this by changing the include guards in the non-API-stable parts of
the tree:

  - libnm-glib/nm-ip4-config.h remains   NM_IP4_CONFIG_H
  - libnm/nm-ip4-config.h now uses     __NM_IP4_CONFIG_H__
  - src/nm-ip4-config.h now uses       __NETWORKMANAGER_IP4_CONFIG_H__

And likewise for all other headers.

The two non-"nm"-prefixed headers, libnm/NetworkManager.h and
src/NetworkManagerUtils.h are now __NETWORKMANAGER_H__ and
__NETWORKMANAGER_UTILS_H__ respectively, which, while not entirely
consistent with the general scheme, do still mostly make sense in
isolation.
2014-08-16 10:17:14 -04:00
Dan Winship
357efd26e4 libnm-core: include ETH_ALEN/INFINIBAND_ALEN defines in nm-utils.h
Include <linux/if_ether.h> and <linux/if_infiniband.h> from
nm-utils.h, to get ETH_ALEN and INFINIBAND_ALEN, and remove those
includes (as well as <net/ethernet.h> and <netinet/ether.h>, and
various headers that had been included to get the ARPHRD_* constants)
from other files where they're not needed now.
2014-08-07 14:04:14 -04:00
Dan Winship
ea456aaa81 all: remove use of struct ether_addr / ether_aton()
Lots of old code used struct ether_addr to store hardware addresses,
and ether_aton() to parse them, but more recent code generally uses
guint8 arrays, and the nm_utils_hwaddr_* methods, to be able to share
code between ETH_ALEN and INFINIBAND_ALEN cases. So update the old
code to match the new. (In many places, this ends up getting rid of
casts between struct ether_addr and guint8* anyway.)

(Also, in some places, variables were switched from struct ether_addr
to guint8[] a while back, but some code still used "&" when referring
to them even though that's unnecessary now. Clean that up.)
2014-08-07 12:11:49 -04:00
Dan Williams
e2270040c0 core: use Interface Identifiers for IPv6 SLAAC addresses
Ethernet-like interfaces aren't the only type of interfaces that can
run IPv6 but the rdisc code only returns an address if the interface's
hardware address is 6 bytes.

Interface types like PPP (rfc5072) and IPoIB (rfc4391) have their own
specifications for constructing IPv6 addresses and we should honor
those.

So instead of expecting a MAC address, let each device subclass
generate an Interface Identifier and use that for rdisc instead.
2014-07-23 12:53:55 -05:00
Dan Winship
b28f6526c2 core: fill in nm-types.h, clean out other headers
Clean up some of the cross-includes between headers (which made it so
that, eg, if you included NetworkManagerUtils.h in a test program, you
would need to build the test with -I$(top_srcdir)/src/platform, and if
you included nm-device.h you'd need $(POLKIT_CFLAGS)) by moving all
GObject struct definitions for src/ and src/settings/ into nm-types.h
(which already existed to solve the NMDevice/NMActRequest circular
references).

Update various .c files to explicitly include the headers they used to
get implicitly, and remove some now-unnecessary -I options from
Makefiles.
2014-07-23 10:56:26 -04:00
Jiří Klimeš
70e930bc0e utils: add nm_utils_is_specific_hostname()
The function detects whether the hostname is a specific hostname diferrent
from default hostnames like localhost, localhost[6].localdomain[6].
2014-07-14 17:36:07 +02:00
Thomas Haller
1f8418541e core: add nm_utils_kill_child_async() and nm_utils_kill_child_sync() function
Add utility function to kill and reap a child process.

https://bugzilla.gnome.org/show_bug.cgi?id=725660

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-07-10 16:25:10 +02:00
Thomas Haller
f600f31289 core: remove nm_utils_normalize_connection function
This functionality is now provided by nm_connection_normalize().

Contrary to nm_utils_normalize_connection(), nm_connection_normalize()
is in libnm-util and available to clients as well.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-30 18:35:46 +02:00
Thomas Haller
ed3f598f63 core: add utility function str_if_set()
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-24 16:07:07 +02:00
Thomas Haller
8f8b247e34 core: add nm_utils_get_monotonic_timestamp_ns() function
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-06 19:04:05 +02:00
Thomas Haller
ec7fc72e67 core: add ASSERT_VALID_PATH_COMPONENT function
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-04-10 16:27:02 +02:00
Thomas Haller
a72079a862 core: add macro STRLEN
Returns the length of a string at compile time. Contrary to strlen(),
which is a run time expression -- even if the compler might be able to
optimize strlen() for string constants.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-04-03 10:55:54 +02:00
Dan Winship
a10bd9991f core: move NMDevice's ip6_property_path() to NetworkManagerUtils 2014-03-04 17:04:01 -05:00
Dan Williams
1d5847c8a6 core: match IPv4 'disabled' method to 'auto' when device has no link
If IPv4 configuration did not succeed or the device has no IPv4 addresses
when NM restarts, it will detect the existing device configuration as
'disabled'.  This can happen when a bridge has no slaves and thus cannot
perform IPv4 addressing because it has no carrier (since bridge carrier
status depends on slave carriers).  When NM starts or restarts, it
sees the bridge has no IPv4 address and assumes the IPv4 method is
'disabled'.  This creates a new connection, which blocks any slave
connections from activating if they specify their master via UUID
 (since the bridge's active connection is generated).

Fix this by allowing matches from 'disabled' to 'auto' if the device
has no carrier, and there are no other differences between the
original and the candidate connections.
2014-03-04 15:21:58 -06:00
Thomas Haller
e8775dd9fc core: add function nm_utils_ip6_address_clear_host_address()
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-02-14 21:40:58 +01:00
Thomas Haller
a0e734764f core: add nm_utils_get_monotonic_timestamp_us() function
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-02-14 15:53:11 +01:00