2014-07-24 08:53:33 -04:00
|
|
|
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
|
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
|
* Boston, MA 02110-1301 USA.
|
|
|
|
|
*
|
|
|
|
|
* Copyright 2007 - 2011 Red Hat, Inc.
|
|
|
|
|
* Copyright 2007 - 2008 Novell, Inc.
|
|
|
|
|
*/
|
|
|
|
|
|
2015-07-17 14:38:54 +02:00
|
|
|
#include "nm-default.h"
|
2016-02-19 14:57:48 +01:00
|
|
|
|
2014-07-24 08:53:33 -04:00
|
|
|
#include "nm-setting.h"
|
2016-02-12 14:44:52 +01:00
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
2014-07-24 08:53:33 -04:00
|
|
|
#include "nm-setting-private.h"
|
|
|
|
|
#include "nm-utils.h"
|
2014-02-25 20:30:27 +01:00
|
|
|
#include "nm-core-internal.h"
|
2014-07-24 08:53:33 -04:00
|
|
|
#include "nm-utils-private.h"
|
2014-07-29 09:22:07 -04:00
|
|
|
#include "nm-property-compare.h"
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2014-10-21 22:09:52 -04:00
|
|
|
#include "nm-setting-connection.h"
|
|
|
|
|
#include "nm-setting-bond.h"
|
|
|
|
|
#include "nm-setting-bridge.h"
|
|
|
|
|
#include "nm-setting-bridge-port.h"
|
|
|
|
|
#include "nm-setting-pppoe.h"
|
|
|
|
|
#include "nm-setting-team.h"
|
|
|
|
|
#include "nm-setting-team-port.h"
|
|
|
|
|
#include "nm-setting-vpn.h"
|
|
|
|
|
|
2014-07-24 08:53:33 -04:00
|
|
|
/**
|
|
|
|
|
* SECTION:nm-setting
|
|
|
|
|
* @short_description: Describes related configuration information
|
|
|
|
|
*
|
|
|
|
|
* Each #NMSetting contains properties that describe configuration that applies
|
|
|
|
|
* to a specific network layer (like IPv4 or IPv6 configuration) or device type
|
|
|
|
|
* (like Ethernet, or Wi-Fi). A collection of individual settings together
|
|
|
|
|
* make up an #NMConnection. Each property is strongly typed and usually has
|
|
|
|
|
* a number of allowed values. See each #NMSetting subclass for a description
|
|
|
|
|
* of properties and allowed values.
|
|
|
|
|
*/
|
|
|
|
|
|
2018-06-24 17:06:28 +02:00
|
|
|
/*****************************************************************************/
|
2014-07-24 08:53:33 -04:00
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
const char *name;
|
|
|
|
|
GType type;
|
2017-06-01 13:43:52 +02:00
|
|
|
NMSettingPriority priority;
|
2014-07-24 08:53:33 -04:00
|
|
|
} SettingInfo;
|
|
|
|
|
|
|
|
|
|
enum {
|
|
|
|
|
PROP_0,
|
|
|
|
|
PROP_NAME,
|
|
|
|
|
|
|
|
|
|
PROP_LAST
|
|
|
|
|
};
|
|
|
|
|
|
2018-06-24 17:06:28 +02:00
|
|
|
typedef struct {
|
libnm: use NMMetaSettingInfo for tracking setting priority
Previously, each (non abstract) NMSetting class had to register
its name and priority via _nm_register_setting().
Note, that libnm-core.la already links against "nm-meta-setting.c",
which also redundantly keeps track of the settings name and gtype
as well.
Re-use NMMetaSettingInfo also in libnm-core.la, to track this meta
data.
The goal is to get rid of private data structures that track
meta data about NMSetting classes. In this case, "registered_settings"
hash. Instead, we should have one place where all this meta data
is tracked. This was, it is also accessible as internal API,
which can be useful (for keyfile).
Note that NMSettingClass has some overlap with NMMetaSettingInfo.
One difference is, that NMMetaSettingInfo is const, while NMSettingClass
is only initialized during the class_init() method. Appart from that,
it's mostly a matter of taste, whether we attach meta data to
NMSettingClass, to NMMetaSettingInfo, or to a static-array indexed
by NMMetaSettingType.
Note, that previously, _nm_register_setting() was private API. That
means, no user could subclass a functioning NMSetting instance. The same
is still true: NMMetaSettingInfo is internal API and users cannot access
it to create their own NMSetting subclasses. But that is almost desired.
libnm is not designed, to be extensible via subclassing, nor is it
clear why that would be a useful thing to do. One day, we should remove
the NMSetting and NMSettingClass definitions from public headers. Their
only use is subclassing the types, which however does not work.
While libnm-core was linking already against nm-meta-setting.c,
nm_meta_setting_infos was unreferenced. So, this change increases
the binary size of libnm and NetworkManager (1032 bytes). Note however
that roughly the same information was previously allocated at runtime.
2018-07-27 14:08:14 +02:00
|
|
|
int dummy;
|
2018-06-24 17:06:28 +02:00
|
|
|
} NMSettingPrivate;
|
|
|
|
|
|
2018-06-24 17:41:02 +02:00
|
|
|
G_DEFINE_ABSTRACT_TYPE (NMSetting, nm_setting, G_TYPE_OBJECT)
|
2018-06-24 17:06:28 +02:00
|
|
|
|
|
|
|
|
#define NM_SETTING_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING, NMSettingPrivate))
|
|
|
|
|
|
2016-10-02 18:22:50 +02:00
|
|
|
/*****************************************************************************/
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2017-06-01 13:43:52 +02:00
|
|
|
static NMSettingPriority
|
libnm: use NMMetaSettingInfo for tracking setting priority
Previously, each (non abstract) NMSetting class had to register
its name and priority via _nm_register_setting().
Note, that libnm-core.la already links against "nm-meta-setting.c",
which also redundantly keeps track of the settings name and gtype
as well.
Re-use NMMetaSettingInfo also in libnm-core.la, to track this meta
data.
The goal is to get rid of private data structures that track
meta data about NMSetting classes. In this case, "registered_settings"
hash. Instead, we should have one place where all this meta data
is tracked. This was, it is also accessible as internal API,
which can be useful (for keyfile).
Note that NMSettingClass has some overlap with NMMetaSettingInfo.
One difference is, that NMMetaSettingInfo is const, while NMSettingClass
is only initialized during the class_init() method. Appart from that,
it's mostly a matter of taste, whether we attach meta data to
NMSettingClass, to NMMetaSettingInfo, or to a static-array indexed
by NMMetaSettingType.
Note, that previously, _nm_register_setting() was private API. That
means, no user could subclass a functioning NMSetting instance. The same
is still true: NMMetaSettingInfo is internal API and users cannot access
it to create their own NMSetting subclasses. But that is almost desired.
libnm is not designed, to be extensible via subclassing, nor is it
clear why that would be a useful thing to do. One day, we should remove
the NMSetting and NMSettingClass definitions from public headers. Their
only use is subclassing the types, which however does not work.
While libnm-core was linking already against nm-meta-setting.c,
nm_meta_setting_infos was unreferenced. So, this change increases
the binary size of libnm and NetworkManager (1032 bytes). Note however
that roughly the same information was previously allocated at runtime.
2018-07-27 14:08:14 +02:00
|
|
|
_get_base_type_priority (const NMMetaSettingInfo *setting_info,
|
|
|
|
|
GType gtype)
|
2014-07-24 08:53:33 -04:00
|
|
|
{
|
libnm: use NMMetaSettingInfo for tracking setting priority
Previously, each (non abstract) NMSetting class had to register
its name and priority via _nm_register_setting().
Note, that libnm-core.la already links against "nm-meta-setting.c",
which also redundantly keeps track of the settings name and gtype
as well.
Re-use NMMetaSettingInfo also in libnm-core.la, to track this meta
data.
The goal is to get rid of private data structures that track
meta data about NMSetting classes. In this case, "registered_settings"
hash. Instead, we should have one place where all this meta data
is tracked. This was, it is also accessible as internal API,
which can be useful (for keyfile).
Note that NMSettingClass has some overlap with NMMetaSettingInfo.
One difference is, that NMMetaSettingInfo is const, while NMSettingClass
is only initialized during the class_init() method. Appart from that,
it's mostly a matter of taste, whether we attach meta data to
NMSettingClass, to NMMetaSettingInfo, or to a static-array indexed
by NMMetaSettingType.
Note, that previously, _nm_register_setting() was private API. That
means, no user could subclass a functioning NMSetting instance. The same
is still true: NMMetaSettingInfo is internal API and users cannot access
it to create their own NMSetting subclasses. But that is almost desired.
libnm is not designed, to be extensible via subclassing, nor is it
clear why that would be a useful thing to do. One day, we should remove
the NMSetting and NMSettingClass definitions from public headers. Their
only use is subclassing the types, which however does not work.
While libnm-core was linking already against nm-meta-setting.c,
nm_meta_setting_infos was unreferenced. So, this change increases
the binary size of libnm and NetworkManager (1032 bytes). Note however
that roughly the same information was previously allocated at runtime.
2018-07-27 14:08:14 +02:00
|
|
|
/* Historical oddity: PPPoE is a base-type even though it's not
|
|
|
|
|
* priority 1. It needs to be sorted *after* lower-level stuff like
|
|
|
|
|
* Wi-Fi security or 802.1x for secrets, but it's still allowed as a
|
|
|
|
|
* base type.
|
|
|
|
|
*/
|
2014-07-24 08:53:33 -04:00
|
|
|
|
libnm: use NMMetaSettingInfo for tracking setting priority
Previously, each (non abstract) NMSetting class had to register
its name and priority via _nm_register_setting().
Note, that libnm-core.la already links against "nm-meta-setting.c",
which also redundantly keeps track of the settings name and gtype
as well.
Re-use NMMetaSettingInfo also in libnm-core.la, to track this meta
data.
The goal is to get rid of private data structures that track
meta data about NMSetting classes. In this case, "registered_settings"
hash. Instead, we should have one place where all this meta data
is tracked. This was, it is also accessible as internal API,
which can be useful (for keyfile).
Note that NMSettingClass has some overlap with NMMetaSettingInfo.
One difference is, that NMMetaSettingInfo is const, while NMSettingClass
is only initialized during the class_init() method. Appart from that,
it's mostly a matter of taste, whether we attach meta data to
NMSettingClass, to NMMetaSettingInfo, or to a static-array indexed
by NMMetaSettingType.
Note, that previously, _nm_register_setting() was private API. That
means, no user could subclass a functioning NMSetting instance. The same
is still true: NMMetaSettingInfo is internal API and users cannot access
it to create their own NMSetting subclasses. But that is almost desired.
libnm is not designed, to be extensible via subclassing, nor is it
clear why that would be a useful thing to do. One day, we should remove
the NMSetting and NMSettingClass definitions from public headers. Their
only use is subclassing the types, which however does not work.
While libnm-core was linking already against nm-meta-setting.c,
nm_meta_setting_infos was unreferenced. So, this change increases
the binary size of libnm and NetworkManager (1032 bytes). Note however
that roughly the same information was previously allocated at runtime.
2018-07-27 14:08:14 +02:00
|
|
|
if (setting_info) {
|
|
|
|
|
if ( NM_IN_SET (setting_info->setting_priority,
|
|
|
|
|
NM_SETTING_PRIORITY_HW_BASE,
|
|
|
|
|
NM_SETTING_PRIORITY_HW_NON_BASE)
|
|
|
|
|
|| gtype == NM_TYPE_SETTING_PPPOE)
|
|
|
|
|
return setting_info->setting_priority;
|
|
|
|
|
}
|
2014-07-24 08:53:33 -04:00
|
|
|
|
libnm: use NMMetaSettingInfo for tracking setting priority
Previously, each (non abstract) NMSetting class had to register
its name and priority via _nm_register_setting().
Note, that libnm-core.la already links against "nm-meta-setting.c",
which also redundantly keeps track of the settings name and gtype
as well.
Re-use NMMetaSettingInfo also in libnm-core.la, to track this meta
data.
The goal is to get rid of private data structures that track
meta data about NMSetting classes. In this case, "registered_settings"
hash. Instead, we should have one place where all this meta data
is tracked. This was, it is also accessible as internal API,
which can be useful (for keyfile).
Note that NMSettingClass has some overlap with NMMetaSettingInfo.
One difference is, that NMMetaSettingInfo is const, while NMSettingClass
is only initialized during the class_init() method. Appart from that,
it's mostly a matter of taste, whether we attach meta data to
NMSettingClass, to NMMetaSettingInfo, or to a static-array indexed
by NMMetaSettingType.
Note, that previously, _nm_register_setting() was private API. That
means, no user could subclass a functioning NMSetting instance. The same
is still true: NMMetaSettingInfo is internal API and users cannot access
it to create their own NMSetting subclasses. But that is almost desired.
libnm is not designed, to be extensible via subclassing, nor is it
clear why that would be a useful thing to do. One day, we should remove
the NMSetting and NMSettingClass definitions from public headers. Their
only use is subclassing the types, which however does not work.
While libnm-core was linking already against nm-meta-setting.c,
nm_meta_setting_infos was unreferenced. So, this change increases
the binary size of libnm and NetworkManager (1032 bytes). Note however
that roughly the same information was previously allocated at runtime.
2018-07-27 14:08:14 +02:00
|
|
|
return NM_SETTING_PRIORITY_INVALID;
|
2014-07-24 08:53:33 -04:00
|
|
|
}
|
|
|
|
|
|
2017-06-01 13:43:52 +02:00
|
|
|
NMSettingPriority
|
2014-02-25 20:30:27 +01:00
|
|
|
_nm_setting_get_setting_priority (NMSetting *setting)
|
|
|
|
|
{
|
libnm: use NMMetaSettingInfo for tracking setting priority
Previously, each (non abstract) NMSetting class had to register
its name and priority via _nm_register_setting().
Note, that libnm-core.la already links against "nm-meta-setting.c",
which also redundantly keeps track of the settings name and gtype
as well.
Re-use NMMetaSettingInfo also in libnm-core.la, to track this meta
data.
The goal is to get rid of private data structures that track
meta data about NMSetting classes. In this case, "registered_settings"
hash. Instead, we should have one place where all this meta data
is tracked. This was, it is also accessible as internal API,
which can be useful (for keyfile).
Note that NMSettingClass has some overlap with NMMetaSettingInfo.
One difference is, that NMMetaSettingInfo is const, while NMSettingClass
is only initialized during the class_init() method. Appart from that,
it's mostly a matter of taste, whether we attach meta data to
NMSettingClass, to NMMetaSettingInfo, or to a static-array indexed
by NMMetaSettingType.
Note, that previously, _nm_register_setting() was private API. That
means, no user could subclass a functioning NMSetting instance. The same
is still true: NMMetaSettingInfo is internal API and users cannot access
it to create their own NMSetting subclasses. But that is almost desired.
libnm is not designed, to be extensible via subclassing, nor is it
clear why that would be a useful thing to do. One day, we should remove
the NMSetting and NMSettingClass definitions from public headers. Their
only use is subclassing the types, which however does not work.
While libnm-core was linking already against nm-meta-setting.c,
nm_meta_setting_infos was unreferenced. So, this change increases
the binary size of libnm and NetworkManager (1032 bytes). Note however
that roughly the same information was previously allocated at runtime.
2018-07-27 14:08:14 +02:00
|
|
|
const NMMetaSettingInfo *setting_info;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING (setting), NM_SETTING_PRIORITY_INVALID);
|
2014-02-25 20:30:27 +01:00
|
|
|
|
libnm: use NMMetaSettingInfo for tracking setting priority
Previously, each (non abstract) NMSetting class had to register
its name and priority via _nm_register_setting().
Note, that libnm-core.la already links against "nm-meta-setting.c",
which also redundantly keeps track of the settings name and gtype
as well.
Re-use NMMetaSettingInfo also in libnm-core.la, to track this meta
data.
The goal is to get rid of private data structures that track
meta data about NMSetting classes. In this case, "registered_settings"
hash. Instead, we should have one place where all this meta data
is tracked. This was, it is also accessible as internal API,
which can be useful (for keyfile).
Note that NMSettingClass has some overlap with NMMetaSettingInfo.
One difference is, that NMMetaSettingInfo is const, while NMSettingClass
is only initialized during the class_init() method. Appart from that,
it's mostly a matter of taste, whether we attach meta data to
NMSettingClass, to NMMetaSettingInfo, or to a static-array indexed
by NMMetaSettingType.
Note, that previously, _nm_register_setting() was private API. That
means, no user could subclass a functioning NMSetting instance. The same
is still true: NMMetaSettingInfo is internal API and users cannot access
it to create their own NMSetting subclasses. But that is almost desired.
libnm is not designed, to be extensible via subclassing, nor is it
clear why that would be a useful thing to do. One day, we should remove
the NMSetting and NMSettingClass definitions from public headers. Their
only use is subclassing the types, which however does not work.
While libnm-core was linking already against nm-meta-setting.c,
nm_meta_setting_infos was unreferenced. So, this change increases
the binary size of libnm and NetworkManager (1032 bytes). Note however
that roughly the same information was previously allocated at runtime.
2018-07-27 14:08:14 +02:00
|
|
|
setting_info = NM_SETTING_GET_CLASS (setting)->setting_info;
|
|
|
|
|
return setting_info ? setting_info->setting_priority : NM_SETTING_PRIORITY_INVALID;
|
2014-02-25 20:30:27 +01:00
|
|
|
}
|
|
|
|
|
|
2017-06-01 13:43:52 +02:00
|
|
|
NMSettingPriority
|
2017-05-22 20:31:00 +02:00
|
|
|
_nm_setting_type_get_base_type_priority (GType type)
|
2014-07-24 08:53:33 -04:00
|
|
|
{
|
libnm: use NMMetaSettingInfo for tracking setting priority
Previously, each (non abstract) NMSetting class had to register
its name and priority via _nm_register_setting().
Note, that libnm-core.la already links against "nm-meta-setting.c",
which also redundantly keeps track of the settings name and gtype
as well.
Re-use NMMetaSettingInfo also in libnm-core.la, to track this meta
data.
The goal is to get rid of private data structures that track
meta data about NMSetting classes. In this case, "registered_settings"
hash. Instead, we should have one place where all this meta data
is tracked. This was, it is also accessible as internal API,
which can be useful (for keyfile).
Note that NMSettingClass has some overlap with NMMetaSettingInfo.
One difference is, that NMMetaSettingInfo is const, while NMSettingClass
is only initialized during the class_init() method. Appart from that,
it's mostly a matter of taste, whether we attach meta data to
NMSettingClass, to NMMetaSettingInfo, or to a static-array indexed
by NMMetaSettingType.
Note, that previously, _nm_register_setting() was private API. That
means, no user could subclass a functioning NMSetting instance. The same
is still true: NMMetaSettingInfo is internal API and users cannot access
it to create their own NMSetting subclasses. But that is almost desired.
libnm is not designed, to be extensible via subclassing, nor is it
clear why that would be a useful thing to do. One day, we should remove
the NMSetting and NMSettingClass definitions from public headers. Their
only use is subclassing the types, which however does not work.
While libnm-core was linking already against nm-meta-setting.c,
nm_meta_setting_infos was unreferenced. So, this change increases
the binary size of libnm and NetworkManager (1032 bytes). Note however
that roughly the same information was previously allocated at runtime.
2018-07-27 14:08:14 +02:00
|
|
|
return _get_base_type_priority (nm_meta_setting_infos_by_gtype (type),
|
|
|
|
|
type);
|
2014-07-24 08:53:33 -04:00
|
|
|
}
|
|
|
|
|
|
2017-06-01 13:43:52 +02:00
|
|
|
NMSettingPriority
|
2017-05-22 20:31:00 +02:00
|
|
|
_nm_setting_get_base_type_priority (NMSetting *setting)
|
2014-07-24 08:53:33 -04:00
|
|
|
{
|
libnm: use NMMetaSettingInfo for tracking setting priority
Previously, each (non abstract) NMSetting class had to register
its name and priority via _nm_register_setting().
Note, that libnm-core.la already links against "nm-meta-setting.c",
which also redundantly keeps track of the settings name and gtype
as well.
Re-use NMMetaSettingInfo also in libnm-core.la, to track this meta
data.
The goal is to get rid of private data structures that track
meta data about NMSetting classes. In this case, "registered_settings"
hash. Instead, we should have one place where all this meta data
is tracked. This was, it is also accessible as internal API,
which can be useful (for keyfile).
Note that NMSettingClass has some overlap with NMMetaSettingInfo.
One difference is, that NMMetaSettingInfo is const, while NMSettingClass
is only initialized during the class_init() method. Appart from that,
it's mostly a matter of taste, whether we attach meta data to
NMSettingClass, to NMMetaSettingInfo, or to a static-array indexed
by NMMetaSettingType.
Note, that previously, _nm_register_setting() was private API. That
means, no user could subclass a functioning NMSetting instance. The same
is still true: NMMetaSettingInfo is internal API and users cannot access
it to create their own NMSetting subclasses. But that is almost desired.
libnm is not designed, to be extensible via subclassing, nor is it
clear why that would be a useful thing to do. One day, we should remove
the NMSetting and NMSettingClass definitions from public headers. Their
only use is subclassing the types, which however does not work.
While libnm-core was linking already against nm-meta-setting.c,
nm_meta_setting_infos was unreferenced. So, this change increases
the binary size of libnm and NetworkManager (1032 bytes). Note however
that roughly the same information was previously allocated at runtime.
2018-07-27 14:08:14 +02:00
|
|
|
g_return_val_if_fail (NM_IS_SETTING (setting), NM_SETTING_PRIORITY_INVALID);
|
|
|
|
|
|
|
|
|
|
return _get_base_type_priority (NM_SETTING_GET_CLASS (setting)->setting_info,
|
|
|
|
|
G_OBJECT_TYPE (setting));
|
2014-07-24 08:53:33 -04:00
|
|
|
}
|
|
|
|
|
|
2014-08-12 17:25:26 -04:00
|
|
|
/**
|
|
|
|
|
* nm_setting_lookup_type:
|
|
|
|
|
* @name: a setting name
|
|
|
|
|
*
|
|
|
|
|
* Returns the #GType of the setting's class for a given setting name.
|
|
|
|
|
*
|
2014-08-22 10:20:29 -04:00
|
|
|
* Returns: the #GType of the setting's class, or %G_TYPE_INVALID if
|
|
|
|
|
* @name is not recognized.
|
2014-08-12 17:25:26 -04:00
|
|
|
**/
|
2014-07-24 08:53:33 -04:00
|
|
|
GType
|
2014-08-12 17:25:26 -04:00
|
|
|
nm_setting_lookup_type (const char *name)
|
2014-07-24 08:53:33 -04:00
|
|
|
{
|
libnm: use NMMetaSettingInfo for tracking setting priority
Previously, each (non abstract) NMSetting class had to register
its name and priority via _nm_register_setting().
Note, that libnm-core.la already links against "nm-meta-setting.c",
which also redundantly keeps track of the settings name and gtype
as well.
Re-use NMMetaSettingInfo also in libnm-core.la, to track this meta
data.
The goal is to get rid of private data structures that track
meta data about NMSetting classes. In this case, "registered_settings"
hash. Instead, we should have one place where all this meta data
is tracked. This was, it is also accessible as internal API,
which can be useful (for keyfile).
Note that NMSettingClass has some overlap with NMMetaSettingInfo.
One difference is, that NMMetaSettingInfo is const, while NMSettingClass
is only initialized during the class_init() method. Appart from that,
it's mostly a matter of taste, whether we attach meta data to
NMSettingClass, to NMMetaSettingInfo, or to a static-array indexed
by NMMetaSettingType.
Note, that previously, _nm_register_setting() was private API. That
means, no user could subclass a functioning NMSetting instance. The same
is still true: NMMetaSettingInfo is internal API and users cannot access
it to create their own NMSetting subclasses. But that is almost desired.
libnm is not designed, to be extensible via subclassing, nor is it
clear why that would be a useful thing to do. One day, we should remove
the NMSetting and NMSettingClass definitions from public headers. Their
only use is subclassing the types, which however does not work.
While libnm-core was linking already against nm-meta-setting.c,
nm_meta_setting_infos was unreferenced. So, this change increases
the binary size of libnm and NetworkManager (1032 bytes). Note however
that roughly the same information was previously allocated at runtime.
2018-07-27 14:08:14 +02:00
|
|
|
const NMMetaSettingInfo *setting_info;
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2017-06-01 21:06:17 +02:00
|
|
|
g_return_val_if_fail (name, G_TYPE_INVALID);
|
2014-07-24 08:53:33 -04:00
|
|
|
|
libnm: use NMMetaSettingInfo for tracking setting priority
Previously, each (non abstract) NMSetting class had to register
its name and priority via _nm_register_setting().
Note, that libnm-core.la already links against "nm-meta-setting.c",
which also redundantly keeps track of the settings name and gtype
as well.
Re-use NMMetaSettingInfo also in libnm-core.la, to track this meta
data.
The goal is to get rid of private data structures that track
meta data about NMSetting classes. In this case, "registered_settings"
hash. Instead, we should have one place where all this meta data
is tracked. This was, it is also accessible as internal API,
which can be useful (for keyfile).
Note that NMSettingClass has some overlap with NMMetaSettingInfo.
One difference is, that NMMetaSettingInfo is const, while NMSettingClass
is only initialized during the class_init() method. Appart from that,
it's mostly a matter of taste, whether we attach meta data to
NMSettingClass, to NMMetaSettingInfo, or to a static-array indexed
by NMMetaSettingType.
Note, that previously, _nm_register_setting() was private API. That
means, no user could subclass a functioning NMSetting instance. The same
is still true: NMMetaSettingInfo is internal API and users cannot access
it to create their own NMSetting subclasses. But that is almost desired.
libnm is not designed, to be extensible via subclassing, nor is it
clear why that would be a useful thing to do. One day, we should remove
the NMSetting and NMSettingClass definitions from public headers. Their
only use is subclassing the types, which however does not work.
While libnm-core was linking already against nm-meta-setting.c,
nm_meta_setting_infos was unreferenced. So, this change increases
the binary size of libnm and NetworkManager (1032 bytes). Note however
that roughly the same information was previously allocated at runtime.
2018-07-27 14:08:14 +02:00
|
|
|
setting_info = nm_meta_setting_infos_by_name (name);
|
|
|
|
|
return setting_info ? setting_info->get_setting_gtype () : G_TYPE_INVALID;
|
2014-07-24 08:53:33 -04:00
|
|
|
}
|
|
|
|
|
|
all: don't use gchar/gshort/gint/glong but C types
We commonly don't use the glib typedefs for char/short/int/long,
but their C types directly.
$ git grep '\<g\(char\|short\|int\|long\|float\|double\)\>' | wc -l
587
$ git grep '\<\(char\|short\|int\|long\|float\|double\)\>' | wc -l
21114
One could argue that using the glib typedefs is preferable in
public API (of our glib based libnm library) or where it clearly
is related to glib, like during
g_object_set (obj, PROPERTY, (gint) value, NULL);
However, that argument does not seem strong, because in practice we don't
follow that argument today, and seldomly use the glib typedefs.
Also, the style guide for this would be hard to formalize, because
"using them where clearly related to a glib" is a very loose suggestion.
Also note that glib typedefs will always just be typedefs of the
underlying C types. There is no danger of glib changing the meaning
of these typedefs (because that would be a major API break of glib).
A simple style guide is instead: don't use these typedefs.
No manual actions, I only ran the bash script:
FILES=($(git ls-files '*.[hc]'))
sed -i \
-e 's/\<g\(char\|short\|int\|long\|float\|double\)\>\( [^ ]\)/\1\2/g' \
-e 's/\<g\(char\|short\|int\|long\|float\|double\)\> /\1 /g' \
-e 's/\<g\(char\|short\|int\|long\|float\|double\)\>/\1/g' \
"${FILES[@]}"
2018-07-11 07:40:19 +02:00
|
|
|
int
|
2014-07-24 08:53:33 -04:00
|
|
|
_nm_setting_compare_priority (gconstpointer a, gconstpointer b)
|
|
|
|
|
{
|
2017-06-01 13:43:52 +02:00
|
|
|
NMSettingPriority prio_a, prio_b;
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2014-02-25 20:30:27 +01:00
|
|
|
prio_a = _nm_setting_get_setting_priority ((NMSetting *) a);
|
|
|
|
|
prio_b = _nm_setting_get_setting_priority ((NMSetting *) b);
|
2014-07-24 08:53:33 -04:00
|
|
|
|
|
|
|
|
if (prio_a < prio_b)
|
|
|
|
|
return -1;
|
|
|
|
|
else if (prio_a == prio_b)
|
|
|
|
|
return 0;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-02 18:22:50 +02:00
|
|
|
/*****************************************************************************/
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2014-07-07 17:05:10 +02:00
|
|
|
gboolean
|
|
|
|
|
_nm_setting_slave_type_is_valid (const char *slave_type, const char **out_port_type)
|
|
|
|
|
{
|
|
|
|
|
const char *port_type = NULL;
|
|
|
|
|
gboolean found = TRUE;
|
|
|
|
|
|
|
|
|
|
if (!slave_type)
|
|
|
|
|
found = FALSE;
|
|
|
|
|
else if (!strcmp (slave_type, NM_SETTING_BOND_SETTING_NAME))
|
|
|
|
|
;
|
|
|
|
|
else if (!strcmp (slave_type, NM_SETTING_BRIDGE_SETTING_NAME))
|
|
|
|
|
port_type = NM_SETTING_BRIDGE_PORT_SETTING_NAME;
|
2017-08-01 18:36:34 +02:00
|
|
|
else if (!strcmp (slave_type, NM_SETTING_OVS_BRIDGE_SETTING_NAME))
|
|
|
|
|
port_type = NM_SETTING_OVS_PORT_SETTING_NAME;
|
2017-10-02 09:03:19 +02:00
|
|
|
else if (!strcmp (slave_type, NM_SETTING_OVS_PORT_SETTING_NAME))
|
|
|
|
|
port_type = NM_SETTING_OVS_INTERFACE_SETTING_NAME;
|
2014-07-07 17:05:10 +02:00
|
|
|
else if (!strcmp (slave_type, NM_SETTING_TEAM_SETTING_NAME))
|
|
|
|
|
port_type = NM_SETTING_TEAM_PORT_SETTING_NAME;
|
|
|
|
|
else
|
|
|
|
|
found = FALSE;
|
|
|
|
|
|
|
|
|
|
if (out_port_type)
|
|
|
|
|
*out_port_type = port_type;
|
|
|
|
|
return found;
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-02 18:22:50 +02:00
|
|
|
/*****************************************************************************/
|
2014-07-07 17:05:10 +02:00
|
|
|
|
libnm-core: add dbus-only properties to NMSettingClass
Add _nm_setting_class_add_dbus_only_property(), for declaring
properties that appear in the D-Bus serialization, but which don't
correspond to GObject properties.
Since some property overrides will require examining settings other
than the setting that they are on (eg, the value of
802-11-wireless.security depends on whether an
NMSettingWirelessSecurity setting is present, and
NMSettingConnection:interface-name might sometimes be set from, eg,
bond.interface-name), we also update _nm_setting_to_dbus() to take the
full NMConnection as an argument, and _nm_setting_new_from_dbus() to
take the full connection hash.
Additionally, with some deprecated properties, we'll want to validate
them on construction, but we don't need to keep the value around after
that. So allow _nm_setting_new_from_dbus() to return a verification
error directly, so we don't need to store the value until the verify()
call.
2014-07-29 18:25:10 -04:00
|
|
|
typedef struct {
|
|
|
|
|
const char *name;
|
|
|
|
|
GParamSpec *param_spec;
|
2014-08-16 10:09:48 -04:00
|
|
|
const GVariantType *dbus_type;
|
2014-07-30 10:46:24 -04:00
|
|
|
|
libnm-core: add dbus-only properties to NMSettingClass
Add _nm_setting_class_add_dbus_only_property(), for declaring
properties that appear in the D-Bus serialization, but which don't
correspond to GObject properties.
Since some property overrides will require examining settings other
than the setting that they are on (eg, the value of
802-11-wireless.security depends on whether an
NMSettingWirelessSecurity setting is present, and
NMSettingConnection:interface-name might sometimes be set from, eg,
bond.interface-name), we also update _nm_setting_to_dbus() to take the
full NMConnection as an argument, and _nm_setting_new_from_dbus() to
take the full connection hash.
Additionally, with some deprecated properties, we'll want to validate
them on construction, but we don't need to keep the value around after
that. So allow _nm_setting_new_from_dbus() to return a verification
error directly, so we don't need to store the value until the verify()
call.
2014-07-29 18:25:10 -04:00
|
|
|
NMSettingPropertyGetFunc get_func;
|
2014-10-14 09:09:15 -04:00
|
|
|
NMSettingPropertySynthFunc synth_func;
|
libnm-core: add dbus-only properties to NMSettingClass
Add _nm_setting_class_add_dbus_only_property(), for declaring
properties that appear in the D-Bus serialization, but which don't
correspond to GObject properties.
Since some property overrides will require examining settings other
than the setting that they are on (eg, the value of
802-11-wireless.security depends on whether an
NMSettingWirelessSecurity setting is present, and
NMSettingConnection:interface-name might sometimes be set from, eg,
bond.interface-name), we also update _nm_setting_to_dbus() to take the
full NMConnection as an argument, and _nm_setting_new_from_dbus() to
take the full connection hash.
Additionally, with some deprecated properties, we'll want to validate
them on construction, but we don't need to keep the value around after
that. So allow _nm_setting_new_from_dbus() to return a verification
error directly, so we don't need to store the value until the verify()
call.
2014-07-29 18:25:10 -04:00
|
|
|
NMSettingPropertySetFunc set_func;
|
2014-07-29 18:25:10 -04:00
|
|
|
NMSettingPropertyNotSetFunc not_set_func;
|
2014-07-30 10:46:24 -04:00
|
|
|
|
2014-08-16 10:09:48 -04:00
|
|
|
NMSettingPropertyTransformToFunc to_dbus;
|
|
|
|
|
NMSettingPropertyTransformFromFunc from_dbus;
|
libnm-core: add dbus-only properties to NMSettingClass
Add _nm_setting_class_add_dbus_only_property(), for declaring
properties that appear in the D-Bus serialization, but which don't
correspond to GObject properties.
Since some property overrides will require examining settings other
than the setting that they are on (eg, the value of
802-11-wireless.security depends on whether an
NMSettingWirelessSecurity setting is present, and
NMSettingConnection:interface-name might sometimes be set from, eg,
bond.interface-name), we also update _nm_setting_to_dbus() to take the
full NMConnection as an argument, and _nm_setting_new_from_dbus() to
take the full connection hash.
Additionally, with some deprecated properties, we'll want to validate
them on construction, but we don't need to keep the value around after
that. So allow _nm_setting_new_from_dbus() to return a verification
error directly, so we don't need to store the value until the verify()
call.
2014-07-29 18:25:10 -04:00
|
|
|
} NMSettingProperty;
|
|
|
|
|
|
2017-02-03 17:21:21 +01:00
|
|
|
static NM_CACHED_QUARK_FCN ("nm-setting-property-overrides", setting_property_overrides_quark)
|
|
|
|
|
static NM_CACHED_QUARK_FCN ("nm-setting-properties", setting_properties_quark)
|
libnm-core: add dbus-only properties to NMSettingClass
Add _nm_setting_class_add_dbus_only_property(), for declaring
properties that appear in the D-Bus serialization, but which don't
correspond to GObject properties.
Since some property overrides will require examining settings other
than the setting that they are on (eg, the value of
802-11-wireless.security depends on whether an
NMSettingWirelessSecurity setting is present, and
NMSettingConnection:interface-name might sometimes be set from, eg,
bond.interface-name), we also update _nm_setting_to_dbus() to take the
full NMConnection as an argument, and _nm_setting_new_from_dbus() to
take the full connection hash.
Additionally, with some deprecated properties, we'll want to validate
them on construction, but we don't need to keep the value around after
that. So allow _nm_setting_new_from_dbus() to return a verification
error directly, so we don't need to store the value until the verify()
call.
2014-07-29 18:25:10 -04:00
|
|
|
|
|
|
|
|
static NMSettingProperty *
|
|
|
|
|
find_property (GArray *properties, const char *name)
|
|
|
|
|
{
|
|
|
|
|
NMSettingProperty *property;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
if (!properties)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < properties->len; i++) {
|
|
|
|
|
property = &g_array_index (properties, NMSettingProperty, i);
|
|
|
|
|
if (strcmp (name, property->name) == 0)
|
|
|
|
|
return property;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
add_property_override (NMSettingClass *setting_class,
|
|
|
|
|
const char *property_name,
|
2014-07-29 18:25:10 -04:00
|
|
|
GParamSpec *param_spec,
|
2014-08-16 10:09:48 -04:00
|
|
|
const GVariantType *dbus_type,
|
libnm-core: add dbus-only properties to NMSettingClass
Add _nm_setting_class_add_dbus_only_property(), for declaring
properties that appear in the D-Bus serialization, but which don't
correspond to GObject properties.
Since some property overrides will require examining settings other
than the setting that they are on (eg, the value of
802-11-wireless.security depends on whether an
NMSettingWirelessSecurity setting is present, and
NMSettingConnection:interface-name might sometimes be set from, eg,
bond.interface-name), we also update _nm_setting_to_dbus() to take the
full NMConnection as an argument, and _nm_setting_new_from_dbus() to
take the full connection hash.
Additionally, with some deprecated properties, we'll want to validate
them on construction, but we don't need to keep the value around after
that. So allow _nm_setting_new_from_dbus() to return a verification
error directly, so we don't need to store the value until the verify()
call.
2014-07-29 18:25:10 -04:00
|
|
|
NMSettingPropertyGetFunc get_func,
|
2014-10-14 09:09:15 -04:00
|
|
|
NMSettingPropertySynthFunc synth_func,
|
2014-07-29 18:25:10 -04:00
|
|
|
NMSettingPropertySetFunc set_func,
|
2014-07-30 10:46:24 -04:00
|
|
|
NMSettingPropertyNotSetFunc not_set_func,
|
2014-08-16 10:09:48 -04:00
|
|
|
NMSettingPropertyTransformToFunc to_dbus,
|
|
|
|
|
NMSettingPropertyTransformFromFunc from_dbus)
|
libnm-core: add dbus-only properties to NMSettingClass
Add _nm_setting_class_add_dbus_only_property(), for declaring
properties that appear in the D-Bus serialization, but which don't
correspond to GObject properties.
Since some property overrides will require examining settings other
than the setting that they are on (eg, the value of
802-11-wireless.security depends on whether an
NMSettingWirelessSecurity setting is present, and
NMSettingConnection:interface-name might sometimes be set from, eg,
bond.interface-name), we also update _nm_setting_to_dbus() to take the
full NMConnection as an argument, and _nm_setting_new_from_dbus() to
take the full connection hash.
Additionally, with some deprecated properties, we'll want to validate
them on construction, but we don't need to keep the value around after
that. So allow _nm_setting_new_from_dbus() to return a verification
error directly, so we don't need to store the value until the verify()
call.
2014-07-29 18:25:10 -04:00
|
|
|
{
|
|
|
|
|
GType setting_type = G_TYPE_FROM_CLASS (setting_class);
|
|
|
|
|
GArray *overrides;
|
|
|
|
|
NMSettingProperty override;
|
|
|
|
|
|
2017-02-03 17:21:21 +01:00
|
|
|
g_return_if_fail (g_type_get_qdata (setting_type, setting_properties_quark ()) == NULL);
|
libnm-core: add dbus-only properties to NMSettingClass
Add _nm_setting_class_add_dbus_only_property(), for declaring
properties that appear in the D-Bus serialization, but which don't
correspond to GObject properties.
Since some property overrides will require examining settings other
than the setting that they are on (eg, the value of
802-11-wireless.security depends on whether an
NMSettingWirelessSecurity setting is present, and
NMSettingConnection:interface-name might sometimes be set from, eg,
bond.interface-name), we also update _nm_setting_to_dbus() to take the
full NMConnection as an argument, and _nm_setting_new_from_dbus() to
take the full connection hash.
Additionally, with some deprecated properties, we'll want to validate
them on construction, but we don't need to keep the value around after
that. So allow _nm_setting_new_from_dbus() to return a verification
error directly, so we don't need to store the value until the verify()
call.
2014-07-29 18:25:10 -04:00
|
|
|
|
|
|
|
|
memset (&override, 0, sizeof (override));
|
|
|
|
|
override.name = property_name;
|
2014-07-29 18:25:10 -04:00
|
|
|
override.param_spec = param_spec;
|
libnm-core: add dbus-only properties to NMSettingClass
Add _nm_setting_class_add_dbus_only_property(), for declaring
properties that appear in the D-Bus serialization, but which don't
correspond to GObject properties.
Since some property overrides will require examining settings other
than the setting that they are on (eg, the value of
802-11-wireless.security depends on whether an
NMSettingWirelessSecurity setting is present, and
NMSettingConnection:interface-name might sometimes be set from, eg,
bond.interface-name), we also update _nm_setting_to_dbus() to take the
full NMConnection as an argument, and _nm_setting_new_from_dbus() to
take the full connection hash.
Additionally, with some deprecated properties, we'll want to validate
them on construction, but we don't need to keep the value around after
that. So allow _nm_setting_new_from_dbus() to return a verification
error directly, so we don't need to store the value until the verify()
call.
2014-07-29 18:25:10 -04:00
|
|
|
override.dbus_type = dbus_type;
|
|
|
|
|
override.get_func = get_func;
|
2014-10-14 09:09:15 -04:00
|
|
|
override.synth_func = synth_func;
|
libnm-core: add dbus-only properties to NMSettingClass
Add _nm_setting_class_add_dbus_only_property(), for declaring
properties that appear in the D-Bus serialization, but which don't
correspond to GObject properties.
Since some property overrides will require examining settings other
than the setting that they are on (eg, the value of
802-11-wireless.security depends on whether an
NMSettingWirelessSecurity setting is present, and
NMSettingConnection:interface-name might sometimes be set from, eg,
bond.interface-name), we also update _nm_setting_to_dbus() to take the
full NMConnection as an argument, and _nm_setting_new_from_dbus() to
take the full connection hash.
Additionally, with some deprecated properties, we'll want to validate
them on construction, but we don't need to keep the value around after
that. So allow _nm_setting_new_from_dbus() to return a verification
error directly, so we don't need to store the value until the verify()
call.
2014-07-29 18:25:10 -04:00
|
|
|
override.set_func = set_func;
|
2014-07-29 18:25:10 -04:00
|
|
|
override.not_set_func = not_set_func;
|
2014-07-30 10:46:24 -04:00
|
|
|
override.to_dbus = to_dbus;
|
|
|
|
|
override.from_dbus = from_dbus;
|
libnm-core: add dbus-only properties to NMSettingClass
Add _nm_setting_class_add_dbus_only_property(), for declaring
properties that appear in the D-Bus serialization, but which don't
correspond to GObject properties.
Since some property overrides will require examining settings other
than the setting that they are on (eg, the value of
802-11-wireless.security depends on whether an
NMSettingWirelessSecurity setting is present, and
NMSettingConnection:interface-name might sometimes be set from, eg,
bond.interface-name), we also update _nm_setting_to_dbus() to take the
full NMConnection as an argument, and _nm_setting_new_from_dbus() to
take the full connection hash.
Additionally, with some deprecated properties, we'll want to validate
them on construction, but we don't need to keep the value around after
that. So allow _nm_setting_new_from_dbus() to return a verification
error directly, so we don't need to store the value until the verify()
call.
2014-07-29 18:25:10 -04:00
|
|
|
|
2017-02-03 17:21:21 +01:00
|
|
|
overrides = g_type_get_qdata (setting_type, setting_property_overrides_quark ());
|
libnm-core: add dbus-only properties to NMSettingClass
Add _nm_setting_class_add_dbus_only_property(), for declaring
properties that appear in the D-Bus serialization, but which don't
correspond to GObject properties.
Since some property overrides will require examining settings other
than the setting that they are on (eg, the value of
802-11-wireless.security depends on whether an
NMSettingWirelessSecurity setting is present, and
NMSettingConnection:interface-name might sometimes be set from, eg,
bond.interface-name), we also update _nm_setting_to_dbus() to take the
full NMConnection as an argument, and _nm_setting_new_from_dbus() to
take the full connection hash.
Additionally, with some deprecated properties, we'll want to validate
them on construction, but we don't need to keep the value around after
that. So allow _nm_setting_new_from_dbus() to return a verification
error directly, so we don't need to store the value until the verify()
call.
2014-07-29 18:25:10 -04:00
|
|
|
if (!overrides) {
|
|
|
|
|
overrides = g_array_new (FALSE, FALSE, sizeof (NMSettingProperty));
|
2017-02-03 17:21:21 +01:00
|
|
|
g_type_set_qdata (setting_type, setting_property_overrides_quark (), overrides);
|
libnm-core: add dbus-only properties to NMSettingClass
Add _nm_setting_class_add_dbus_only_property(), for declaring
properties that appear in the D-Bus serialization, but which don't
correspond to GObject properties.
Since some property overrides will require examining settings other
than the setting that they are on (eg, the value of
802-11-wireless.security depends on whether an
NMSettingWirelessSecurity setting is present, and
NMSettingConnection:interface-name might sometimes be set from, eg,
bond.interface-name), we also update _nm_setting_to_dbus() to take the
full NMConnection as an argument, and _nm_setting_new_from_dbus() to
take the full connection hash.
Additionally, with some deprecated properties, we'll want to validate
them on construction, but we don't need to keep the value around after
that. So allow _nm_setting_new_from_dbus() to return a verification
error directly, so we don't need to store the value until the verify()
call.
2014-07-29 18:25:10 -04:00
|
|
|
}
|
|
|
|
|
g_return_if_fail (find_property (overrides, property_name) == NULL);
|
|
|
|
|
|
|
|
|
|
g_array_append_val (overrides, override);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* _nm_setting_class_add_dbus_only_property:
|
|
|
|
|
* @setting_class: the setting class
|
|
|
|
|
* @property_name: the name of the property to override
|
2014-08-16 10:09:48 -04:00
|
|
|
* @dbus_type: the type of the property (in its D-Bus representation)
|
2014-10-14 09:09:15 -04:00
|
|
|
* @synth_func: (allow-none): function to call to synthesize a value for the property
|
libnm-core: add dbus-only properties to NMSettingClass
Add _nm_setting_class_add_dbus_only_property(), for declaring
properties that appear in the D-Bus serialization, but which don't
correspond to GObject properties.
Since some property overrides will require examining settings other
than the setting that they are on (eg, the value of
802-11-wireless.security depends on whether an
NMSettingWirelessSecurity setting is present, and
NMSettingConnection:interface-name might sometimes be set from, eg,
bond.interface-name), we also update _nm_setting_to_dbus() to take the
full NMConnection as an argument, and _nm_setting_new_from_dbus() to
take the full connection hash.
Additionally, with some deprecated properties, we'll want to validate
them on construction, but we don't need to keep the value around after
that. So allow _nm_setting_new_from_dbus() to return a verification
error directly, so we don't need to store the value until the verify()
call.
2014-07-29 18:25:10 -04:00
|
|
|
* @set_func: (allow-none): function to call to set the value of the property
|
|
|
|
|
*
|
|
|
|
|
* Registers a property named @property_name, which will be used in the D-Bus
|
|
|
|
|
* serialization of objects of @setting_class, but which does not correspond to
|
|
|
|
|
* a #GObject property.
|
|
|
|
|
*
|
2014-10-14 09:09:15 -04:00
|
|
|
* When serializing a setting to D-Bus, @synth_func will be called to synthesize
|
|
|
|
|
* a value for the property. (If it returns %NULL, no value will be added to the
|
|
|
|
|
* serialization. If @synth_func is %NULL, the property will always be omitted
|
|
|
|
|
* in the serialization.)
|
libnm-core: add dbus-only properties to NMSettingClass
Add _nm_setting_class_add_dbus_only_property(), for declaring
properties that appear in the D-Bus serialization, but which don't
correspond to GObject properties.
Since some property overrides will require examining settings other
than the setting that they are on (eg, the value of
802-11-wireless.security depends on whether an
NMSettingWirelessSecurity setting is present, and
NMSettingConnection:interface-name might sometimes be set from, eg,
bond.interface-name), we also update _nm_setting_to_dbus() to take the
full NMConnection as an argument, and _nm_setting_new_from_dbus() to
take the full connection hash.
Additionally, with some deprecated properties, we'll want to validate
them on construction, but we don't need to keep the value around after
that. So allow _nm_setting_new_from_dbus() to return a verification
error directly, so we don't need to store the value until the verify()
call.
2014-07-29 18:25:10 -04:00
|
|
|
*
|
|
|
|
|
* When deserializing a D-Bus representation into a setting, if @property_name
|
2014-10-14 08:56:50 -04:00
|
|
|
* is present, then @set_func will be called to set it. (If @set_func is %NULL
|
|
|
|
|
* then the property will be ignored when deserializing.)
|
libnm-core: add dbus-only properties to NMSettingClass
Add _nm_setting_class_add_dbus_only_property(), for declaring
properties that appear in the D-Bus serialization, but which don't
correspond to GObject properties.
Since some property overrides will require examining settings other
than the setting that they are on (eg, the value of
802-11-wireless.security depends on whether an
NMSettingWirelessSecurity setting is present, and
NMSettingConnection:interface-name might sometimes be set from, eg,
bond.interface-name), we also update _nm_setting_to_dbus() to take the
full NMConnection as an argument, and _nm_setting_new_from_dbus() to
take the full connection hash.
Additionally, with some deprecated properties, we'll want to validate
them on construction, but we don't need to keep the value around after
that. So allow _nm_setting_new_from_dbus() to return a verification
error directly, so we don't need to store the value until the verify()
call.
2014-07-29 18:25:10 -04:00
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
_nm_setting_class_add_dbus_only_property (NMSettingClass *setting_class,
|
|
|
|
|
const char *property_name,
|
2014-08-16 10:09:48 -04:00
|
|
|
const GVariantType *dbus_type,
|
2014-10-14 09:09:15 -04:00
|
|
|
NMSettingPropertySynthFunc synth_func,
|
libnm-core: add dbus-only properties to NMSettingClass
Add _nm_setting_class_add_dbus_only_property(), for declaring
properties that appear in the D-Bus serialization, but which don't
correspond to GObject properties.
Since some property overrides will require examining settings other
than the setting that they are on (eg, the value of
802-11-wireless.security depends on whether an
NMSettingWirelessSecurity setting is present, and
NMSettingConnection:interface-name might sometimes be set from, eg,
bond.interface-name), we also update _nm_setting_to_dbus() to take the
full NMConnection as an argument, and _nm_setting_new_from_dbus() to
take the full connection hash.
Additionally, with some deprecated properties, we'll want to validate
them on construction, but we don't need to keep the value around after
that. So allow _nm_setting_new_from_dbus() to return a verification
error directly, so we don't need to store the value until the verify()
call.
2014-07-29 18:25:10 -04:00
|
|
|
NMSettingPropertySetFunc set_func)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (NM_IS_SETTING_CLASS (setting_class));
|
|
|
|
|
g_return_if_fail (property_name != NULL);
|
|
|
|
|
|
|
|
|
|
/* Must not match any GObject property. */
|
|
|
|
|
g_return_if_fail (!g_object_class_find_property (G_OBJECT_CLASS (setting_class), property_name));
|
|
|
|
|
|
|
|
|
|
add_property_override (setting_class,
|
2014-07-29 18:25:10 -04:00
|
|
|
property_name, NULL, dbus_type,
|
2014-10-14 09:09:15 -04:00
|
|
|
NULL, synth_func, set_func, NULL,
|
2014-07-30 10:46:24 -04:00
|
|
|
NULL, NULL);
|
2014-07-29 18:25:10 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* _nm_setting_class_override_property:
|
|
|
|
|
* @setting_class: the setting class
|
|
|
|
|
* @property_name: the name of the property to override
|
|
|
|
|
* @dbus_type: the type of the property (in its D-Bus representation)
|
|
|
|
|
* @get_func: (allow-none): function to call to get the value of the property
|
|
|
|
|
* @set_func: (allow-none): function to call to set the value of the property
|
|
|
|
|
* @not_set_func: (allow-none): function to call to indicate the property was not set
|
|
|
|
|
*
|
|
|
|
|
* Overrides the D-Bus representation of the #GObject property named
|
|
|
|
|
* @property_name on @setting_class.
|
|
|
|
|
*
|
|
|
|
|
* When serializing a setting to D-Bus, if @get_func is non-%NULL, then it will
|
2014-10-14 08:56:50 -04:00
|
|
|
* be called to get the property's value. If it returns a #GVariant, the
|
|
|
|
|
* property will be added to the hash, and if it returns %NULL, the property
|
|
|
|
|
* will be omitted. (If @get_func is %NULL, the property will be read normally
|
|
|
|
|
* with g_object_get_property(), and added to the hash if it is not the default
|
|
|
|
|
* value.)
|
2014-07-29 18:25:10 -04:00
|
|
|
*
|
|
|
|
|
* When deserializing a D-Bus representation into a setting, if @property_name
|
2014-10-14 08:56:50 -04:00
|
|
|
* is present, then @set_func will be called to set it. (If @set_func is %NULL
|
|
|
|
|
* then the property will be set normally with g_object_set_property().)
|
2014-07-29 18:25:10 -04:00
|
|
|
*
|
|
|
|
|
* If @not_set_func is non-%NULL, then it will be called when deserializing a
|
|
|
|
|
* representation that does NOT contain @property_name. This can be used, eg, if
|
|
|
|
|
* a new property needs to be initialized from some older deprecated property
|
|
|
|
|
* when it is not present.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
_nm_setting_class_override_property (NMSettingClass *setting_class,
|
|
|
|
|
const char *property_name,
|
2014-08-16 10:09:48 -04:00
|
|
|
const GVariantType *dbus_type,
|
2014-07-29 18:25:10 -04:00
|
|
|
NMSettingPropertyGetFunc get_func,
|
|
|
|
|
NMSettingPropertySetFunc set_func,
|
|
|
|
|
NMSettingPropertyNotSetFunc not_set_func)
|
|
|
|
|
{
|
|
|
|
|
GParamSpec *param_spec;
|
|
|
|
|
|
|
|
|
|
param_spec = g_object_class_find_property (G_OBJECT_CLASS (setting_class), property_name);
|
|
|
|
|
g_return_if_fail (param_spec != NULL);
|
|
|
|
|
|
|
|
|
|
add_property_override (setting_class,
|
|
|
|
|
property_name, param_spec, dbus_type,
|
2014-10-14 09:09:15 -04:00
|
|
|
get_func, NULL, set_func, not_set_func,
|
2014-07-30 10:46:24 -04:00
|
|
|
NULL, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* _nm_setting_class_transform_property:
|
|
|
|
|
* @setting_class: the setting class
|
|
|
|
|
* @property: the name of the property to transform
|
|
|
|
|
* @dbus_type: the type of the property (in its D-Bus representation)
|
|
|
|
|
* @to_dbus: function to convert from object to D-Bus format
|
|
|
|
|
* @from_dbus: function to convert from D-Bus to object format
|
|
|
|
|
*
|
|
|
|
|
* Indicates that @property on @setting_class does not have the same format as
|
|
|
|
|
* its corresponding D-Bus representation, and so must be transformed when
|
|
|
|
|
* serializing/deserializing.
|
|
|
|
|
*
|
|
|
|
|
* The transformation will also be used by nm_setting_compare(), meaning that
|
|
|
|
|
* the underlying object property does not need to be of a type that
|
|
|
|
|
* nm_property_compare() recognizes, as long as it recognizes @dbus_type.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
_nm_setting_class_transform_property (NMSettingClass *setting_class,
|
|
|
|
|
const char *property,
|
2014-08-16 10:09:48 -04:00
|
|
|
const GVariantType *dbus_type,
|
|
|
|
|
NMSettingPropertyTransformToFunc to_dbus,
|
|
|
|
|
NMSettingPropertyTransformFromFunc from_dbus)
|
2014-07-30 10:46:24 -04:00
|
|
|
{
|
|
|
|
|
GParamSpec *param_spec;
|
|
|
|
|
|
|
|
|
|
param_spec = g_object_class_find_property (G_OBJECT_CLASS (setting_class), property);
|
|
|
|
|
g_return_if_fail (param_spec != NULL);
|
|
|
|
|
|
|
|
|
|
add_property_override (setting_class,
|
|
|
|
|
property, param_spec, dbus_type,
|
2014-10-14 09:09:15 -04:00
|
|
|
NULL, NULL, NULL, NULL,
|
2014-07-30 10:46:24 -04:00
|
|
|
to_dbus, from_dbus);
|
libnm-core: add dbus-only properties to NMSettingClass
Add _nm_setting_class_add_dbus_only_property(), for declaring
properties that appear in the D-Bus serialization, but which don't
correspond to GObject properties.
Since some property overrides will require examining settings other
than the setting that they are on (eg, the value of
802-11-wireless.security depends on whether an
NMSettingWirelessSecurity setting is present, and
NMSettingConnection:interface-name might sometimes be set from, eg,
bond.interface-name), we also update _nm_setting_to_dbus() to take the
full NMConnection as an argument, and _nm_setting_new_from_dbus() to
take the full connection hash.
Additionally, with some deprecated properties, we'll want to validate
them on construction, but we don't need to keep the value around after
that. So allow _nm_setting_new_from_dbus() to return a verification
error directly, so we don't need to store the value until the verify()
call.
2014-07-29 18:25:10 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static GArray *
|
|
|
|
|
nm_setting_class_ensure_properties (NMSettingClass *setting_class)
|
|
|
|
|
{
|
|
|
|
|
GType type = G_TYPE_FROM_CLASS (setting_class), otype;
|
|
|
|
|
NMSettingProperty property, *override;
|
|
|
|
|
GArray *overrides, *type_overrides, *properties;
|
|
|
|
|
GParamSpec **property_specs;
|
|
|
|
|
guint n_property_specs, i;
|
|
|
|
|
|
2017-02-03 17:21:21 +01:00
|
|
|
properties = g_type_get_qdata (type, setting_properties_quark ());
|
libnm-core: add dbus-only properties to NMSettingClass
Add _nm_setting_class_add_dbus_only_property(), for declaring
properties that appear in the D-Bus serialization, but which don't
correspond to GObject properties.
Since some property overrides will require examining settings other
than the setting that they are on (eg, the value of
802-11-wireless.security depends on whether an
NMSettingWirelessSecurity setting is present, and
NMSettingConnection:interface-name might sometimes be set from, eg,
bond.interface-name), we also update _nm_setting_to_dbus() to take the
full NMConnection as an argument, and _nm_setting_new_from_dbus() to
take the full connection hash.
Additionally, with some deprecated properties, we'll want to validate
them on construction, but we don't need to keep the value around after
that. So allow _nm_setting_new_from_dbus() to return a verification
error directly, so we don't need to store the value until the verify()
call.
2014-07-29 18:25:10 -04:00
|
|
|
if (properties)
|
|
|
|
|
return properties;
|
|
|
|
|
|
|
|
|
|
/* Build overrides array from @setting_class and its superclasses */
|
|
|
|
|
overrides = g_array_new (FALSE, FALSE, sizeof (NMSettingProperty));
|
|
|
|
|
for (otype = type; otype != G_TYPE_OBJECT; otype = g_type_parent (otype)) {
|
2017-02-03 17:21:21 +01:00
|
|
|
type_overrides = g_type_get_qdata (otype, setting_property_overrides_quark ());
|
libnm-core: add dbus-only properties to NMSettingClass
Add _nm_setting_class_add_dbus_only_property(), for declaring
properties that appear in the D-Bus serialization, but which don't
correspond to GObject properties.
Since some property overrides will require examining settings other
than the setting that they are on (eg, the value of
802-11-wireless.security depends on whether an
NMSettingWirelessSecurity setting is present, and
NMSettingConnection:interface-name might sometimes be set from, eg,
bond.interface-name), we also update _nm_setting_to_dbus() to take the
full NMConnection as an argument, and _nm_setting_new_from_dbus() to
take the full connection hash.
Additionally, with some deprecated properties, we'll want to validate
them on construction, but we don't need to keep the value around after
that. So allow _nm_setting_new_from_dbus() to return a verification
error directly, so we don't need to store the value until the verify()
call.
2014-07-29 18:25:10 -04:00
|
|
|
if (type_overrides)
|
|
|
|
|
g_array_append_vals (overrides, (NMSettingProperty *)type_overrides->data, type_overrides->len);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Build the properties array from the GParamSpecs, obeying overrides */
|
|
|
|
|
properties = g_array_new (FALSE, FALSE, sizeof (NMSettingProperty));
|
|
|
|
|
|
|
|
|
|
property_specs = g_object_class_list_properties (G_OBJECT_CLASS (setting_class),
|
|
|
|
|
&n_property_specs);
|
|
|
|
|
for (i = 0; i < n_property_specs; i++) {
|
|
|
|
|
override = find_property (overrides, property_specs[i]->name);
|
|
|
|
|
if (override)
|
|
|
|
|
property = *override;
|
|
|
|
|
else {
|
|
|
|
|
memset (&property, 0, sizeof (property));
|
|
|
|
|
property.name = property_specs[i]->name;
|
|
|
|
|
property.param_spec = property_specs[i];
|
|
|
|
|
}
|
|
|
|
|
g_array_append_val (properties, property);
|
|
|
|
|
}
|
|
|
|
|
g_free (property_specs);
|
|
|
|
|
|
|
|
|
|
/* Add any remaining overrides not corresponding to GObject properties */
|
|
|
|
|
for (i = 0; i < overrides->len; i++) {
|
|
|
|
|
override = &g_array_index (overrides, NMSettingProperty, i);
|
|
|
|
|
if (!g_object_class_find_property (G_OBJECT_CLASS (setting_class), override->name))
|
|
|
|
|
g_array_append_val (properties, *override);
|
|
|
|
|
}
|
|
|
|
|
g_array_unref (overrides);
|
|
|
|
|
|
2017-02-03 17:21:21 +01:00
|
|
|
g_type_set_qdata (type, setting_properties_quark (), properties);
|
libnm-core: add dbus-only properties to NMSettingClass
Add _nm_setting_class_add_dbus_only_property(), for declaring
properties that appear in the D-Bus serialization, but which don't
correspond to GObject properties.
Since some property overrides will require examining settings other
than the setting that they are on (eg, the value of
802-11-wireless.security depends on whether an
NMSettingWirelessSecurity setting is present, and
NMSettingConnection:interface-name might sometimes be set from, eg,
bond.interface-name), we also update _nm_setting_to_dbus() to take the
full NMConnection as an argument, and _nm_setting_new_from_dbus() to
take the full connection hash.
Additionally, with some deprecated properties, we'll want to validate
them on construction, but we don't need to keep the value around after
that. So allow _nm_setting_new_from_dbus() to return a verification
error directly, so we don't need to store the value until the verify()
call.
2014-07-29 18:25:10 -04:00
|
|
|
return properties;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const NMSettingProperty *
|
|
|
|
|
nm_setting_class_get_properties (NMSettingClass *setting_class, guint *n_properties)
|
|
|
|
|
{
|
|
|
|
|
GArray *properties;
|
|
|
|
|
|
|
|
|
|
properties = nm_setting_class_ensure_properties (setting_class);
|
|
|
|
|
|
|
|
|
|
*n_properties = properties->len;
|
|
|
|
|
return (NMSettingProperty *) properties->data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const NMSettingProperty *
|
|
|
|
|
nm_setting_class_find_property (NMSettingClass *setting_class, const char *property_name)
|
|
|
|
|
{
|
|
|
|
|
GArray *properties;
|
|
|
|
|
|
|
|
|
|
properties = nm_setting_class_ensure_properties (setting_class);
|
|
|
|
|
return find_property (properties, property_name);
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-02 18:22:50 +02:00
|
|
|
/*****************************************************************************/
|
libnm-core: add dbus-only properties to NMSettingClass
Add _nm_setting_class_add_dbus_only_property(), for declaring
properties that appear in the D-Bus serialization, but which don't
correspond to GObject properties.
Since some property overrides will require examining settings other
than the setting that they are on (eg, the value of
802-11-wireless.security depends on whether an
NMSettingWirelessSecurity setting is present, and
NMSettingConnection:interface-name might sometimes be set from, eg,
bond.interface-name), we also update _nm_setting_to_dbus() to take the
full NMConnection as an argument, and _nm_setting_new_from_dbus() to
take the full connection hash.
Additionally, with some deprecated properties, we'll want to validate
them on construction, but we don't need to keep the value around after
that. So allow _nm_setting_new_from_dbus() to return a verification
error directly, so we don't need to store the value until the verify()
call.
2014-07-29 18:25:10 -04:00
|
|
|
|
2018-07-29 13:25:49 +02:00
|
|
|
gboolean
|
|
|
|
|
_nm_setting_use_legacy_property (NMSetting *setting,
|
|
|
|
|
GVariant *connection_dict,
|
|
|
|
|
const char *legacy_property,
|
|
|
|
|
const char *new_property)
|
|
|
|
|
{
|
|
|
|
|
GVariant *setting_dict, *value;
|
|
|
|
|
|
|
|
|
|
setting_dict = g_variant_lookup_value (connection_dict, nm_setting_get_name (NM_SETTING (setting)), NM_VARIANT_TYPE_SETTING);
|
|
|
|
|
g_return_val_if_fail (setting_dict != NULL, FALSE);
|
|
|
|
|
|
|
|
|
|
/* If the new property isn't set, we have to use the legacy property. */
|
|
|
|
|
value = g_variant_lookup_value (setting_dict, new_property, NULL);
|
|
|
|
|
if (!value) {
|
|
|
|
|
g_variant_unref (setting_dict);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
g_variant_unref (value);
|
|
|
|
|
|
|
|
|
|
/* Otherwise, clients always prefer new properties sent from the daemon. */
|
|
|
|
|
if (!_nm_utils_is_manager_process) {
|
|
|
|
|
g_variant_unref (setting_dict);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* The daemon prefers the legacy property if it exists. */
|
|
|
|
|
value = g_variant_lookup_value (setting_dict, legacy_property, NULL);
|
|
|
|
|
g_variant_unref (setting_dict);
|
|
|
|
|
|
|
|
|
|
if (value) {
|
|
|
|
|
g_variant_unref (value);
|
|
|
|
|
return TRUE;
|
|
|
|
|
} else
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2014-08-16 10:09:48 -04:00
|
|
|
static const GVariantType *
|
|
|
|
|
variant_type_for_gtype (GType type)
|
|
|
|
|
{
|
|
|
|
|
if (type == G_TYPE_BOOLEAN)
|
|
|
|
|
return G_VARIANT_TYPE_BOOLEAN;
|
|
|
|
|
else if (type == G_TYPE_UCHAR)
|
|
|
|
|
return G_VARIANT_TYPE_BYTE;
|
|
|
|
|
else if (type == G_TYPE_INT)
|
|
|
|
|
return G_VARIANT_TYPE_INT32;
|
|
|
|
|
else if (type == G_TYPE_UINT)
|
|
|
|
|
return G_VARIANT_TYPE_UINT32;
|
|
|
|
|
else if (type == G_TYPE_INT64)
|
|
|
|
|
return G_VARIANT_TYPE_INT64;
|
|
|
|
|
else if (type == G_TYPE_UINT64)
|
|
|
|
|
return G_VARIANT_TYPE_UINT64;
|
|
|
|
|
else if (type == G_TYPE_STRING)
|
|
|
|
|
return G_VARIANT_TYPE_STRING;
|
|
|
|
|
else if (type == G_TYPE_DOUBLE)
|
|
|
|
|
return G_VARIANT_TYPE_DOUBLE;
|
|
|
|
|
else if (type == G_TYPE_STRV)
|
|
|
|
|
return G_VARIANT_TYPE_STRING_ARRAY;
|
2014-11-16 16:13:06 -05:00
|
|
|
else if (type == G_TYPE_BYTES)
|
|
|
|
|
return G_VARIANT_TYPE_BYTESTRING;
|
|
|
|
|
else if (g_type_is_a (type, G_TYPE_ENUM))
|
|
|
|
|
return G_VARIANT_TYPE_INT32;
|
|
|
|
|
else if (g_type_is_a (type, G_TYPE_FLAGS))
|
|
|
|
|
return G_VARIANT_TYPE_UINT32;
|
2014-08-16 10:09:48 -04:00
|
|
|
else
|
|
|
|
|
g_assert_not_reached ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static GVariant *
|
|
|
|
|
get_property_for_dbus (NMSetting *setting,
|
|
|
|
|
const NMSettingProperty *property,
|
|
|
|
|
gboolean ignore_default)
|
|
|
|
|
{
|
|
|
|
|
GValue prop_value = { 0, };
|
|
|
|
|
GVariant *dbus_value;
|
|
|
|
|
|
2014-10-14 09:09:15 -04:00
|
|
|
if (property->get_func)
|
|
|
|
|
return property->get_func (setting, property->name);
|
|
|
|
|
else
|
|
|
|
|
g_return_val_if_fail (property->param_spec != NULL, NULL);
|
2014-08-16 10:09:48 -04:00
|
|
|
|
|
|
|
|
g_value_init (&prop_value, property->param_spec->value_type);
|
|
|
|
|
g_object_get_property (G_OBJECT (setting), property->param_spec->name, &prop_value);
|
|
|
|
|
|
|
|
|
|
if (ignore_default && g_param_value_defaults (property->param_spec, &prop_value)) {
|
|
|
|
|
g_value_unset (&prop_value);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (property->to_dbus)
|
|
|
|
|
dbus_value = property->to_dbus (&prop_value);
|
|
|
|
|
else if (property->dbus_type)
|
|
|
|
|
dbus_value = g_dbus_gvalue_to_gvariant (&prop_value, property->dbus_type);
|
2014-06-26 16:47:46 -04:00
|
|
|
else if (g_type_is_a (prop_value.g_type, G_TYPE_ENUM))
|
|
|
|
|
dbus_value = g_variant_new_int32 (g_value_get_enum (&prop_value));
|
|
|
|
|
else if (g_type_is_a (prop_value.g_type, G_TYPE_FLAGS))
|
|
|
|
|
dbus_value = g_variant_new_uint32 (g_value_get_flags (&prop_value));
|
2014-11-15 17:34:19 -05:00
|
|
|
else if (prop_value.g_type == G_TYPE_BYTES)
|
|
|
|
|
dbus_value = _nm_utils_bytes_to_dbus (&prop_value);
|
2014-08-16 10:09:48 -04:00
|
|
|
else
|
|
|
|
|
dbus_value = g_dbus_gvalue_to_gvariant (&prop_value, variant_type_for_gtype (prop_value.g_type));
|
|
|
|
|
g_value_unset (&prop_value);
|
|
|
|
|
|
|
|
|
|
return dbus_value;
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-15 12:19:06 -05:00
|
|
|
static gboolean
|
|
|
|
|
set_property_from_dbus (const NMSettingProperty *property,
|
|
|
|
|
GVariant *src_value,
|
|
|
|
|
GValue *dst_value)
|
2014-07-24 08:53:33 -04:00
|
|
|
{
|
2015-01-16 13:39:33 +01:00
|
|
|
g_return_val_if_fail (property->param_spec != NULL, FALSE);
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2015-01-15 12:19:06 -05:00
|
|
|
if (property->from_dbus) {
|
|
|
|
|
if (!g_variant_type_equal (g_variant_get_type (src_value), property->dbus_type))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
2014-08-16 10:09:48 -04:00
|
|
|
property->from_dbus (src_value, dst_value);
|
2015-01-15 12:19:06 -05:00
|
|
|
} else if (dst_value->g_type == G_TYPE_BYTES) {
|
|
|
|
|
if (!g_variant_is_of_type (src_value, G_VARIANT_TYPE_BYTESTRING))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
2014-11-15 17:34:19 -05:00
|
|
|
_nm_utils_bytes_from_dbus (src_value, dst_value);
|
2015-01-15 12:19:06 -05:00
|
|
|
} else {
|
|
|
|
|
GValue tmp = G_VALUE_INIT;
|
|
|
|
|
|
|
|
|
|
g_dbus_gvariant_to_gvalue (src_value, &tmp);
|
|
|
|
|
if (G_VALUE_TYPE (&tmp) == G_VALUE_TYPE (dst_value))
|
|
|
|
|
*dst_value = tmp;
|
|
|
|
|
else {
|
|
|
|
|
gboolean success;
|
|
|
|
|
|
|
|
|
|
success = g_value_transform (&tmp, dst_value);
|
|
|
|
|
g_value_unset (&tmp);
|
|
|
|
|
if (!success)
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
2014-07-24 08:53:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2014-08-06 19:35:31 -04:00
|
|
|
* _nm_setting_to_dbus:
|
2014-07-24 08:53:33 -04:00
|
|
|
* @setting: the #NMSetting
|
libnm-core: add dbus-only properties to NMSettingClass
Add _nm_setting_class_add_dbus_only_property(), for declaring
properties that appear in the D-Bus serialization, but which don't
correspond to GObject properties.
Since some property overrides will require examining settings other
than the setting that they are on (eg, the value of
802-11-wireless.security depends on whether an
NMSettingWirelessSecurity setting is present, and
NMSettingConnection:interface-name might sometimes be set from, eg,
bond.interface-name), we also update _nm_setting_to_dbus() to take the
full NMConnection as an argument, and _nm_setting_new_from_dbus() to
take the full connection hash.
Additionally, with some deprecated properties, we'll want to validate
them on construction, but we don't need to keep the value around after
that. So allow _nm_setting_new_from_dbus() to return a verification
error directly, so we don't need to store the value until the verify()
call.
2014-07-29 18:25:10 -04:00
|
|
|
* @connection: the #NMConnection containing @setting
|
2014-08-06 19:35:31 -04:00
|
|
|
* @flags: hash flags, e.g. %NM_CONNECTION_SERIALIZE_ALL
|
2014-07-24 08:53:33 -04:00
|
|
|
*
|
2014-08-16 10:09:48 -04:00
|
|
|
* Converts the #NMSetting into a #GVariant of type #NM_VARIANT_TYPE_SETTING
|
|
|
|
|
* mapping each setting property name to a value describing that property,
|
|
|
|
|
* suitable for marshalling over D-Bus or serializing.
|
2014-07-24 08:53:33 -04:00
|
|
|
*
|
2014-08-16 10:09:48 -04:00
|
|
|
* Returns: (transfer none): a new floating #GVariant describing the setting's
|
|
|
|
|
* properties
|
2014-07-24 08:53:33 -04:00
|
|
|
**/
|
2014-08-16 10:09:48 -04:00
|
|
|
GVariant *
|
libnm-core: add dbus-only properties to NMSettingClass
Add _nm_setting_class_add_dbus_only_property(), for declaring
properties that appear in the D-Bus serialization, but which don't
correspond to GObject properties.
Since some property overrides will require examining settings other
than the setting that they are on (eg, the value of
802-11-wireless.security depends on whether an
NMSettingWirelessSecurity setting is present, and
NMSettingConnection:interface-name might sometimes be set from, eg,
bond.interface-name), we also update _nm_setting_to_dbus() to take the
full NMConnection as an argument, and _nm_setting_new_from_dbus() to
take the full connection hash.
Additionally, with some deprecated properties, we'll want to validate
them on construction, but we don't need to keep the value around after
that. So allow _nm_setting_new_from_dbus() to return a verification
error directly, so we don't need to store the value until the verify()
call.
2014-07-29 18:25:10 -04:00
|
|
|
_nm_setting_to_dbus (NMSetting *setting, NMConnection *connection, NMConnectionSerializationFlags flags)
|
2014-07-24 08:53:33 -04:00
|
|
|
{
|
2014-08-16 10:09:48 -04:00
|
|
|
GVariantBuilder builder;
|
|
|
|
|
GVariant *dbus_value;
|
libnm-core: add dbus-only properties to NMSettingClass
Add _nm_setting_class_add_dbus_only_property(), for declaring
properties that appear in the D-Bus serialization, but which don't
correspond to GObject properties.
Since some property overrides will require examining settings other
than the setting that they are on (eg, the value of
802-11-wireless.security depends on whether an
NMSettingWirelessSecurity setting is present, and
NMSettingConnection:interface-name might sometimes be set from, eg,
bond.interface-name), we also update _nm_setting_to_dbus() to take the
full NMConnection as an argument, and _nm_setting_new_from_dbus() to
take the full connection hash.
Additionally, with some deprecated properties, we'll want to validate
them on construction, but we don't need to keep the value around after
that. So allow _nm_setting_new_from_dbus() to return a verification
error directly, so we don't need to store the value until the verify()
call.
2014-07-29 18:25:10 -04:00
|
|
|
const NMSettingProperty *properties;
|
|
|
|
|
guint n_properties, i;
|
2014-07-24 08:53:33 -04:00
|
|
|
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING (setting), NULL);
|
|
|
|
|
|
libnm-core: add dbus-only properties to NMSettingClass
Add _nm_setting_class_add_dbus_only_property(), for declaring
properties that appear in the D-Bus serialization, but which don't
correspond to GObject properties.
Since some property overrides will require examining settings other
than the setting that they are on (eg, the value of
802-11-wireless.security depends on whether an
NMSettingWirelessSecurity setting is present, and
NMSettingConnection:interface-name might sometimes be set from, eg,
bond.interface-name), we also update _nm_setting_to_dbus() to take the
full NMConnection as an argument, and _nm_setting_new_from_dbus() to
take the full connection hash.
Additionally, with some deprecated properties, we'll want to validate
them on construction, but we don't need to keep the value around after
that. So allow _nm_setting_new_from_dbus() to return a verification
error directly, so we don't need to store the value until the verify()
call.
2014-07-29 18:25:10 -04:00
|
|
|
properties = nm_setting_class_get_properties (NM_SETTING_GET_CLASS (setting), &n_properties);
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2014-08-16 10:09:48 -04:00
|
|
|
g_variant_builder_init (&builder, NM_VARIANT_TYPE_SETTING);
|
2014-07-24 08:53:33 -04:00
|
|
|
|
libnm-core: add dbus-only properties to NMSettingClass
Add _nm_setting_class_add_dbus_only_property(), for declaring
properties that appear in the D-Bus serialization, but which don't
correspond to GObject properties.
Since some property overrides will require examining settings other
than the setting that they are on (eg, the value of
802-11-wireless.security depends on whether an
NMSettingWirelessSecurity setting is present, and
NMSettingConnection:interface-name might sometimes be set from, eg,
bond.interface-name), we also update _nm_setting_to_dbus() to take the
full NMConnection as an argument, and _nm_setting_new_from_dbus() to
take the full connection hash.
Additionally, with some deprecated properties, we'll want to validate
them on construction, but we don't need to keep the value around after
that. So allow _nm_setting_new_from_dbus() to return a verification
error directly, so we don't need to store the value until the verify()
call.
2014-07-29 18:25:10 -04:00
|
|
|
for (i = 0; i < n_properties; i++) {
|
|
|
|
|
const NMSettingProperty *property = &properties[i];
|
|
|
|
|
GParamSpec *prop_spec = property->param_spec;
|
|
|
|
|
|
2018-07-29 14:32:36 +02:00
|
|
|
if (!prop_spec) {
|
|
|
|
|
if (!property->synth_func)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if (flags & NM_CONNECTION_SERIALIZE_ONLY_SECRETS)
|
|
|
|
|
continue;
|
|
|
|
|
} else {
|
|
|
|
|
if (!(prop_spec->flags & G_PARAM_WRITABLE))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if ( (prop_spec->flags & NM_SETTING_PARAM_LEGACY)
|
|
|
|
|
&& !_nm_utils_is_manager_process)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if ( (flags & NM_CONNECTION_SERIALIZE_NO_SECRETS)
|
|
|
|
|
&& (prop_spec->flags & NM_SETTING_PARAM_SECRET))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if ( (flags & NM_CONNECTION_SERIALIZE_ONLY_SECRETS)
|
|
|
|
|
&& !(prop_spec->flags & NM_SETTING_PARAM_SECRET))
|
|
|
|
|
continue;
|
libnm-core: add dbus-only properties to NMSettingClass
Add _nm_setting_class_add_dbus_only_property(), for declaring
properties that appear in the D-Bus serialization, but which don't
correspond to GObject properties.
Since some property overrides will require examining settings other
than the setting that they are on (eg, the value of
802-11-wireless.security depends on whether an
NMSettingWirelessSecurity setting is present, and
NMSettingConnection:interface-name might sometimes be set from, eg,
bond.interface-name), we also update _nm_setting_to_dbus() to take the
full NMConnection as an argument, and _nm_setting_new_from_dbus() to
take the full connection hash.
Additionally, with some deprecated properties, we'll want to validate
them on construction, but we don't need to keep the value around after
that. So allow _nm_setting_new_from_dbus() to return a verification
error directly, so we don't need to store the value until the verify()
call.
2014-07-29 18:25:10 -04:00
|
|
|
}
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2014-10-14 09:09:15 -04:00
|
|
|
if (property->synth_func)
|
|
|
|
|
dbus_value = property->synth_func (setting, connection, property->name);
|
2014-08-16 10:09:48 -04:00
|
|
|
else
|
2014-10-14 09:09:15 -04:00
|
|
|
dbus_value = get_property_for_dbus (setting, property, TRUE);
|
2014-08-16 10:09:48 -04:00
|
|
|
if (dbus_value) {
|
|
|
|
|
/* Allow dbus_value to be either floating or not. */
|
|
|
|
|
g_variant_take_ref (dbus_value);
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2014-08-16 10:09:48 -04:00
|
|
|
g_variant_builder_add (&builder, "{sv}", property->name, dbus_value);
|
|
|
|
|
g_variant_unref (dbus_value);
|
|
|
|
|
}
|
2014-07-24 08:53:33 -04:00
|
|
|
}
|
|
|
|
|
|
2014-08-16 10:09:48 -04:00
|
|
|
return g_variant_builder_end (&builder);
|
2014-07-24 08:53:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2014-08-06 19:35:31 -04:00
|
|
|
* _nm_setting_new_from_dbus:
|
2014-07-24 08:53:33 -04:00
|
|
|
* @setting_type: the #NMSetting type which the hash contains properties for
|
2014-08-16 10:09:48 -04:00
|
|
|
* @setting_dict: the #GVariant containing an %NM_VARIANT_TYPE_SETTING dictionary
|
|
|
|
|
* mapping property names to values
|
|
|
|
|
* @connection_dict: the #GVariant containing an %NM_VARIANT_TYPE_CONNECTION
|
|
|
|
|
* dictionary mapping setting names to dictionaries.
|
libnm-core: allow strict and relaxed error behavior for _nm_setting_new_from_dbus()
In some situations, we want strict checking of errors, for example when
NetworkManager receives a new connection from a client, the connection
must make sense as a whole (and since NetworkManager service is backward
compatible to the clients and not the other way around, there is no
excuse for sending invalid data to the server).
In other situations, we want a best-effort behavior. Like when
NetworkManager sends a connection to its clients, those clients
want to extract as many properties as they understand, but in order
to be forward compatible against newer server versions, invalid
or unknown properties must be accepted.
Previously, a mixture of both was done. Some issues caused a failure
to create a new NMSetting, other invalid parts were just silently
ignored or triggered a g_warning() in glib.
Now allow for both. When doing strict-validation, be more strict and
reject all unknown properties and catch when the user sets an invalid
argument. On the other hand, allow for a best-effort mode that
effectively cannot fail and will return a new NMSetting instance.
For now, add NMSettingParseFlags so that the caller can choose the
old behavior, strict parsing, or best effort.
This patch doesn't have any externally visible change except that
no more g_warnings will be emitted.
2016-03-18 13:42:50 +01:00
|
|
|
* @parse_flags: flags to determine behavior during parsing.
|
libnm-core: add dbus-only properties to NMSettingClass
Add _nm_setting_class_add_dbus_only_property(), for declaring
properties that appear in the D-Bus serialization, but which don't
correspond to GObject properties.
Since some property overrides will require examining settings other
than the setting that they are on (eg, the value of
802-11-wireless.security depends on whether an
NMSettingWirelessSecurity setting is present, and
NMSettingConnection:interface-name might sometimes be set from, eg,
bond.interface-name), we also update _nm_setting_to_dbus() to take the
full NMConnection as an argument, and _nm_setting_new_from_dbus() to
take the full connection hash.
Additionally, with some deprecated properties, we'll want to validate
them on construction, but we don't need to keep the value around after
that. So allow _nm_setting_new_from_dbus() to return a verification
error directly, so we don't need to store the value until the verify()
call.
2014-07-29 18:25:10 -04:00
|
|
|
* @error: location to store error, or %NULL
|
2014-07-24 08:53:33 -04:00
|
|
|
*
|
|
|
|
|
* Creates a new #NMSetting object and populates that object with the properties
|
2014-08-16 10:09:48 -04:00
|
|
|
* contained in @setting_dict, using each key as the property to set, and each
|
|
|
|
|
* value as the value to set that property to. Setting properties are strongly
|
|
|
|
|
* typed, thus the #GVariantType of the dict value must be correct. See the
|
|
|
|
|
* documentation on each #NMSetting object subclass for the correct property
|
|
|
|
|
* names and value types.
|
2014-07-24 08:53:33 -04:00
|
|
|
*
|
|
|
|
|
* Returns: a new #NMSetting object populated with the properties from the
|
2014-09-15 13:30:07 -04:00
|
|
|
* hash table, or %NULL if @setting_hash could not be deserialized.
|
2014-07-24 08:53:33 -04:00
|
|
|
**/
|
|
|
|
|
NMSetting *
|
libnm-core: add dbus-only properties to NMSettingClass
Add _nm_setting_class_add_dbus_only_property(), for declaring
properties that appear in the D-Bus serialization, but which don't
correspond to GObject properties.
Since some property overrides will require examining settings other
than the setting that they are on (eg, the value of
802-11-wireless.security depends on whether an
NMSettingWirelessSecurity setting is present, and
NMSettingConnection:interface-name might sometimes be set from, eg,
bond.interface-name), we also update _nm_setting_to_dbus() to take the
full NMConnection as an argument, and _nm_setting_new_from_dbus() to
take the full connection hash.
Additionally, with some deprecated properties, we'll want to validate
them on construction, but we don't need to keep the value around after
that. So allow _nm_setting_new_from_dbus() to return a verification
error directly, so we don't need to store the value until the verify()
call.
2014-07-29 18:25:10 -04:00
|
|
|
_nm_setting_new_from_dbus (GType setting_type,
|
2014-08-16 10:09:48 -04:00
|
|
|
GVariant *setting_dict,
|
|
|
|
|
GVariant *connection_dict,
|
libnm-core: allow strict and relaxed error behavior for _nm_setting_new_from_dbus()
In some situations, we want strict checking of errors, for example when
NetworkManager receives a new connection from a client, the connection
must make sense as a whole (and since NetworkManager service is backward
compatible to the clients and not the other way around, there is no
excuse for sending invalid data to the server).
In other situations, we want a best-effort behavior. Like when
NetworkManager sends a connection to its clients, those clients
want to extract as many properties as they understand, but in order
to be forward compatible against newer server versions, invalid
or unknown properties must be accepted.
Previously, a mixture of both was done. Some issues caused a failure
to create a new NMSetting, other invalid parts were just silently
ignored or triggered a g_warning() in glib.
Now allow for both. When doing strict-validation, be more strict and
reject all unknown properties and catch when the user sets an invalid
argument. On the other hand, allow for a best-effort mode that
effectively cannot fail and will return a new NMSetting instance.
For now, add NMSettingParseFlags so that the caller can choose the
old behavior, strict parsing, or best effort.
This patch doesn't have any externally visible change except that
no more g_warnings will be emitted.
2016-03-18 13:42:50 +01:00
|
|
|
NMSettingParseFlags parse_flags,
|
libnm-core: add dbus-only properties to NMSettingClass
Add _nm_setting_class_add_dbus_only_property(), for declaring
properties that appear in the D-Bus serialization, but which don't
correspond to GObject properties.
Since some property overrides will require examining settings other
than the setting that they are on (eg, the value of
802-11-wireless.security depends on whether an
NMSettingWirelessSecurity setting is present, and
NMSettingConnection:interface-name might sometimes be set from, eg,
bond.interface-name), we also update _nm_setting_to_dbus() to take the
full NMConnection as an argument, and _nm_setting_new_from_dbus() to
take the full connection hash.
Additionally, with some deprecated properties, we'll want to validate
them on construction, but we don't need to keep the value around after
that. So allow _nm_setting_new_from_dbus() to return a verification
error directly, so we don't need to store the value until the verify()
call.
2014-07-29 18:25:10 -04:00
|
|
|
GError **error)
|
2014-07-24 08:53:33 -04:00
|
|
|
{
|
libnm-core: allow strict and relaxed error behavior for _nm_setting_new_from_dbus()
In some situations, we want strict checking of errors, for example when
NetworkManager receives a new connection from a client, the connection
must make sense as a whole (and since NetworkManager service is backward
compatible to the clients and not the other way around, there is no
excuse for sending invalid data to the server).
In other situations, we want a best-effort behavior. Like when
NetworkManager sends a connection to its clients, those clients
want to extract as many properties as they understand, but in order
to be forward compatible against newer server versions, invalid
or unknown properties must be accepted.
Previously, a mixture of both was done. Some issues caused a failure
to create a new NMSetting, other invalid parts were just silently
ignored or triggered a g_warning() in glib.
Now allow for both. When doing strict-validation, be more strict and
reject all unknown properties and catch when the user sets an invalid
argument. On the other hand, allow for a best-effort mode that
effectively cannot fail and will return a new NMSetting instance.
For now, add NMSettingParseFlags so that the caller can choose the
old behavior, strict parsing, or best effort.
This patch doesn't have any externally visible change except that
no more g_warnings will be emitted.
2016-03-18 13:42:50 +01:00
|
|
|
gs_unref_object NMSetting *setting = NULL;
|
|
|
|
|
gs_unref_hashtable GHashTable *keys = NULL;
|
libnm-core: add dbus-only properties to NMSettingClass
Add _nm_setting_class_add_dbus_only_property(), for declaring
properties that appear in the D-Bus serialization, but which don't
correspond to GObject properties.
Since some property overrides will require examining settings other
than the setting that they are on (eg, the value of
802-11-wireless.security depends on whether an
NMSettingWirelessSecurity setting is present, and
NMSettingConnection:interface-name might sometimes be set from, eg,
bond.interface-name), we also update _nm_setting_to_dbus() to take the
full NMConnection as an argument, and _nm_setting_new_from_dbus() to
take the full connection hash.
Additionally, with some deprecated properties, we'll want to validate
them on construction, but we don't need to keep the value around after
that. So allow _nm_setting_new_from_dbus() to return a verification
error directly, so we don't need to store the value until the verify()
call.
2014-07-29 18:25:10 -04:00
|
|
|
const NMSettingProperty *properties;
|
libnm-core: allow strict and relaxed error behavior for _nm_setting_new_from_dbus()
In some situations, we want strict checking of errors, for example when
NetworkManager receives a new connection from a client, the connection
must make sense as a whole (and since NetworkManager service is backward
compatible to the clients and not the other way around, there is no
excuse for sending invalid data to the server).
In other situations, we want a best-effort behavior. Like when
NetworkManager sends a connection to its clients, those clients
want to extract as many properties as they understand, but in order
to be forward compatible against newer server versions, invalid
or unknown properties must be accepted.
Previously, a mixture of both was done. Some issues caused a failure
to create a new NMSetting, other invalid parts were just silently
ignored or triggered a g_warning() in glib.
Now allow for both. When doing strict-validation, be more strict and
reject all unknown properties and catch when the user sets an invalid
argument. On the other hand, allow for a best-effort mode that
effectively cannot fail and will return a new NMSetting instance.
For now, add NMSettingParseFlags so that the caller can choose the
old behavior, strict parsing, or best effort.
This patch doesn't have any externally visible change except that
no more g_warnings will be emitted.
2016-03-18 13:42:50 +01:00
|
|
|
guint i, n_properties;
|
2014-07-24 08:53:33 -04:00
|
|
|
|
|
|
|
|
g_return_val_if_fail (G_TYPE_IS_INSTANTIATABLE (setting_type), NULL);
|
2014-08-16 10:09:48 -04:00
|
|
|
g_return_val_if_fail (g_variant_is_of_type (setting_dict, NM_VARIANT_TYPE_SETTING), NULL);
|
|
|
|
|
|
libnm-core: allow strict and relaxed error behavior for _nm_setting_new_from_dbus()
In some situations, we want strict checking of errors, for example when
NetworkManager receives a new connection from a client, the connection
must make sense as a whole (and since NetworkManager service is backward
compatible to the clients and not the other way around, there is no
excuse for sending invalid data to the server).
In other situations, we want a best-effort behavior. Like when
NetworkManager sends a connection to its clients, those clients
want to extract as many properties as they understand, but in order
to be forward compatible against newer server versions, invalid
or unknown properties must be accepted.
Previously, a mixture of both was done. Some issues caused a failure
to create a new NMSetting, other invalid parts were just silently
ignored or triggered a g_warning() in glib.
Now allow for both. When doing strict-validation, be more strict and
reject all unknown properties and catch when the user sets an invalid
argument. On the other hand, allow for a best-effort mode that
effectively cannot fail and will return a new NMSetting instance.
For now, add NMSettingParseFlags so that the caller can choose the
old behavior, strict parsing, or best effort.
This patch doesn't have any externally visible change except that
no more g_warnings will be emitted.
2016-03-18 13:42:50 +01:00
|
|
|
nm_assert (!NM_FLAGS_ANY (parse_flags, ~NM_SETTING_PARSE_FLAGS_ALL));
|
|
|
|
|
nm_assert (!NM_FLAGS_ALL (parse_flags, NM_SETTING_PARSE_FLAGS_STRICT | NM_SETTING_PARSE_FLAGS_BEST_EFFORT));
|
|
|
|
|
|
2014-08-16 10:09:48 -04:00
|
|
|
/* connection_dict is not technically optional, but some tests in test-general
|
|
|
|
|
* don't bother with it in cases where they know it's not needed.
|
|
|
|
|
*/
|
|
|
|
|
if (connection_dict)
|
|
|
|
|
g_return_val_if_fail (g_variant_is_of_type (connection_dict, NM_VARIANT_TYPE_CONNECTION), NULL);
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2014-10-21 11:41:44 -04:00
|
|
|
/* Build the setting object from the properties we know about; we assume
|
|
|
|
|
* that any propreties in @setting_dict that we don't know about can
|
|
|
|
|
* either be ignored or else has a backward-compatibility equivalent
|
|
|
|
|
* that we do know about.
|
|
|
|
|
*/
|
2014-08-04 11:39:33 -04:00
|
|
|
setting = (NMSetting *) g_object_new (setting_type, NULL);
|
2014-05-09 15:02:57 -04:00
|
|
|
|
libnm-core: allow strict and relaxed error behavior for _nm_setting_new_from_dbus()
In some situations, we want strict checking of errors, for example when
NetworkManager receives a new connection from a client, the connection
must make sense as a whole (and since NetworkManager service is backward
compatible to the clients and not the other way around, there is no
excuse for sending invalid data to the server).
In other situations, we want a best-effort behavior. Like when
NetworkManager sends a connection to its clients, those clients
want to extract as many properties as they understand, but in order
to be forward compatible against newer server versions, invalid
or unknown properties must be accepted.
Previously, a mixture of both was done. Some issues caused a failure
to create a new NMSetting, other invalid parts were just silently
ignored or triggered a g_warning() in glib.
Now allow for both. When doing strict-validation, be more strict and
reject all unknown properties and catch when the user sets an invalid
argument. On the other hand, allow for a best-effort mode that
effectively cannot fail and will return a new NMSetting instance.
For now, add NMSettingParseFlags so that the caller can choose the
old behavior, strict parsing, or best effort.
This patch doesn't have any externally visible change except that
no more g_warnings will be emitted.
2016-03-18 13:42:50 +01:00
|
|
|
if (NM_FLAGS_HAS (parse_flags, NM_SETTING_PARSE_FLAGS_STRICT)) {
|
|
|
|
|
GVariantIter iter;
|
|
|
|
|
GVariant *entry, *entry_key;
|
|
|
|
|
char *key;
|
|
|
|
|
|
2017-11-15 16:06:43 +01:00
|
|
|
keys = g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, NULL);
|
libnm-core: allow strict and relaxed error behavior for _nm_setting_new_from_dbus()
In some situations, we want strict checking of errors, for example when
NetworkManager receives a new connection from a client, the connection
must make sense as a whole (and since NetworkManager service is backward
compatible to the clients and not the other way around, there is no
excuse for sending invalid data to the server).
In other situations, we want a best-effort behavior. Like when
NetworkManager sends a connection to its clients, those clients
want to extract as many properties as they understand, but in order
to be forward compatible against newer server versions, invalid
or unknown properties must be accepted.
Previously, a mixture of both was done. Some issues caused a failure
to create a new NMSetting, other invalid parts were just silently
ignored or triggered a g_warning() in glib.
Now allow for both. When doing strict-validation, be more strict and
reject all unknown properties and catch when the user sets an invalid
argument. On the other hand, allow for a best-effort mode that
effectively cannot fail and will return a new NMSetting instance.
For now, add NMSettingParseFlags so that the caller can choose the
old behavior, strict parsing, or best effort.
This patch doesn't have any externally visible change except that
no more g_warnings will be emitted.
2016-03-18 13:42:50 +01:00
|
|
|
|
|
|
|
|
g_variant_iter_init (&iter, setting_dict);
|
|
|
|
|
while ((entry = g_variant_iter_next_value (&iter))) {
|
|
|
|
|
entry_key = g_variant_get_child_value (entry, 0);
|
|
|
|
|
key = g_strdup (g_variant_get_string (entry_key, NULL));
|
|
|
|
|
g_variant_unref (entry_key);
|
|
|
|
|
g_variant_unref (entry);
|
|
|
|
|
|
2018-01-02 15:47:37 +01:00
|
|
|
if (!g_hash_table_add (keys, key)) {
|
libnm-core: allow strict and relaxed error behavior for _nm_setting_new_from_dbus()
In some situations, we want strict checking of errors, for example when
NetworkManager receives a new connection from a client, the connection
must make sense as a whole (and since NetworkManager service is backward
compatible to the clients and not the other way around, there is no
excuse for sending invalid data to the server).
In other situations, we want a best-effort behavior. Like when
NetworkManager sends a connection to its clients, those clients
want to extract as many properties as they understand, but in order
to be forward compatible against newer server versions, invalid
or unknown properties must be accepted.
Previously, a mixture of both was done. Some issues caused a failure
to create a new NMSetting, other invalid parts were just silently
ignored or triggered a g_warning() in glib.
Now allow for both. When doing strict-validation, be more strict and
reject all unknown properties and catch when the user sets an invalid
argument. On the other hand, allow for a best-effort mode that
effectively cannot fail and will return a new NMSetting instance.
For now, add NMSettingParseFlags so that the caller can choose the
old behavior, strict parsing, or best effort.
This patch doesn't have any externally visible change except that
no more g_warnings will be emitted.
2016-03-18 13:42:50 +01:00
|
|
|
g_set_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_SETTING,
|
|
|
|
|
_("duplicate property"));
|
|
|
|
|
g_prefix_error (error, "%s.%s: ", nm_setting_get_name (setting), key);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-15 11:09:00 -05:00
|
|
|
properties = nm_setting_class_get_properties (NM_SETTING_GET_CLASS (setting), &n_properties);
|
libnm-core: add dbus-only properties to NMSettingClass
Add _nm_setting_class_add_dbus_only_property(), for declaring
properties that appear in the D-Bus serialization, but which don't
correspond to GObject properties.
Since some property overrides will require examining settings other
than the setting that they are on (eg, the value of
802-11-wireless.security depends on whether an
NMSettingWirelessSecurity setting is present, and
NMSettingConnection:interface-name might sometimes be set from, eg,
bond.interface-name), we also update _nm_setting_to_dbus() to take the
full NMConnection as an argument, and _nm_setting_new_from_dbus() to
take the full connection hash.
Additionally, with some deprecated properties, we'll want to validate
them on construction, but we don't need to keep the value around after
that. So allow _nm_setting_new_from_dbus() to return a verification
error directly, so we don't need to store the value until the verify()
call.
2014-07-29 18:25:10 -04:00
|
|
|
for (i = 0; i < n_properties; i++) {
|
|
|
|
|
const NMSettingProperty *property = &properties[i];
|
libnm-core: allow strict and relaxed error behavior for _nm_setting_new_from_dbus()
In some situations, we want strict checking of errors, for example when
NetworkManager receives a new connection from a client, the connection
must make sense as a whole (and since NetworkManager service is backward
compatible to the clients and not the other way around, there is no
excuse for sending invalid data to the server).
In other situations, we want a best-effort behavior. Like when
NetworkManager sends a connection to its clients, those clients
want to extract as many properties as they understand, but in order
to be forward compatible against newer server versions, invalid
or unknown properties must be accepted.
Previously, a mixture of both was done. Some issues caused a failure
to create a new NMSetting, other invalid parts were just silently
ignored or triggered a g_warning() in glib.
Now allow for both. When doing strict-validation, be more strict and
reject all unknown properties and catch when the user sets an invalid
argument. On the other hand, allow for a best-effort mode that
effectively cannot fail and will return a new NMSetting instance.
For now, add NMSettingParseFlags so that the caller can choose the
old behavior, strict parsing, or best effort.
This patch doesn't have any externally visible change except that
no more g_warnings will be emitted.
2016-03-18 13:42:50 +01:00
|
|
|
gs_unref_variant GVariant *value = NULL;
|
|
|
|
|
gs_free_error GError *local = NULL;
|
2015-01-15 10:56:02 -05:00
|
|
|
|
|
|
|
|
if (property->param_spec && !(property->param_spec->flags & G_PARAM_WRITABLE))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
value = g_variant_lookup_value (setting_dict, property->name, NULL);
|
2014-07-24 08:53:33 -04:00
|
|
|
|
libnm-core: allow strict and relaxed error behavior for _nm_setting_new_from_dbus()
In some situations, we want strict checking of errors, for example when
NetworkManager receives a new connection from a client, the connection
must make sense as a whole (and since NetworkManager service is backward
compatible to the clients and not the other way around, there is no
excuse for sending invalid data to the server).
In other situations, we want a best-effort behavior. Like when
NetworkManager sends a connection to its clients, those clients
want to extract as many properties as they understand, but in order
to be forward compatible against newer server versions, invalid
or unknown properties must be accepted.
Previously, a mixture of both was done. Some issues caused a failure
to create a new NMSetting, other invalid parts were just silently
ignored or triggered a g_warning() in glib.
Now allow for both. When doing strict-validation, be more strict and
reject all unknown properties and catch when the user sets an invalid
argument. On the other hand, allow for a best-effort mode that
effectively cannot fail and will return a new NMSetting instance.
For now, add NMSettingParseFlags so that the caller can choose the
old behavior, strict parsing, or best effort.
This patch doesn't have any externally visible change except that
no more g_warnings will be emitted.
2016-03-18 13:42:50 +01:00
|
|
|
if (value && keys)
|
|
|
|
|
g_hash_table_remove (keys, property->name);
|
|
|
|
|
|
2014-07-29 18:25:10 -04:00
|
|
|
if (value && property->set_func) {
|
libnm-core: allow strict and relaxed error behavior for _nm_setting_new_from_dbus()
In some situations, we want strict checking of errors, for example when
NetworkManager receives a new connection from a client, the connection
must make sense as a whole (and since NetworkManager service is backward
compatible to the clients and not the other way around, there is no
excuse for sending invalid data to the server).
In other situations, we want a best-effort behavior. Like when
NetworkManager sends a connection to its clients, those clients
want to extract as many properties as they understand, but in order
to be forward compatible against newer server versions, invalid
or unknown properties must be accepted.
Previously, a mixture of both was done. Some issues caused a failure
to create a new NMSetting, other invalid parts were just silently
ignored or triggered a g_warning() in glib.
Now allow for both. When doing strict-validation, be more strict and
reject all unknown properties and catch when the user sets an invalid
argument. On the other hand, allow for a best-effort mode that
effectively cannot fail and will return a new NMSetting instance.
For now, add NMSettingParseFlags so that the caller can choose the
old behavior, strict parsing, or best effort.
This patch doesn't have any externally visible change except that
no more g_warnings will be emitted.
2016-03-18 13:42:50 +01:00
|
|
|
|
2015-01-15 12:19:06 -05:00
|
|
|
if (!g_variant_type_equal (g_variant_get_type (value), property->dbus_type)) {
|
libnm-core: allow strict and relaxed error behavior for _nm_setting_new_from_dbus()
In some situations, we want strict checking of errors, for example when
NetworkManager receives a new connection from a client, the connection
must make sense as a whole (and since NetworkManager service is backward
compatible to the clients and not the other way around, there is no
excuse for sending invalid data to the server).
In other situations, we want a best-effort behavior. Like when
NetworkManager sends a connection to its clients, those clients
want to extract as many properties as they understand, but in order
to be forward compatible against newer server versions, invalid
or unknown properties must be accepted.
Previously, a mixture of both was done. Some issues caused a failure
to create a new NMSetting, other invalid parts were just silently
ignored or triggered a g_warning() in glib.
Now allow for both. When doing strict-validation, be more strict and
reject all unknown properties and catch when the user sets an invalid
argument. On the other hand, allow for a best-effort mode that
effectively cannot fail and will return a new NMSetting instance.
For now, add NMSettingParseFlags so that the caller can choose the
old behavior, strict parsing, or best effort.
This patch doesn't have any externally visible change except that
no more g_warnings will be emitted.
2016-03-18 13:42:50 +01:00
|
|
|
/* for backward behavior, fail unless best-effort is chosen. */
|
|
|
|
|
if (NM_FLAGS_HAS (parse_flags, NM_SETTING_PARSE_FLAGS_BEST_EFFORT))
|
|
|
|
|
continue;
|
2015-01-15 12:19:06 -05:00
|
|
|
g_set_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
|
|
|
|
_("can't set property of type '%s' from value of type '%s'"),
|
|
|
|
|
property->dbus_type ?
|
|
|
|
|
g_variant_type_peek_string (property->dbus_type) :
|
2015-01-22 14:14:45 +01:00
|
|
|
property->param_spec ?
|
|
|
|
|
g_type_name (property->param_spec->value_type) : "(unknown)",
|
2015-01-15 12:19:06 -05:00
|
|
|
g_variant_get_type_string (value));
|
|
|
|
|
g_prefix_error (error, "%s.%s: ", nm_setting_get_name (setting), property->name);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
libnm-core: allow strict and relaxed error behavior for _nm_setting_new_from_dbus()
In some situations, we want strict checking of errors, for example when
NetworkManager receives a new connection from a client, the connection
must make sense as a whole (and since NetworkManager service is backward
compatible to the clients and not the other way around, there is no
excuse for sending invalid data to the server).
In other situations, we want a best-effort behavior. Like when
NetworkManager sends a connection to its clients, those clients
want to extract as many properties as they understand, but in order
to be forward compatible against newer server versions, invalid
or unknown properties must be accepted.
Previously, a mixture of both was done. Some issues caused a failure
to create a new NMSetting, other invalid parts were just silently
ignored or triggered a g_warning() in glib.
Now allow for both. When doing strict-validation, be more strict and
reject all unknown properties and catch when the user sets an invalid
argument. On the other hand, allow for a best-effort mode that
effectively cannot fail and will return a new NMSetting instance.
For now, add NMSettingParseFlags so that the caller can choose the
old behavior, strict parsing, or best effort.
This patch doesn't have any externally visible change except that
no more g_warnings will be emitted.
2016-03-18 13:42:50 +01:00
|
|
|
if (!property->set_func (setting,
|
|
|
|
|
connection_dict,
|
|
|
|
|
property->name,
|
|
|
|
|
value,
|
|
|
|
|
parse_flags,
|
|
|
|
|
&local)) {
|
|
|
|
|
if (!NM_FLAGS_HAS (parse_flags, NM_SETTING_PARSE_FLAGS_STRICT))
|
|
|
|
|
continue;
|
|
|
|
|
g_set_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
|
|
|
|
_("failed to set property: %s"),
|
|
|
|
|
local->message);
|
|
|
|
|
g_prefix_error (error, "%s.%s: ", nm_setting_get_name (setting), property->name);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2014-07-29 18:25:10 -04:00
|
|
|
} else if (!value && property->not_set_func) {
|
libnm-core: allow strict and relaxed error behavior for _nm_setting_new_from_dbus()
In some situations, we want strict checking of errors, for example when
NetworkManager receives a new connection from a client, the connection
must make sense as a whole (and since NetworkManager service is backward
compatible to the clients and not the other way around, there is no
excuse for sending invalid data to the server).
In other situations, we want a best-effort behavior. Like when
NetworkManager sends a connection to its clients, those clients
want to extract as many properties as they understand, but in order
to be forward compatible against newer server versions, invalid
or unknown properties must be accepted.
Previously, a mixture of both was done. Some issues caused a failure
to create a new NMSetting, other invalid parts were just silently
ignored or triggered a g_warning() in glib.
Now allow for both. When doing strict-validation, be more strict and
reject all unknown properties and catch when the user sets an invalid
argument. On the other hand, allow for a best-effort mode that
effectively cannot fail and will return a new NMSetting instance.
For now, add NMSettingParseFlags so that the caller can choose the
old behavior, strict parsing, or best effort.
This patch doesn't have any externally visible change except that
no more g_warnings will be emitted.
2016-03-18 13:42:50 +01:00
|
|
|
if (!property->not_set_func (setting,
|
|
|
|
|
connection_dict,
|
|
|
|
|
property->name,
|
|
|
|
|
parse_flags,
|
|
|
|
|
&local)) {
|
|
|
|
|
if (!NM_FLAGS_HAS (parse_flags, NM_SETTING_PARSE_FLAGS_STRICT))
|
|
|
|
|
continue;
|
|
|
|
|
g_set_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
|
|
|
|
_("failed to set property: %s"),
|
|
|
|
|
local->message);
|
|
|
|
|
g_prefix_error (error, "%s.%s: ", nm_setting_get_name (setting), property->name);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2014-07-29 18:25:10 -04:00
|
|
|
} else if (value && property->param_spec) {
|
libnm-core: allow strict and relaxed error behavior for _nm_setting_new_from_dbus()
In some situations, we want strict checking of errors, for example when
NetworkManager receives a new connection from a client, the connection
must make sense as a whole (and since NetworkManager service is backward
compatible to the clients and not the other way around, there is no
excuse for sending invalid data to the server).
In other situations, we want a best-effort behavior. Like when
NetworkManager sends a connection to its clients, those clients
want to extract as many properties as they understand, but in order
to be forward compatible against newer server versions, invalid
or unknown properties must be accepted.
Previously, a mixture of both was done. Some issues caused a failure
to create a new NMSetting, other invalid parts were just silently
ignored or triggered a g_warning() in glib.
Now allow for both. When doing strict-validation, be more strict and
reject all unknown properties and catch when the user sets an invalid
argument. On the other hand, allow for a best-effort mode that
effectively cannot fail and will return a new NMSetting instance.
For now, add NMSettingParseFlags so that the caller can choose the
old behavior, strict parsing, or best effort.
This patch doesn't have any externally visible change except that
no more g_warnings will be emitted.
2016-03-18 13:42:50 +01:00
|
|
|
nm_auto_unset_gvalue GValue object_value = G_VALUE_INIT;
|
2014-08-16 10:09:48 -04:00
|
|
|
|
|
|
|
|
g_value_init (&object_value, property->param_spec->value_type);
|
libnm-core: allow strict and relaxed error behavior for _nm_setting_new_from_dbus()
In some situations, we want strict checking of errors, for example when
NetworkManager receives a new connection from a client, the connection
must make sense as a whole (and since NetworkManager service is backward
compatible to the clients and not the other way around, there is no
excuse for sending invalid data to the server).
In other situations, we want a best-effort behavior. Like when
NetworkManager sends a connection to its clients, those clients
want to extract as many properties as they understand, but in order
to be forward compatible against newer server versions, invalid
or unknown properties must be accepted.
Previously, a mixture of both was done. Some issues caused a failure
to create a new NMSetting, other invalid parts were just silently
ignored or triggered a g_warning() in glib.
Now allow for both. When doing strict-validation, be more strict and
reject all unknown properties and catch when the user sets an invalid
argument. On the other hand, allow for a best-effort mode that
effectively cannot fail and will return a new NMSetting instance.
For now, add NMSettingParseFlags so that the caller can choose the
old behavior, strict parsing, or best effort.
This patch doesn't have any externally visible change except that
no more g_warnings will be emitted.
2016-03-18 13:42:50 +01:00
|
|
|
if (!set_property_from_dbus (property, value, &object_value)) {
|
|
|
|
|
/* for backward behavior, fail unless best-effort is chosen. */
|
|
|
|
|
if (NM_FLAGS_HAS (parse_flags, NM_SETTING_PARSE_FLAGS_BEST_EFFORT))
|
|
|
|
|
continue;
|
|
|
|
|
g_set_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
|
|
|
|
_("can't set property of type '%s' from value of type '%s'"),
|
|
|
|
|
property->dbus_type ?
|
|
|
|
|
g_variant_type_peek_string (property->dbus_type) :
|
|
|
|
|
property->param_spec ?
|
|
|
|
|
g_type_name (property->param_spec->value_type) : "(unknown)",
|
|
|
|
|
g_variant_get_type_string (value));
|
|
|
|
|
g_prefix_error (error, "%s.%s: ", nm_setting_get_name (setting), property->name);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2015-01-15 12:19:06 -05:00
|
|
|
|
libnm-core: allow strict and relaxed error behavior for _nm_setting_new_from_dbus()
In some situations, we want strict checking of errors, for example when
NetworkManager receives a new connection from a client, the connection
must make sense as a whole (and since NetworkManager service is backward
compatible to the clients and not the other way around, there is no
excuse for sending invalid data to the server).
In other situations, we want a best-effort behavior. Like when
NetworkManager sends a connection to its clients, those clients
want to extract as many properties as they understand, but in order
to be forward compatible against newer server versions, invalid
or unknown properties must be accepted.
Previously, a mixture of both was done. Some issues caused a failure
to create a new NMSetting, other invalid parts were just silently
ignored or triggered a g_warning() in glib.
Now allow for both. When doing strict-validation, be more strict and
reject all unknown properties and catch when the user sets an invalid
argument. On the other hand, allow for a best-effort mode that
effectively cannot fail and will return a new NMSetting instance.
For now, add NMSettingParseFlags so that the caller can choose the
old behavior, strict parsing, or best effort.
This patch doesn't have any externally visible change except that
no more g_warnings will be emitted.
2016-03-18 13:42:50 +01:00
|
|
|
if (!nm_g_object_set_property (G_OBJECT (setting), property->param_spec->name, &object_value, &local)) {
|
|
|
|
|
if (!NM_FLAGS_HAS (parse_flags, NM_SETTING_PARSE_FLAGS_STRICT))
|
|
|
|
|
continue;
|
|
|
|
|
g_set_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
|
|
|
|
_("can not set property: %s"),
|
|
|
|
|
local->message);
|
|
|
|
|
g_prefix_error (error, "%s.%s: ", nm_setting_get_name (setting), property->name);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
libnm-core: add dbus-only properties to NMSettingClass
Add _nm_setting_class_add_dbus_only_property(), for declaring
properties that appear in the D-Bus serialization, but which don't
correspond to GObject properties.
Since some property overrides will require examining settings other
than the setting that they are on (eg, the value of
802-11-wireless.security depends on whether an
NMSettingWirelessSecurity setting is present, and
NMSettingConnection:interface-name might sometimes be set from, eg,
bond.interface-name), we also update _nm_setting_to_dbus() to take the
full NMConnection as an argument, and _nm_setting_new_from_dbus() to
take the full connection hash.
Additionally, with some deprecated properties, we'll want to validate
them on construction, but we don't need to keep the value around after
that. So allow _nm_setting_new_from_dbus() to return a verification
error directly, so we don't need to store the value until the verify()
call.
2014-07-29 18:25:10 -04:00
|
|
|
}
|
libnm-core: allow strict and relaxed error behavior for _nm_setting_new_from_dbus()
In some situations, we want strict checking of errors, for example when
NetworkManager receives a new connection from a client, the connection
must make sense as a whole (and since NetworkManager service is backward
compatible to the clients and not the other way around, there is no
excuse for sending invalid data to the server).
In other situations, we want a best-effort behavior. Like when
NetworkManager sends a connection to its clients, those clients
want to extract as many properties as they understand, but in order
to be forward compatible against newer server versions, invalid
or unknown properties must be accepted.
Previously, a mixture of both was done. Some issues caused a failure
to create a new NMSetting, other invalid parts were just silently
ignored or triggered a g_warning() in glib.
Now allow for both. When doing strict-validation, be more strict and
reject all unknown properties and catch when the user sets an invalid
argument. On the other hand, allow for a best-effort mode that
effectively cannot fail and will return a new NMSetting instance.
For now, add NMSettingParseFlags so that the caller can choose the
old behavior, strict parsing, or best effort.
This patch doesn't have any externally visible change except that
no more g_warnings will be emitted.
2016-03-18 13:42:50 +01:00
|
|
|
}
|
2014-08-16 10:09:48 -04:00
|
|
|
|
libnm-core: allow strict and relaxed error behavior for _nm_setting_new_from_dbus()
In some situations, we want strict checking of errors, for example when
NetworkManager receives a new connection from a client, the connection
must make sense as a whole (and since NetworkManager service is backward
compatible to the clients and not the other way around, there is no
excuse for sending invalid data to the server).
In other situations, we want a best-effort behavior. Like when
NetworkManager sends a connection to its clients, those clients
want to extract as many properties as they understand, but in order
to be forward compatible against newer server versions, invalid
or unknown properties must be accepted.
Previously, a mixture of both was done. Some issues caused a failure
to create a new NMSetting, other invalid parts were just silently
ignored or triggered a g_warning() in glib.
Now allow for both. When doing strict-validation, be more strict and
reject all unknown properties and catch when the user sets an invalid
argument. On the other hand, allow for a best-effort mode that
effectively cannot fail and will return a new NMSetting instance.
For now, add NMSettingParseFlags so that the caller can choose the
old behavior, strict parsing, or best effort.
This patch doesn't have any externally visible change except that
no more g_warnings will be emitted.
2016-03-18 13:42:50 +01:00
|
|
|
if ( NM_FLAGS_HAS (parse_flags, NM_SETTING_PARSE_FLAGS_STRICT)
|
|
|
|
|
&& g_hash_table_size (keys) > 0) {
|
|
|
|
|
GHashTableIter iter;
|
|
|
|
|
const char *key;
|
|
|
|
|
|
|
|
|
|
g_hash_table_iter_init (&iter, keys);
|
|
|
|
|
if (g_hash_table_iter_next (&iter, (gpointer *) &key, NULL)) {
|
|
|
|
|
g_set_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
|
|
|
|
_("unknown property"));
|
|
|
|
|
g_prefix_error (error, "%s.%s: ", nm_setting_get_name (setting), key);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2014-08-04 11:39:33 -04:00
|
|
|
}
|
libnm-core: add dbus-only properties to NMSettingClass
Add _nm_setting_class_add_dbus_only_property(), for declaring
properties that appear in the D-Bus serialization, but which don't
correspond to GObject properties.
Since some property overrides will require examining settings other
than the setting that they are on (eg, the value of
802-11-wireless.security depends on whether an
NMSettingWirelessSecurity setting is present, and
NMSettingConnection:interface-name might sometimes be set from, eg,
bond.interface-name), we also update _nm_setting_to_dbus() to take the
full NMConnection as an argument, and _nm_setting_new_from_dbus() to
take the full connection hash.
Additionally, with some deprecated properties, we'll want to validate
them on construction, but we don't need to keep the value around after
that. So allow _nm_setting_new_from_dbus() to return a verification
error directly, so we don't need to store the value until the verify()
call.
2014-07-29 18:25:10 -04:00
|
|
|
|
2016-05-12 14:28:34 +02:00
|
|
|
return g_steal_pointer (&setting);
|
2014-07-24 08:53:33 -04:00
|
|
|
}
|
|
|
|
|
|
2014-11-16 16:13:06 -05:00
|
|
|
/**
|
|
|
|
|
* nm_setting_get_dbus_property_type:
|
|
|
|
|
* @setting: an #NMSetting
|
|
|
|
|
* @property_name: the property of @setting to get the type of
|
|
|
|
|
*
|
|
|
|
|
* Gets the D-Bus marshalling type of a property. @property_name is a D-Bus
|
|
|
|
|
* property name, which may not necessarily be a #GObject property.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the D-Bus marshalling type of @property on @setting.
|
|
|
|
|
*/
|
|
|
|
|
const GVariantType *
|
|
|
|
|
nm_setting_get_dbus_property_type (NMSetting *setting,
|
|
|
|
|
const char *property_name)
|
|
|
|
|
{
|
|
|
|
|
const NMSettingProperty *property;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING (setting), NULL);
|
|
|
|
|
g_return_val_if_fail (property_name != NULL, NULL);
|
|
|
|
|
|
|
|
|
|
property = nm_setting_class_find_property (NM_SETTING_GET_CLASS (setting), property_name);
|
|
|
|
|
g_return_val_if_fail (property != NULL, NULL);
|
|
|
|
|
|
|
|
|
|
if (property->dbus_type)
|
|
|
|
|
return property->dbus_type;
|
|
|
|
|
else
|
|
|
|
|
return variant_type_for_gtype (property->param_spec->value_type);
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-26 10:09:54 +01:00
|
|
|
gboolean
|
|
|
|
|
_nm_setting_get_property (NMSetting *setting, const char *property_name, GValue *value)
|
|
|
|
|
{
|
|
|
|
|
GParamSpec *prop_spec;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING (setting), FALSE);
|
|
|
|
|
g_return_val_if_fail (property_name, FALSE);
|
|
|
|
|
g_return_val_if_fail (value, FALSE);
|
|
|
|
|
|
|
|
|
|
prop_spec = g_object_class_find_property (G_OBJECT_GET_CLASS (setting), property_name);
|
|
|
|
|
|
|
|
|
|
if (!prop_spec) {
|
|
|
|
|
g_value_unset (value);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_value_init (value, prop_spec->value_type);
|
|
|
|
|
g_object_get_property (G_OBJECT (setting), property_name, value);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-24 08:53:33 -04:00
|
|
|
static void
|
|
|
|
|
duplicate_setting (NMSetting *setting,
|
|
|
|
|
const char *name,
|
|
|
|
|
const GValue *value,
|
|
|
|
|
GParamFlags flags,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
if ((flags & (G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY)) == G_PARAM_WRITABLE)
|
|
|
|
|
g_object_set_property (G_OBJECT (user_data), name, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_duplicate:
|
|
|
|
|
* @setting: the #NMSetting to duplicate
|
|
|
|
|
*
|
|
|
|
|
* Duplicates a #NMSetting.
|
|
|
|
|
*
|
|
|
|
|
* Returns: (transfer full): a new #NMSetting containing the same properties and values as the
|
|
|
|
|
* source #NMSetting
|
|
|
|
|
**/
|
|
|
|
|
NMSetting *
|
|
|
|
|
nm_setting_duplicate (NMSetting *setting)
|
|
|
|
|
{
|
|
|
|
|
GObject *dup;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING (setting), NULL);
|
|
|
|
|
|
|
|
|
|
dup = g_object_new (G_OBJECT_TYPE (setting), NULL);
|
|
|
|
|
|
|
|
|
|
g_object_freeze_notify (dup);
|
|
|
|
|
nm_setting_enumerate_values (setting, duplicate_setting, dup);
|
|
|
|
|
g_object_thaw_notify (dup);
|
|
|
|
|
|
|
|
|
|
return NM_SETTING (dup);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_get_name:
|
|
|
|
|
* @setting: the #NMSetting
|
|
|
|
|
*
|
|
|
|
|
* Returns the type name of the #NMSetting object
|
|
|
|
|
*
|
|
|
|
|
* Returns: a string containing the type name of the #NMSetting object,
|
|
|
|
|
* like 'ppp' or 'wireless' or 'wired'.
|
|
|
|
|
**/
|
|
|
|
|
const char *
|
|
|
|
|
nm_setting_get_name (NMSetting *setting)
|
|
|
|
|
{
|
libnm: use NMMetaSettingInfo for tracking setting priority
Previously, each (non abstract) NMSetting class had to register
its name and priority via _nm_register_setting().
Note, that libnm-core.la already links against "nm-meta-setting.c",
which also redundantly keeps track of the settings name and gtype
as well.
Re-use NMMetaSettingInfo also in libnm-core.la, to track this meta
data.
The goal is to get rid of private data structures that track
meta data about NMSetting classes. In this case, "registered_settings"
hash. Instead, we should have one place where all this meta data
is tracked. This was, it is also accessible as internal API,
which can be useful (for keyfile).
Note that NMSettingClass has some overlap with NMMetaSettingInfo.
One difference is, that NMMetaSettingInfo is const, while NMSettingClass
is only initialized during the class_init() method. Appart from that,
it's mostly a matter of taste, whether we attach meta data to
NMSettingClass, to NMMetaSettingInfo, or to a static-array indexed
by NMMetaSettingType.
Note, that previously, _nm_register_setting() was private API. That
means, no user could subclass a functioning NMSetting instance. The same
is still true: NMMetaSettingInfo is internal API and users cannot access
it to create their own NMSetting subclasses. But that is almost desired.
libnm is not designed, to be extensible via subclassing, nor is it
clear why that would be a useful thing to do. One day, we should remove
the NMSetting and NMSettingClass definitions from public headers. Their
only use is subclassing the types, which however does not work.
While libnm-core was linking already against nm-meta-setting.c,
nm_meta_setting_infos was unreferenced. So, this change increases
the binary size of libnm and NetworkManager (1032 bytes). Note however
that roughly the same information was previously allocated at runtime.
2018-07-27 14:08:14 +02:00
|
|
|
const NMMetaSettingInfo *setting_info;
|
2014-07-24 08:53:33 -04:00
|
|
|
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING (setting), NULL);
|
libnm: use NMMetaSettingInfo for tracking setting priority
Previously, each (non abstract) NMSetting class had to register
its name and priority via _nm_register_setting().
Note, that libnm-core.la already links against "nm-meta-setting.c",
which also redundantly keeps track of the settings name and gtype
as well.
Re-use NMMetaSettingInfo also in libnm-core.la, to track this meta
data.
The goal is to get rid of private data structures that track
meta data about NMSetting classes. In this case, "registered_settings"
hash. Instead, we should have one place where all this meta data
is tracked. This was, it is also accessible as internal API,
which can be useful (for keyfile).
Note that NMSettingClass has some overlap with NMMetaSettingInfo.
One difference is, that NMMetaSettingInfo is const, while NMSettingClass
is only initialized during the class_init() method. Appart from that,
it's mostly a matter of taste, whether we attach meta data to
NMSettingClass, to NMMetaSettingInfo, or to a static-array indexed
by NMMetaSettingType.
Note, that previously, _nm_register_setting() was private API. That
means, no user could subclass a functioning NMSetting instance. The same
is still true: NMMetaSettingInfo is internal API and users cannot access
it to create their own NMSetting subclasses. But that is almost desired.
libnm is not designed, to be extensible via subclassing, nor is it
clear why that would be a useful thing to do. One day, we should remove
the NMSetting and NMSettingClass definitions from public headers. Their
only use is subclassing the types, which however does not work.
While libnm-core was linking already against nm-meta-setting.c,
nm_meta_setting_infos was unreferenced. So, this change increases
the binary size of libnm and NetworkManager (1032 bytes). Note however
that roughly the same information was previously allocated at runtime.
2018-07-27 14:08:14 +02:00
|
|
|
|
|
|
|
|
setting_info = NM_SETTING_GET_CLASS (setting)->setting_info;
|
|
|
|
|
return setting_info ? setting_info->setting_name : NULL;
|
2014-07-24 08:53:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_verify:
|
|
|
|
|
* @setting: the #NMSetting to verify
|
2014-10-21 22:30:31 -04:00
|
|
|
* @connection: (allow-none): the #NMConnection that @setting came from, or
|
|
|
|
|
* %NULL if @setting is being verified in isolation.
|
2014-07-24 08:53:33 -04:00
|
|
|
* @error: location to store error, or %NULL
|
|
|
|
|
*
|
|
|
|
|
* Validates the setting. Each setting's properties have allowed values, and
|
2014-10-21 22:30:31 -04:00
|
|
|
* some are dependent on other values (hence the need for @connection). The
|
2014-07-24 08:53:33 -04:00
|
|
|
* returned #GError contains information about which property of the setting
|
|
|
|
|
* failed validation, and in what way that property failed validation.
|
|
|
|
|
*
|
|
|
|
|
* Returns: %TRUE if the setting is valid, %FALSE if it is not
|
|
|
|
|
**/
|
|
|
|
|
gboolean
|
2014-10-21 22:30:31 -04:00
|
|
|
nm_setting_verify (NMSetting *setting, NMConnection *connection, GError **error)
|
2014-07-24 08:53:33 -04:00
|
|
|
{
|
2014-10-21 22:30:31 -04:00
|
|
|
NMSettingVerifyResult result = _nm_setting_verify (setting, connection, error);
|
2014-07-24 08:53:33 -04:00
|
|
|
|
|
|
|
|
if (result == NM_SETTING_VERIFY_NORMALIZABLE)
|
|
|
|
|
g_clear_error (error);
|
|
|
|
|
|
|
|
|
|
return result == NM_SETTING_VERIFY_SUCCESS || result == NM_SETTING_VERIFY_NORMALIZABLE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NMSettingVerifyResult
|
2014-10-21 22:30:31 -04:00
|
|
|
_nm_setting_verify (NMSetting *setting, NMConnection *connection, GError **error)
|
2014-07-24 08:53:33 -04:00
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING (setting), NM_SETTING_VERIFY_ERROR);
|
2014-10-21 22:30:31 -04:00
|
|
|
g_return_val_if_fail (!connection || NM_IS_CONNECTION (connection), NM_SETTING_VERIFY_ERROR);
|
2014-07-24 08:53:33 -04:00
|
|
|
g_return_val_if_fail (!error || *error == NULL, NM_SETTING_VERIFY_ERROR);
|
|
|
|
|
|
|
|
|
|
if (NM_SETTING_GET_CLASS (setting)->verify)
|
2014-10-21 22:30:31 -04:00
|
|
|
return NM_SETTING_GET_CLASS (setting)->verify (setting, connection, error);
|
2014-07-24 08:53:33 -04:00
|
|
|
|
|
|
|
|
return NM_SETTING_VERIFY_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-10 14:36:20 +01:00
|
|
|
/**
|
|
|
|
|
* nm_setting_verify_secrets:
|
|
|
|
|
* @setting: the #NMSetting to verify secrets in
|
|
|
|
|
* @connection: (allow-none): the #NMConnection that @setting came from, or
|
|
|
|
|
* %NULL if @setting is being verified in isolation.
|
|
|
|
|
* @error: location to store error, or %NULL
|
|
|
|
|
*
|
|
|
|
|
* Verifies the secrets in the setting.
|
|
|
|
|
* The returned #GError contains information about which secret of the setting
|
|
|
|
|
* failed validation, and in what way that secret failed validation.
|
|
|
|
|
* The secret validation is done separately from main setting validation, because
|
|
|
|
|
* in some cases connection failure is not desired just for the secrets.
|
|
|
|
|
*
|
|
|
|
|
* Returns: %TRUE if the setting secrets are valid, %FALSE if they are not
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.2
|
|
|
|
|
**/
|
|
|
|
|
gboolean
|
|
|
|
|
nm_setting_verify_secrets (NMSetting *setting, NMConnection *connection, GError **error)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING (setting), NM_SETTING_VERIFY_ERROR);
|
|
|
|
|
g_return_val_if_fail (!connection || NM_IS_CONNECTION (connection), NM_SETTING_VERIFY_ERROR);
|
|
|
|
|
g_return_val_if_fail (!error || *error == NULL, NM_SETTING_VERIFY_ERROR);
|
|
|
|
|
|
|
|
|
|
if (NM_SETTING_GET_CLASS (setting)->verify_secrets)
|
|
|
|
|
return NM_SETTING_GET_CLASS (setting)->verify_secrets (setting, connection, error);
|
|
|
|
|
|
|
|
|
|
return NM_SETTING_VERIFY_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
|
_nm_setting_verify_secret_string (const char *str,
|
|
|
|
|
const char *setting_name,
|
|
|
|
|
const char *property,
|
|
|
|
|
GError **error)
|
|
|
|
|
{
|
|
|
|
|
if (str && !*str) {
|
|
|
|
|
g_set_error_literal (error,
|
|
|
|
|
NM_CONNECTION_ERROR,
|
|
|
|
|
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
|
|
|
|
_("property is empty"));
|
|
|
|
|
g_prefix_error (error, "%s.%s: ", setting_name, property);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-24 08:53:33 -04:00
|
|
|
static gboolean
|
|
|
|
|
compare_property (NMSetting *setting,
|
|
|
|
|
NMSetting *other,
|
|
|
|
|
const GParamSpec *prop_spec,
|
|
|
|
|
NMSettingCompareFlags flags)
|
|
|
|
|
{
|
2014-07-30 10:46:24 -04:00
|
|
|
const NMSettingProperty *property;
|
2014-08-16 10:09:48 -04:00
|
|
|
GVariant *value1, *value2;
|
2014-07-29 09:22:07 -04:00
|
|
|
int cmp;
|
2014-07-24 08:53:33 -04:00
|
|
|
|
|
|
|
|
/* Handle compare flags */
|
|
|
|
|
if (prop_spec->flags & NM_SETTING_PARAM_SECRET) {
|
|
|
|
|
NMSettingSecretFlags a_secret_flags = NM_SETTING_SECRET_FLAG_NONE;
|
|
|
|
|
NMSettingSecretFlags b_secret_flags = NM_SETTING_SECRET_FLAG_NONE;
|
|
|
|
|
|
libnm-util: don't assert in nm_setting_get_secret_flags() and avoid assertion in agent_secrets_done_cb()
When secret providers return the connection hash in GetSecrets(),
this hash should only contain secrets. However, some providers also
return non-secret properties.
for_each_secret() iterated over all entries of the @secrets hash
and triggered the assertion in nm_setting_get_secret_flags() (see
below).
NM should not assert against user provided input. Change
nm_setting_get_secret_flags() to silently return FALSE, if the property
is not a secret.
Indeed, handling of secrets is very different for NMSettingVpn and
others. Hence nm_setting_get_secret_flags() has only an inconsistent
behavior and we have to fix all call sites to do the right thing
(depending on whether we have a VPN setting or not).
Now for_each_secret() checks whether the property is a secret
without hitting the assertion. Adjust all other calls of
nm_setting_get_secret_flags(), to anticipate non-secret flags and
assert/warn where appropriate.
Also, agent_secrets_done_cb() clears now all non-secrets properties
from the hash, using the new argument @remove_non_secrets when calling
for_each_secret().
#0 0x0000003370c504e9 in g_logv () from /lib64/libglib-2.0.so.0
#1 0x0000003370c5063f in g_log () from /lib64/libglib-2.0.so.0
#2 0x00007fa4b0c1c156 in get_secret_flags (setting=0x1e3ac60, secret_name=0x1ea9180 "security", verify_secret=1, out_flags=0x7fff7507857c, error=0x0) at nm-setting.c:1091
#3 0x00007fa4b0c1c2b2 in nm_setting_get_secret_flags (setting=0x1e3ac60, secret_name=0x1ea9180 "security", out_flags=0x7fff7507857c, error=0x0) at nm-setting.c:1124
#4 0x0000000000463d03 in for_each_secret (connection=0x1deb2f0, secrets=0x1e9f860, callback=0x464f1b <has_system_owned_secrets>, callback_data=0x7fff7507865c) at settings/nm-settings-connection.c:203
#5 0x000000000046525f in agent_secrets_done_cb (manager=0x1dddf50, call_id=1, agent_dbus_owner=0x1ddb9e0 ":1.39", agent_username=0x1e51710 "thom", agent_has_modify=1, setting_name=0x1e91f90 "802-11-wireless-security",
flags=NM_SETTINGS_GET_SECRETS_FLAG_ALLOW_INTERACTION, secrets=0x1e9f860, error=0x0, user_data=0x1deb2f0, other_data2=0x477d61 <get_secrets_cb>, other_data3=0x1ea92a0) at settings/nm-settings-connection.c:757
#6 0x00000000004dc4fd in get_complete_cb (parent=0x1ea6300, secrets=0x1e9f860, agent_dbus_owner=0x1ddb9e0 ":1.39", agent_username=0x1e51710 "thom", error=0x0, user_data=0x1dddf50) at settings/nm-agent-manager.c:1139
#7 0x00000000004dab54 in req_complete_success (req=0x1ea6300, secrets=0x1e9f860, agent_dbus_owner=0x1ddb9e0 ":1.39", agent_uname=0x1e51710 "thom") at settings/nm-agent-manager.c:502
#8 0x00000000004db86e in get_done_cb (agent=0x1e89530, call_id=0x1, secrets=0x1e9f860, error=0x0, user_data=0x1ea6300) at settings/nm-agent-manager.c:856
#9 0x00000000004de9d0 in get_callback (proxy=0x1e47530, call=0x1, user_data=0x1ea10f0) at settings/nm-secret-agent.c:267
#10 0x000000337380cad2 in complete_pending_call_and_unlock () from /lib64/libdbus-1.so.3
#11 0x000000337380fdc1 in dbus_connection_dispatch () from /lib64/libdbus-1.so.3
#12 0x000000342800ad65 in message_queue_dispatch () from /lib64/libdbus-glib-1.so.2
#13 0x0000003370c492a6 in g_main_context_dispatch () from /lib64/libglib-2.0.so.0
#14 0x0000003370c49628 in g_main_context_iterate.isra.24 () from /lib64/libglib-2.0.so.0
#15 0x0000003370c49a3a in g_main_loop_run () from /lib64/libglib-2.0.so.0
#16 0x000000000042e5c6 in main (argc=1, argv=0x7fff75078e88) at main.c:644
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-02-23 17:03:01 +01:00
|
|
|
g_return_val_if_fail (!NM_IS_SETTING_VPN (setting), FALSE);
|
|
|
|
|
|
|
|
|
|
if (!nm_setting_get_secret_flags (setting, prop_spec->name, &a_secret_flags, NULL))
|
|
|
|
|
g_return_val_if_reached (FALSE);
|
|
|
|
|
if (!nm_setting_get_secret_flags (other, prop_spec->name, &b_secret_flags, NULL))
|
|
|
|
|
g_return_val_if_reached (FALSE);
|
2014-07-24 08:53:33 -04:00
|
|
|
|
|
|
|
|
/* If the secret flags aren't the same the settings aren't the same */
|
|
|
|
|
if (a_secret_flags != b_secret_flags)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
/* Check for various secret flags that might cause us to ignore comparing
|
|
|
|
|
* this property.
|
|
|
|
|
*/
|
|
|
|
|
if ( (flags & NM_SETTING_COMPARE_FLAG_IGNORE_AGENT_OWNED_SECRETS)
|
|
|
|
|
&& (a_secret_flags & NM_SETTING_SECRET_FLAG_AGENT_OWNED))
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
|
|
if ( (flags & NM_SETTING_COMPARE_FLAG_IGNORE_NOT_SAVED_SECRETS)
|
|
|
|
|
&& (a_secret_flags & NM_SETTING_SECRET_FLAG_NOT_SAVED))
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-30 10:46:24 -04:00
|
|
|
property = nm_setting_class_find_property (NM_SETTING_GET_CLASS (setting), prop_spec->name);
|
|
|
|
|
g_return_val_if_fail (property != NULL, FALSE);
|
|
|
|
|
|
2015-05-20 17:53:25 +02:00
|
|
|
value1 = get_property_for_dbus (setting, property, TRUE);
|
|
|
|
|
value2 = get_property_for_dbus (other, property, TRUE);
|
2014-07-30 10:46:24 -04:00
|
|
|
|
2014-08-16 10:09:48 -04:00
|
|
|
cmp = nm_property_compare (value1, value2);
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2015-05-20 17:53:25 +02:00
|
|
|
if (value1)
|
|
|
|
|
g_variant_unref (value1);
|
|
|
|
|
if (value2)
|
|
|
|
|
g_variant_unref (value2);
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2014-07-29 09:22:07 -04:00
|
|
|
return cmp == 0;
|
2014-07-24 08:53:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_compare:
|
|
|
|
|
* @a: a #NMSetting
|
|
|
|
|
* @b: a second #NMSetting to compare with the first
|
|
|
|
|
* @flags: compare flags, e.g. %NM_SETTING_COMPARE_FLAG_EXACT
|
|
|
|
|
*
|
|
|
|
|
* Compares two #NMSetting objects for similarity, with comparison behavior
|
|
|
|
|
* modified by a set of flags. See the documentation for #NMSettingCompareFlags
|
|
|
|
|
* for a description of each flag's behavior.
|
|
|
|
|
*
|
|
|
|
|
* Returns: %TRUE if the comparison succeeds, %FALSE if it does not
|
|
|
|
|
**/
|
|
|
|
|
gboolean
|
|
|
|
|
nm_setting_compare (NMSetting *a,
|
|
|
|
|
NMSetting *b,
|
|
|
|
|
NMSettingCompareFlags flags)
|
|
|
|
|
{
|
|
|
|
|
GParamSpec **property_specs;
|
|
|
|
|
guint n_property_specs;
|
all: don't use gchar/gshort/gint/glong but C types
We commonly don't use the glib typedefs for char/short/int/long,
but their C types directly.
$ git grep '\<g\(char\|short\|int\|long\|float\|double\)\>' | wc -l
587
$ git grep '\<\(char\|short\|int\|long\|float\|double\)\>' | wc -l
21114
One could argue that using the glib typedefs is preferable in
public API (of our glib based libnm library) or where it clearly
is related to glib, like during
g_object_set (obj, PROPERTY, (gint) value, NULL);
However, that argument does not seem strong, because in practice we don't
follow that argument today, and seldomly use the glib typedefs.
Also, the style guide for this would be hard to formalize, because
"using them where clearly related to a glib" is a very loose suggestion.
Also note that glib typedefs will always just be typedefs of the
underlying C types. There is no danger of glib changing the meaning
of these typedefs (because that would be a major API break of glib).
A simple style guide is instead: don't use these typedefs.
No manual actions, I only ran the bash script:
FILES=($(git ls-files '*.[hc]'))
sed -i \
-e 's/\<g\(char\|short\|int\|long\|float\|double\)\>\( [^ ]\)/\1\2/g' \
-e 's/\<g\(char\|short\|int\|long\|float\|double\)\> /\1 /g' \
-e 's/\<g\(char\|short\|int\|long\|float\|double\)\>/\1/g' \
"${FILES[@]}"
2018-07-11 07:40:19 +02:00
|
|
|
int same = TRUE;
|
2014-07-24 08:53:33 -04:00
|
|
|
guint i;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING (a), FALSE);
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING (b), FALSE);
|
|
|
|
|
|
|
|
|
|
/* First check that both have the same type */
|
|
|
|
|
if (G_OBJECT_TYPE (a) != G_OBJECT_TYPE (b))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
/* And now all properties */
|
|
|
|
|
property_specs = g_object_class_list_properties (G_OBJECT_GET_CLASS (a), &n_property_specs);
|
|
|
|
|
for (i = 0; i < n_property_specs && same; i++) {
|
|
|
|
|
GParamSpec *prop_spec = property_specs[i];
|
|
|
|
|
|
|
|
|
|
/* Fuzzy compare ignores secrets and properties defined with the FUZZY_IGNORE flag */
|
2015-09-18 15:10:25 +02:00
|
|
|
if ( NM_FLAGS_HAS (flags, NM_SETTING_COMPARE_FLAG_FUZZY)
|
|
|
|
|
&& !NM_FLAGS_ANY (prop_spec->flags, NM_SETTING_PARAM_FUZZY_IGNORE | NM_SETTING_PARAM_SECRET))
|
2014-07-24 08:53:33 -04:00
|
|
|
continue;
|
|
|
|
|
|
2015-09-18 15:10:25 +02:00
|
|
|
if ( NM_FLAGS_HAS (flags, NM_SETTING_COMPARE_FLAG_INFERRABLE)
|
|
|
|
|
&& !NM_FLAGS_HAS (prop_spec->flags, NM_SETTING_PARAM_INFERRABLE))
|
2014-07-24 08:53:33 -04:00
|
|
|
continue;
|
|
|
|
|
|
2015-09-18 17:21:34 +02:00
|
|
|
if ( NM_FLAGS_HAS (flags, NM_SETTING_COMPARE_FLAG_IGNORE_REAPPLY_IMMEDIATELY)
|
|
|
|
|
&& NM_FLAGS_HAS (prop_spec->flags, NM_SETTING_PARAM_REAPPLY_IMMEDIATELY))
|
|
|
|
|
continue;
|
|
|
|
|
|
2015-09-18 15:10:25 +02:00
|
|
|
if ( NM_FLAGS_HAS (flags, NM_SETTING_COMPARE_FLAG_IGNORE_SECRETS)
|
|
|
|
|
&& NM_FLAGS_HAS (prop_spec->flags, NM_SETTING_PARAM_SECRET))
|
2014-07-24 08:53:33 -04:00
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
same = NM_SETTING_GET_CLASS (a)->compare_property (a, b, prop_spec, flags);
|
|
|
|
|
}
|
|
|
|
|
g_free (property_specs);
|
|
|
|
|
|
|
|
|
|
return same;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline gboolean
|
|
|
|
|
should_compare_prop (NMSetting *setting,
|
|
|
|
|
const char *prop_name,
|
|
|
|
|
NMSettingCompareFlags comp_flags,
|
|
|
|
|
GParamFlags prop_flags)
|
|
|
|
|
{
|
|
|
|
|
/* Fuzzy compare ignores secrets and properties defined with the FUZZY_IGNORE flag */
|
|
|
|
|
if ( (comp_flags & NM_SETTING_COMPARE_FLAG_FUZZY)
|
|
|
|
|
&& (prop_flags & (NM_SETTING_PARAM_FUZZY_IGNORE | NM_SETTING_PARAM_SECRET)))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
if ((comp_flags & NM_SETTING_COMPARE_FLAG_INFERRABLE) && !(prop_flags & NM_SETTING_PARAM_INFERRABLE))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
2015-09-18 17:21:34 +02:00
|
|
|
if ((comp_flags & NM_SETTING_COMPARE_FLAG_IGNORE_REAPPLY_IMMEDIATELY) && !(prop_flags & NM_SETTING_PARAM_REAPPLY_IMMEDIATELY))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
2014-07-24 08:53:33 -04:00
|
|
|
if (prop_flags & NM_SETTING_PARAM_SECRET) {
|
|
|
|
|
NMSettingSecretFlags secret_flags = NM_SETTING_SECRET_FLAG_NONE;
|
|
|
|
|
|
|
|
|
|
if (comp_flags & NM_SETTING_COMPARE_FLAG_IGNORE_SECRETS)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
libnm-util: don't assert in nm_setting_get_secret_flags() and avoid assertion in agent_secrets_done_cb()
When secret providers return the connection hash in GetSecrets(),
this hash should only contain secrets. However, some providers also
return non-secret properties.
for_each_secret() iterated over all entries of the @secrets hash
and triggered the assertion in nm_setting_get_secret_flags() (see
below).
NM should not assert against user provided input. Change
nm_setting_get_secret_flags() to silently return FALSE, if the property
is not a secret.
Indeed, handling of secrets is very different for NMSettingVpn and
others. Hence nm_setting_get_secret_flags() has only an inconsistent
behavior and we have to fix all call sites to do the right thing
(depending on whether we have a VPN setting or not).
Now for_each_secret() checks whether the property is a secret
without hitting the assertion. Adjust all other calls of
nm_setting_get_secret_flags(), to anticipate non-secret flags and
assert/warn where appropriate.
Also, agent_secrets_done_cb() clears now all non-secrets properties
from the hash, using the new argument @remove_non_secrets when calling
for_each_secret().
#0 0x0000003370c504e9 in g_logv () from /lib64/libglib-2.0.so.0
#1 0x0000003370c5063f in g_log () from /lib64/libglib-2.0.so.0
#2 0x00007fa4b0c1c156 in get_secret_flags (setting=0x1e3ac60, secret_name=0x1ea9180 "security", verify_secret=1, out_flags=0x7fff7507857c, error=0x0) at nm-setting.c:1091
#3 0x00007fa4b0c1c2b2 in nm_setting_get_secret_flags (setting=0x1e3ac60, secret_name=0x1ea9180 "security", out_flags=0x7fff7507857c, error=0x0) at nm-setting.c:1124
#4 0x0000000000463d03 in for_each_secret (connection=0x1deb2f0, secrets=0x1e9f860, callback=0x464f1b <has_system_owned_secrets>, callback_data=0x7fff7507865c) at settings/nm-settings-connection.c:203
#5 0x000000000046525f in agent_secrets_done_cb (manager=0x1dddf50, call_id=1, agent_dbus_owner=0x1ddb9e0 ":1.39", agent_username=0x1e51710 "thom", agent_has_modify=1, setting_name=0x1e91f90 "802-11-wireless-security",
flags=NM_SETTINGS_GET_SECRETS_FLAG_ALLOW_INTERACTION, secrets=0x1e9f860, error=0x0, user_data=0x1deb2f0, other_data2=0x477d61 <get_secrets_cb>, other_data3=0x1ea92a0) at settings/nm-settings-connection.c:757
#6 0x00000000004dc4fd in get_complete_cb (parent=0x1ea6300, secrets=0x1e9f860, agent_dbus_owner=0x1ddb9e0 ":1.39", agent_username=0x1e51710 "thom", error=0x0, user_data=0x1dddf50) at settings/nm-agent-manager.c:1139
#7 0x00000000004dab54 in req_complete_success (req=0x1ea6300, secrets=0x1e9f860, agent_dbus_owner=0x1ddb9e0 ":1.39", agent_uname=0x1e51710 "thom") at settings/nm-agent-manager.c:502
#8 0x00000000004db86e in get_done_cb (agent=0x1e89530, call_id=0x1, secrets=0x1e9f860, error=0x0, user_data=0x1ea6300) at settings/nm-agent-manager.c:856
#9 0x00000000004de9d0 in get_callback (proxy=0x1e47530, call=0x1, user_data=0x1ea10f0) at settings/nm-secret-agent.c:267
#10 0x000000337380cad2 in complete_pending_call_and_unlock () from /lib64/libdbus-1.so.3
#11 0x000000337380fdc1 in dbus_connection_dispatch () from /lib64/libdbus-1.so.3
#12 0x000000342800ad65 in message_queue_dispatch () from /lib64/libdbus-glib-1.so.2
#13 0x0000003370c492a6 in g_main_context_dispatch () from /lib64/libglib-2.0.so.0
#14 0x0000003370c49628 in g_main_context_iterate.isra.24 () from /lib64/libglib-2.0.so.0
#15 0x0000003370c49a3a in g_main_loop_run () from /lib64/libglib-2.0.so.0
#16 0x000000000042e5c6 in main (argc=1, argv=0x7fff75078e88) at main.c:644
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-02-23 17:03:01 +01:00
|
|
|
if ( NM_IS_SETTING_VPN (setting)
|
|
|
|
|
&& g_strcmp0 (prop_name, NM_SETTING_VPN_SECRETS) == 0) {
|
|
|
|
|
/* FIXME: NMSettingVPN:NM_SETTING_VPN_SECRETS has NM_SETTING_PARAM_SECRET.
|
|
|
|
|
* nm_setting_get_secret_flags() quite possibly fails, but it might succeed if the
|
|
|
|
|
* setting accidently uses a key "secrets". */
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!nm_setting_get_secret_flags (setting, prop_name, &secret_flags, NULL))
|
|
|
|
|
g_return_val_if_reached (FALSE);
|
2014-07-24 08:53:33 -04:00
|
|
|
|
|
|
|
|
if ( (comp_flags & NM_SETTING_COMPARE_FLAG_IGNORE_AGENT_OWNED_SECRETS)
|
|
|
|
|
&& (secret_flags & NM_SETTING_SECRET_FLAG_AGENT_OWNED))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
if ( (comp_flags & NM_SETTING_COMPARE_FLAG_IGNORE_NOT_SAVED_SECRETS)
|
|
|
|
|
&& (secret_flags & NM_SETTING_SECRET_FLAG_NOT_SAVED))
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( (comp_flags & NM_SETTING_COMPARE_FLAG_IGNORE_ID)
|
|
|
|
|
&& NM_IS_SETTING_CONNECTION (setting)
|
|
|
|
|
&& !strcmp (prop_name, NM_SETTING_CONNECTION_ID))
|
|
|
|
|
return FALSE;
|
2014-11-18 14:20:12 +01:00
|
|
|
|
|
|
|
|
if ( (comp_flags & NM_SETTING_COMPARE_FLAG_IGNORE_TIMESTAMP)
|
|
|
|
|
&& NM_IS_SETTING_CONNECTION (setting)
|
|
|
|
|
&& !strcmp (prop_name, NM_SETTING_CONNECTION_TIMESTAMP))
|
|
|
|
|
return FALSE;
|
2014-07-24 08:53:33 -04:00
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_diff:
|
|
|
|
|
* @a: a #NMSetting
|
|
|
|
|
* @b: a second #NMSetting to compare with the first
|
|
|
|
|
* @flags: compare flags, e.g. %NM_SETTING_COMPARE_FLAG_EXACT
|
2014-07-04 13:26:57 -04:00
|
|
|
* @invert_results: this parameter is used internally by libnm and should
|
2014-07-24 08:53:33 -04:00
|
|
|
* be set to %FALSE. If %TRUE inverts the meaning of the #NMSettingDiffResult.
|
|
|
|
|
* @results: (inout) (transfer full) (element-type utf8 guint32): if the
|
|
|
|
|
* settings differ, on return a hash table mapping the differing keys to one or
|
|
|
|
|
* more %NMSettingDiffResult values OR-ed together. If the settings do not
|
|
|
|
|
* differ, any hash table passed in is unmodified. If no hash table is passed
|
|
|
|
|
* in and the settings differ, a new one is created and returned.
|
|
|
|
|
*
|
|
|
|
|
* Compares two #NMSetting objects for similarity, with comparison behavior
|
|
|
|
|
* modified by a set of flags. See the documentation for #NMSettingCompareFlags
|
|
|
|
|
* for a description of each flag's behavior. If the settings differ, the keys
|
|
|
|
|
* of each setting that differ from the other are added to @results, mapped to
|
|
|
|
|
* one or more #NMSettingDiffResult values.
|
|
|
|
|
*
|
|
|
|
|
* Returns: %TRUE if the settings contain the same values, %FALSE if they do not
|
|
|
|
|
**/
|
|
|
|
|
gboolean
|
|
|
|
|
nm_setting_diff (NMSetting *a,
|
|
|
|
|
NMSetting *b,
|
|
|
|
|
NMSettingCompareFlags flags,
|
|
|
|
|
gboolean invert_results,
|
|
|
|
|
GHashTable **results)
|
|
|
|
|
{
|
|
|
|
|
GParamSpec **property_specs;
|
|
|
|
|
guint n_property_specs;
|
|
|
|
|
guint i;
|
|
|
|
|
NMSettingDiffResult a_result = NM_SETTING_DIFF_RESULT_IN_A;
|
|
|
|
|
NMSettingDiffResult b_result = NM_SETTING_DIFF_RESULT_IN_B;
|
2014-02-26 11:26:25 +01:00
|
|
|
NMSettingDiffResult a_result_default = NM_SETTING_DIFF_RESULT_IN_A_DEFAULT;
|
|
|
|
|
NMSettingDiffResult b_result_default = NM_SETTING_DIFF_RESULT_IN_B_DEFAULT;
|
2014-07-24 08:53:33 -04:00
|
|
|
gboolean results_created = FALSE;
|
2017-10-26 13:25:54 +02:00
|
|
|
gboolean compared_any = FALSE;
|
libnm: fix the return value of nm_setting_diff() if a results hash was given
Previously, nm_setting_diff() would return !(*results), that means,
if the caller passed in a hash table (empty or not), the return value
would always be FALSE, indicating a difference.
That is not documented, and makes no sense.
The return value, should solely indicate whether some difference was
found. The only convenience is, if nm_setting_diff() created a hash
table internally and no difference was found, it would destroy
it again, without returning it to the caller.
2017-10-26 13:49:03 +02:00
|
|
|
gboolean diff_found = FALSE;
|
2014-07-24 08:53:33 -04:00
|
|
|
|
|
|
|
|
g_return_val_if_fail (results != NULL, FALSE);
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING (a), FALSE);
|
|
|
|
|
if (b) {
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING (b), FALSE);
|
|
|
|
|
g_return_val_if_fail (G_OBJECT_TYPE (a) == G_OBJECT_TYPE (b), FALSE);
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-26 11:26:25 +01:00
|
|
|
if ((flags & (NM_SETTING_COMPARE_FLAG_DIFF_RESULT_WITH_DEFAULT | NM_SETTING_COMPARE_FLAG_DIFF_RESULT_NO_DEFAULT)) ==
|
|
|
|
|
(NM_SETTING_COMPARE_FLAG_DIFF_RESULT_WITH_DEFAULT | NM_SETTING_COMPARE_FLAG_DIFF_RESULT_NO_DEFAULT)) {
|
|
|
|
|
/* conflicting flags: default to WITH_DEFAULT (clearing NO_DEFAULT). */
|
|
|
|
|
flags &= ~NM_SETTING_COMPARE_FLAG_DIFF_RESULT_NO_DEFAULT;
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-24 08:53:33 -04:00
|
|
|
/* If the caller is calling this function in a pattern like this to get
|
|
|
|
|
* complete diffs:
|
|
|
|
|
*
|
|
|
|
|
* nm_setting_diff (A, B, FALSE, &results);
|
|
|
|
|
* nm_setting_diff (B, A, TRUE, &results);
|
|
|
|
|
*
|
|
|
|
|
* and wants us to invert the results so that the second invocation comes
|
|
|
|
|
* out correctly, do that here.
|
|
|
|
|
*/
|
|
|
|
|
if (invert_results) {
|
|
|
|
|
a_result = NM_SETTING_DIFF_RESULT_IN_B;
|
|
|
|
|
b_result = NM_SETTING_DIFF_RESULT_IN_A;
|
2014-02-26 11:26:25 +01:00
|
|
|
a_result_default = NM_SETTING_DIFF_RESULT_IN_B_DEFAULT;
|
|
|
|
|
b_result_default = NM_SETTING_DIFF_RESULT_IN_A_DEFAULT;
|
2014-07-24 08:53:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (*results == NULL) {
|
2017-11-15 16:06:43 +01:00
|
|
|
*results = g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, NULL);
|
2014-07-24 08:53:33 -04:00
|
|
|
results_created = TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* And now all properties */
|
|
|
|
|
property_specs = g_object_class_list_properties (G_OBJECT_GET_CLASS (a), &n_property_specs);
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < n_property_specs; i++) {
|
|
|
|
|
GParamSpec *prop_spec = property_specs[i];
|
2014-02-26 11:26:25 +01:00
|
|
|
NMSettingDiffResult r = NM_SETTING_DIFF_RESULT_UNKNOWN;
|
2014-07-24 08:53:33 -04:00
|
|
|
|
|
|
|
|
/* Handle compare flags */
|
|
|
|
|
if (!should_compare_prop (a, prop_spec->name, flags, prop_spec->flags))
|
|
|
|
|
continue;
|
|
|
|
|
if (strcmp (prop_spec->name, NM_SETTING_NAME) == 0)
|
|
|
|
|
continue;
|
|
|
|
|
|
2017-10-26 13:25:54 +02:00
|
|
|
compared_any = TRUE;
|
|
|
|
|
|
2014-07-24 08:53:33 -04:00
|
|
|
if (b) {
|
2014-02-26 11:26:25 +01:00
|
|
|
gboolean different;
|
|
|
|
|
|
2014-07-24 08:53:33 -04:00
|
|
|
different = !NM_SETTING_GET_CLASS (a)->compare_property (a, b, prop_spec, flags);
|
|
|
|
|
if (different) {
|
2014-02-26 11:26:25 +01:00
|
|
|
gboolean a_is_default, b_is_default;
|
2014-07-24 08:53:33 -04:00
|
|
|
GValue value = G_VALUE_INIT;
|
|
|
|
|
|
|
|
|
|
g_value_init (&value, prop_spec->value_type);
|
|
|
|
|
g_object_get_property (G_OBJECT (a), prop_spec->name, &value);
|
2014-02-26 11:26:25 +01:00
|
|
|
a_is_default = g_param_value_defaults (prop_spec, &value);
|
2014-07-24 08:53:33 -04:00
|
|
|
|
|
|
|
|
g_value_reset (&value);
|
|
|
|
|
g_object_get_property (G_OBJECT (b), prop_spec->name, &value);
|
2014-02-26 11:26:25 +01:00
|
|
|
b_is_default = g_param_value_defaults (prop_spec, &value);
|
2014-07-24 08:53:33 -04:00
|
|
|
|
|
|
|
|
g_value_unset (&value);
|
2014-02-26 11:26:25 +01:00
|
|
|
if ((flags & NM_SETTING_COMPARE_FLAG_DIFF_RESULT_WITH_DEFAULT) == 0) {
|
|
|
|
|
if (!a_is_default)
|
|
|
|
|
r |= a_result;
|
|
|
|
|
if (!b_is_default)
|
|
|
|
|
r |= b_result;
|
|
|
|
|
} else {
|
|
|
|
|
r |= a_result | b_result;
|
|
|
|
|
if (a_is_default)
|
|
|
|
|
r |= a_result_default;
|
|
|
|
|
if (b_is_default)
|
|
|
|
|
r |= b_result_default;
|
|
|
|
|
}
|
2014-07-24 08:53:33 -04:00
|
|
|
}
|
2014-02-26 11:26:25 +01:00
|
|
|
} else if ((flags & (NM_SETTING_COMPARE_FLAG_DIFF_RESULT_WITH_DEFAULT | NM_SETTING_COMPARE_FLAG_DIFF_RESULT_NO_DEFAULT)) == 0)
|
2014-07-24 08:53:33 -04:00
|
|
|
r = a_result; /* only in A */
|
2014-02-26 11:26:25 +01:00
|
|
|
else {
|
|
|
|
|
GValue value = G_VALUE_INIT;
|
|
|
|
|
|
|
|
|
|
g_value_init (&value, prop_spec->value_type);
|
|
|
|
|
g_object_get_property (G_OBJECT (a), prop_spec->name, &value);
|
|
|
|
|
if (!g_param_value_defaults (prop_spec, &value))
|
|
|
|
|
r |= a_result;
|
|
|
|
|
else if (flags & NM_SETTING_COMPARE_FLAG_DIFF_RESULT_WITH_DEFAULT)
|
|
|
|
|
r |= a_result | a_result_default;
|
|
|
|
|
|
|
|
|
|
g_value_unset (&value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (r != NM_SETTING_DIFF_RESULT_UNKNOWN) {
|
|
|
|
|
void *p;
|
2014-07-24 08:53:33 -04:00
|
|
|
|
libnm: fix the return value of nm_setting_diff() if a results hash was given
Previously, nm_setting_diff() would return !(*results), that means,
if the caller passed in a hash table (empty or not), the return value
would always be FALSE, indicating a difference.
That is not documented, and makes no sense.
The return value, should solely indicate whether some difference was
found. The only convenience is, if nm_setting_diff() created a hash
table internally and no difference was found, it would destroy
it again, without returning it to the caller.
2017-10-26 13:49:03 +02:00
|
|
|
diff_found = TRUE;
|
2014-02-26 11:26:25 +01:00
|
|
|
if (g_hash_table_lookup_extended (*results, prop_spec->name, NULL, &p)) {
|
|
|
|
|
if ((r & GPOINTER_TO_UINT (p)) != r)
|
|
|
|
|
g_hash_table_insert (*results, g_strdup (prop_spec->name), GUINT_TO_POINTER (r | GPOINTER_TO_UINT (p)));
|
|
|
|
|
} else
|
|
|
|
|
g_hash_table_insert (*results, g_strdup (prop_spec->name), GUINT_TO_POINTER (r));
|
2014-07-24 08:53:33 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
g_free (property_specs);
|
|
|
|
|
|
2017-10-26 13:25:54 +02:00
|
|
|
if (!compared_any && !b) {
|
|
|
|
|
/* special case: the setting has no properties, and the opposite
|
|
|
|
|
* setting @b is not given. The settings differ, and we signal that
|
|
|
|
|
* by returning an empty results hash. */
|
libnm: fix the return value of nm_setting_diff() if a results hash was given
Previously, nm_setting_diff() would return !(*results), that means,
if the caller passed in a hash table (empty or not), the return value
would always be FALSE, indicating a difference.
That is not documented, and makes no sense.
The return value, should solely indicate whether some difference was
found. The only convenience is, if nm_setting_diff() created a hash
table internally and no difference was found, it would destroy
it again, without returning it to the caller.
2017-10-26 13:49:03 +02:00
|
|
|
diff_found = TRUE;
|
2017-10-26 13:25:54 +02:00
|
|
|
}
|
|
|
|
|
|
libnm: fix the return value of nm_setting_diff() if a results hash was given
Previously, nm_setting_diff() would return !(*results), that means,
if the caller passed in a hash table (empty or not), the return value
would always be FALSE, indicating a difference.
That is not documented, and makes no sense.
The return value, should solely indicate whether some difference was
found. The only convenience is, if nm_setting_diff() created a hash
table internally and no difference was found, it would destroy
it again, without returning it to the caller.
2017-10-26 13:49:03 +02:00
|
|
|
if (diff_found) {
|
|
|
|
|
/* if there is a difference, we always return FALSE. It also means, we might
|
|
|
|
|
* have allocated a new @results hash, and return if to the caller. */
|
|
|
|
|
return FALSE;
|
|
|
|
|
} else {
|
|
|
|
|
if (results_created) {
|
|
|
|
|
/* the allocated hash is unused. Clear it again. */
|
|
|
|
|
g_hash_table_destroy (*results);
|
|
|
|
|
*results = NULL;
|
|
|
|
|
} else {
|
|
|
|
|
/* we found no diff, and return false. However, the input
|
|
|
|
|
* @result is returned unmodified. */
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
2014-07-24 08:53:33 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-13 16:35:23 +01:00
|
|
|
#define CMP_AND_RETURN(n_a, n_b, name) \
|
|
|
|
|
G_STMT_START { \
|
|
|
|
|
gboolean _is = (strcmp (n_a, ""name) == 0); \
|
|
|
|
|
\
|
|
|
|
|
if (_is || (strcmp (n_b, ""name) == 0)) \
|
|
|
|
|
return _is ? -1 : 1; \
|
2015-03-20 13:38:28 +01:00
|
|
|
} G_STMT_END
|
2015-03-13 16:35:23 +01:00
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
_enumerate_values_sort (GParamSpec **p_a, GParamSpec **p_b, GType *p_type)
|
|
|
|
|
{
|
|
|
|
|
const char *n_a = (*p_a)->name;
|
|
|
|
|
const char *n_b = (*p_b)->name;
|
|
|
|
|
int c = strcmp (n_a, n_b);
|
|
|
|
|
|
|
|
|
|
if (c) {
|
|
|
|
|
if (*p_type == NM_TYPE_SETTING_CONNECTION) {
|
|
|
|
|
/* for [connection], report first id, uuid, type in that order. */
|
|
|
|
|
CMP_AND_RETURN (n_a, n_b, NM_SETTING_CONNECTION_ID);
|
|
|
|
|
CMP_AND_RETURN (n_a, n_b, NM_SETTING_CONNECTION_UUID);
|
|
|
|
|
CMP_AND_RETURN (n_a, n_b, NM_SETTING_CONNECTION_TYPE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return c;
|
|
|
|
|
}
|
|
|
|
|
#undef CMP_AND_RETURN
|
|
|
|
|
|
2014-07-24 08:53:33 -04:00
|
|
|
/**
|
|
|
|
|
* nm_setting_enumerate_values:
|
|
|
|
|
* @setting: the #NMSetting
|
|
|
|
|
* @func: (scope call): user-supplied function called for each property of the setting
|
|
|
|
|
* @user_data: user data passed to @func at each invocation
|
|
|
|
|
*
|
|
|
|
|
* Iterates over each property of the #NMSetting object, calling the supplied
|
|
|
|
|
* user function for each property.
|
|
|
|
|
**/
|
|
|
|
|
void
|
|
|
|
|
nm_setting_enumerate_values (NMSetting *setting,
|
|
|
|
|
NMSettingValueIterFn func,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
GParamSpec **property_specs;
|
|
|
|
|
guint n_property_specs;
|
|
|
|
|
int i;
|
2015-03-13 16:35:23 +01:00
|
|
|
GType type;
|
2014-07-24 08:53:33 -04:00
|
|
|
|
|
|
|
|
g_return_if_fail (NM_IS_SETTING (setting));
|
|
|
|
|
g_return_if_fail (func != NULL);
|
|
|
|
|
|
|
|
|
|
property_specs = g_object_class_list_properties (G_OBJECT_GET_CLASS (setting), &n_property_specs);
|
2015-03-13 16:35:23 +01:00
|
|
|
|
|
|
|
|
/* sort the properties. This has an effect on the order in which keyfile
|
|
|
|
|
* prints them. */
|
|
|
|
|
type = G_OBJECT_TYPE (setting);
|
|
|
|
|
g_qsort_with_data (property_specs, n_property_specs, sizeof (gpointer),
|
|
|
|
|
(GCompareDataFunc) _enumerate_values_sort, &type);
|
|
|
|
|
|
2014-07-24 08:53:33 -04:00
|
|
|
for (i = 0; i < n_property_specs; i++) {
|
|
|
|
|
GParamSpec *prop_spec = property_specs[i];
|
|
|
|
|
GValue value = G_VALUE_INIT;
|
|
|
|
|
|
|
|
|
|
g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (prop_spec));
|
|
|
|
|
g_object_get_property (G_OBJECT (setting), prop_spec->name, &value);
|
|
|
|
|
func (setting, prop_spec->name, &value, prop_spec->flags, user_data);
|
|
|
|
|
g_value_unset (&value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_free (property_specs);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2014-10-07 08:46:36 +02:00
|
|
|
* _nm_setting_clear_secrets:
|
2014-07-24 08:53:33 -04:00
|
|
|
* @setting: the #NMSetting
|
|
|
|
|
*
|
|
|
|
|
* Resets and clears any secrets in the setting. Secrets should be added to the
|
|
|
|
|
* setting only when needed, and cleared immediately after use to prevent
|
|
|
|
|
* leakage of information.
|
2014-10-07 08:46:36 +02:00
|
|
|
*
|
|
|
|
|
* Returns: %TRUE if the setting changed at all
|
2014-07-24 08:53:33 -04:00
|
|
|
**/
|
|
|
|
|
gboolean
|
|
|
|
|
_nm_setting_clear_secrets (NMSetting *setting)
|
|
|
|
|
{
|
|
|
|
|
GParamSpec **property_specs;
|
|
|
|
|
guint n_property_specs;
|
|
|
|
|
guint i;
|
|
|
|
|
gboolean changed = FALSE;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING (setting), FALSE);
|
|
|
|
|
|
|
|
|
|
property_specs = g_object_class_list_properties (G_OBJECT_GET_CLASS (setting), &n_property_specs);
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < n_property_specs; i++) {
|
|
|
|
|
GParamSpec *prop_spec = property_specs[i];
|
|
|
|
|
|
|
|
|
|
if (prop_spec->flags & NM_SETTING_PARAM_SECRET) {
|
|
|
|
|
GValue value = G_VALUE_INIT;
|
|
|
|
|
|
|
|
|
|
g_value_init (&value, prop_spec->value_type);
|
|
|
|
|
g_object_get_property (G_OBJECT (setting), prop_spec->name, &value);
|
|
|
|
|
if (!g_param_value_defaults (prop_spec, &value)) {
|
|
|
|
|
g_param_value_set_default (prop_spec, &value);
|
|
|
|
|
g_object_set_property (G_OBJECT (setting), prop_spec->name, &value);
|
|
|
|
|
changed = TRUE;
|
|
|
|
|
}
|
|
|
|
|
g_value_unset (&value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_free (property_specs);
|
|
|
|
|
|
|
|
|
|
return changed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
clear_secrets_with_flags (NMSetting *setting,
|
|
|
|
|
GParamSpec *pspec,
|
|
|
|
|
NMSettingClearSecretsWithFlagsFn func,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMSettingSecretFlags flags = NM_SETTING_SECRET_FLAG_NONE;
|
|
|
|
|
gboolean changed = FALSE;
|
|
|
|
|
|
libnm-util: don't assert in nm_setting_get_secret_flags() and avoid assertion in agent_secrets_done_cb()
When secret providers return the connection hash in GetSecrets(),
this hash should only contain secrets. However, some providers also
return non-secret properties.
for_each_secret() iterated over all entries of the @secrets hash
and triggered the assertion in nm_setting_get_secret_flags() (see
below).
NM should not assert against user provided input. Change
nm_setting_get_secret_flags() to silently return FALSE, if the property
is not a secret.
Indeed, handling of secrets is very different for NMSettingVpn and
others. Hence nm_setting_get_secret_flags() has only an inconsistent
behavior and we have to fix all call sites to do the right thing
(depending on whether we have a VPN setting or not).
Now for_each_secret() checks whether the property is a secret
without hitting the assertion. Adjust all other calls of
nm_setting_get_secret_flags(), to anticipate non-secret flags and
assert/warn where appropriate.
Also, agent_secrets_done_cb() clears now all non-secrets properties
from the hash, using the new argument @remove_non_secrets when calling
for_each_secret().
#0 0x0000003370c504e9 in g_logv () from /lib64/libglib-2.0.so.0
#1 0x0000003370c5063f in g_log () from /lib64/libglib-2.0.so.0
#2 0x00007fa4b0c1c156 in get_secret_flags (setting=0x1e3ac60, secret_name=0x1ea9180 "security", verify_secret=1, out_flags=0x7fff7507857c, error=0x0) at nm-setting.c:1091
#3 0x00007fa4b0c1c2b2 in nm_setting_get_secret_flags (setting=0x1e3ac60, secret_name=0x1ea9180 "security", out_flags=0x7fff7507857c, error=0x0) at nm-setting.c:1124
#4 0x0000000000463d03 in for_each_secret (connection=0x1deb2f0, secrets=0x1e9f860, callback=0x464f1b <has_system_owned_secrets>, callback_data=0x7fff7507865c) at settings/nm-settings-connection.c:203
#5 0x000000000046525f in agent_secrets_done_cb (manager=0x1dddf50, call_id=1, agent_dbus_owner=0x1ddb9e0 ":1.39", agent_username=0x1e51710 "thom", agent_has_modify=1, setting_name=0x1e91f90 "802-11-wireless-security",
flags=NM_SETTINGS_GET_SECRETS_FLAG_ALLOW_INTERACTION, secrets=0x1e9f860, error=0x0, user_data=0x1deb2f0, other_data2=0x477d61 <get_secrets_cb>, other_data3=0x1ea92a0) at settings/nm-settings-connection.c:757
#6 0x00000000004dc4fd in get_complete_cb (parent=0x1ea6300, secrets=0x1e9f860, agent_dbus_owner=0x1ddb9e0 ":1.39", agent_username=0x1e51710 "thom", error=0x0, user_data=0x1dddf50) at settings/nm-agent-manager.c:1139
#7 0x00000000004dab54 in req_complete_success (req=0x1ea6300, secrets=0x1e9f860, agent_dbus_owner=0x1ddb9e0 ":1.39", agent_uname=0x1e51710 "thom") at settings/nm-agent-manager.c:502
#8 0x00000000004db86e in get_done_cb (agent=0x1e89530, call_id=0x1, secrets=0x1e9f860, error=0x0, user_data=0x1ea6300) at settings/nm-agent-manager.c:856
#9 0x00000000004de9d0 in get_callback (proxy=0x1e47530, call=0x1, user_data=0x1ea10f0) at settings/nm-secret-agent.c:267
#10 0x000000337380cad2 in complete_pending_call_and_unlock () from /lib64/libdbus-1.so.3
#11 0x000000337380fdc1 in dbus_connection_dispatch () from /lib64/libdbus-1.so.3
#12 0x000000342800ad65 in message_queue_dispatch () from /lib64/libdbus-glib-1.so.2
#13 0x0000003370c492a6 in g_main_context_dispatch () from /lib64/libglib-2.0.so.0
#14 0x0000003370c49628 in g_main_context_iterate.isra.24 () from /lib64/libglib-2.0.so.0
#15 0x0000003370c49a3a in g_main_loop_run () from /lib64/libglib-2.0.so.0
#16 0x000000000042e5c6 in main (argc=1, argv=0x7fff75078e88) at main.c:644
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-02-23 17:03:01 +01:00
|
|
|
g_return_val_if_fail (!NM_IS_SETTING_VPN (setting), FALSE);
|
|
|
|
|
|
2014-07-24 08:53:33 -04:00
|
|
|
/* Clear the secret if the user function says to do so */
|
libnm-util: don't assert in nm_setting_get_secret_flags() and avoid assertion in agent_secrets_done_cb()
When secret providers return the connection hash in GetSecrets(),
this hash should only contain secrets. However, some providers also
return non-secret properties.
for_each_secret() iterated over all entries of the @secrets hash
and triggered the assertion in nm_setting_get_secret_flags() (see
below).
NM should not assert against user provided input. Change
nm_setting_get_secret_flags() to silently return FALSE, if the property
is not a secret.
Indeed, handling of secrets is very different for NMSettingVpn and
others. Hence nm_setting_get_secret_flags() has only an inconsistent
behavior and we have to fix all call sites to do the right thing
(depending on whether we have a VPN setting or not).
Now for_each_secret() checks whether the property is a secret
without hitting the assertion. Adjust all other calls of
nm_setting_get_secret_flags(), to anticipate non-secret flags and
assert/warn where appropriate.
Also, agent_secrets_done_cb() clears now all non-secrets properties
from the hash, using the new argument @remove_non_secrets when calling
for_each_secret().
#0 0x0000003370c504e9 in g_logv () from /lib64/libglib-2.0.so.0
#1 0x0000003370c5063f in g_log () from /lib64/libglib-2.0.so.0
#2 0x00007fa4b0c1c156 in get_secret_flags (setting=0x1e3ac60, secret_name=0x1ea9180 "security", verify_secret=1, out_flags=0x7fff7507857c, error=0x0) at nm-setting.c:1091
#3 0x00007fa4b0c1c2b2 in nm_setting_get_secret_flags (setting=0x1e3ac60, secret_name=0x1ea9180 "security", out_flags=0x7fff7507857c, error=0x0) at nm-setting.c:1124
#4 0x0000000000463d03 in for_each_secret (connection=0x1deb2f0, secrets=0x1e9f860, callback=0x464f1b <has_system_owned_secrets>, callback_data=0x7fff7507865c) at settings/nm-settings-connection.c:203
#5 0x000000000046525f in agent_secrets_done_cb (manager=0x1dddf50, call_id=1, agent_dbus_owner=0x1ddb9e0 ":1.39", agent_username=0x1e51710 "thom", agent_has_modify=1, setting_name=0x1e91f90 "802-11-wireless-security",
flags=NM_SETTINGS_GET_SECRETS_FLAG_ALLOW_INTERACTION, secrets=0x1e9f860, error=0x0, user_data=0x1deb2f0, other_data2=0x477d61 <get_secrets_cb>, other_data3=0x1ea92a0) at settings/nm-settings-connection.c:757
#6 0x00000000004dc4fd in get_complete_cb (parent=0x1ea6300, secrets=0x1e9f860, agent_dbus_owner=0x1ddb9e0 ":1.39", agent_username=0x1e51710 "thom", error=0x0, user_data=0x1dddf50) at settings/nm-agent-manager.c:1139
#7 0x00000000004dab54 in req_complete_success (req=0x1ea6300, secrets=0x1e9f860, agent_dbus_owner=0x1ddb9e0 ":1.39", agent_uname=0x1e51710 "thom") at settings/nm-agent-manager.c:502
#8 0x00000000004db86e in get_done_cb (agent=0x1e89530, call_id=0x1, secrets=0x1e9f860, error=0x0, user_data=0x1ea6300) at settings/nm-agent-manager.c:856
#9 0x00000000004de9d0 in get_callback (proxy=0x1e47530, call=0x1, user_data=0x1ea10f0) at settings/nm-secret-agent.c:267
#10 0x000000337380cad2 in complete_pending_call_and_unlock () from /lib64/libdbus-1.so.3
#11 0x000000337380fdc1 in dbus_connection_dispatch () from /lib64/libdbus-1.so.3
#12 0x000000342800ad65 in message_queue_dispatch () from /lib64/libdbus-glib-1.so.2
#13 0x0000003370c492a6 in g_main_context_dispatch () from /lib64/libglib-2.0.so.0
#14 0x0000003370c49628 in g_main_context_iterate.isra.24 () from /lib64/libglib-2.0.so.0
#15 0x0000003370c49a3a in g_main_loop_run () from /lib64/libglib-2.0.so.0
#16 0x000000000042e5c6 in main (argc=1, argv=0x7fff75078e88) at main.c:644
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-02-23 17:03:01 +01:00
|
|
|
if (!nm_setting_get_secret_flags (setting, pspec->name, &flags, NULL))
|
|
|
|
|
g_return_val_if_reached (FALSE);
|
|
|
|
|
|
2014-07-24 08:53:33 -04:00
|
|
|
if (func (setting, pspec->name, flags, user_data) == TRUE) {
|
|
|
|
|
GValue value = G_VALUE_INIT;
|
|
|
|
|
|
|
|
|
|
g_value_init (&value, pspec->value_type);
|
|
|
|
|
g_object_get_property (G_OBJECT (setting), pspec->name, &value);
|
|
|
|
|
if (!g_param_value_defaults (pspec, &value)) {
|
|
|
|
|
g_param_value_set_default (pspec, &value);
|
|
|
|
|
g_object_set_property (G_OBJECT (setting), pspec->name, &value);
|
|
|
|
|
changed = TRUE;
|
|
|
|
|
}
|
|
|
|
|
g_value_unset (&value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return changed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2014-10-07 08:46:36 +02:00
|
|
|
* _nm_setting_clear_secrets_with_flags:
|
2014-07-24 08:53:33 -04:00
|
|
|
* @setting: the #NMSetting
|
|
|
|
|
* @func: (scope call): function to be called to determine whether a
|
|
|
|
|
* specific secret should be cleared or not
|
|
|
|
|
* @user_data: caller-supplied data passed to @func
|
|
|
|
|
*
|
|
|
|
|
* Clears and frees secrets determined by @func.
|
2014-10-07 08:46:36 +02:00
|
|
|
*
|
|
|
|
|
* Returns: %TRUE if the setting changed at all
|
2014-07-24 08:53:33 -04:00
|
|
|
**/
|
|
|
|
|
gboolean
|
|
|
|
|
_nm_setting_clear_secrets_with_flags (NMSetting *setting,
|
|
|
|
|
NMSettingClearSecretsWithFlagsFn func,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
GParamSpec **property_specs;
|
|
|
|
|
guint n_property_specs;
|
|
|
|
|
guint i;
|
|
|
|
|
gboolean changed = FALSE;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (setting, FALSE);
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING (setting), FALSE);
|
|
|
|
|
g_return_val_if_fail (func != NULL, FALSE);
|
|
|
|
|
|
|
|
|
|
property_specs = g_object_class_list_properties (G_OBJECT_GET_CLASS (setting), &n_property_specs);
|
|
|
|
|
for (i = 0; i < n_property_specs; i++) {
|
|
|
|
|
if (property_specs[i]->flags & NM_SETTING_PARAM_SECRET) {
|
|
|
|
|
changed |= NM_SETTING_GET_CLASS (setting)->clear_secrets_with_flags (setting,
|
|
|
|
|
property_specs[i],
|
|
|
|
|
func,
|
|
|
|
|
user_data);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_free (property_specs);
|
|
|
|
|
return changed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2014-10-07 08:46:36 +02:00
|
|
|
* _nm_setting_need_secrets:
|
2014-07-24 08:53:33 -04:00
|
|
|
* @setting: the #NMSetting
|
|
|
|
|
*
|
|
|
|
|
* Returns an array of property names for each secret which may be required
|
|
|
|
|
* to make a successful connection. The returned hints are only intended as a
|
|
|
|
|
* guide to what secrets may be required, because in some circumstances, there
|
|
|
|
|
* is no way to conclusively determine exactly which secrets are needed.
|
|
|
|
|
*
|
|
|
|
|
* Returns: (transfer container) (element-type utf8): a #GPtrArray containing
|
|
|
|
|
* the property names of secrets of the #NMSetting which may be required; the
|
|
|
|
|
* caller owns the array and must free it with g_ptr_array_free(), but must not
|
|
|
|
|
* free the elements.
|
|
|
|
|
**/
|
|
|
|
|
GPtrArray *
|
2014-10-07 08:46:36 +02:00
|
|
|
_nm_setting_need_secrets (NMSetting *setting)
|
2014-07-24 08:53:33 -04:00
|
|
|
{
|
|
|
|
|
GPtrArray *secrets = NULL;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING (setting), NULL);
|
|
|
|
|
|
|
|
|
|
if (NM_SETTING_GET_CLASS (setting)->need_secrets)
|
|
|
|
|
secrets = NM_SETTING_GET_CLASS (setting)->need_secrets (setting);
|
|
|
|
|
|
|
|
|
|
return secrets;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
2014-08-16 10:09:48 -04:00
|
|
|
update_one_secret (NMSetting *setting, const char *key, GVariant *value, GError **error)
|
2014-07-24 08:53:33 -04:00
|
|
|
{
|
libnm-core: add dbus-only properties to NMSettingClass
Add _nm_setting_class_add_dbus_only_property(), for declaring
properties that appear in the D-Bus serialization, but which don't
correspond to GObject properties.
Since some property overrides will require examining settings other
than the setting that they are on (eg, the value of
802-11-wireless.security depends on whether an
NMSettingWirelessSecurity setting is present, and
NMSettingConnection:interface-name might sometimes be set from, eg,
bond.interface-name), we also update _nm_setting_to_dbus() to take the
full NMConnection as an argument, and _nm_setting_new_from_dbus() to
take the full connection hash.
Additionally, with some deprecated properties, we'll want to validate
them on construction, but we don't need to keep the value around after
that. So allow _nm_setting_new_from_dbus() to return a verification
error directly, so we don't need to store the value until the verify()
call.
2014-07-29 18:25:10 -04:00
|
|
|
const NMSettingProperty *property;
|
2014-07-24 08:53:33 -04:00
|
|
|
GParamSpec *prop_spec;
|
2014-08-16 10:09:48 -04:00
|
|
|
GValue prop_value = { 0, };
|
2014-07-24 08:53:33 -04:00
|
|
|
|
libnm-core: add dbus-only properties to NMSettingClass
Add _nm_setting_class_add_dbus_only_property(), for declaring
properties that appear in the D-Bus serialization, but which don't
correspond to GObject properties.
Since some property overrides will require examining settings other
than the setting that they are on (eg, the value of
802-11-wireless.security depends on whether an
NMSettingWirelessSecurity setting is present, and
NMSettingConnection:interface-name might sometimes be set from, eg,
bond.interface-name), we also update _nm_setting_to_dbus() to take the
full NMConnection as an argument, and _nm_setting_new_from_dbus() to
take the full connection hash.
Additionally, with some deprecated properties, we'll want to validate
them on construction, but we don't need to keep the value around after
that. So allow _nm_setting_new_from_dbus() to return a verification
error directly, so we don't need to store the value until the verify()
call.
2014-07-29 18:25:10 -04:00
|
|
|
property = nm_setting_class_find_property (NM_SETTING_GET_CLASS (setting), key);
|
|
|
|
|
if (!property) {
|
libnm-core: merge NMSetting*Error into NMConnectionError
Each setting type was defining its own error type, but most of them
had exactly the same three errors ("unknown", "missing property", and
"invalid property"), and none of the other values was of much use
programmatically anyway.
So, this commit merges NMSettingError, NMSettingAdslError, etc, all
into NMConnectionError. (The reason for merging into NMConnectionError
rather than NMSettingError is that we also already have
"NMSettingsError", for errors related to the settings service, so
"NMConnectionError" is a less-confusable name for settings/connection
errors than "NMSettingError".)
Also, make sure that all of the affected error messages are localized,
and (where appropriate) prefix them with the relevant property name.
Renamed error codes:
NM_SETTING_ERROR_PROPERTY_NOT_FOUND -> NM_CONNECTION_ERROR_PROPERTY_NOT_FOUND
NM_SETTING_ERROR_PROPERTY_NOT_SECRET -> NM_CONNECTION_ERROR_PROPERTY_NOT_SECRET
Remapped error codes:
NM_SETTING_*_ERROR_MISSING_PROPERTY -> NM_CONNECTION_ERROR_MISSING_PROPERTY
NM_SETTING_*_ERROR_INVALID_PROPERTY -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_ERROR_PROPERTY_TYPE_MISMATCH -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_BLUETOOTH_ERROR_TYPE_SETTING_NOT_FOUND -> NM_CONNECTION_ERROR_INVALID_SETTING
NM_SETTING_BOND_ERROR_INVALID_OPTION -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_BOND_ERROR_MISSING_OPTION -> NM_CONNECTION_ERROR_MISSING_PROPERTY
NM_SETTING_CONNECTION_ERROR_TYPE_SETTING_NOT_FOUND -> NM_CONNECTION_ERROR_MISSING_SETTING
NM_SETTING_CONNECTION_ERROR_SLAVE_SETTING_NOT_FOUND -> NM_CONNECTION_ERROR_MISSING_SETTING
NM_SETTING_IP4_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_IP6_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_VLAN_ERROR_INVALID_PARENT -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_WIRELESS_SECURITY_ERROR_MISSING_802_1X_SETTING -> NM_CONNECTION_ERROR_MISSING_SETTING
NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_802_1X -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_USERNAME -> NM_CONNECTION_ERROR_MISSING_PROPERTY
NM_SETTING_WIRELESS_SECURITY_ERROR_SHARED_KEY_REQUIRES_WEP -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_WIRELESS_ERROR_CHANNEL_REQUIRES_BAND -> NM_CONNECTION_ERROR_MISSING_PROPERTY
Dropped error codes (were previously defined but unused):
NM_SETTING_CDMA_ERROR_MISSING_SERIAL_SETTING
NM_SETTING_CONNECTION_ERROR_IP_CONFIG_NOT_ALLOWED
NM_SETTING_GSM_ERROR_MISSING_SERIAL_SETTING
NM_SETTING_PPP_ERROR_REQUIRE_MPPE_NOT_ALLOWED
NM_SETTING_PPPOE_ERROR_MISSING_PPP_SETTING
NM_SETTING_SERIAL_ERROR_MISSING_PPP_SETTING
NM_SETTING_WIRELESS_ERROR_MISSING_SECURITY_SETTING
2014-10-20 13:52:23 -04:00
|
|
|
g_set_error_literal (error,
|
|
|
|
|
NM_CONNECTION_ERROR,
|
|
|
|
|
NM_CONNECTION_ERROR_PROPERTY_NOT_FOUND,
|
|
|
|
|
_("secret not found"));
|
|
|
|
|
g_prefix_error (error, "%s.%s: ", nm_setting_get_name (setting), key);
|
2014-07-24 08:53:33 -04:00
|
|
|
return NM_SETTING_UPDATE_SECRET_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Silently ignore non-secrets */
|
libnm-core: add dbus-only properties to NMSettingClass
Add _nm_setting_class_add_dbus_only_property(), for declaring
properties that appear in the D-Bus serialization, but which don't
correspond to GObject properties.
Since some property overrides will require examining settings other
than the setting that they are on (eg, the value of
802-11-wireless.security depends on whether an
NMSettingWirelessSecurity setting is present, and
NMSettingConnection:interface-name might sometimes be set from, eg,
bond.interface-name), we also update _nm_setting_to_dbus() to take the
full NMConnection as an argument, and _nm_setting_new_from_dbus() to
take the full connection hash.
Additionally, with some deprecated properties, we'll want to validate
them on construction, but we don't need to keep the value around after
that. So allow _nm_setting_new_from_dbus() to return a verification
error directly, so we don't need to store the value until the verify()
call.
2014-07-29 18:25:10 -04:00
|
|
|
prop_spec = property->param_spec;
|
|
|
|
|
if (!prop_spec || !(prop_spec->flags & NM_SETTING_PARAM_SECRET))
|
2014-07-24 08:53:33 -04:00
|
|
|
return NM_SETTING_UPDATE_SECRET_SUCCESS_UNCHANGED;
|
|
|
|
|
|
2014-08-16 10:09:48 -04:00
|
|
|
if ( g_variant_is_of_type (value, G_VARIANT_TYPE_STRING)
|
|
|
|
|
&& G_IS_PARAM_SPEC_STRING (prop_spec)) {
|
|
|
|
|
/* String is expected to be a common case. Handle it specially and check
|
|
|
|
|
* whether the value is already set. Otherwise, we just reset the
|
|
|
|
|
* property and assume the value got modified.
|
|
|
|
|
*/
|
|
|
|
|
char *v;
|
|
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (setting), prop_spec->name, &v, NULL);
|
|
|
|
|
if (g_strcmp0 (v, g_variant_get_string (value, NULL)) == 0) {
|
2014-07-24 08:53:33 -04:00
|
|
|
g_free (v);
|
2014-08-16 10:09:48 -04:00
|
|
|
return NM_SETTING_UPDATE_SECRET_SUCCESS_UNCHANGED;
|
2014-07-24 08:53:33 -04:00
|
|
|
}
|
2014-08-16 10:09:48 -04:00
|
|
|
g_free (v);
|
2014-07-24 08:53:33 -04:00
|
|
|
}
|
2014-08-16 10:09:48 -04:00
|
|
|
|
|
|
|
|
g_value_init (&prop_value, prop_spec->value_type);
|
|
|
|
|
set_property_from_dbus (property, value, &prop_value);
|
|
|
|
|
g_object_set_property (G_OBJECT (setting), prop_spec->name, &prop_value);
|
|
|
|
|
g_value_unset (&prop_value);
|
|
|
|
|
|
|
|
|
|
return NM_SETTING_UPDATE_SECRET_SUCCESS_MODIFIED;
|
2014-07-24 08:53:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2014-08-04 11:23:11 -04:00
|
|
|
* _nm_setting_update_secrets:
|
2014-07-24 08:53:33 -04:00
|
|
|
* @setting: the #NMSetting
|
2014-08-16 10:09:48 -04:00
|
|
|
* @secrets: a #GVariant of type #NM_VARIANT_TYPE_SETTING, mapping property
|
|
|
|
|
* names to secrets.
|
2014-07-24 08:53:33 -04:00
|
|
|
* @error: location to store error, or %NULL
|
|
|
|
|
*
|
2014-08-16 10:09:48 -04:00
|
|
|
* Update the setting's secrets, given a dictionary of secrets intended for that
|
2014-07-24 08:53:33 -04:00
|
|
|
* setting (deserialized from D-Bus for example).
|
|
|
|
|
*
|
2014-08-04 11:23:11 -04:00
|
|
|
* Returns: an #NMSettingUpdateSecretResult
|
2014-07-24 08:53:33 -04:00
|
|
|
**/
|
|
|
|
|
NMSettingUpdateSecretResult
|
2014-08-16 10:09:48 -04:00
|
|
|
_nm_setting_update_secrets (NMSetting *setting, GVariant *secrets, GError **error)
|
2014-07-24 08:53:33 -04:00
|
|
|
{
|
2014-08-16 10:09:48 -04:00
|
|
|
GVariantIter iter;
|
|
|
|
|
const char *secret_key;
|
|
|
|
|
GVariant *secret_value;
|
2014-07-24 08:53:33 -04:00
|
|
|
GError *tmp_error = NULL;
|
|
|
|
|
NMSettingUpdateSecretResult result = NM_SETTING_UPDATE_SECRET_SUCCESS_UNCHANGED;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING (setting), NM_SETTING_UPDATE_SECRET_ERROR);
|
2014-08-16 10:09:48 -04:00
|
|
|
g_return_val_if_fail (g_variant_is_of_type (secrets, NM_VARIANT_TYPE_SETTING), NM_SETTING_UPDATE_SECRET_ERROR);
|
2014-07-24 08:53:33 -04:00
|
|
|
if (error)
|
|
|
|
|
g_return_val_if_fail (*error == NULL, NM_SETTING_UPDATE_SECRET_ERROR);
|
|
|
|
|
|
2014-08-16 10:09:48 -04:00
|
|
|
g_variant_iter_init (&iter, secrets);
|
|
|
|
|
while (g_variant_iter_next (&iter, "{&sv}", &secret_key, &secret_value)) {
|
2014-07-24 08:53:33 -04:00
|
|
|
int success;
|
|
|
|
|
|
|
|
|
|
success = NM_SETTING_GET_CLASS (setting)->update_one_secret (setting, secret_key, secret_value, &tmp_error);
|
|
|
|
|
g_assert (!((success == NM_SETTING_UPDATE_SECRET_ERROR) ^ (!!tmp_error)));
|
|
|
|
|
|
2014-08-16 10:09:48 -04:00
|
|
|
g_variant_unref (secret_value);
|
|
|
|
|
|
2014-07-24 08:53:33 -04:00
|
|
|
if (success == NM_SETTING_UPDATE_SECRET_ERROR) {
|
|
|
|
|
g_propagate_error (error, tmp_error);
|
|
|
|
|
return NM_SETTING_UPDATE_SECRET_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (success == NM_SETTING_UPDATE_SECRET_SUCCESS_MODIFIED)
|
|
|
|
|
result = NM_SETTING_UPDATE_SECRET_SUCCESS_MODIFIED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
is_secret_prop (NMSetting *setting, const char *secret_name, GError **error)
|
|
|
|
|
{
|
libnm-core: add dbus-only properties to NMSettingClass
Add _nm_setting_class_add_dbus_only_property(), for declaring
properties that appear in the D-Bus serialization, but which don't
correspond to GObject properties.
Since some property overrides will require examining settings other
than the setting that they are on (eg, the value of
802-11-wireless.security depends on whether an
NMSettingWirelessSecurity setting is present, and
NMSettingConnection:interface-name might sometimes be set from, eg,
bond.interface-name), we also update _nm_setting_to_dbus() to take the
full NMConnection as an argument, and _nm_setting_new_from_dbus() to
take the full connection hash.
Additionally, with some deprecated properties, we'll want to validate
them on construction, but we don't need to keep the value around after
that. So allow _nm_setting_new_from_dbus() to return a verification
error directly, so we don't need to store the value until the verify()
call.
2014-07-29 18:25:10 -04:00
|
|
|
const NMSettingProperty *property;
|
2014-07-24 08:53:33 -04:00
|
|
|
GParamSpec *pspec;
|
|
|
|
|
|
libnm-core: add dbus-only properties to NMSettingClass
Add _nm_setting_class_add_dbus_only_property(), for declaring
properties that appear in the D-Bus serialization, but which don't
correspond to GObject properties.
Since some property overrides will require examining settings other
than the setting that they are on (eg, the value of
802-11-wireless.security depends on whether an
NMSettingWirelessSecurity setting is present, and
NMSettingConnection:interface-name might sometimes be set from, eg,
bond.interface-name), we also update _nm_setting_to_dbus() to take the
full NMConnection as an argument, and _nm_setting_new_from_dbus() to
take the full connection hash.
Additionally, with some deprecated properties, we'll want to validate
them on construction, but we don't need to keep the value around after
that. So allow _nm_setting_new_from_dbus() to return a verification
error directly, so we don't need to store the value until the verify()
call.
2014-07-29 18:25:10 -04:00
|
|
|
property = nm_setting_class_find_property (NM_SETTING_GET_CLASS (setting), secret_name);
|
|
|
|
|
if (!property) {
|
libnm-core: merge NMSetting*Error into NMConnectionError
Each setting type was defining its own error type, but most of them
had exactly the same three errors ("unknown", "missing property", and
"invalid property"), and none of the other values was of much use
programmatically anyway.
So, this commit merges NMSettingError, NMSettingAdslError, etc, all
into NMConnectionError. (The reason for merging into NMConnectionError
rather than NMSettingError is that we also already have
"NMSettingsError", for errors related to the settings service, so
"NMConnectionError" is a less-confusable name for settings/connection
errors than "NMSettingError".)
Also, make sure that all of the affected error messages are localized,
and (where appropriate) prefix them with the relevant property name.
Renamed error codes:
NM_SETTING_ERROR_PROPERTY_NOT_FOUND -> NM_CONNECTION_ERROR_PROPERTY_NOT_FOUND
NM_SETTING_ERROR_PROPERTY_NOT_SECRET -> NM_CONNECTION_ERROR_PROPERTY_NOT_SECRET
Remapped error codes:
NM_SETTING_*_ERROR_MISSING_PROPERTY -> NM_CONNECTION_ERROR_MISSING_PROPERTY
NM_SETTING_*_ERROR_INVALID_PROPERTY -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_ERROR_PROPERTY_TYPE_MISMATCH -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_BLUETOOTH_ERROR_TYPE_SETTING_NOT_FOUND -> NM_CONNECTION_ERROR_INVALID_SETTING
NM_SETTING_BOND_ERROR_INVALID_OPTION -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_BOND_ERROR_MISSING_OPTION -> NM_CONNECTION_ERROR_MISSING_PROPERTY
NM_SETTING_CONNECTION_ERROR_TYPE_SETTING_NOT_FOUND -> NM_CONNECTION_ERROR_MISSING_SETTING
NM_SETTING_CONNECTION_ERROR_SLAVE_SETTING_NOT_FOUND -> NM_CONNECTION_ERROR_MISSING_SETTING
NM_SETTING_IP4_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_IP6_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_VLAN_ERROR_INVALID_PARENT -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_WIRELESS_SECURITY_ERROR_MISSING_802_1X_SETTING -> NM_CONNECTION_ERROR_MISSING_SETTING
NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_802_1X -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_USERNAME -> NM_CONNECTION_ERROR_MISSING_PROPERTY
NM_SETTING_WIRELESS_SECURITY_ERROR_SHARED_KEY_REQUIRES_WEP -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_WIRELESS_ERROR_CHANNEL_REQUIRES_BAND -> NM_CONNECTION_ERROR_MISSING_PROPERTY
Dropped error codes (were previously defined but unused):
NM_SETTING_CDMA_ERROR_MISSING_SERIAL_SETTING
NM_SETTING_CONNECTION_ERROR_IP_CONFIG_NOT_ALLOWED
NM_SETTING_GSM_ERROR_MISSING_SERIAL_SETTING
NM_SETTING_PPP_ERROR_REQUIRE_MPPE_NOT_ALLOWED
NM_SETTING_PPPOE_ERROR_MISSING_PPP_SETTING
NM_SETTING_SERIAL_ERROR_MISSING_PPP_SETTING
NM_SETTING_WIRELESS_ERROR_MISSING_SECURITY_SETTING
2014-10-20 13:52:23 -04:00
|
|
|
g_set_error_literal (error,
|
|
|
|
|
NM_CONNECTION_ERROR,
|
|
|
|
|
NM_CONNECTION_ERROR_PROPERTY_NOT_FOUND,
|
|
|
|
|
_("secret is not set"));
|
|
|
|
|
g_prefix_error (error, "%s.%s: ", nm_setting_get_name (setting), secret_name);
|
2014-07-24 08:53:33 -04:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
libnm-core: add dbus-only properties to NMSettingClass
Add _nm_setting_class_add_dbus_only_property(), for declaring
properties that appear in the D-Bus serialization, but which don't
correspond to GObject properties.
Since some property overrides will require examining settings other
than the setting that they are on (eg, the value of
802-11-wireless.security depends on whether an
NMSettingWirelessSecurity setting is present, and
NMSettingConnection:interface-name might sometimes be set from, eg,
bond.interface-name), we also update _nm_setting_to_dbus() to take the
full NMConnection as an argument, and _nm_setting_new_from_dbus() to
take the full connection hash.
Additionally, with some deprecated properties, we'll want to validate
them on construction, but we don't need to keep the value around after
that. So allow _nm_setting_new_from_dbus() to return a verification
error directly, so we don't need to store the value until the verify()
call.
2014-07-29 18:25:10 -04:00
|
|
|
pspec = property->param_spec;
|
|
|
|
|
if (!pspec || !(pspec->flags & NM_SETTING_PARAM_SECRET)) {
|
libnm-core: merge NMSetting*Error into NMConnectionError
Each setting type was defining its own error type, but most of them
had exactly the same three errors ("unknown", "missing property", and
"invalid property"), and none of the other values was of much use
programmatically anyway.
So, this commit merges NMSettingError, NMSettingAdslError, etc, all
into NMConnectionError. (The reason for merging into NMConnectionError
rather than NMSettingError is that we also already have
"NMSettingsError", for errors related to the settings service, so
"NMConnectionError" is a less-confusable name for settings/connection
errors than "NMSettingError".)
Also, make sure that all of the affected error messages are localized,
and (where appropriate) prefix them with the relevant property name.
Renamed error codes:
NM_SETTING_ERROR_PROPERTY_NOT_FOUND -> NM_CONNECTION_ERROR_PROPERTY_NOT_FOUND
NM_SETTING_ERROR_PROPERTY_NOT_SECRET -> NM_CONNECTION_ERROR_PROPERTY_NOT_SECRET
Remapped error codes:
NM_SETTING_*_ERROR_MISSING_PROPERTY -> NM_CONNECTION_ERROR_MISSING_PROPERTY
NM_SETTING_*_ERROR_INVALID_PROPERTY -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_ERROR_PROPERTY_TYPE_MISMATCH -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_BLUETOOTH_ERROR_TYPE_SETTING_NOT_FOUND -> NM_CONNECTION_ERROR_INVALID_SETTING
NM_SETTING_BOND_ERROR_INVALID_OPTION -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_BOND_ERROR_MISSING_OPTION -> NM_CONNECTION_ERROR_MISSING_PROPERTY
NM_SETTING_CONNECTION_ERROR_TYPE_SETTING_NOT_FOUND -> NM_CONNECTION_ERROR_MISSING_SETTING
NM_SETTING_CONNECTION_ERROR_SLAVE_SETTING_NOT_FOUND -> NM_CONNECTION_ERROR_MISSING_SETTING
NM_SETTING_IP4_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_IP6_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_VLAN_ERROR_INVALID_PARENT -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_WIRELESS_SECURITY_ERROR_MISSING_802_1X_SETTING -> NM_CONNECTION_ERROR_MISSING_SETTING
NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_802_1X -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_USERNAME -> NM_CONNECTION_ERROR_MISSING_PROPERTY
NM_SETTING_WIRELESS_SECURITY_ERROR_SHARED_KEY_REQUIRES_WEP -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_WIRELESS_ERROR_CHANNEL_REQUIRES_BAND -> NM_CONNECTION_ERROR_MISSING_PROPERTY
Dropped error codes (were previously defined but unused):
NM_SETTING_CDMA_ERROR_MISSING_SERIAL_SETTING
NM_SETTING_CONNECTION_ERROR_IP_CONFIG_NOT_ALLOWED
NM_SETTING_GSM_ERROR_MISSING_SERIAL_SETTING
NM_SETTING_PPP_ERROR_REQUIRE_MPPE_NOT_ALLOWED
NM_SETTING_PPPOE_ERROR_MISSING_PPP_SETTING
NM_SETTING_SERIAL_ERROR_MISSING_PPP_SETTING
NM_SETTING_WIRELESS_ERROR_MISSING_SECURITY_SETTING
2014-10-20 13:52:23 -04:00
|
|
|
g_set_error_literal (error,
|
|
|
|
|
NM_CONNECTION_ERROR,
|
|
|
|
|
NM_CONNECTION_ERROR_PROPERTY_NOT_SECRET,
|
|
|
|
|
_("not a secret property"));
|
|
|
|
|
g_prefix_error (error, "%s.%s: ", nm_setting_get_name (setting), secret_name);
|
2014-07-24 08:53:33 -04:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
get_secret_flags (NMSetting *setting,
|
|
|
|
|
const char *secret_name,
|
|
|
|
|
gboolean verify_secret,
|
|
|
|
|
NMSettingSecretFlags *out_flags,
|
|
|
|
|
GError **error)
|
|
|
|
|
{
|
2017-11-20 13:52:18 +01:00
|
|
|
gs_free char *name_to_free = NULL;
|
2014-07-24 08:53:33 -04:00
|
|
|
NMSettingSecretFlags flags = NM_SETTING_SECRET_FLAG_NONE;
|
|
|
|
|
|
libnm-util: don't assert in nm_setting_get_secret_flags() and avoid assertion in agent_secrets_done_cb()
When secret providers return the connection hash in GetSecrets(),
this hash should only contain secrets. However, some providers also
return non-secret properties.
for_each_secret() iterated over all entries of the @secrets hash
and triggered the assertion in nm_setting_get_secret_flags() (see
below).
NM should not assert against user provided input. Change
nm_setting_get_secret_flags() to silently return FALSE, if the property
is not a secret.
Indeed, handling of secrets is very different for NMSettingVpn and
others. Hence nm_setting_get_secret_flags() has only an inconsistent
behavior and we have to fix all call sites to do the right thing
(depending on whether we have a VPN setting or not).
Now for_each_secret() checks whether the property is a secret
without hitting the assertion. Adjust all other calls of
nm_setting_get_secret_flags(), to anticipate non-secret flags and
assert/warn where appropriate.
Also, agent_secrets_done_cb() clears now all non-secrets properties
from the hash, using the new argument @remove_non_secrets when calling
for_each_secret().
#0 0x0000003370c504e9 in g_logv () from /lib64/libglib-2.0.so.0
#1 0x0000003370c5063f in g_log () from /lib64/libglib-2.0.so.0
#2 0x00007fa4b0c1c156 in get_secret_flags (setting=0x1e3ac60, secret_name=0x1ea9180 "security", verify_secret=1, out_flags=0x7fff7507857c, error=0x0) at nm-setting.c:1091
#3 0x00007fa4b0c1c2b2 in nm_setting_get_secret_flags (setting=0x1e3ac60, secret_name=0x1ea9180 "security", out_flags=0x7fff7507857c, error=0x0) at nm-setting.c:1124
#4 0x0000000000463d03 in for_each_secret (connection=0x1deb2f0, secrets=0x1e9f860, callback=0x464f1b <has_system_owned_secrets>, callback_data=0x7fff7507865c) at settings/nm-settings-connection.c:203
#5 0x000000000046525f in agent_secrets_done_cb (manager=0x1dddf50, call_id=1, agent_dbus_owner=0x1ddb9e0 ":1.39", agent_username=0x1e51710 "thom", agent_has_modify=1, setting_name=0x1e91f90 "802-11-wireless-security",
flags=NM_SETTINGS_GET_SECRETS_FLAG_ALLOW_INTERACTION, secrets=0x1e9f860, error=0x0, user_data=0x1deb2f0, other_data2=0x477d61 <get_secrets_cb>, other_data3=0x1ea92a0) at settings/nm-settings-connection.c:757
#6 0x00000000004dc4fd in get_complete_cb (parent=0x1ea6300, secrets=0x1e9f860, agent_dbus_owner=0x1ddb9e0 ":1.39", agent_username=0x1e51710 "thom", error=0x0, user_data=0x1dddf50) at settings/nm-agent-manager.c:1139
#7 0x00000000004dab54 in req_complete_success (req=0x1ea6300, secrets=0x1e9f860, agent_dbus_owner=0x1ddb9e0 ":1.39", agent_uname=0x1e51710 "thom") at settings/nm-agent-manager.c:502
#8 0x00000000004db86e in get_done_cb (agent=0x1e89530, call_id=0x1, secrets=0x1e9f860, error=0x0, user_data=0x1ea6300) at settings/nm-agent-manager.c:856
#9 0x00000000004de9d0 in get_callback (proxy=0x1e47530, call=0x1, user_data=0x1ea10f0) at settings/nm-secret-agent.c:267
#10 0x000000337380cad2 in complete_pending_call_and_unlock () from /lib64/libdbus-1.so.3
#11 0x000000337380fdc1 in dbus_connection_dispatch () from /lib64/libdbus-1.so.3
#12 0x000000342800ad65 in message_queue_dispatch () from /lib64/libdbus-glib-1.so.2
#13 0x0000003370c492a6 in g_main_context_dispatch () from /lib64/libglib-2.0.so.0
#14 0x0000003370c49628 in g_main_context_iterate.isra.24 () from /lib64/libglib-2.0.so.0
#15 0x0000003370c49a3a in g_main_loop_run () from /lib64/libglib-2.0.so.0
#16 0x000000000042e5c6 in main (argc=1, argv=0x7fff75078e88) at main.c:644
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-02-23 17:03:01 +01:00
|
|
|
if (verify_secret && !is_secret_prop (setting, secret_name, error)) {
|
2017-11-20 13:52:18 +01:00
|
|
|
NM_SET_OUT (out_flags, NM_SETTING_SECRET_FLAG_NONE);
|
libnm-util: don't assert in nm_setting_get_secret_flags() and avoid assertion in agent_secrets_done_cb()
When secret providers return the connection hash in GetSecrets(),
this hash should only contain secrets. However, some providers also
return non-secret properties.
for_each_secret() iterated over all entries of the @secrets hash
and triggered the assertion in nm_setting_get_secret_flags() (see
below).
NM should not assert against user provided input. Change
nm_setting_get_secret_flags() to silently return FALSE, if the property
is not a secret.
Indeed, handling of secrets is very different for NMSettingVpn and
others. Hence nm_setting_get_secret_flags() has only an inconsistent
behavior and we have to fix all call sites to do the right thing
(depending on whether we have a VPN setting or not).
Now for_each_secret() checks whether the property is a secret
without hitting the assertion. Adjust all other calls of
nm_setting_get_secret_flags(), to anticipate non-secret flags and
assert/warn where appropriate.
Also, agent_secrets_done_cb() clears now all non-secrets properties
from the hash, using the new argument @remove_non_secrets when calling
for_each_secret().
#0 0x0000003370c504e9 in g_logv () from /lib64/libglib-2.0.so.0
#1 0x0000003370c5063f in g_log () from /lib64/libglib-2.0.so.0
#2 0x00007fa4b0c1c156 in get_secret_flags (setting=0x1e3ac60, secret_name=0x1ea9180 "security", verify_secret=1, out_flags=0x7fff7507857c, error=0x0) at nm-setting.c:1091
#3 0x00007fa4b0c1c2b2 in nm_setting_get_secret_flags (setting=0x1e3ac60, secret_name=0x1ea9180 "security", out_flags=0x7fff7507857c, error=0x0) at nm-setting.c:1124
#4 0x0000000000463d03 in for_each_secret (connection=0x1deb2f0, secrets=0x1e9f860, callback=0x464f1b <has_system_owned_secrets>, callback_data=0x7fff7507865c) at settings/nm-settings-connection.c:203
#5 0x000000000046525f in agent_secrets_done_cb (manager=0x1dddf50, call_id=1, agent_dbus_owner=0x1ddb9e0 ":1.39", agent_username=0x1e51710 "thom", agent_has_modify=1, setting_name=0x1e91f90 "802-11-wireless-security",
flags=NM_SETTINGS_GET_SECRETS_FLAG_ALLOW_INTERACTION, secrets=0x1e9f860, error=0x0, user_data=0x1deb2f0, other_data2=0x477d61 <get_secrets_cb>, other_data3=0x1ea92a0) at settings/nm-settings-connection.c:757
#6 0x00000000004dc4fd in get_complete_cb (parent=0x1ea6300, secrets=0x1e9f860, agent_dbus_owner=0x1ddb9e0 ":1.39", agent_username=0x1e51710 "thom", error=0x0, user_data=0x1dddf50) at settings/nm-agent-manager.c:1139
#7 0x00000000004dab54 in req_complete_success (req=0x1ea6300, secrets=0x1e9f860, agent_dbus_owner=0x1ddb9e0 ":1.39", agent_uname=0x1e51710 "thom") at settings/nm-agent-manager.c:502
#8 0x00000000004db86e in get_done_cb (agent=0x1e89530, call_id=0x1, secrets=0x1e9f860, error=0x0, user_data=0x1ea6300) at settings/nm-agent-manager.c:856
#9 0x00000000004de9d0 in get_callback (proxy=0x1e47530, call=0x1, user_data=0x1ea10f0) at settings/nm-secret-agent.c:267
#10 0x000000337380cad2 in complete_pending_call_and_unlock () from /lib64/libdbus-1.so.3
#11 0x000000337380fdc1 in dbus_connection_dispatch () from /lib64/libdbus-1.so.3
#12 0x000000342800ad65 in message_queue_dispatch () from /lib64/libdbus-glib-1.so.2
#13 0x0000003370c492a6 in g_main_context_dispatch () from /lib64/libglib-2.0.so.0
#14 0x0000003370c49628 in g_main_context_iterate.isra.24 () from /lib64/libglib-2.0.so.0
#15 0x0000003370c49a3a in g_main_loop_run () from /lib64/libglib-2.0.so.0
#16 0x000000000042e5c6 in main (argc=1, argv=0x7fff75078e88) at main.c:644
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-02-23 17:03:01 +01:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2017-11-20 13:52:18 +01:00
|
|
|
g_object_get (G_OBJECT (setting),
|
|
|
|
|
nm_construct_name_a ("%s-flags", secret_name, &name_to_free),
|
|
|
|
|
&flags,
|
|
|
|
|
NULL);
|
|
|
|
|
NM_SET_OUT (out_flags, flags);
|
2014-07-24 08:53:33 -04:00
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_get_secret_flags:
|
|
|
|
|
* @setting: the #NMSetting
|
|
|
|
|
* @secret_name: the secret key name to get flags for
|
|
|
|
|
* @out_flags: on success, the #NMSettingSecretFlags for the secret
|
|
|
|
|
* @error: location to store error, or %NULL
|
|
|
|
|
*
|
|
|
|
|
* For a given secret, retrieves the #NMSettingSecretFlags describing how to
|
|
|
|
|
* handle that secret.
|
|
|
|
|
*
|
|
|
|
|
* Returns: %TRUE on success (if the given secret name was a valid property of
|
|
|
|
|
* this setting, and if that property is secret), %FALSE if not
|
|
|
|
|
**/
|
|
|
|
|
gboolean
|
|
|
|
|
nm_setting_get_secret_flags (NMSetting *setting,
|
|
|
|
|
const char *secret_name,
|
|
|
|
|
NMSettingSecretFlags *out_flags,
|
|
|
|
|
GError **error)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING (setting), FALSE);
|
|
|
|
|
g_return_val_if_fail (secret_name != NULL, FALSE);
|
|
|
|
|
|
|
|
|
|
return NM_SETTING_GET_CLASS (setting)->get_secret_flags (setting, secret_name, TRUE, out_flags, error);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
set_secret_flags (NMSetting *setting,
|
|
|
|
|
const char *secret_name,
|
|
|
|
|
gboolean verify_secret,
|
|
|
|
|
NMSettingSecretFlags flags,
|
|
|
|
|
GError **error)
|
|
|
|
|
{
|
2017-11-20 13:52:18 +01:00
|
|
|
gs_free char *name_to_free = NULL;
|
2014-07-24 08:53:33 -04:00
|
|
|
|
|
|
|
|
if (verify_secret)
|
|
|
|
|
g_return_val_if_fail (is_secret_prop (setting, secret_name, error), FALSE);
|
|
|
|
|
|
2017-11-20 13:52:18 +01:00
|
|
|
g_object_set (G_OBJECT (setting),
|
|
|
|
|
nm_construct_name_a ("%s-flags", secret_name, &name_to_free),
|
|
|
|
|
flags,
|
|
|
|
|
NULL);
|
2014-07-24 08:53:33 -04:00
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_set_secret_flags:
|
|
|
|
|
* @setting: the #NMSetting
|
|
|
|
|
* @secret_name: the secret key name to set flags for
|
|
|
|
|
* @flags: the #NMSettingSecretFlags for the secret
|
|
|
|
|
* @error: location to store error, or %NULL
|
|
|
|
|
*
|
|
|
|
|
* For a given secret, stores the #NMSettingSecretFlags describing how to
|
|
|
|
|
* handle that secret.
|
|
|
|
|
*
|
|
|
|
|
* Returns: %TRUE on success (if the given secret name was a valid property of
|
|
|
|
|
* this setting, and if that property is secret), %FALSE if not
|
|
|
|
|
**/
|
|
|
|
|
gboolean
|
|
|
|
|
nm_setting_set_secret_flags (NMSetting *setting,
|
|
|
|
|
const char *secret_name,
|
|
|
|
|
NMSettingSecretFlags flags,
|
|
|
|
|
GError **error)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING (setting), FALSE);
|
|
|
|
|
g_return_val_if_fail (secret_name != NULL, FALSE);
|
|
|
|
|
g_return_val_if_fail (flags <= NM_SETTING_SECRET_FLAGS_ALL, FALSE);
|
|
|
|
|
|
|
|
|
|
return NM_SETTING_GET_CLASS (setting)->set_secret_flags (setting, secret_name, TRUE, flags, error);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_to_string:
|
|
|
|
|
* @setting: the #NMSetting
|
|
|
|
|
*
|
2018-07-26 11:59:24 +02:00
|
|
|
* Convert the setting (including secrets!) into a string. For debugging
|
|
|
|
|
* purposes ONLY, should NOT be used for serialization of the setting,
|
|
|
|
|
* or machine-parsed in any way. The output format is not guaranteed to
|
|
|
|
|
* be stable and may change at any time.
|
2014-07-24 08:53:33 -04:00
|
|
|
*
|
|
|
|
|
* Returns: an allocated string containing a textual representation of the
|
2018-07-26 11:59:24 +02:00
|
|
|
* setting's properties and values, which the caller should
|
2014-07-24 08:53:33 -04:00
|
|
|
* free with g_free()
|
|
|
|
|
**/
|
|
|
|
|
char *
|
|
|
|
|
nm_setting_to_string (NMSetting *setting)
|
|
|
|
|
{
|
|
|
|
|
GString *string;
|
2018-07-26 12:34:23 +02:00
|
|
|
gs_unref_variant GVariant *variant = NULL;
|
2018-07-26 11:59:24 +02:00
|
|
|
GVariant *child;
|
|
|
|
|
GVariantIter iter;
|
2014-07-24 08:53:33 -04:00
|
|
|
|
|
|
|
|
string = g_string_new (nm_setting_get_name (setting));
|
|
|
|
|
g_string_append_c (string, '\n');
|
|
|
|
|
|
2018-07-26 11:59:24 +02:00
|
|
|
variant = _nm_setting_to_dbus (setting, NULL, NM_CONNECTION_SERIALIZE_ALL);
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2018-07-26 11:59:24 +02:00
|
|
|
g_variant_iter_init (&iter, variant);
|
|
|
|
|
while ((child = g_variant_iter_next_value (&iter))) {
|
2018-07-26 12:34:23 +02:00
|
|
|
gs_free char *name = NULL;
|
|
|
|
|
gs_free char *value_str = NULL;
|
|
|
|
|
gs_unref_variant GVariant *value = NULL;
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2018-07-26 11:59:24 +02:00
|
|
|
g_variant_get (child, "{sv}", &name, &value);
|
|
|
|
|
value_str = g_variant_print (value, FALSE);
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2018-07-26 11:59:24 +02:00
|
|
|
g_string_append_printf (string, "\t%s : %s\n", name, value_str);
|
2014-07-24 08:53:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return g_string_free (string, FALSE);
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-16 10:09:48 -04:00
|
|
|
GVariant *
|
2014-08-04 19:57:20 -04:00
|
|
|
_nm_setting_get_deprecated_virtual_interface_name (NMSetting *setting,
|
|
|
|
|
NMConnection *connection,
|
2014-08-16 10:09:48 -04:00
|
|
|
const char *property)
|
2014-08-04 19:57:20 -04:00
|
|
|
{
|
|
|
|
|
NMSettingConnection *s_con;
|
|
|
|
|
|
|
|
|
|
s_con = nm_connection_get_setting_connection (connection);
|
2014-08-16 10:09:48 -04:00
|
|
|
g_return_val_if_fail (s_con != NULL, NULL);
|
2014-08-04 19:57:20 -04:00
|
|
|
|
2014-08-16 10:09:48 -04:00
|
|
|
if (nm_setting_connection_get_interface_name (s_con))
|
|
|
|
|
return g_variant_new_string (nm_setting_connection_get_interface_name (s_con));
|
|
|
|
|
else
|
|
|
|
|
return NULL;
|
2014-08-04 19:57:20 -04:00
|
|
|
}
|
|
|
|
|
|
2014-07-24 08:53:33 -04:00
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
nm_setting_init (NMSetting *setting)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
get_property (GObject *object, guint prop_id,
|
|
|
|
|
GValue *value, GParamSpec *pspec)
|
|
|
|
|
{
|
|
|
|
|
NMSetting *setting = NM_SETTING (object);
|
|
|
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
|
case PROP_NAME:
|
|
|
|
|
g_value_set_string (value, nm_setting_get_name (setting));
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
nm_setting_class_init (NMSettingClass *setting_class)
|
|
|
|
|
{
|
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (setting_class);
|
2018-07-13 15:47:45 +02:00
|
|
|
GModule *self_module;
|
|
|
|
|
gpointer func;
|
|
|
|
|
|
|
|
|
|
/* loading libnm and legacy libraries libnm-util/libnm-glib at the same
|
|
|
|
|
* time is not supported. The reason is, that both libraries use the same
|
|
|
|
|
* glib type names ("NMSetting"), and glib does not support namespacing
|
|
|
|
|
* to allow for that.
|
|
|
|
|
*
|
|
|
|
|
* Arbitrarily, add a check here, see whether a known symbol from libnm-util
|
|
|
|
|
* is present. If it is, it indicates that the process is borked and we
|
|
|
|
|
* abort. */
|
|
|
|
|
self_module = g_module_open (NULL, 0);
|
|
|
|
|
if (g_module_symbol (self_module, "nm_util_get_private", &func))
|
|
|
|
|
g_error ("libnm-util symbols detected; Mixing libnm with libnm-util/libnm-glib is not supported");
|
|
|
|
|
g_module_close (self_module);
|
2014-07-24 08:53:33 -04:00
|
|
|
|
|
|
|
|
g_type_class_add_private (setting_class, sizeof (NMSettingPrivate));
|
|
|
|
|
|
|
|
|
|
object_class->get_property = get_property;
|
|
|
|
|
|
|
|
|
|
setting_class->update_one_secret = update_one_secret;
|
|
|
|
|
setting_class->get_secret_flags = get_secret_flags;
|
|
|
|
|
setting_class->set_secret_flags = set_secret_flags;
|
|
|
|
|
setting_class->compare_property = compare_property;
|
|
|
|
|
setting_class->clear_secrets_with_flags = clear_secrets_with_flags;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* NMSetting:name:
|
|
|
|
|
*
|
|
|
|
|
* The setting's name, which uniquely identifies the setting within the
|
|
|
|
|
* connection. Each setting type has a name unique to that type, for
|
2018-08-03 13:38:01 +02:00
|
|
|
* example "ppp" or "802-11-wireless" or "802-3-ethernet".
|
2014-07-24 08:53:33 -04:00
|
|
|
**/
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_NAME,
|
|
|
|
|
g_param_spec_string (NM_SETTING_NAME, "", "",
|
|
|
|
|
NULL,
|
2014-05-09 15:02:57 -04:00
|
|
|
G_PARAM_READABLE |
|
2014-07-24 08:53:33 -04:00
|
|
|
G_PARAM_STATIC_STRINGS));
|
|
|
|
|
}
|