Commit Graph

7207 Commits

Author SHA1 Message Date
Dan Williams
6a19e68a7d libnm-core: clear secrets from NMSimpleConnection and NMSettingsConnection dispose()
A few of the settings plugins were calling nm_connection_clear_secrets()
from their finalize() method, but this call can emit signals, and by
the time finalize() runs, the object has a refcount of 0.  Signals
cannot be emitted from a finalized object, but instead could be
emitted from dispose() before the object is finalized.

Instead of moving the nm_connection_clear_secrets() to dispose() in each
plugin, make the behavior generic instead.  The settings plugins' parent
object is NMSettingsConnection, so clear secrets there.  Plus,
NMSettingsConnection caches system & agent secrets with NMSimpleConnection
objects, so clear secrets in NMSimpleConnection's dispose too.
2014-08-20 10:53:00 -05:00
Geoffrey Thomas
c75d878aa2 supplicant: fix expected return type of AddBlob D-Bus call
Commit fb6cde50 changed from setBlobs in the old wpa_supplicant D-Bus
interface, which returned an integer status code, to AddBlob in the new
one, which doesn't, but didn't account for that change. That caused
error messages of the form "Couldn't set network certificates: Too few
arguments in reply." on valid connection requests.

Signed-off-by: Geoffrey Thomas <gthomas@mokafive.com>
2014-08-20 09:32:12 -05:00
Thomas Haller
fe6b002f0f settings: fix memory leak in get_settings_auth_cb()
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-19 00:23:35 +02:00
Thomas Haller
25aa0a0705 libnm-core: fix crash in NMSettingAdsl:verify()
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-19 00:13:11 +02:00
Thomas Haller
722712b0df keyfile: fix crash due to uninitialized variable when reading invalid connection
Fixes: 2bfccab710
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-17 23:16:42 +02:00
Dan Winship
e1ba13a426 libnm-core, libnm, core: make NMConnection an interface
The fact that NMRemoteConnection has to be an NMConnection and
therefore can't be an NMObject means that it needs to reimplement bits
of NMObject functionality (and likewise NMObject needs some special
magic to deal with it). Likewise, we will need a daemon-side
equivalent of NMObject as part of the gdbus port, and we would want
NMSettingsConnection to be able to inherit from this as well.

Solve this problem by making NMConnection into an interface, and
having NMRemoteConnection and NMSettingsConnection implement it. (We
use some hacks to keep the GHashTable of NMSettings objects inside
nm-connection.c rather than having to be implemented by the
implementations.)

Since NMConnection is no longer an instantiable type, this adds
NMSimpleConnection to replace the various non-D-Bus-based uses of
NMConnection throughout the code. nm_connection_new() becomes
nm_simple_connection_new(), nm_connection_new_from_hash() becomes
nm_simple_connection_new_from_hash(), and nm_connection_duplicate()
becomes nm_simple_connection_new_clone().
2014-08-16 10:17:53 -04:00
Dan Winship
32c26a859b libnm-core: move some fake NMConnection methods over to NMSetting
nm_connection_lookup_setting_type() and
nm_connection_lookup_setting_type_by_quark() have nothing to do with
NMConnection. So move them to NMSetting (and rename them to
nm_setting_lookup_type() and nm_setting_lookup_type_by_quark()).
2014-08-16 10:17:53 -04:00
Dan Winship
2bfccab710 libnm-core: drop nm_connection_create_setting()
This was only used in one place, and is trivial to implement inline
there.
2014-08-16 10:17:52 -04: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 Williams
76ac21b26d keyfile: allow "," as unmanaged-devices separator
Only using ";" (the GKeyFile default) often confuses people.
2014-08-15 14:40:02 -05:00
Peter Korsgaard
123322c6d6 core: fix build with toolchains not exporting CLOCK_BOOTTIME
E.G. uClibc 0.9.33 and earlier.

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

Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-11 13:16:22 +02:00
Dan Williams
2bd5cf51b8 dhcp: fix killing wrong process ID on dhclient release
The prototype of dhclient_start() changed in 30cdd1248 but that
commit didn't update stop() correctly.  Clearly treating a gboolean
as pid_t isn't going to work.  Second, we don't want to watch the
child process on DHCP release because we're just going to kill it
shortly after.
2014-08-08 13:51:47 -05:00
Dan Winship
58a66cc70b core: fix a warning and a leak
For devices where we don't set the hardware address at construct time,
the first call to nm_device_update_hw_address() was hitting a
return-if-fail.

