Commit Graph

10612 Commits

Author SHA1 Message Date
Dan Williams
0bc1b5138a core: add support for internal device factories 2014-09-11 12:50:15 -05:00
Dan Williams
38b076de8f build: ensure device source file constructors can be linked and called
gcc's linker does not add constructors from object files to the main
executable if they are built into a convenience library and then the
library is linked to the executable, unless something outside of the
object file with the constructor references a symbol from the object
file.

http://osdir.com/ml/libtool-gnu/2011-06/msg00003.html

"Yes, when convenience libraries are used to create a shared library, all the
objects are included in the output, when the output is an application they are
used like a normal archive library.

Either use them to create a shared library or, if creating an application,
don't use them, use the objects instead."

Further patches will remove all references to the NMDevice subclasses
from nm-manager.c, and have each NMDevice subclass register itself
with a factory through a constructor.  But due to the above issue,
we need to somehow ensure the constructor in each nm-device-*.c file
gets added to the executable.  This is accomplished by explicitly
linking each NMDevice subclass' object file into the main executable.

(Note that we cannot use -Wl,-whole-archive here because libtool only
supports this option for linking a convenience library to a shared
library, but not to an executable, and will actively prevent using
-whole-archive in LDFLAGS)
2014-09-11 12:48:17 -05:00
Dan Williams
706b9d2056 core: pass parent to device factories when creating devices for connections
We'll use it later for InfiniBand and VLAN.
2014-09-11 12:47:23 -05:00
Dan Williams
560fe126b5 core: split out device factory registration function
We'll soon use it for both shared-library-based plugins, and internal
device factories.
2014-09-11 12:47:23 -05:00
Dan Williams
00fe31f5cd core: move device factory type function into factory object
In preparation for internal device types exposing factories too, it's
easier to have the device type that the factory creates be returned
by the factory object instead of the plugin, because internal device
types don't have plugins.

