Commit Graph

15047 Commits

Author SHA1 Message Date
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
Dan Winship
f71218d70a libnm: simplify NMDevice:state-reason
The NMDevice:state-reason property was awkward to work with since it
was a tuple of two values (state and reason), and likewise, although
we had nm_device_get_state() to return just the state, there was no
corresponding function to get just the reason.

Fix this; make the state-reason property contain just the
NMDeviceStateReason, and make nm_device_get_state_reason() return just
that.
2014-09-04 09:21:04 -04:00
Dan Winship
fa0fde04fa libnm-core: add NMSetting property transforms, improve object property types [bgo #734492] 2014-09-04 09:20:17 -04:00
Dan Winship
22b92a7574 libnm-core: change DCB DBUS_TYPE_G_UINT_ARRAY properties to G_TYPE_ARRAY
Change NMSettingDCB's guint-array properties to G_TYPE_ARRAY, with
annotations indicating the element type.

Since DBUS_TYPE_G_UINT_ARRAY was already represented as a GArray, this
does not require any changes anywhere else.
2014-09-04 09:20:12 -04:00
Dan Winship
c43f88907b libnm-core: change DBUS_TYPE_G_UCHAR_ARRAY properties to G_TYPE_BYTES
Change all DBUS_TYPE_G_UCHAR_ARRAY properties to G_TYPE_BYTES, and
update corresponding APIs. Notably, this means they are now refcounted
rather than being copied.

Update the rest of NM for the changes. The daemon still converts SSIDs
to GByteArrays internally, because changing it to use GBytes has lots
of trickle-down effects. It can possibly be changed later.
2014-09-04 09:20:11 -04:00
Dan Winship
3fbabde4c3 libnm-core: replace GByteArray with pointer + length in some APIs
APIs that take arbitrary data should take it in the form of a pointer
and length, not a GByteArray, so that you can use them regardless of
what format you have the data in (GByteArray, GBytes, plain array,
etc).
2014-09-04 09:20:11 -04:00
Dan Winship
9837565789 libnm-core: improve NMSettingIP4Config / NMSettingIP6Config property types
Make the :addresses and :routes properties be GPtrArrays of
NMIP4Address, etc, rather than just reflecting the D-Bus data.

Make the :dns properties be arrays of strings rather than arrays of
binary IP addresses (and update the corresponding APIs as well).
2014-09-04 09:20:11 -04:00
Dan Winship
9ed6bd2be5 libnm-core: change map-of-string properties to G_TYPE_HASH_TABLE
Change all DBUS_TYPE_G_MAP_OF_STRING properties to G_TYPE_HASH_TABLE,
with annotations indicating they are string->string. Not much outside
libnm-core needs to changed for this, since DBUS_TYPE_G_MAP_OF_STRING
was already represented as a hash table.

(One change needed within libnm-core is that we now need to copy the
hash tables in get_property(), or else the caller will receive a
reffed copy of the object's own hash table, which we don't want.)
2014-09-04 09:20:11 -04:00
Dan Winship
6a4127cfa0 libnm-core: change list-of-string and array-of-string properties to G_TYPE_STRV
Change all DBUS_TYPE_G_LIST_OF_STRING and DBUS_TYPE_G_ARRAY_OF_STRING
properties to G_TYPE_STRV, and update everything accordingly.

(This doesn't actually require using
_nm_setting_class_transform_property(); dbus-glib is happy to transform
between 'as' and G_TYPE_STRV.)
2014-09-04 09:20:10 -04: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
f4957eb0b7 libnm-core: add _nm_setting_class_transform_property()
Add a new kind of setting property override, for indicating that a
property exists in both the NMSetting and the D-Bus representation,
but in different formats, requiring conversion from one to the other.

Also, if a property is transformable, then compare the transformed
forms in nm_setting_compare() (since the D-Bus property types have
more metadata built-in).
2014-09-04 09:20:10 -04:00
Dan Winship
ca9938f458 libnm-core: drop NMParamSpecSpecialized, add nm_property_compare()
NMParamSpecSpecialized existed basically to provide a version of
GParamSpecBoxed that could compare dbus-glib-valued properties
correctly.

However, g_param_values_cmp() was only used by NM directly in one
place (NMSetting's compare_property()), and we don't actually need to
indirect through GParamSpec there; we could just call
NMParamSpecSpecialized's value-comparison function directly.

So, change all NMParamSpecSpecialized properties to GParamSpecBoxed,
rename the _gvalues_compare() function it used to
"nm_property_compare()", and use that from NMSetting.

(g_param_values_cmp() also gets used internally by
g_param_value_defaults(), but all NMParamSpecSpecialized properties
have a default value of NULL, so GParamSpecBoxed's pointer-equality
check will do the job just fine there.)
2014-09-04 09:20:10 -04:00
Dan Winship
99e1699d89 libnm-core: fix up the new property-comparison test program
Make the formerly-nm-param-spec-specialized test compile (fix use of
inet_pton), and pass (include the mandatory "gateway" element in the
IPv6 addresses), make it use gtestutils and g_assert (so it actually
fails when it fails), and test a few more cases.
2014-09-04 09:20:09 -04:00
Dan Winship
290598494d libnm-core: split the test program out of nm-param-spec-specialized.c 2014-09-04 09:20:09 -04:00
Dan Winship
0bf7311716 libnm-core: drop virtual setting :interface-name props [bgo #734492] 2014-09-04 09:19:06 -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