Also, when updating the hardware address, we were leaking the old
value.
2014-08-08 11:17:03 -04:00
Dan Winship
b019348fdd core: update data types of some hwaddr properties
Now that we have nm_utils_hwaddr_matches() for comparing addresses
(even when one is a string and the other binary), there are now places
where it's more convenient to store hardware addresses as strings
rather than binary, since we want them in string form for most
non-comparison purposes. So update for that.

In particular, this also changes nm_device_get_hw_address() to return
a string.

Also, simplify the update_permanent_hw_address() implementations by
assuming that they will only be called once. (Since they will.)
2014-08-07 15:41:04 -04:00
Dan Winship
44b9a8708b libnm-core, etc: add nm_utils_hwaddr_matches()
Add nm_utils_hwaddr_matches(), for comparing hardware addresses for
equality, allowing either binary or ASCII hardware addresses to be
passed, and handling the special rules for InfiniBand hardware
addresses automatically. Update code to use it.
2014-08-07 15:34:50 -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 Winship
35f36ba4c3 libnm-core, etc: drop type-based hwaddr funcs, port to length-based ones
Drop the arptype-based nm_utils_hwaddr funcs, and rename the
length-based ones to no longer have _len in their names. This also
switches nm_utils_hwaddr_atoba() to using a length rather than an
arptype, and adds a length argument to nm_utils_hwaddr_valid() (making
nm_utils_hwaddr_valid() now a replacement for nm_utils_hwaddr_aton()
in some places, where we were only using aton() to do validity
checking).
2014-08-07 12:08:16 -04:00
Thomas Haller
4b36f8b35b logging: use new logging macros in NMDevice subclasses
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-06 19:22:02 +02:00
Thomas Haller
950989c45c logging: extract logging macros for devices to nm-device-logging.h
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-06 19:22:02 +02:00
Dan Winship
e9fbf805a8 trivial: fix spacing in src/devices/wifi/nm-wifi-ap.h
This file had a bad mix of tabs and spaces. Fix it.
2014-08-05 10:54:39 -04:00
Thomas Haller
67ad3fcb5b platform/tests: disable platform root test 'test-link-linux' for now
This test is quite broken and fails often. It does not fail
always, but the changes for a failure are high.

We certainly should fix that, but for now exclude the test from
`make check`.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-04 16:17:49 +02:00
Geoffrey Thomas
5c31ed880d supplicant: fix invalid parameter type in AddBlob D-Bus call
Types passed to dbus-glib need to be GTypes, not D-Bus type. While the
DBUS_TYPE_G_* macros are GTypes from libdbus-glib, the other DBUS_ types
aren't.

Signed-off-by: Geoffrey Thomas <gthomas@mokafive.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-04 14:59:03 +02:00
Thomas Haller
ab8966d935 core: cleanup getting iface for NMDevice for logging
Since refactoring logging, these calls are not needed.
Just forgot to remove them.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-02 00:51:36 +02:00
Dan Winship
d0b05b34d5 libnm: add NetworkManager.h, disallow including individual headers
Add NetworkManager.h, which includes all of the other NM header, and
require all external users of libnm to use that rather than the
individual headers.

(An exception is made for nm-dbus-interface.h,
nm-vpn-dbus-interface.h, and nm-version.h, which can be included
separately.)
2014-08-01 14:34:40 -04:00
Dan Winship
3ddce74803 libnm: rename NetworkManager.h and NetworkManagerVPN.h
"NetworkManager.h"'s name (and non-standard capitalization) suggest
that it's some sort of high-level super-important header, but it's
really just low-level D-Bus stuff. Rename it to "nm-dbus-interface.h"
and likewise "NetworkManagerVPN.h" to "nm-vpn-dbus-interface.h"
2014-08-01 14:34:40 -04:00
Dan Winship
bdda66a813 libnm-core, etc: move NMSecretAgentCapabilities to NetworkManager.h
NMSecretAgentCapabilities was being defined in both
libnm/nm-secret-agent.h and in src/settings/nm-secret-agent.h. Since
it's part of the D-Bus interface, move it to
libnm-core/nm-dbus-interface.h.
2014-08-01 14:34:40 -04:00
Dan Winship
dc1b76432b include: drop nm-settings-flags.h, move NMSecretAgentGetSecretsFlags
For some reason, the flags used by o.fd.NM.SecretAgent.GetSecrets were
defined as both NMSecretAgentGetSecretsFlags in
libnm{,-glib}/nm-secret-agent.h, and then separately as
NMSettingsGetSecretsFlags in include/nm-settings-flags.h.
(NMSettingsGetSecretsFlags also had an additional internal-use-only
value, but that was added later after the duplication already
existed.)