This requires that we create the factory objects earlier, which
further requires that any operations that trigger signals must be
moved out of each factory's construction path to a separate start()
function.
2014-09-11 12:47:23 -05:00
Dan Williams
beb18050b5 settings: create default wired connection from NMDeviceEthernet
Instead of creating it in NMSettings, where we must use
NM_IS_DEVICE_ETHERNET() (not NM_DEVICE_TYPE_ETHERNET because various generic
devices masquerade as NM_DEVICE_TYPE_ETHERNET too), push knowledge
of which device types create default wired connections into the device
types themselves.  This solves a problem with testcases where
libNetworkManager.a (which testcases link to) requires the symbol
nm_type_device_ethernet().
2014-09-11 12:47:07 -05:00
Dan Williams
56e2915536 trivial: spacing and code cleanups in nm-manager.h
Remove some dead code and a redundant function.
2014-09-11 12:40:08 -05:00
Dan Williams
3382d3e1a2 merge: consolidate searching for helper programs (bgo #734131)
https://bugzilla.gnome.org/show_bug.cgi?id=734131
2014-09-11 12:28:12 -05:00
Dan Williams
005cb2fc35 core: search for arping binary too (bgo #734131) 2014-09-11 12:11:57 -05: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š
053c8fa5df libnm-core: allow G_TYPE_STRV to be NULL
Otherwise we assert in _nm_utils_strv_to_slist() when setting a property,
using the code like:
g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (param_spec));
g_param_value_set_default (param_spec, &value);
g_object_set_property (G_OBJECT (setting), prop, &value);

e.g:
nmcli con mod my_profile eth.mac-address-blacklist "02:14:20:e6:16:83"

(changed by commit 6a4127cfa0)
2014-09-10 15:00:49 +02:00
Jiří Klimeš
8657b4229c ifcfg-rh: fix reading HWADDR_BLACKLIST
Adding GSList to the property may crash NetworkManager. Also check MAC
addresses and filter out the invalid ones.

(broken by commit 6a4127cfa0)
2014-09-10 15:00:49 +02:00
Jiří Klimeš
112c53be32 nm-utils: add a wrapper for g_strsplit_set() removing empty strings from array
g_strsplit_set() puts empty strings ("") into the resulting string array when
a delimiter character appears as the first or last character in the string or
when there are adjacent delimiter characters. However, this is not what is
useful in most cases.
2014-09-10 15:00:49 +02:00
Jiří Klimeš
9197d76e96 libnm: use g_return_if_fail() in a function returning void 2014-09-10 15:00:49 +02:00
Dan Winship
a098c8789b libnm: add test-secret-agent, glib-ify NMSecretAgent APIs (bgo #735916) 2014-09-09 12:16:46 -04:00
Dan Winship
d3b53b707a libnm: start glib-ifying NMSecretAgent APIs
Make register() and unregister() have cancellable sync and async
variants. And make NMSecretAgent implement GInitable/GAsyncInitable,
and do the initial auto-registration as part of initialization rather
than doing it asynchronously and emitting a signal.
2014-09-09 12:16:38 -04:00
Dan Winship
c9fb96e02e libnm: add test-secret-agent
Implement some basic secret agent functionality in
test-networkmanager-service.py, and add test-secret-agent to test that
NMSecretAgent works as expected.
2014-09-09 12:16:38 -04:00
Dan Winship
79093c655b libnm: NMSecretAgent shouldn't check peer UID on session bus
If an NMSecretAgent is attached to the session bus rather than the
system bus, then it's presumably a test program, and so we don't want
to check that the peer is root.
2014-09-09 12:16:37 -04:00
Dan Winship
8723bbd3e8 libnm: drop NMObject:dbus-connection (bgo #735916) 2014-09-09 12:15:54 -04:00
Dan Winship
b732380d1e libnm: drop NMObject:dbus-connection
The only plausible use case for the NMObject:dbus-connection property
is for using the session bus in test programs. So just drop it and use
an environment variable to decide which bus to use instead.
2014-09-09 12:10:13 -04:00
Dan Winship
a874e0beac libnm: assert that dbus_connection_allocate_data_slot() doesn't fail
dbus_connection_allocate_data_slot() can only fail on ENOMEM, in which
case the immediately-following call to g_set_error() would also get
ENOMEM and abort. So just simplify and assert that the libdbus call
didn't fail.
2014-09-09 12:10:13 -04:00
Jiří Klimeš
c6a932a2ce cli: fix ssid parameter processing in 'nmcli con add'
(broken by commit c43f88907b)
2014-09-09 16:54:32 +02:00
Dan Winship
730d096fe1 cli: fix MAC address validation (bgo #736275)
nm_utils_hwaddr_valid() accepts length while check_mac() mistakenly passes
type.

(broken by 3a54d05098)

https://bugzilla.gnome.org/show_bug.cgi?id=736275
2014-09-09 11:13:00 +02:00
Jiří Klimeš
886c3d7586 libnm-core: fix DCB's _nm_setting_dcb_uint_array_from_dbus()
and rename functions to be clearer:
set_uint_array()  -> set_array_from_gvalue()
take_uint_array() -> set_gvalue_from_array()
2014-09-08 17:56:51 +02:00
Jiří Klimeš
ac46435f2c Revert "libnm-core: fix NMSettingDcb"
This reverts commit b4bebbd02d.
2014-09-08 10:51:36 +02:00
Jiří Klimeš
aee8eb837b contrib/rpm: use HTTPS for connectivity check URL (rh #1135777)
https://bugzilla.redhat.com/show_bug.cgi?id=1135777
2014-09-05 23:24:08 +02:00
Dan Winship
d50795efd0 trivial: alphabetize the nm-*.xml files in introspection/Makefile.am 2014-09-05 14:18:15 -04:00
Dan Winship
b4bebbd02d libnm-core: fix NMSettingDcb
This got broken in the libnm-props changes (specifically 22b92a75).
2014-09-05 09:59:21 -04:00
Thomas Haller
6325c596c0 libnm: handle all-default settings in nm_setting_to_hash() properly
Before, _nm_setting_to_dbus() would return NULL instead of an empty
hash. This would be the case, if all properties are default.

When exporting connections via DBUS, we eventually call
_nm_setting_to_dbus() to convert the connection into a hash of hashes.
By _nm_setting_to_hash() converting empty hashes to NULL, the setting
is missing. Not returning empty hashes means that to_dbus() and
new_from_dbus() don't make a valid round-trip conversion.

Fix that by always returning a hash from _nm_setting_to_dbus()

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

See-also: 4d32618264
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-09-05 09:35:56 -04:00
Jiří Klimeš
85909d080f examples: fix python GI examples to work after libnm changes 2014-09-05 13:48:56 +02:00
Jiří Klimeš
2f3b45b76e libnm: add missing (transfer) annotations for return values 2014-09-05 13:46:00 +02: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
Jiří Klimeš
01d0d37615 dhcp: fix g_error_free() called with a bad argument 2014-09-05 10:25:03 +02:00
Dan Winship
00695f1939 Port non-libnm*-based code to GDBus (bgo #622927) 2014-09-04 18:20:33 -04:00
Dan Winship
9e5ddb5830 examples: port dbus-glib-based examples to gdbus
Port the dbus-glib-based examples to GDBus.

Also, don't use libnm in them at all; there's not much point in
examples that use the D-Bus API directly if they're just going to fall
back to libnm for the hard stuff... (And also, this avoids the problem
that GDBus uses GVariant, while the libnm-core APIs currently still
use GHashTables.)

Also fix up some comment grammar and copyright style, and add emacs
modelines where missing.

Also rename the existing GDBus-based examples to have names ending in
"-gdbus", not "-GDBus", since there's no reason to gratuitously
capitalize here.
2014-09-04 18:19:22 -04:00
Dan Winship
89228569f8 ppp-manager: port nm-pppd-plugin from dbus-glib to gdbus 2014-09-04 18:19:21 -04:00
Dan Winship
66c238e7b2 dhcp-manager: port nm-dhcp-helper from dbus-glib to gdbus 2014-09-04 18:19:21 -04:00
Dan Williams
4e530adf60 merge: handle IPv6 link-local addresses from userspace when possible (bgo #734149) 2014-09-04 15:11:55 -05:00
Dan Williams
5e4761a3a9 core: take over IPv6LL address management if kernel supports it (bgo #734149)
NM keeps interfaces IFF_UP when possible to receive link layer
events like carrier changes.  Unfortunately, the kernel also
uses IFF_UP as a flag to assign an IPv6LL address to the interface,
which results in IPv6 connectivity on the link even if the interface
is not supposed to be activated/connected.

NM sets disable_ipv6=1 to ensure that the kernel does not set up
IPv6LL connectivity on interfaces when they are not supposed to
be active and connected.  Unfortunately, that prevents users from
manually adding IPv6 addresses to the interface, since they expect
previous kernel behavior where IPv6 is enabled whenever the
interface is IFF_UP.

Furthermore, interfaces like PPP and some WWAN devices provide
misleading information to the kernel which causes the kernel to
create the wrong IPv6LL address for the interface.  The IPv6LL
address for these devices is obtained through control channels
instead (IPV6CP for PPP, proprietary protocols for WWAN devices)
and should be used instead of the kernel address.  So we'd like
to suppress kernel IPv6LL address generation on these interfaces
anyway.

This patch makes use of the netlink IFLA_INET6_ADDR_GEN_MODE
attribute to take over assignment of IPv6LL addresses while
keeping the interface IFF_UP, to ensure there is only IPv6
connectivity when the user requests it.

To remain compliant with standards, if a user adds IPv6 addresses
externally, NetworkManager must also immediately add an IPv6LL
address for that interface too.

https://bugzilla.gnome.org/show_bug.cgi?id=734149
2014-09-04 15:11:04 -05:00
Dan Williams
37f11fbdf8 platform: add support for kernel IPv6LL address generation modes
This patch requires both upstream kernel support for
IFLA_INET6_ADDR_GEN_MODE which was merged in this patch:

ipv6: addrconf: implement address generation modes
bc91b0f07ada5535427373a4e2050877bcc12218

and corresponding libnl support, merged in these patches:

veth: add kernel header linux/veth.h for VETH defines
9dc6e6da90016a33929f262bea0187396e1a061b

link: update copy of kernel header include/linux/if_link.h
b51815a9dbd8e45fd2558bbe337fb360ca2fd861

link/inet6: add link IPv6 address generation mode support
558f966782539f6d975da705fd73cea561c9dc83
2014-09-04 15:10:26 -05:00
Dan Williams
899df02e4c merge: fix some nmtui password issues (bgo #733002) 2014-09-04 09:53:06 -05:00
Dan Williams
82b0ea8707 tui: fix updating of NmtPasswordFields passwords (bgo #733002)
The actual entry is a sub-widget, and was getting updated when the
user changed the password, but those changes were not being
propagated to the NmtPasswordFields object's 'password' property.

https://bugzilla.gnome.org/show_bug.cgi?id=733002
2014-09-04 09:49:14 -05:00
Dan Williams
240a9a92ae tui: fix requesting and displaying secrets
nmt_sync_op_complete_pointer() completes the operation after the
caller of this function returns.  This means that any values passed
to this function must either be allocated from its caller, or
referenced by the caller.

nm_remote_connection_get_secrets() owns the 'secrets' hash passed
to the callback, and it is destroyed when the callback returns.
So nmtui's got_secrets() must copy the hash to ensure the data
sticks around for nmt_sync_op_wait_pointer() later.
2014-09-04 09:49:10 -05:00
Dan Winship
e7f01ae590 libnm: simplify property types [bgo #734492] 2014-09-04 09:21:10 -04:00
Dan Winship
98959d5432 libnm: fix NMIP4Config/NMIP6Config addresses/routes properties
The docs for NMIP4Config:addresses and NMIP4Config:routes claimed that
they were GPtrArrays of NMIP4Address/NMIP4Route, but get_property()
was actually trying to set them the D-Bus representation type, and it
was failing anyway because it used g_value_set_boxed() on a parameter
that was declared GParamSpecPointer. Fix it to use a GPtrArray-valued
property, and set it to the right thing.

NMIP6Config did the right thing with its :addresses and :routes
properties, but was using custom types (NM_TYPE_IP6_ADDRESS_OBJECT_ARRAY and
NM_TYPE_IP6_ROUTE_OBJECT_ARRAY). Make it use G_TYPE_PTR_ARRAY instead.

nm-types.c, nm-types.h, and nm-types-private.h are now empty, and so
can be dropped.
2014-09-04 09:21:05 -04:00
Dan Winship
356fb7d77e libnm: drop libnm IP-address-array types, use G_TYPE_STRV
Make NMIP4Config:nameservers, NMIP4Config:wins-servers, and
NMIP6Config:nameservers be G_TYPE_STRV, with stringified IP addresses,
and update the APIs accordingly.
2014-09-04 09:21:05 -04:00
Dan Winship
3e5b3833aa libnm: change empty-GPtrArray-return semantics
libnm functions that return GPtrArrays of objects had a rule that if
the array was empty, they would return NULL rather than a 0-length
array. As it turns out, this is just a nuisance to clients, since in
most places the code for the non-empty case would end up doing the
right thing for the empty case as well (and where it doesn't, we can
check "array->len == 0" just as easily as "array == NULL"). So just
return the 0-length array instead.
2014-09-04 09:21:05 -04:00
Dan Winship
074c2093b6 libnm: drop NM_TYPE_OBJECT_ARRAY, use G_TYPE_PTR_ARRAY
Use G_TYPE_PTR_ARRAY for GPtrArray-of-NMObject-valued properties,
because it has better introspection/bindings support.

As with the strdict change in libnm-core, we need to manually copy the
array in get_property() implementations, to preserve the standard
semantics that get_property() returns a copy, not the internal array.

(This patch also changes those properties so that they are always
non-NULL until dispose(); previously some of them could be either NULL
or 0-length at different times.)
2014-09-04 09:21:04 -04:00
Dan Winship
20dc44bda9 libnm: drop NM_TYPE_SSID, use G_TYPE_BYTES
Make NMAccessPoint:ssid be G_TYPE_BYTES and update the corresponding
APIs accordingly.
2014-09-04 09:21:04 -04:00
Dan Winship
4eb04dbcf8 libnm: drop NM_TYPE_STRING_ARRAY, use G_TYPE_STRV
Make NMIP4Config and NMIP6Config's array-of-string properties be
G_TYPE_STRV, and update the corresponding APIs accordingly.
2014-09-04 09:21:04 -04:00