Fix this by moving NMSecretAgentGetSecretsFlags from libnm to
nm-dbus-interface.h, adding the internal-use-only value to it as well,
updating the core code to use that, and then removing
nm-settings-flags.h.
2014-08-01 14:34:39 -04:00
Dan Winship
f441cf2b90 libnm: consistently use "INTERFACE" rather than "IFACE" in macros
Most D-Bus interface name macros used "INTERFACE" in their name (eg,
NM_DBUS_INTERFACE), but a few used "IFACE" instead (eg,
NM_DBUS_IFACE_SETTINGS). Make them consistent.
2014-08-01 14:34:06 -04:00
Dan Winship
3ac0f52878 libnm, core, cli, tui: fix the capitalization of various types
GLib/Gtk have mostly settled on the convention that two-letter
acronyms in type names remain all-caps (eg, "IO"), but longer acronyms
become initial-caps-only (eg, "Tcp").

NM was inconsistent, with most long acronyms using initial caps only
(Adsl, Cdma, Dcb, Gsm, Olpc, Vlan), but others using all caps (DHCP,
PPP, PPPOE, VPN). Fix libnm and src/ to use initial-caps only for all
three-or-more-letter-long acronyms (and update nmcli and nmtui for the
libnm changes).
2014-08-01 14:34:06 -04:00
Dan Winship
054c12ea30 libnm: remove all deprecated functions and types
Remove deprecated functions and enum types.

For now, deprecated properties are still around, because removing them
would cause warnings when talking to older implementations.
2014-08-01 14:34:05 -04:00
Dan Winship
a7c4d53d03 all: port everything to libnm
Since the API has not changed at this point, this is mostly just a
matter of updating Makefiles, and changing references to the library
name in comments.

NetworkManager cannot link to libnm due to the duplicated type/symbol
names. So it links to libnm-core.la directly, which means that
NetworkManager gets a separate copy of that code from libnm.so.
Everything else links to libnm.
2014-08-01 14:34:05 -04:00
Thomas Haller
be55d774eb core: refactoring logging in NMDevice to use new _LOG() macros
Make use of the previously added _LOG() macros in nm-device.c.
This reduces code, but also ensures printing the same prefix for
every logline produced *for* a device instance.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-01 19:09:47 +02:00
Thomas Haller
7de955c0d2 core/trivial: change variable name for self pointer in NMDevice to @self
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-01 19:09:23 +02:00
Thomas Haller
75d8a805e7 core: add logging macro _LOG() and _LOGD() to nm-device.c
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-01 19:06:25 +02:00
Thomas Haller
ca7329f7d4 core/logging: add new logging macro nm_log_obj()
Add new macro nm_log_obj() to prefix the log line with a pointer value
as identifier. This macro can be used to give each logging line a common
prefix with defined format. It is mainly intended to print a message
"for" an object, for example inside a method function.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-01 19:06:25 +02:00
Thomas Haller
573576bedd core/logging: define nm_log() to check for nm_logging_enabled() first
Change the definition of nm_log() to first check whether logging is
enabled. This has the benefit, that the logging arguments don't have
to be evaluated if logging is disabled.

With this change, you must ensure, that calling any logging function
is side-effect-free. For example:
    nm_log_debug ("This is a bug %s, %d", has_side_effect (), ++i);
would be a bug, because the logging arguments get only evaluated
depending on the logging setup.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-01 19:06:25 +02:00
Thomas Haller
7509d4f80f core/logging: change order or domain/level arguments for nm_log()
Now the order of arguments corresponds to nm_logging_enabled().

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-01 19:06:25 +02:00
Thomas Haller
60cf1b8fcd core/logging: define logging macros based on nm_log()
Base the definition of nm_log_*() macros on the nm_log() macro,
instead of directly on the _nm_log() function.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-01 19:06:25 +02:00
Thomas Haller
19d4bda69a core/logging: ensure that logging is always initialized
Ensure that nm_logging_setup() was called for all functions
where it actually makes a difference.

This is especially important for nm_logging_enabled(),
so that the behavior of the following is identical:

    nm_log_info(LOGD_CORE, "hello world");

and
    if (nm_logging_enabled (LOGL_INFO, LOGD_CORE))
        nm_log_info(LOGD_CORE, "hello world");

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-01 19:06:25 +02:00
Thomas Haller
453d1aa71d core/logging: return static string from nm_logging_domains_to_string()
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-01 19:06:25 +02:00
Thomas Haller
85b972e9b8 core/logging: return static string from nm_logging_level_to_string()
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-01 19:06:25 +02:00
Thomas Haller
ff6946a193 core/logging: align logging after "<LEVEL>" prefix
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-01 19:06:25 +02:00
Thomas Haller
f6882496e3 core/logging: add assert to nm_logging_setup() to check input arguments
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-01 19:06:25 +02:00
Thomas Haller
a69037431c core/logging: remove unused #undef from header file
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-01 19:06:25 +02:00
Thomas Haller
8720c8e136 core: no need to clone ifname in nm_device_generate_connection()
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-01 19:06:24 +02:00
Thomas Haller
d005c77213 build/dns: fix compilation error due to invalid #include path
Out-of-tree build fails with:
  ../../src/dns-manager/nm-dns-manager.c:38:33: fatal error: libnm-util/nm-utils.h: No such file or directory

Fixes regression introduced by commit 7580cfef20.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-01 13:59:11 +02:00
Thomas Haller
7580cfef20 dns: fix compiler warning by refactoring use of inet_ntop
Use nm_utils_inet4_ntop() and nm_utils_inet6_ntop() instead.
And get rid of the unneeded error-checking.

gcc warns:

    make[4]: Entering directory `/data/src/NetworkManager/src'
      CC       nm-dns-manager.lo
    dns-manager/nm-dns-manager.c: In function 'merge_one_ip4_config':
    dns-manager/nm-dns-manager.c:137:37: warning: ordered comparison of pointer with integer zero [-Wextra]
       if (inet_ntop (AF_INET, &addr, buf, INET_ADDRSTRLEN) > 0)
                                         ^
    dns-manager/nm-dns-manager.c:168:37: warning: ordered comparison of pointer with integer zero [-Wextra]
       if (inet_ntop (AF_INET, &addr, buf, INET_ADDRSTRLEN) > 0)
                                         ^
    dns-manager/nm-dns-manager.c: In function 'merge_one_ip6_config':
    dns-manager/nm-dns-manager.c:197:64: warning: ordered comparison of pointer with integer zero [-Wextra]
        if (inet_ntop (AF_INET, &(addr->s6_addr32[3]), buf, INET_ADDRSTRLEN) > 0)
                                                                    ^
    dns-manager/nm-dns-manager.c:200:38: warning: ordered comparison of pointer with integer zero [-Wextra]
        if (inet_ntop (AF_INET6, addr, buf, INET6_ADDRSTRLEN) > 0) {
                                          ^

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-01 13:17:01 +02:00
Thomas Haller
b835111129 libnm-util, core: fix warning about signed integer overflow (-Wstrict-overflow)
gcc warns:

    make[4]: Entering directory `./NetworkManager/libnm-util'
      CC       nm-value-transforms.lo
    nm-value-transforms.c: In function '_nm_utils_convert_op_array_to_string':
    nm-value-transforms.c:121:6: error: assuming signed overflow does not occur when simplifying conditional to constant [-Werror=strict-overflow]
       if (i > 0)
          ^
    nm-value-transforms.c: In function '_nm_utils_convert_string_array_to_string':
    nm-value-transforms.c:121:6: error: assuming signed overflow does not occur when simplifying conditional to constant [-Werror=strict-overflow]
       if (i > 0)
          ^

    make[7]: Entering directory `./NetworkManager/src/settings/plugins/ifcfg-rh'
      CC       reader.lo
    reader.c: In function 'make_wired_setting':
    reader.c:3295:6: error: assuming signed overflow does not occur when simplifying conditional to constant [-Werror=strict-overflow]
       if (!found)
          ^
    reader.c: In function 'wireless_connection_from_ifcfg':
    reader.c:3295:6: error: assuming signed overflow does not occur when simplifying conditional to constant [-Werror=strict-overflow]
       if (!found)
          ^

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-01 13:17:01 +02:00
Thomas Haller
f808c3603a platform/test: fix warning about uninitialized value
gcc warns:

    make[5]: Entering directory `./NetworkManager/src/platform/tests'
      CC       platform.o
    platform.c: In function ‘do_ip6_route_add’:
    platform.c:696:2: error: ‘plen’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
      return nm_platform_ip6_route_add (ifindex, NM_PLATFORM_SOURCE_USER,
      ^
    platform.c: In function ‘do_ip6_route_delete’:
    platform.c:724:2: error: ‘plen’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
      return nm_platform_ip6_route_delete (ifindex, network, plen, metric);
      ^
    platform.c: In function ‘do_ip4_route_delete’:
    [...]

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-01 13:17:01 +02:00