2014-07-24 12:53:33 +00: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 - 2013 Red Hat, Inc.
|
|
|
|
* Copyright 2007 - 2008 Novell, Inc.
|
|
|
|
*/
|
|
|
|
|
2016-02-19 13:57:48 +00:00
|
|
|
#include "nm-default.h"
|
2014-11-13 15:07:02 +00:00
|
|
|
|
2014-07-24 12:53:33 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include "nm-setting-vpn.h"
|
|
|
|
#include "nm-utils.h"
|
2014-06-24 21:40:08 +00:00
|
|
|
#include "nm-utils-private.h"
|
2014-07-24 12:53:33 +00:00
|
|
|
#include "nm-setting-private.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* SECTION:nm-setting-vpn
|
|
|
|
* @short_description: Describes connection properties for Virtual Private Networks
|
|
|
|
*
|
libnm, core, cli, tui: fix the capitalization of various types
GLib/Gtk have mostly settled on the convention that two-letter
acronyms in type names remain all-caps (eg, "IO"), but longer acronyms
become initial-caps-only (eg, "Tcp").
NM was inconsistent, with most long acronyms using initial caps only
(Adsl, Cdma, Dcb, Gsm, Olpc, Vlan), but others using all caps (DHCP,
PPP, PPPOE, VPN). Fix libnm and src/ to use initial-caps only for all
three-or-more-letter-long acronyms (and update nmcli and nmtui for the
libnm changes).
2014-06-26 17:44:36 +00:00
|
|
|
* The #NMSettingVpn object is a #NMSetting subclass that describes properties
|
2014-07-24 12:53:33 +00:00
|
|
|
* necessary for connection to Virtual Private Networks. NetworkManager uses
|
|
|
|
* a plugin architecture to allow easier use of new VPN types, and this
|
|
|
|
* setting abstracts the configuration for those plugins. Since the configuration
|
|
|
|
* options are only known to the VPN plugins themselves, the VPN configuration
|
|
|
|
* options are stored as key/value pairs of strings rather than GObject
|
|
|
|
* properties.
|
|
|
|
**/
|
|
|
|
|
libnm, core, cli, tui: fix the capitalization of various types
GLib/Gtk have mostly settled on the convention that two-letter
acronyms in type names remain all-caps (eg, "IO"), but longer acronyms
become initial-caps-only (eg, "Tcp").
NM was inconsistent, with most long acronyms using initial caps only
(Adsl, Cdma, Dcb, Gsm, Olpc, Vlan), but others using all caps (DHCP,
PPP, PPPOE, VPN). Fix libnm and src/ to use initial-caps only for all
three-or-more-letter-long acronyms (and update nmcli and nmtui for the
libnm changes).
2014-06-26 17:44:36 +00:00
|
|
|
G_DEFINE_TYPE_WITH_CODE (NMSettingVpn, nm_setting_vpn, NM_TYPE_SETTING,
|
2014-08-07 21:19:40 +00:00
|
|
|
_nm_register_setting (VPN, 1))
|
2014-07-24 12:53:33 +00:00
|
|
|
NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_VPN)
|
|
|
|
|
libnm, core, cli, tui: fix the capitalization of various types
GLib/Gtk have mostly settled on the convention that two-letter
acronyms in type names remain all-caps (eg, "IO"), but longer acronyms
become initial-caps-only (eg, "Tcp").
NM was inconsistent, with most long acronyms using initial caps only
(Adsl, Cdma, Dcb, Gsm, Olpc, Vlan), but others using all caps (DHCP,
PPP, PPPOE, VPN). Fix libnm and src/ to use initial-caps only for all
three-or-more-letter-long acronyms (and update nmcli and nmtui for the
libnm changes).
2014-06-26 17:44:36 +00:00
|
|
|
#define NM_SETTING_VPN_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_VPN, NMSettingVpnPrivate))
|
2014-07-24 12:53:33 +00:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
char *service_type;
|
|
|
|
|
|
|
|
/* username of the user requesting this connection, thus
|
|
|
|
* it's really only valid for user connections, and it also
|
|
|
|
* should never be saved out to persistent config.
|
|
|
|
*/
|
|
|
|
char *user_name;
|
|
|
|
|
2014-10-17 01:09:38 +00:00
|
|
|
/* Whether the VPN stays up across link changes, until the user
|
|
|
|
* explicitly disconnects it.
|
|
|
|
*/
|
|
|
|
gboolean persistent;
|
|
|
|
|
2014-07-24 12:53:33 +00:00
|
|
|
/* The hash table is created at setting object
|
|
|
|
* init time and should not be replaced. It is
|
|
|
|
* a char * -> char * mapping, and both the key
|
|
|
|
* and value are owned by the hash table, and should
|
|
|
|
* be allocated with functions whose value can be
|
|
|
|
* freed with g_free(). Should not contain secrets.
|
|
|
|
*/
|
|
|
|
GHashTable *data;
|
|
|
|
|
|
|
|
/* The hash table is created at setting object
|
|
|
|
* init time and should not be replaced. It is
|
|
|
|
* a char * -> char * mapping, and both the key
|
|
|
|
* and value are owned by the hash table, and should
|
|
|
|
* be allocated with functions whose value can be
|
|
|
|
* freed with g_free(). Should contain secrets only.
|
|
|
|
*/
|
|
|
|
GHashTable *secrets;
|
2015-09-16 07:34:33 +00:00
|
|
|
|
|
|
|
/* Timeout for the VPN service to establish the connection */
|
|
|
|
guint32 timeout;
|
libnm, core, cli, tui: fix the capitalization of various types
GLib/Gtk have mostly settled on the convention that two-letter
acronyms in type names remain all-caps (eg, "IO"), but longer acronyms
become initial-caps-only (eg, "Tcp").
NM was inconsistent, with most long acronyms using initial caps only
(Adsl, Cdma, Dcb, Gsm, Olpc, Vlan), but others using all caps (DHCP,
PPP, PPPOE, VPN). Fix libnm and src/ to use initial-caps only for all
three-or-more-letter-long acronyms (and update nmcli and nmtui for the
libnm changes).
2014-06-26 17:44:36 +00:00
|
|
|
} NMSettingVpnPrivate;
|
2014-07-24 12:53:33 +00:00
|
|
|
|
|
|
|
enum {
|
|
|
|
PROP_0,
|
|
|
|
PROP_SERVICE_TYPE,
|
|
|
|
PROP_USER_NAME,
|
2014-10-17 01:09:38 +00:00
|
|
|
PROP_PERSISTENT,
|
2014-07-24 12:53:33 +00:00
|
|
|
PROP_DATA,
|
|
|
|
PROP_SECRETS,
|
2015-09-16 07:34:33 +00:00
|
|
|
PROP_TIMEOUT,
|
2014-07-24 12:53:33 +00:00
|
|
|
|
|
|
|
LAST_PROP
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* nm_setting_vpn_new:
|
|
|
|
*
|
libnm, core, cli, tui: fix the capitalization of various types
GLib/Gtk have mostly settled on the convention that two-letter
acronyms in type names remain all-caps (eg, "IO"), but longer acronyms
become initial-caps-only (eg, "Tcp").
NM was inconsistent, with most long acronyms using initial caps only
(Adsl, Cdma, Dcb, Gsm, Olpc, Vlan), but others using all caps (DHCP,
PPP, PPPOE, VPN). Fix libnm and src/ to use initial-caps only for all
three-or-more-letter-long acronyms (and update nmcli and nmtui for the
libnm changes).
2014-06-26 17:44:36 +00:00
|
|
|
* Creates a new #NMSettingVpn object with default values.
|
2014-07-24 12:53:33 +00:00
|
|
|
*
|
libnm, core, cli, tui: fix the capitalization of various types
GLib/Gtk have mostly settled on the convention that two-letter
acronyms in type names remain all-caps (eg, "IO"), but longer acronyms
become initial-caps-only (eg, "Tcp").
NM was inconsistent, with most long acronyms using initial caps only
(Adsl, Cdma, Dcb, Gsm, Olpc, Vlan), but others using all caps (DHCP,
PPP, PPPOE, VPN). Fix libnm and src/ to use initial-caps only for all
three-or-more-letter-long acronyms (and update nmcli and nmtui for the
libnm changes).
2014-06-26 17:44:36 +00:00
|
|
|
* Returns: (transfer full): the new empty #NMSettingVpn object
|
2014-07-24 12:53:33 +00:00
|
|
|
**/
|
|
|
|
NMSetting *
|
|
|
|
nm_setting_vpn_new (void)
|
|
|
|
{
|
|
|
|
return (NMSetting *) g_object_new (NM_TYPE_SETTING_VPN, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* nm_setting_vpn_get_service_type:
|
libnm, core, cli, tui: fix the capitalization of various types
GLib/Gtk have mostly settled on the convention that two-letter
acronyms in type names remain all-caps (eg, "IO"), but longer acronyms
become initial-caps-only (eg, "Tcp").
NM was inconsistent, with most long acronyms using initial caps only
(Adsl, Cdma, Dcb, Gsm, Olpc, Vlan), but others using all caps (DHCP,
PPP, PPPOE, VPN). Fix libnm and src/ to use initial-caps only for all
three-or-more-letter-long acronyms (and update nmcli and nmtui for the
libnm changes).
2014-06-26 17:44:36 +00:00
|
|
|
* @setting: the #NMSettingVpn
|
2014-07-24 12:53:33 +00:00
|
|
|
*
|
|
|
|
* Returns the service name of the VPN, which identifies the specific VPN
|
|
|
|
* plugin that should be used to connect to this VPN.
|
|
|
|
*
|
|
|
|
* Returns: the VPN plugin's service name
|
|
|
|
**/
|
|
|
|
const char *
|
libnm, core, cli, tui: fix the capitalization of various types
GLib/Gtk have mostly settled on the convention that two-letter
acronyms in type names remain all-caps (eg, "IO"), but longer acronyms
become initial-caps-only (eg, "Tcp").
NM was inconsistent, with most long acronyms using initial caps only
(Adsl, Cdma, Dcb, Gsm, Olpc, Vlan), but others using all caps (DHCP,
PPP, PPPOE, VPN). Fix libnm and src/ to use initial-caps only for all
three-or-more-letter-long acronyms (and update nmcli and nmtui for the
libnm changes).
2014-06-26 17:44:36 +00:00
|
|
|
nm_setting_vpn_get_service_type (NMSettingVpn *setting)
|
2014-07-24 12:53:33 +00:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_VPN (setting), NULL);
|
|
|
|
|
|
|
|
return NM_SETTING_VPN_GET_PRIVATE (setting)->service_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* nm_setting_vpn_get_user_name:
|
libnm, core, cli, tui: fix the capitalization of various types
GLib/Gtk have mostly settled on the convention that two-letter
acronyms in type names remain all-caps (eg, "IO"), but longer acronyms
become initial-caps-only (eg, "Tcp").
NM was inconsistent, with most long acronyms using initial caps only
(Adsl, Cdma, Dcb, Gsm, Olpc, Vlan), but others using all caps (DHCP,
PPP, PPPOE, VPN). Fix libnm and src/ to use initial-caps only for all
three-or-more-letter-long acronyms (and update nmcli and nmtui for the
libnm changes).
2014-06-26 17:44:36 +00:00
|
|
|
* @setting: the #NMSettingVpn
|
2014-07-24 12:53:33 +00:00
|
|
|
*
|
libnm, core, cli, tui: fix the capitalization of various types
GLib/Gtk have mostly settled on the convention that two-letter
acronyms in type names remain all-caps (eg, "IO"), but longer acronyms
become initial-caps-only (eg, "Tcp").
NM was inconsistent, with most long acronyms using initial caps only
(Adsl, Cdma, Dcb, Gsm, Olpc, Vlan), but others using all caps (DHCP,
PPP, PPPOE, VPN). Fix libnm and src/ to use initial-caps only for all
three-or-more-letter-long acronyms (and update nmcli and nmtui for the
libnm changes).
2014-06-26 17:44:36 +00:00
|
|
|
* Returns: the #NMSettingVpn:user-name property of the setting
|
2014-07-24 12:53:33 +00:00
|
|
|
**/
|
|
|
|
const char *
|
libnm, core, cli, tui: fix the capitalization of various types
GLib/Gtk have mostly settled on the convention that two-letter
acronyms in type names remain all-caps (eg, "IO"), but longer acronyms
become initial-caps-only (eg, "Tcp").
NM was inconsistent, with most long acronyms using initial caps only
(Adsl, Cdma, Dcb, Gsm, Olpc, Vlan), but others using all caps (DHCP,
PPP, PPPOE, VPN). Fix libnm and src/ to use initial-caps only for all
three-or-more-letter-long acronyms (and update nmcli and nmtui for the
libnm changes).
2014-06-26 17:44:36 +00:00
|
|
|
nm_setting_vpn_get_user_name (NMSettingVpn *setting)
|
2014-07-24 12:53:33 +00:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_VPN (setting), NULL);
|
|
|
|
|
|
|
|
return NM_SETTING_VPN_GET_PRIVATE (setting)->user_name;
|
|
|
|
}
|
|
|
|
|
2014-10-17 01:09:38 +00:00
|
|
|
/**
|
|
|
|
* nm_setting_vpn_get_persistent:
|
|
|
|
* @setting: the #NMSettingVpn
|
|
|
|
*
|
|
|
|
* Returns: the #NMSettingVpn:persistent property of the setting
|
|
|
|
**/
|
|
|
|
gboolean
|
|
|
|
nm_setting_vpn_get_persistent (NMSettingVpn *setting)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_VPN (setting), FALSE);
|
|
|
|
|
|
|
|
return NM_SETTING_VPN_GET_PRIVATE (setting)->persistent;
|
|
|
|
}
|
|
|
|
|
2014-07-24 12:53:33 +00:00
|
|
|
/**
|
|
|
|
* nm_setting_vpn_get_num_data_items:
|
libnm, core, cli, tui: fix the capitalization of various types
GLib/Gtk have mostly settled on the convention that two-letter
acronyms in type names remain all-caps (eg, "IO"), but longer acronyms
become initial-caps-only (eg, "Tcp").
NM was inconsistent, with most long acronyms using initial caps only
(Adsl, Cdma, Dcb, Gsm, Olpc, Vlan), but others using all caps (DHCP,
PPP, PPPOE, VPN). Fix libnm and src/ to use initial-caps only for all
three-or-more-letter-long acronyms (and update nmcli and nmtui for the
libnm changes).
2014-06-26 17:44:36 +00:00
|
|
|
* @setting: the #NMSettingVpn
|
2014-07-24 12:53:33 +00:00
|
|
|
*
|
|
|
|
* Gets number of key/value pairs of VPN configuration data.
|
|
|
|
*
|
|
|
|
* Returns: the number of VPN plugin specific configuration data items
|
|
|
|
**/
|
|
|
|
guint32
|
libnm, core, cli, tui: fix the capitalization of various types
GLib/Gtk have mostly settled on the convention that two-letter
acronyms in type names remain all-caps (eg, "IO"), but longer acronyms
become initial-caps-only (eg, "Tcp").
NM was inconsistent, with most long acronyms using initial caps only
(Adsl, Cdma, Dcb, Gsm, Olpc, Vlan), but others using all caps (DHCP,
PPP, PPPOE, VPN). Fix libnm and src/ to use initial-caps only for all
three-or-more-letter-long acronyms (and update nmcli and nmtui for the
libnm changes).
2014-06-26 17:44:36 +00:00
|
|
|
nm_setting_vpn_get_num_data_items (NMSettingVpn *setting)
|
2014-07-24 12:53:33 +00:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_VPN (setting), 0);
|
|
|
|
|
|
|
|
return g_hash_table_size (NM_SETTING_VPN_GET_PRIVATE (setting)->data);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* nm_setting_vpn_add_data_item:
|
libnm, core, cli, tui: fix the capitalization of various types
GLib/Gtk have mostly settled on the convention that two-letter
acronyms in type names remain all-caps (eg, "IO"), but longer acronyms
become initial-caps-only (eg, "Tcp").
NM was inconsistent, with most long acronyms using initial caps only
(Adsl, Cdma, Dcb, Gsm, Olpc, Vlan), but others using all caps (DHCP,
PPP, PPPOE, VPN). Fix libnm and src/ to use initial-caps only for all
three-or-more-letter-long acronyms (and update nmcli and nmtui for the
libnm changes).
2014-06-26 17:44:36 +00:00
|
|
|
* @setting: the #NMSettingVpn
|
2014-07-24 12:53:33 +00:00
|
|
|
* @key: a name that uniquely identifies the given value @item
|
|
|
|
* @item: the value to be referenced by @key
|
|
|
|
*
|
|
|
|
* Establishes a relationship between @key and @item internally in the
|
|
|
|
* setting which may be retrieved later. Should not be used to store passwords
|
|
|
|
* or other secrets, which is what nm_setting_vpn_add_secret() is for.
|
|
|
|
**/
|
|
|
|
void
|
libnm, core, cli, tui: fix the capitalization of various types
GLib/Gtk have mostly settled on the convention that two-letter
acronyms in type names remain all-caps (eg, "IO"), but longer acronyms
become initial-caps-only (eg, "Tcp").
NM was inconsistent, with most long acronyms using initial caps only
(Adsl, Cdma, Dcb, Gsm, Olpc, Vlan), but others using all caps (DHCP,
PPP, PPPOE, VPN). Fix libnm and src/ to use initial-caps only for all
three-or-more-letter-long acronyms (and update nmcli and nmtui for the
libnm changes).
2014-06-26 17:44:36 +00:00
|
|
|
nm_setting_vpn_add_data_item (NMSettingVpn *setting,
|
2014-07-24 12:53:33 +00:00
|
|
|
const char *key,
|
|
|
|
const char *item)
|
|
|
|
{
|
|
|
|
g_return_if_fail (NM_IS_SETTING_VPN (setting));
|
|
|
|
g_return_if_fail (key != NULL);
|
|
|
|
g_return_if_fail (strlen (key) > 0);
|
|
|
|
g_return_if_fail (item != NULL);
|
|
|
|
g_return_if_fail (strlen (item) > 0);
|
|
|
|
|
|
|
|
g_hash_table_insert (NM_SETTING_VPN_GET_PRIVATE (setting)->data,
|
|
|
|
g_strdup (key), g_strdup (item));
|
|
|
|
g_object_notify (G_OBJECT (setting), NM_SETTING_VPN_DATA);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* nm_setting_vpn_get_data_item:
|
libnm, core, cli, tui: fix the capitalization of various types
GLib/Gtk have mostly settled on the convention that two-letter
acronyms in type names remain all-caps (eg, "IO"), but longer acronyms
become initial-caps-only (eg, "Tcp").
NM was inconsistent, with most long acronyms using initial caps only
(Adsl, Cdma, Dcb, Gsm, Olpc, Vlan), but others using all caps (DHCP,
PPP, PPPOE, VPN). Fix libnm and src/ to use initial-caps only for all
three-or-more-letter-long acronyms (and update nmcli and nmtui for the
libnm changes).
2014-06-26 17:44:36 +00:00
|
|
|
* @setting: the #NMSettingVpn
|
2014-07-24 12:53:33 +00:00
|
|
|
* @key: the name of the data item to retrieve
|
|
|
|
*
|
|
|
|
* Retrieves the data item of a key/value relationship previously established
|
|
|
|
* by nm_setting_vpn_add_data_item().
|
|
|
|
*
|
|
|
|
* Returns: the data item, if any
|
|
|
|
**/
|
|
|
|
const char *
|
libnm, core, cli, tui: fix the capitalization of various types
GLib/Gtk have mostly settled on the convention that two-letter
acronyms in type names remain all-caps (eg, "IO"), but longer acronyms
become initial-caps-only (eg, "Tcp").
NM was inconsistent, with most long acronyms using initial caps only
(Adsl, Cdma, Dcb, Gsm, Olpc, Vlan), but others using all caps (DHCP,
PPP, PPPOE, VPN). Fix libnm and src/ to use initial-caps only for all
three-or-more-letter-long acronyms (and update nmcli and nmtui for the
libnm changes).
2014-06-26 17:44:36 +00:00
|
|
|
nm_setting_vpn_get_data_item (NMSettingVpn *setting, const char *key)
|
2014-07-24 12:53:33 +00:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_VPN (setting), NULL);
|
|
|
|
|
|
|
|
return (const char *) g_hash_table_lookup (NM_SETTING_VPN_GET_PRIVATE (setting)->data, key);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* nm_setting_vpn_remove_data_item:
|
libnm, core, cli, tui: fix the capitalization of various types
GLib/Gtk have mostly settled on the convention that two-letter
acronyms in type names remain all-caps (eg, "IO"), but longer acronyms
become initial-caps-only (eg, "Tcp").
NM was inconsistent, with most long acronyms using initial caps only
(Adsl, Cdma, Dcb, Gsm, Olpc, Vlan), but others using all caps (DHCP,
PPP, PPPOE, VPN). Fix libnm and src/ to use initial-caps only for all
three-or-more-letter-long acronyms (and update nmcli and nmtui for the
libnm changes).
2014-06-26 17:44:36 +00:00
|
|
|
* @setting: the #NMSettingVpn
|
2014-07-24 12:53:33 +00:00
|
|
|
* @key: the name of the data item to remove
|
|
|
|
*
|
|
|
|
* Deletes a key/value relationship previously established by
|
|
|
|
* nm_setting_vpn_add_data_item().
|
|
|
|
*
|
|
|
|
* Returns: %TRUE if the data item was found and removed from the internal list,
|
|
|
|
* %FALSE if it was not.
|
|
|
|
**/
|
|
|
|
gboolean
|
libnm, core, cli, tui: fix the capitalization of various types
GLib/Gtk have mostly settled on the convention that two-letter
acronyms in type names remain all-caps (eg, "IO"), but longer acronyms
become initial-caps-only (eg, "Tcp").
NM was inconsistent, with most long acronyms using initial caps only
(Adsl, Cdma, Dcb, Gsm, Olpc, Vlan), but others using all caps (DHCP,
PPP, PPPOE, VPN). Fix libnm and src/ to use initial-caps only for all
three-or-more-letter-long acronyms (and update nmcli and nmtui for the
libnm changes).
2014-06-26 17:44:36 +00:00
|
|
|
nm_setting_vpn_remove_data_item (NMSettingVpn *setting, const char *key)
|
2014-07-24 12:53:33 +00:00
|
|
|
{
|
|
|
|
gboolean found;
|
|
|
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_VPN (setting), FALSE);
|
|
|
|
|
|
|
|
found = g_hash_table_remove (NM_SETTING_VPN_GET_PRIVATE (setting)->data, key);
|
|
|
|
if (found)
|
|
|
|
g_object_notify (G_OBJECT (setting), NM_SETTING_VPN_DATA);
|
|
|
|
return found;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
foreach_item_helper (GHashTable *hash,
|
libnm, core, cli, tui: fix the capitalization of various types
GLib/Gtk have mostly settled on the convention that two-letter
acronyms in type names remain all-caps (eg, "IO"), but longer acronyms
become initial-caps-only (eg, "Tcp").
NM was inconsistent, with most long acronyms using initial caps only
(Adsl, Cdma, Dcb, Gsm, Olpc, Vlan), but others using all caps (DHCP,
PPP, PPPOE, VPN). Fix libnm and src/ to use initial-caps only for all
three-or-more-letter-long acronyms (and update nmcli and nmtui for the
libnm changes).
2014-06-26 17:44:36 +00:00
|
|
|
NMVpnIterFunc func,
|
2014-07-24 12:53:33 +00:00
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
GList *keys, *liter;
|
|
|
|
GSList *copied = NULL, *siter;
|
|
|
|
|
|
|
|
g_return_if_fail (hash != NULL);
|
|
|
|
|
|
|
|
/* Grab keys and copy them so that the callback func can modify
|
|
|
|
* the hash table items if it wants to.
|
|
|
|
*/
|
|
|
|
keys = g_hash_table_get_keys (hash);
|
|
|
|
for (liter = keys; liter; liter = g_list_next (liter))
|
|
|
|
copied = g_slist_prepend (copied, g_strdup (liter->data));
|
|
|
|
copied = g_slist_reverse (copied);
|
|
|
|
g_list_free (keys);
|
|
|
|
|
|
|
|
for (siter = copied; siter; siter = g_slist_next (siter)) {
|
|
|
|
gpointer value;
|
|
|
|
|
|
|
|
value = g_hash_table_lookup (hash, siter->data);
|
|
|
|
func (siter->data, value, user_data);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_slist_free_full (copied, g_free);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* nm_setting_vpn_foreach_data_item:
|
libnm, core, cli, tui: fix the capitalization of various types
GLib/Gtk have mostly settled on the convention that two-letter
acronyms in type names remain all-caps (eg, "IO"), but longer acronyms
become initial-caps-only (eg, "Tcp").
NM was inconsistent, with most long acronyms using initial caps only
(Adsl, Cdma, Dcb, Gsm, Olpc, Vlan), but others using all caps (DHCP,
PPP, PPPOE, VPN). Fix libnm and src/ to use initial-caps only for all
three-or-more-letter-long acronyms (and update nmcli and nmtui for the
libnm changes).
2014-06-26 17:44:36 +00:00
|
|
|
* @setting: a #NMSettingVpn
|
2014-07-24 12:53:33 +00:00
|
|
|
* @func: (scope call): an user provided function
|
|
|
|
* @user_data: data to be passed to @func
|
|
|
|
*
|
|
|
|
* Iterates all data items stored in this setting. It is safe to add, remove,
|
|
|
|
* and modify data items inside @func, though any additions or removals made
|
|
|
|
* during iteration will not be part of the iteration.
|
|
|
|
*/
|
|
|
|
void
|
libnm, core, cli, tui: fix the capitalization of various types
GLib/Gtk have mostly settled on the convention that two-letter
acronyms in type names remain all-caps (eg, "IO"), but longer acronyms
become initial-caps-only (eg, "Tcp").
NM was inconsistent, with most long acronyms using initial caps only
(Adsl, Cdma, Dcb, Gsm, Olpc, Vlan), but others using all caps (DHCP,
PPP, PPPOE, VPN). Fix libnm and src/ to use initial-caps only for all
three-or-more-letter-long acronyms (and update nmcli and nmtui for the
libnm changes).
2014-06-26 17:44:36 +00:00
|
|
|
nm_setting_vpn_foreach_data_item (NMSettingVpn *setting,
|
|
|
|
NMVpnIterFunc func,
|
2014-07-24 12:53:33 +00:00
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
g_return_if_fail (NM_IS_SETTING_VPN (setting));
|
|
|
|
|
|
|
|
foreach_item_helper (NM_SETTING_VPN_GET_PRIVATE (setting)->data, func, user_data);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* nm_setting_vpn_get_num_secrets:
|
libnm, core, cli, tui: fix the capitalization of various types
GLib/Gtk have mostly settled on the convention that two-letter
acronyms in type names remain all-caps (eg, "IO"), but longer acronyms
become initial-caps-only (eg, "Tcp").
NM was inconsistent, with most long acronyms using initial caps only
(Adsl, Cdma, Dcb, Gsm, Olpc, Vlan), but others using all caps (DHCP,
PPP, PPPOE, VPN). Fix libnm and src/ to use initial-caps only for all
three-or-more-letter-long acronyms (and update nmcli and nmtui for the
libnm changes).
2014-06-26 17:44:36 +00:00
|
|
|
* @setting: the #NMSettingVpn
|
2014-07-24 12:53:33 +00:00
|
|
|
*
|
|
|
|
* Gets number of VPN plugin specific secrets in the setting.
|
|
|
|
*
|
|
|
|
* Returns: the number of VPN plugin specific secrets
|
|
|
|
**/
|
|
|
|
guint32
|
libnm, core, cli, tui: fix the capitalization of various types
GLib/Gtk have mostly settled on the convention that two-letter
acronyms in type names remain all-caps (eg, "IO"), but longer acronyms
become initial-caps-only (eg, "Tcp").
NM was inconsistent, with most long acronyms using initial caps only
(Adsl, Cdma, Dcb, Gsm, Olpc, Vlan), but others using all caps (DHCP,
PPP, PPPOE, VPN). Fix libnm and src/ to use initial-caps only for all
three-or-more-letter-long acronyms (and update nmcli and nmtui for the
libnm changes).
2014-06-26 17:44:36 +00:00
|
|
|
nm_setting_vpn_get_num_secrets (NMSettingVpn *setting)
|
2014-07-24 12:53:33 +00:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_VPN (setting), 0);
|
|
|
|
|
|
|
|
return g_hash_table_size (NM_SETTING_VPN_GET_PRIVATE (setting)->secrets);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* nm_setting_vpn_add_secret:
|
libnm, core, cli, tui: fix the capitalization of various types
GLib/Gtk have mostly settled on the convention that two-letter
acronyms in type names remain all-caps (eg, "IO"), but longer acronyms
become initial-caps-only (eg, "Tcp").
NM was inconsistent, with most long acronyms using initial caps only
(Adsl, Cdma, Dcb, Gsm, Olpc, Vlan), but others using all caps (DHCP,
PPP, PPPOE, VPN). Fix libnm and src/ to use initial-caps only for all
three-or-more-letter-long acronyms (and update nmcli and nmtui for the
libnm changes).
2014-06-26 17:44:36 +00:00
|
|
|
* @setting: the #NMSettingVpn
|
2014-07-24 12:53:33 +00:00
|
|
|
* @key: a name that uniquely identifies the given secret @secret
|
|
|
|
* @secret: the secret to be referenced by @key
|
|
|
|
*
|
|
|
|
* Establishes a relationship between @key and @secret internally in the
|
|
|
|
* setting which may be retrieved later.
|
|
|
|
**/
|
|
|
|
void
|
libnm, core, cli, tui: fix the capitalization of various types
GLib/Gtk have mostly settled on the convention that two-letter
acronyms in type names remain all-caps (eg, "IO"), but longer acronyms
become initial-caps-only (eg, "Tcp").
NM was inconsistent, with most long acronyms using initial caps only
(Adsl, Cdma, Dcb, Gsm, Olpc, Vlan), but others using all caps (DHCP,
PPP, PPPOE, VPN). Fix libnm and src/ to use initial-caps only for all
three-or-more-letter-long acronyms (and update nmcli and nmtui for the
libnm changes).
2014-06-26 17:44:36 +00:00
|
|
|
nm_setting_vpn_add_secret (NMSettingVpn *setting,
|
2014-07-24 12:53:33 +00:00
|
|
|
const char *key,
|
|
|
|
const char *secret)
|
|
|
|
{
|
|
|
|
g_return_if_fail (NM_IS_SETTING_VPN (setting));
|
|
|
|
g_return_if_fail (key != NULL);
|
|
|
|
g_return_if_fail (strlen (key) > 0);
|
|
|
|
g_return_if_fail (secret != NULL);
|
|
|
|
g_return_if_fail (strlen (secret) > 0);
|
|
|
|
|
|
|
|
g_hash_table_insert (NM_SETTING_VPN_GET_PRIVATE (setting)->secrets,
|
|
|
|
g_strdup (key), g_strdup (secret));
|
|
|
|
g_object_notify (G_OBJECT (setting), NM_SETTING_VPN_SECRETS);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* nm_setting_vpn_get_secret:
|
libnm, core, cli, tui: fix the capitalization of various types
GLib/Gtk have mostly settled on the convention that two-letter
acronyms in type names remain all-caps (eg, "IO"), but longer acronyms
become initial-caps-only (eg, "Tcp").
NM was inconsistent, with most long acronyms using initial caps only
(Adsl, Cdma, Dcb, Gsm, Olpc, Vlan), but others using all caps (DHCP,
PPP, PPPOE, VPN). Fix libnm and src/ to use initial-caps only for all
three-or-more-letter-long acronyms (and update nmcli and nmtui for the
libnm changes).
2014-06-26 17:44:36 +00:00
|
|
|
* @setting: the #NMSettingVpn
|
2014-07-24 12:53:33 +00:00
|
|
|
* @key: the name of the secret to retrieve
|
|
|
|
*
|
|
|
|
* Retrieves the secret of a key/value relationship previously established
|
|
|
|
* by nm_setting_vpn_add_secret().
|
|
|
|
*
|
|
|
|
* Returns: the secret, if any
|
|
|
|
**/
|
|
|
|
const char *
|
libnm, core, cli, tui: fix the capitalization of various types
GLib/Gtk have mostly settled on the convention that two-letter
acronyms in type names remain all-caps (eg, "IO"), but longer acronyms
become initial-caps-only (eg, "Tcp").
NM was inconsistent, with most long acronyms using initial caps only
(Adsl, Cdma, Dcb, Gsm, Olpc, Vlan), but others using all caps (DHCP,
PPP, PPPOE, VPN). Fix libnm and src/ to use initial-caps only for all
three-or-more-letter-long acronyms (and update nmcli and nmtui for the
libnm changes).
2014-06-26 17:44:36 +00:00
|
|
|
nm_setting_vpn_get_secret (NMSettingVpn *setting, const char *key)
|
2014-07-24 12:53:33 +00:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_VPN (setting), NULL);
|
|
|
|
|
|
|
|
return (const char *) g_hash_table_lookup (NM_SETTING_VPN_GET_PRIVATE (setting)->secrets, key);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* nm_setting_vpn_remove_secret:
|
libnm, core, cli, tui: fix the capitalization of various types
GLib/Gtk have mostly settled on the convention that two-letter
acronyms in type names remain all-caps (eg, "IO"), but longer acronyms
become initial-caps-only (eg, "Tcp").
NM was inconsistent, with most long acronyms using initial caps only
(Adsl, Cdma, Dcb, Gsm, Olpc, Vlan), but others using all caps (DHCP,
PPP, PPPOE, VPN). Fix libnm and src/ to use initial-caps only for all
three-or-more-letter-long acronyms (and update nmcli and nmtui for the
libnm changes).
2014-06-26 17:44:36 +00:00
|
|
|
* @setting: the #NMSettingVpn
|
2014-07-24 12:53:33 +00:00
|
|
|
* @key: the name of the secret to remove
|
|
|
|
*
|
|
|
|
* Deletes a key/value relationship previously established by
|
|
|
|
* nm_setting_vpn_add_secret().
|
|
|
|
*
|
|
|
|
* Returns: %TRUE if the secret was found and removed from the internal list,
|
|
|
|
* %FALSE if it was not.
|
|
|
|
**/
|
|
|
|
gboolean
|
libnm, core, cli, tui: fix the capitalization of various types
GLib/Gtk have mostly settled on the convention that two-letter
acronyms in type names remain all-caps (eg, "IO"), but longer acronyms
become initial-caps-only (eg, "Tcp").
NM was inconsistent, with most long acronyms using initial caps only
(Adsl, Cdma, Dcb, Gsm, Olpc, Vlan), but others using all caps (DHCP,
PPP, PPPOE, VPN). Fix libnm and src/ to use initial-caps only for all
three-or-more-letter-long acronyms (and update nmcli and nmtui for the
libnm changes).
2014-06-26 17:44:36 +00:00
|
|
|
nm_setting_vpn_remove_secret (NMSettingVpn *setting, const char *key)
|
2014-07-24 12:53:33 +00:00
|
|
|
{
|
|
|
|
gboolean found;
|
|
|
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_VPN (setting), FALSE);
|
|
|
|
|
|
|
|
found = g_hash_table_remove (NM_SETTING_VPN_GET_PRIVATE (setting)->secrets, key);
|
|
|
|
if (found)
|
|
|
|
g_object_notify (G_OBJECT (setting), NM_SETTING_VPN_SECRETS);
|
|
|
|
return found;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* nm_setting_vpn_foreach_secret:
|
libnm, core, cli, tui: fix the capitalization of various types
GLib/Gtk have mostly settled on the convention that two-letter
acronyms in type names remain all-caps (eg, "IO"), but longer acronyms
become initial-caps-only (eg, "Tcp").
NM was inconsistent, with most long acronyms using initial caps only
(Adsl, Cdma, Dcb, Gsm, Olpc, Vlan), but others using all caps (DHCP,
PPP, PPPOE, VPN). Fix libnm and src/ to use initial-caps only for all
three-or-more-letter-long acronyms (and update nmcli and nmtui for the
libnm changes).
2014-06-26 17:44:36 +00:00
|
|
|
* @setting: a #NMSettingVpn
|
2014-07-24 12:53:33 +00:00
|
|
|
* @func: (scope call): an user provided function
|
|
|
|
* @user_data: data to be passed to @func
|
|
|
|
*
|
|
|
|
* Iterates all secrets stored in this setting. It is safe to add, remove,
|
|
|
|
* and modify secrets inside @func, though any additions or removals made during
|
|
|
|
* iteration will not be part of the iteration.
|
|
|
|
*/
|
|
|
|
void
|
libnm, core, cli, tui: fix the capitalization of various types
GLib/Gtk have mostly settled on the convention that two-letter
acronyms in type names remain all-caps (eg, "IO"), but longer acronyms
become initial-caps-only (eg, "Tcp").
NM was inconsistent, with most long acronyms using initial caps only
(Adsl, Cdma, Dcb, Gsm, Olpc, Vlan), but others using all caps (DHCP,
PPP, PPPOE, VPN). Fix libnm and src/ to use initial-caps only for all
three-or-more-letter-long acronyms (and update nmcli and nmtui for the
libnm changes).
2014-06-26 17:44:36 +00:00
|
|
|
nm_setting_vpn_foreach_secret (NMSettingVpn *setting,
|
|
|
|
NMVpnIterFunc func,
|
2014-07-24 12:53:33 +00:00
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
g_return_if_fail (NM_IS_SETTING_VPN (setting));
|
|
|
|
|
|
|
|
foreach_item_helper (NM_SETTING_VPN_GET_PRIVATE (setting)->secrets, func, user_data);
|
|
|
|
}
|
|
|
|
|
2015-09-16 07:34:33 +00:00
|
|
|
/**
|
|
|
|
* nm_setting_vpn_get_timeout:
|
|
|
|
* @setting: the #NMSettingVpn
|
|
|
|
*
|
|
|
|
* Returns: the #NMSettingVpn:timeout property of the setting
|
|
|
|
*
|
|
|
|
* Since: 1.2
|
|
|
|
**/
|
|
|
|
guint32
|
|
|
|
nm_setting_vpn_get_timeout (NMSettingVpn *setting)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_VPN (setting), 0);
|
|
|
|
|
|
|
|
return NM_SETTING_VPN_GET_PRIVATE (setting)->timeout;
|
|
|
|
}
|
|
|
|
|
2014-07-24 12:53:33 +00:00
|
|
|
static gboolean
|
2014-10-22 02:30:31 +00:00
|
|
|
verify (NMSetting *setting, NMConnection *connection, GError **error)
|
2014-07-24 12:53:33 +00:00
|
|
|
{
|
libnm, core, cli, tui: fix the capitalization of various types
GLib/Gtk have mostly settled on the convention that two-letter
acronyms in type names remain all-caps (eg, "IO"), but longer acronyms
become initial-caps-only (eg, "Tcp").
NM was inconsistent, with most long acronyms using initial caps only
(Adsl, Cdma, Dcb, Gsm, Olpc, Vlan), but others using all caps (DHCP,
PPP, PPPOE, VPN). Fix libnm and src/ to use initial-caps only for all
three-or-more-letter-long acronyms (and update nmcli and nmtui for the
libnm changes).
2014-06-26 17:44:36 +00:00
|
|
|
NMSettingVpnPrivate *priv = NM_SETTING_VPN_GET_PRIVATE (setting);
|
2014-07-24 12:53:33 +00:00
|
|
|
|
|
|
|
if (!priv->service_type) {
|
|
|
|
g_set_error_literal (error,
|
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 17:52:23 +00:00
|
|
|
NM_CONNECTION_ERROR,
|
|
|
|
NM_CONNECTION_ERROR_MISSING_PROPERTY,
|
2014-07-24 12:53:33 +00:00
|
|
|
_("property is missing"));
|
|
|
|
g_prefix_error (error, "%s.%s: ", NM_SETTING_VPN_SETTING_NAME, NM_SETTING_VPN_SERVICE_TYPE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!strlen (priv->service_type)) {
|
|
|
|
g_set_error_literal (error,
|
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 17:52:23 +00:00
|
|
|
NM_CONNECTION_ERROR,
|
|
|
|
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
2014-07-24 12:53:33 +00:00
|
|
|
_("property is empty"));
|
|
|
|
g_prefix_error (error, "%s.%s: ", NM_SETTING_VPN_SETTING_NAME, NM_SETTING_VPN_SERVICE_TYPE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* default username can be NULL, but can't be zero-length */
|
|
|
|
if (priv->user_name && !strlen (priv->user_name)) {
|
|
|
|
g_set_error_literal (error,
|
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 17:52:23 +00:00
|
|
|
NM_CONNECTION_ERROR,
|
|
|
|
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
2014-07-24 12:53:33 +00:00
|
|
|
_("property is empty"));
|
|
|
|
g_prefix_error (error, "%s.%s: ", NM_SETTING_VPN_SETTING_NAME, NM_SETTING_VPN_USER_NAME);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static NMSettingUpdateSecretResult
|
|
|
|
update_secret_string (NMSetting *setting,
|
|
|
|
const char *key,
|
|
|
|
const char *value,
|
|
|
|
GError **error)
|
|
|
|
{
|
libnm, core, cli, tui: fix the capitalization of various types
GLib/Gtk have mostly settled on the convention that two-letter
acronyms in type names remain all-caps (eg, "IO"), but longer acronyms
become initial-caps-only (eg, "Tcp").
NM was inconsistent, with most long acronyms using initial caps only
(Adsl, Cdma, Dcb, Gsm, Olpc, Vlan), but others using all caps (DHCP,
PPP, PPPOE, VPN). Fix libnm and src/ to use initial-caps only for all
three-or-more-letter-long acronyms (and update nmcli and nmtui for the
libnm changes).
2014-06-26 17:44:36 +00:00
|
|
|
NMSettingVpnPrivate *priv = NM_SETTING_VPN_GET_PRIVATE (setting);
|
2014-07-24 12:53:33 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (key != NULL, NM_SETTING_UPDATE_SECRET_ERROR);
|
|
|
|
g_return_val_if_fail (value != NULL, NM_SETTING_UPDATE_SECRET_ERROR);
|
|
|
|
|
|
|
|
if (!value || !strlen (value)) {
|
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 17:52:23 +00:00
|
|
|
g_set_error (error, NM_CONNECTION_ERROR,
|
|
|
|
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
|
|
|
_("secret was empty"));
|
|
|
|
g_prefix_error (error, "%s.%s: ", NM_SETTING_VPN_SETTING_NAME, key);
|
2014-07-24 12:53:33 +00:00
|
|
|
return NM_SETTING_UPDATE_SECRET_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (g_strcmp0 (g_hash_table_lookup (priv->secrets, key), value) == 0)
|
|
|
|
return NM_SETTING_UPDATE_SECRET_SUCCESS_UNCHANGED;
|
|
|
|
|
|
|
|
g_hash_table_insert (priv->secrets, g_strdup (key), g_strdup (value));
|
|
|
|
return NM_SETTING_UPDATE_SECRET_SUCCESS_MODIFIED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static NMSettingUpdateSecretResult
|
2014-08-16 14:09:48 +00:00
|
|
|
update_secret_dict (NMSetting *setting,
|
|
|
|
GVariant *secrets,
|
2014-07-24 12:53:33 +00:00
|
|
|
GError **error)
|
|
|
|
{
|
libnm, core, cli, tui: fix the capitalization of various types
GLib/Gtk have mostly settled on the convention that two-letter
acronyms in type names remain all-caps (eg, "IO"), but longer acronyms
become initial-caps-only (eg, "Tcp").
NM was inconsistent, with most long acronyms using initial caps only
(Adsl, Cdma, Dcb, Gsm, Olpc, Vlan), but others using all caps (DHCP,
PPP, PPPOE, VPN). Fix libnm and src/ to use initial-caps only for all
three-or-more-letter-long acronyms (and update nmcli and nmtui for the
libnm changes).
2014-06-26 17:44:36 +00:00
|
|
|
NMSettingVpnPrivate *priv = NM_SETTING_VPN_GET_PRIVATE (setting);
|
2014-08-16 14:09:48 +00:00
|
|
|
GVariantIter iter;
|
2014-07-24 12:53:33 +00:00
|
|
|
const char *name, *value;
|
|
|
|
NMSettingUpdateSecretResult result = NM_SETTING_UPDATE_SECRET_SUCCESS_UNCHANGED;
|
|
|
|
|
|
|
|
g_return_val_if_fail (secrets != NULL, NM_SETTING_UPDATE_SECRET_ERROR);
|
|
|
|
|
|
|
|
/* Make sure the items are valid */
|
2014-08-16 14:09:48 +00:00
|
|
|
g_variant_iter_init (&iter, secrets);
|
|
|
|
while (g_variant_iter_next (&iter, "{&s&s}", &name, &value)) {
|
2014-07-24 12:53:33 +00:00
|
|
|
if (!name || !strlen (name)) {
|
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 17:52:23 +00:00
|
|
|
g_set_error_literal (error, NM_CONNECTION_ERROR,
|
|
|
|
NM_CONNECTION_ERROR_INVALID_SETTING,
|
|
|
|
_("setting contained a secret with an empty name"));
|
|
|
|
g_prefix_error (error, "%s: ", NM_SETTING_VPN_SETTING_NAME);
|
2014-07-24 12:53:33 +00:00
|
|
|
return NM_SETTING_UPDATE_SECRET_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!value || !strlen (value)) {
|
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 17:52:23 +00:00
|
|
|
g_set_error (error, NM_CONNECTION_ERROR,
|
|
|
|
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
|
|
|
_("secret value was empty"));
|
|
|
|
g_prefix_error (error, "%s.%s: ", NM_SETTING_VPN_SETTING_NAME, name);
|
2014-07-24 12:53:33 +00:00
|
|
|
return NM_SETTING_UPDATE_SECRET_ERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now add the items to the settings' secrets list */
|
2014-08-16 14:09:48 +00:00
|
|
|
g_variant_iter_init (&iter, secrets);
|
|
|
|
while (g_variant_iter_next (&iter, "{&s&s}", &name, &value)) {
|
2014-07-24 12:53:33 +00:00
|
|
|
if (value == NULL) {
|
|
|
|
g_warn_if_fail (value != NULL);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (strlen (value) == 0) {
|
|
|
|
g_warn_if_fail (strlen (value) > 0);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (g_strcmp0 (g_hash_table_lookup (priv->secrets, name), value) == 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
g_hash_table_insert (priv->secrets, g_strdup (name), g_strdup (value));
|
|
|
|
result = NM_SETTING_UPDATE_SECRET_SUCCESS_MODIFIED;
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2014-08-16 14:09:48 +00:00
|
|
|
update_one_secret (NMSetting *setting, const char *key, GVariant *value, GError **error)
|
2014-07-24 12:53:33 +00:00
|
|
|
{
|
|
|
|
NMSettingUpdateSecretResult success = NM_SETTING_UPDATE_SECRET_ERROR;
|
|
|
|
|
|
|
|
g_return_val_if_fail (key != NULL, NM_SETTING_UPDATE_SECRET_ERROR);
|
|
|
|
g_return_val_if_fail (value != NULL, NM_SETTING_UPDATE_SECRET_ERROR);
|
|
|
|
|
2014-08-16 14:09:48 +00:00
|
|
|
if (g_variant_is_of_type (value, G_VARIANT_TYPE_STRING)) {
|
2014-07-24 12:53:33 +00:00
|
|
|
/* Passing the string properties individually isn't correct, and won't
|
|
|
|
* produce the correct result, but for some reason that's how it used
|
|
|
|
* to be done. So even though it's not correct, keep the code around
|
|
|
|
* for compatibility's sake.
|
|
|
|
*/
|
2014-08-16 14:09:48 +00:00
|
|
|
success = update_secret_string (setting, key, g_variant_get_string (value, NULL), error);
|
|
|
|
} else if (g_variant_is_of_type (value, G_VARIANT_TYPE ("a{ss}"))) {
|
2014-07-24 12:53:33 +00:00
|
|
|
if (strcmp (key, NM_SETTING_VPN_SECRETS) != 0) {
|
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 17:52:23 +00: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_VPN_SETTING_NAME, key);
|
2014-07-24 12:53:33 +00:00
|
|
|
} else
|
2014-08-16 14:09:48 +00:00
|
|
|
success = update_secret_dict (setting, value, error);
|
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 17:52:23 +00:00
|
|
|
} else {
|
|
|
|
g_set_error_literal (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
|
|
|
_("secret is not of correct type"));
|
|
|
|
g_prefix_error (error, "%s.%s: ", NM_SETTING_VPN_SETTING_NAME, key);
|
|
|
|
}
|
2014-07-24 12:53:33 +00:00
|
|
|
|
|
|
|
if (success == NM_SETTING_UPDATE_SECRET_SUCCESS_MODIFIED)
|
|
|
|
g_object_notify (G_OBJECT (setting), NM_SETTING_VPN_SECRETS);
|
|
|
|
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
get_secret_flags (NMSetting *setting,
|
|
|
|
const char *secret_name,
|
|
|
|
gboolean verify_secret,
|
|
|
|
NMSettingSecretFlags *out_flags,
|
|
|
|
GError **error)
|
|
|
|
{
|
libnm, core, cli, tui: fix the capitalization of various types
GLib/Gtk have mostly settled on the convention that two-letter
acronyms in type names remain all-caps (eg, "IO"), but longer acronyms
become initial-caps-only (eg, "Tcp").
NM was inconsistent, with most long acronyms using initial caps only
(Adsl, Cdma, Dcb, Gsm, Olpc, Vlan), but others using all caps (DHCP,
PPP, PPPOE, VPN). Fix libnm and src/ to use initial-caps only for all
three-or-more-letter-long acronyms (and update nmcli and nmtui for the
libnm changes).
2014-06-26 17:44:36 +00:00
|
|
|
NMSettingVpnPrivate *priv = NM_SETTING_VPN_GET_PRIVATE (setting);
|
2016-07-19 12:41:40 +00:00
|
|
|
gs_free char *flags_key = NULL;
|
2014-07-24 12:53:33 +00:00
|
|
|
gpointer val;
|
|
|
|
unsigned long tmp;
|
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 16:03:01 +00:00
|
|
|
NMSettingSecretFlags flags = NM_SETTING_SECRET_FLAG_NONE;
|
2014-07-24 12:53:33 +00:00
|
|
|
|
|
|
|
flags_key = g_strdup_printf ("%s-flags", secret_name);
|
|
|
|
if (g_hash_table_lookup_extended (priv->data, flags_key, NULL, &val)) {
|
|
|
|
errno = 0;
|
|
|
|
tmp = strtoul ((const char *) val, NULL, 10);
|
2016-07-19 12:41:40 +00:00
|
|
|
if ((errno != 0) || (tmp > NM_SETTING_SECRET_FLAGS_ALL)) {
|
2014-07-24 12:53:33 +00:00
|
|
|
g_set_error (error,
|
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 17:52:23 +00:00
|
|
|
NM_CONNECTION_ERROR,
|
|
|
|
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
|
|
|
_("failed to convert value '%s' to uint"),
|
|
|
|
(const char *) val);
|
|
|
|
g_prefix_error (error, "%s.%s: ", NM_SETTING_VPN_SETTING_NAME, flags_key);
|
2016-07-19 12:41:40 +00:00
|
|
|
return FALSE;
|
2014-07-24 12:53:33 +00:00
|
|
|
}
|
2016-07-19 12:41:40 +00:00
|
|
|
flags = (NMSettingSecretFlags) tmp;
|
2014-07-24 12:53:33 +00:00
|
|
|
}
|
2016-07-19 12:41:40 +00:00
|
|
|
|
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 16:03:01 +00:00
|
|
|
if (out_flags)
|
|
|
|
*out_flags = flags;
|
2016-07-19 12:41:40 +00:00
|
|
|
return TRUE;
|
2014-07-24 12:53:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
set_secret_flags (NMSetting *setting,
|
|
|
|
const char *secret_name,
|
|
|
|
gboolean verify_secret,
|
|
|
|
NMSettingSecretFlags flags,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
g_hash_table_insert (NM_SETTING_VPN_GET_PRIVATE (setting)->data,
|
|
|
|
g_strdup_printf ("%s-flags", secret_name),
|
|
|
|
g_strdup_printf ("%u", flags));
|
|
|
|
g_object_notify (G_OBJECT (setting), NM_SETTING_VPN_SECRETS);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GPtrArray *
|
|
|
|
need_secrets (NMSetting *setting)
|
|
|
|
{
|
|
|
|
/* Assume that VPN connections need secrets since they almost always will */
|
|
|
|
return g_ptr_array_sized_new (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
libnm, core, cli, tui: fix the capitalization of various types
GLib/Gtk have mostly settled on the convention that two-letter
acronyms in type names remain all-caps (eg, "IO"), but longer acronyms
become initial-caps-only (eg, "Tcp").
NM was inconsistent, with most long acronyms using initial caps only
(Adsl, Cdma, Dcb, Gsm, Olpc, Vlan), but others using all caps (DHCP,
PPP, PPPOE, VPN). Fix libnm and src/ to use initial-caps only for all
three-or-more-letter-long acronyms (and update nmcli and nmtui for the
libnm changes).
2014-06-26 17:44:36 +00:00
|
|
|
compare_one_secret (NMSettingVpn *a,
|
|
|
|
NMSettingVpn *b,
|
2014-07-24 12:53:33 +00:00
|
|
|
NMSettingCompareFlags flags)
|
|
|
|
{
|
|
|
|
GHashTable *a_secrets, *b_secrets;
|
|
|
|
GHashTableIter iter;
|
|
|
|
const char *key, *val;
|
|
|
|
|
|
|
|
a_secrets = NM_SETTING_VPN_GET_PRIVATE (a)->secrets;
|
|
|
|
b_secrets = NM_SETTING_VPN_GET_PRIVATE (b)->secrets;
|
|
|
|
|
|
|
|
g_hash_table_iter_init (&iter, a_secrets);
|
|
|
|
while (g_hash_table_iter_next (&iter, (gpointer) &key, (gpointer) &val)) {
|
|
|
|
NMSettingSecretFlags a_secret_flags = NM_SETTING_SECRET_FLAG_NONE;
|
|
|
|
NMSettingSecretFlags b_secret_flags = NM_SETTING_SECRET_FLAG_NONE;
|
|
|
|
|
|
|
|
nm_setting_get_secret_flags (NM_SETTING (a), key, &a_secret_flags, NULL);
|
|
|
|
nm_setting_get_secret_flags (NM_SETTING (b), key, &b_secret_flags, NULL);
|
|
|
|
|
|
|
|
/* If the secret flags aren't the same, the settings aren't the same */
|
|
|
|
if (a_secret_flags != b_secret_flags)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if ( (flags & NM_SETTING_COMPARE_FLAG_IGNORE_AGENT_OWNED_SECRETS)
|
|
|
|
&& (a_secret_flags & NM_SETTING_SECRET_FLAG_AGENT_OWNED))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if ( (flags & NM_SETTING_COMPARE_FLAG_IGNORE_NOT_SAVED_SECRETS)
|
|
|
|
&& (a_secret_flags & NM_SETTING_SECRET_FLAG_NOT_SAVED))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* Now compare the values themselves */
|
|
|
|
if (g_strcmp0 (val, nm_setting_vpn_get_secret (b, key)) != 0)
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
compare_property (NMSetting *setting,
|
|
|
|
NMSetting *other,
|
|
|
|
const GParamSpec *prop_spec,
|
|
|
|
NMSettingCompareFlags flags)
|
|
|
|
{
|
|
|
|
gboolean same;
|
|
|
|
|
|
|
|
/* We only need to treat the 'secrets' property specially */
|
|
|
|
if (g_strcmp0 (prop_spec->name, NM_SETTING_VPN_SECRETS) != 0)
|
|
|
|
return NM_SETTING_CLASS (nm_setting_vpn_parent_class)->compare_property (setting, other, prop_spec, flags);
|
|
|
|
|
|
|
|
/* Compare A to B to ensure everything in A is found in B */
|
|
|
|
same = compare_one_secret (NM_SETTING_VPN (setting), NM_SETTING_VPN (other), flags);
|
|
|
|
if (same) {
|
|
|
|
/* And then B to A to ensure everything in B is also found in A */
|
|
|
|
same = compare_one_secret (NM_SETTING_VPN (other), NM_SETTING_VPN (setting), flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
return same;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
clear_secrets_with_flags (NMSetting *setting,
|
|
|
|
GParamSpec *pspec,
|
|
|
|
NMSettingClearSecretsWithFlagsFn func,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
libnm, core, cli, tui: fix the capitalization of various types
GLib/Gtk have mostly settled on the convention that two-letter
acronyms in type names remain all-caps (eg, "IO"), but longer acronyms
become initial-caps-only (eg, "Tcp").
NM was inconsistent, with most long acronyms using initial caps only
(Adsl, Cdma, Dcb, Gsm, Olpc, Vlan), but others using all caps (DHCP,
PPP, PPPOE, VPN). Fix libnm and src/ to use initial-caps only for all
three-or-more-letter-long acronyms (and update nmcli and nmtui for the
libnm changes).
2014-06-26 17:44:36 +00:00
|
|
|
NMSettingVpnPrivate *priv = NM_SETTING_VPN_GET_PRIVATE (setting);
|
2014-07-24 12:53:33 +00:00
|
|
|
GHashTableIter iter;
|
|
|
|
const char *secret;
|
|
|
|
gboolean changed = TRUE;
|
|
|
|
|
|
|
|
if (priv->secrets == NULL)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
/* Iterate through secrets hash and check each entry */
|
|
|
|
g_hash_table_iter_init (&iter, priv->secrets);
|
|
|
|
while (g_hash_table_iter_next (&iter, (gpointer) &secret, NULL)) {
|
|
|
|
NMSettingSecretFlags flags = NM_SETTING_SECRET_FLAG_NONE;
|
|
|
|
|
|
|
|
nm_setting_get_secret_flags (setting, secret, &flags, NULL);
|
|
|
|
if (func (setting, pspec->name, flags, user_data) == TRUE) {
|
|
|
|
g_hash_table_iter_remove (&iter);
|
|
|
|
changed = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (changed)
|
|
|
|
g_object_notify (G_OBJECT (setting), NM_SETTING_VPN_SECRETS);
|
|
|
|
|
|
|
|
return changed;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
destroy_one_secret (gpointer data)
|
|
|
|
{
|
|
|
|
char *secret = (char *) data;
|
|
|
|
|
|
|
|
/* Don't leave the secret lying around in memory */
|
|
|
|
memset (secret, 0, strlen (secret));
|
|
|
|
g_free (secret);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
libnm, core, cli, tui: fix the capitalization of various types
GLib/Gtk have mostly settled on the convention that two-letter
acronyms in type names remain all-caps (eg, "IO"), but longer acronyms
become initial-caps-only (eg, "Tcp").
NM was inconsistent, with most long acronyms using initial caps only
(Adsl, Cdma, Dcb, Gsm, Olpc, Vlan), but others using all caps (DHCP,
PPP, PPPOE, VPN). Fix libnm and src/ to use initial-caps only for all
three-or-more-letter-long acronyms (and update nmcli and nmtui for the
libnm changes).
2014-06-26 17:44:36 +00:00
|
|
|
nm_setting_vpn_init (NMSettingVpn *setting)
|
2014-07-24 12:53:33 +00:00
|
|
|
{
|
libnm, core, cli, tui: fix the capitalization of various types
GLib/Gtk have mostly settled on the convention that two-letter
acronyms in type names remain all-caps (eg, "IO"), but longer acronyms
become initial-caps-only (eg, "Tcp").
NM was inconsistent, with most long acronyms using initial caps only
(Adsl, Cdma, Dcb, Gsm, Olpc, Vlan), but others using all caps (DHCP,
PPP, PPPOE, VPN). Fix libnm and src/ to use initial-caps only for all
three-or-more-letter-long acronyms (and update nmcli and nmtui for the
libnm changes).
2014-06-26 17:44:36 +00:00
|
|
|
NMSettingVpnPrivate *priv = NM_SETTING_VPN_GET_PRIVATE (setting);
|
2014-07-24 12:53:33 +00:00
|
|
|
|
|
|
|
priv->data = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
|
|
|
|
priv->secrets = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, destroy_one_secret);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
finalize (GObject *object)
|
|
|
|
{
|
libnm, core, cli, tui: fix the capitalization of various types
GLib/Gtk have mostly settled on the convention that two-letter
acronyms in type names remain all-caps (eg, "IO"), but longer acronyms
become initial-caps-only (eg, "Tcp").
NM was inconsistent, with most long acronyms using initial caps only
(Adsl, Cdma, Dcb, Gsm, Olpc, Vlan), but others using all caps (DHCP,
PPP, PPPOE, VPN). Fix libnm and src/ to use initial-caps only for all
three-or-more-letter-long acronyms (and update nmcli and nmtui for the
libnm changes).
2014-06-26 17:44:36 +00:00
|
|
|
NMSettingVpnPrivate *priv = NM_SETTING_VPN_GET_PRIVATE (object);
|
2014-07-24 12:53:33 +00:00
|
|
|
|
|
|
|
g_free (priv->service_type);
|
|
|
|
g_free (priv->user_name);
|
|
|
|
g_hash_table_destroy (priv->data);
|
|
|
|
g_hash_table_destroy (priv->secrets);
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (nm_setting_vpn_parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
set_property (GObject *object, guint prop_id,
|
|
|
|
const GValue *value, GParamSpec *pspec)
|
|
|
|
{
|
libnm, core, cli, tui: fix the capitalization of various types
GLib/Gtk have mostly settled on the convention that two-letter
acronyms in type names remain all-caps (eg, "IO"), but longer acronyms
become initial-caps-only (eg, "Tcp").
NM was inconsistent, with most long acronyms using initial caps only
(Adsl, Cdma, Dcb, Gsm, Olpc, Vlan), but others using all caps (DHCP,
PPP, PPPOE, VPN). Fix libnm and src/ to use initial-caps only for all
three-or-more-letter-long acronyms (and update nmcli and nmtui for the
libnm changes).
2014-06-26 17:44:36 +00:00
|
|
|
NMSettingVpnPrivate *priv = NM_SETTING_VPN_GET_PRIVATE (object);
|
2014-07-24 12:53:33 +00:00
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
case PROP_SERVICE_TYPE:
|
|
|
|
g_free (priv->service_type);
|
|
|
|
priv->service_type = g_value_dup_string (value);
|
|
|
|
break;
|
|
|
|
case PROP_USER_NAME:
|
|
|
|
g_free (priv->user_name);
|
|
|
|
priv->user_name = g_value_dup_string (value);
|
|
|
|
break;
|
2014-10-17 01:09:38 +00:00
|
|
|
case PROP_PERSISTENT:
|
|
|
|
priv->persistent = g_value_get_boolean (value);
|
|
|
|
break;
|
2014-07-24 12:53:33 +00:00
|
|
|
case PROP_DATA:
|
2014-06-24 21:40:08 +00:00
|
|
|
g_hash_table_unref (priv->data);
|
|
|
|
priv->data = _nm_utils_copy_strdict (g_value_get_boxed (value));
|
2014-07-24 12:53:33 +00:00
|
|
|
break;
|
|
|
|
case PROP_SECRETS:
|
2014-06-24 21:40:08 +00:00
|
|
|
g_hash_table_unref (priv->secrets);
|
|
|
|
priv->secrets = _nm_utils_copy_strdict (g_value_get_boxed (value));
|
2014-07-24 12:53:33 +00:00
|
|
|
break;
|
2015-09-16 07:34:33 +00:00
|
|
|
case PROP_TIMEOUT:
|
|
|
|
priv->timeout = g_value_get_uint (value);
|
|
|
|
break;
|
2014-07-24 12:53:33 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
get_property (GObject *object, guint prop_id,
|
|
|
|
GValue *value, GParamSpec *pspec)
|
|
|
|
{
|
libnm, core, cli, tui: fix the capitalization of various types
GLib/Gtk have mostly settled on the convention that two-letter
acronyms in type names remain all-caps (eg, "IO"), but longer acronyms
become initial-caps-only (eg, "Tcp").
NM was inconsistent, with most long acronyms using initial caps only
(Adsl, Cdma, Dcb, Gsm, Olpc, Vlan), but others using all caps (DHCP,
PPP, PPPOE, VPN). Fix libnm and src/ to use initial-caps only for all
three-or-more-letter-long acronyms (and update nmcli and nmtui for the
libnm changes).
2014-06-26 17:44:36 +00:00
|
|
|
NMSettingVpn *setting = NM_SETTING_VPN (object);
|
|
|
|
NMSettingVpnPrivate *priv = NM_SETTING_VPN_GET_PRIVATE (setting);
|
2014-07-24 12:53:33 +00:00
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
case PROP_SERVICE_TYPE:
|
|
|
|
g_value_set_string (value, nm_setting_vpn_get_service_type (setting));
|
|
|
|
break;
|
|
|
|
case PROP_USER_NAME:
|
|
|
|
g_value_set_string (value, nm_setting_vpn_get_user_name (setting));
|
|
|
|
break;
|
2014-10-17 01:09:38 +00:00
|
|
|
case PROP_PERSISTENT:
|
|
|
|
g_value_set_boolean (value, priv->persistent);
|
|
|
|
break;
|
2014-07-24 12:53:33 +00:00
|
|
|
case PROP_DATA:
|
2014-06-24 21:40:08 +00:00
|
|
|
g_value_take_boxed (value, _nm_utils_copy_strdict (priv->data));
|
2014-07-24 12:53:33 +00:00
|
|
|
break;
|
|
|
|
case PROP_SECRETS:
|
2014-06-24 21:40:08 +00:00
|
|
|
g_value_take_boxed (value, _nm_utils_copy_strdict (priv->secrets));
|
2014-07-24 12:53:33 +00:00
|
|
|
break;
|
2015-09-16 07:34:33 +00:00
|
|
|
case PROP_TIMEOUT:
|
|
|
|
g_value_set_uint (value, nm_setting_vpn_get_timeout (setting));
|
|
|
|
break;
|
2014-07-24 12:53:33 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
libnm, core, cli, tui: fix the capitalization of various types
GLib/Gtk have mostly settled on the convention that two-letter
acronyms in type names remain all-caps (eg, "IO"), but longer acronyms
become initial-caps-only (eg, "Tcp").
NM was inconsistent, with most long acronyms using initial caps only
(Adsl, Cdma, Dcb, Gsm, Olpc, Vlan), but others using all caps (DHCP,
PPP, PPPOE, VPN). Fix libnm and src/ to use initial-caps only for all
three-or-more-letter-long acronyms (and update nmcli and nmtui for the
libnm changes).
2014-06-26 17:44:36 +00:00
|
|
|
nm_setting_vpn_class_init (NMSettingVpnClass *setting_class)
|
2014-07-24 12:53:33 +00:00
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (setting_class);
|
|
|
|
NMSettingClass *parent_class = NM_SETTING_CLASS (setting_class);
|
|
|
|
|
libnm, core, cli, tui: fix the capitalization of various types
GLib/Gtk have mostly settled on the convention that two-letter
acronyms in type names remain all-caps (eg, "IO"), but longer acronyms
become initial-caps-only (eg, "Tcp").
NM was inconsistent, with most long acronyms using initial caps only
(Adsl, Cdma, Dcb, Gsm, Olpc, Vlan), but others using all caps (DHCP,
PPP, PPPOE, VPN). Fix libnm and src/ to use initial-caps only for all
three-or-more-letter-long acronyms (and update nmcli and nmtui for the
libnm changes).
2014-06-26 17:44:36 +00:00
|
|
|
g_type_class_add_private (setting_class, sizeof (NMSettingVpnPrivate));
|
2014-07-24 12:53:33 +00:00
|
|
|
|
|
|
|
/* virtual methods */
|
|
|
|
object_class->set_property = set_property;
|
|
|
|
object_class->get_property = get_property;
|
|
|
|
object_class->finalize = finalize;
|
|
|
|
|
|
|
|
parent_class->verify = verify;
|
|
|
|
parent_class->update_one_secret = update_one_secret;
|
|
|
|
parent_class->get_secret_flags = get_secret_flags;
|
|
|
|
parent_class->set_secret_flags = set_secret_flags;
|
|
|
|
parent_class->need_secrets = need_secrets;
|
|
|
|
parent_class->compare_property = compare_property;
|
|
|
|
parent_class->clear_secrets_with_flags = clear_secrets_with_flags;
|
|
|
|
|
|
|
|
/* Properties */
|
|
|
|
/**
|
libnm, core, cli, tui: fix the capitalization of various types
GLib/Gtk have mostly settled on the convention that two-letter
acronyms in type names remain all-caps (eg, "IO"), but longer acronyms
become initial-caps-only (eg, "Tcp").
NM was inconsistent, with most long acronyms using initial caps only
(Adsl, Cdma, Dcb, Gsm, Olpc, Vlan), but others using all caps (DHCP,
PPP, PPPOE, VPN). Fix libnm and src/ to use initial-caps only for all
three-or-more-letter-long acronyms (and update nmcli and nmtui for the
libnm changes).
2014-06-26 17:44:36 +00:00
|
|
|
* NMSettingVpn:service-type:
|
2014-07-24 12:53:33 +00:00
|
|
|
*
|
|
|
|
* D-Bus service name of the VPN plugin that this setting uses to connect to
|
|
|
|
* its network. i.e. org.freedesktop.NetworkManager.vpnc for the vpnc
|
|
|
|
* plugin.
|
|
|
|
**/
|
|
|
|
g_object_class_install_property
|
|
|
|
(object_class, PROP_SERVICE_TYPE,
|
|
|
|
g_param_spec_string (NM_SETTING_VPN_SERVICE_TYPE, "", "",
|
|
|
|
NULL,
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
|
|
|
|
|
|
|
/**
|
libnm, core, cli, tui: fix the capitalization of various types
GLib/Gtk have mostly settled on the convention that two-letter
acronyms in type names remain all-caps (eg, "IO"), but longer acronyms
become initial-caps-only (eg, "Tcp").
NM was inconsistent, with most long acronyms using initial caps only
(Adsl, Cdma, Dcb, Gsm, Olpc, Vlan), but others using all caps (DHCP,
PPP, PPPOE, VPN). Fix libnm and src/ to use initial-caps only for all
three-or-more-letter-long acronyms (and update nmcli and nmtui for the
libnm changes).
2014-06-26 17:44:36 +00:00
|
|
|
* NMSettingVpn:user-name:
|
2014-07-24 12:53:33 +00:00
|
|
|
*
|
|
|
|
* If the VPN connection requires a user name for authentication, that name
|
|
|
|
* should be provided here. If the connection is available to more than one
|
|
|
|
* user, and the VPN requires each user to supply a different name, then
|
|
|
|
* leave this property empty. If this property is empty, NetworkManager
|
|
|
|
* will automatically supply the username of the user which requested the
|
|
|
|
* VPN connection.
|
|
|
|
**/
|
|
|
|
g_object_class_install_property
|
|
|
|
(object_class, PROP_USER_NAME,
|
|
|
|
g_param_spec_string (NM_SETTING_VPN_USER_NAME, "", "",
|
|
|
|
NULL,
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
|
|
|
|
2014-10-17 01:09:38 +00:00
|
|
|
/**
|
|
|
|
* NMSettingVpn:persistent:
|
|
|
|
*
|
|
|
|
* If the VPN service supports persistence, and this property is %TRUE,
|
|
|
|
* the VPN will attempt to stay connected across link changes and outages,
|
|
|
|
* until explicitly disconnected.
|
|
|
|
**/
|
|
|
|
g_object_class_install_property
|
|
|
|
(object_class, PROP_PERSISTENT,
|
|
|
|
g_param_spec_boolean (NM_SETTING_VPN_PERSISTENT, "", "",
|
|
|
|
FALSE,
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
|
|
|
|
2014-07-24 12:53:33 +00:00
|
|
|
/**
|
libnm, core, cli, tui: fix the capitalization of various types
GLib/Gtk have mostly settled on the convention that two-letter
acronyms in type names remain all-caps (eg, "IO"), but longer acronyms
become initial-caps-only (eg, "Tcp").
NM was inconsistent, with most long acronyms using initial caps only
(Adsl, Cdma, Dcb, Gsm, Olpc, Vlan), but others using all caps (DHCP,
PPP, PPPOE, VPN). Fix libnm and src/ to use initial-caps only for all
three-or-more-letter-long acronyms (and update nmcli and nmtui for the
libnm changes).
2014-06-26 17:44:36 +00:00
|
|
|
* NMSettingVpn:data:
|
2014-07-24 12:53:33 +00:00
|
|
|
*
|
|
|
|
* Dictionary of key/value pairs of VPN plugin specific data. Both keys and
|
|
|
|
* values must be strings.
|
2014-06-24 21:40:08 +00:00
|
|
|
*
|
|
|
|
* Type: GHashTable(utf8,utf8)
|
2014-07-24 12:53:33 +00:00
|
|
|
**/
|
libnm, libnm-util: move settings doc generation to libnm-core
Move the settings/plugins doc generation from libnm-util to
libnm-core, since libnm-util isn't being updated for all new
properties.
With this commit, the keyfile and ifcfg-rh documentation is basically
unchanged, except that deprecated properties are now gone, and new
properties have been added, and the sections are in a different order.
(generate-plugin-docs.pl just outputs the settings in Makefile order,
and they were unsorted in libnm-util, but are sorted in libnm-core).
The settings documentation used for nm-settings.5, the D-Bus API docs,
and the nmcli help is changed a bit more at this point, and mostly for
the worse, since the libnm-core setting properties don't match up with
the D-Bus API as well as the libnm-util ones do. To be fixed...
(I also removed the "plugins docs" line in each plugin docs comment
block while moving them, since those blocks will be used for more than
just plugins soon, and it's sort of obvious anyway.)
2014-10-28 13:58:25 +00:00
|
|
|
/* ---keyfile---
|
|
|
|
* property: data
|
|
|
|
* variable: separate variables named after keys of the dictionary
|
|
|
|
* description: The keys of the data dictionary are used as variable names directly
|
|
|
|
* under [vpn] section.
|
|
|
|
* example: remote=ovpn.corp.com cipher=AES-256-CBC username=joe
|
|
|
|
* ---end---
|
|
|
|
*/
|
2014-07-24 12:53:33 +00:00
|
|
|
g_object_class_install_property
|
|
|
|
(object_class, PROP_DATA,
|
2014-07-29 13:22:07 +00:00
|
|
|
g_param_spec_boxed (NM_SETTING_VPN_DATA, "", "",
|
2014-06-24 21:40:08 +00:00
|
|
|
G_TYPE_HASH_TABLE,
|
2014-07-29 13:22:07 +00:00
|
|
|
G_PARAM_READWRITE |
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
2014-06-24 21:40:08 +00:00
|
|
|
_nm_setting_class_transform_property (parent_class, NM_SETTING_VPN_DATA,
|
2014-08-16 14:09:48 +00:00
|
|
|
G_VARIANT_TYPE ("a{ss}"),
|
2014-06-24 21:40:08 +00:00
|
|
|
_nm_utils_strdict_to_dbus,
|
|
|
|
_nm_utils_strdict_from_dbus);
|
2014-07-24 12:53:33 +00:00
|
|
|
|
|
|
|
/**
|
libnm, core, cli, tui: fix the capitalization of various types
GLib/Gtk have mostly settled on the convention that two-letter
acronyms in type names remain all-caps (eg, "IO"), but longer acronyms
become initial-caps-only (eg, "Tcp").
NM was inconsistent, with most long acronyms using initial caps only
(Adsl, Cdma, Dcb, Gsm, Olpc, Vlan), but others using all caps (DHCP,
PPP, PPPOE, VPN). Fix libnm and src/ to use initial-caps only for all
three-or-more-letter-long acronyms (and update nmcli and nmtui for the
libnm changes).
2014-06-26 17:44:36 +00:00
|
|
|
* NMSettingVpn:secrets:
|
2014-07-24 12:53:33 +00:00
|
|
|
*
|
|
|
|
* Dictionary of key/value pairs of VPN plugin specific secrets like
|
|
|
|
* passwords or private keys. Both keys and values must be strings.
|
2014-06-24 21:40:08 +00:00
|
|
|
*
|
|
|
|
* Type: GHashTable(utf8,utf8)
|
2014-07-24 12:53:33 +00:00
|
|
|
**/
|
libnm, libnm-util: move settings doc generation to libnm-core
Move the settings/plugins doc generation from libnm-util to
libnm-core, since libnm-util isn't being updated for all new
properties.
With this commit, the keyfile and ifcfg-rh documentation is basically
unchanged, except that deprecated properties are now gone, and new
properties have been added, and the sections are in a different order.
(generate-plugin-docs.pl just outputs the settings in Makefile order,
and they were unsorted in libnm-util, but are sorted in libnm-core).
The settings documentation used for nm-settings.5, the D-Bus API docs,
and the nmcli help is changed a bit more at this point, and mostly for
the worse, since the libnm-core setting properties don't match up with
the D-Bus API as well as the libnm-util ones do. To be fixed...
(I also removed the "plugins docs" line in each plugin docs comment
block while moving them, since those blocks will be used for more than
just plugins soon, and it's sort of obvious anyway.)
2014-10-28 13:58:25 +00:00
|
|
|
/* ---keyfile---
|
|
|
|
* property: secrets
|
|
|
|
* variable: separate variables named after keys of the dictionary
|
|
|
|
* description: The keys of the secrets dictionary are used as variable names directly
|
|
|
|
* under [vpn-secrets] section.
|
|
|
|
* example: password=Popocatepetl
|
|
|
|
* ---end---
|
|
|
|
*/
|
2014-07-24 12:53:33 +00:00
|
|
|
g_object_class_install_property
|
|
|
|
(object_class, PROP_SECRETS,
|
2014-07-29 13:22:07 +00:00
|
|
|
g_param_spec_boxed (NM_SETTING_VPN_SECRETS, "", "",
|
2014-06-24 21:40:08 +00:00
|
|
|
G_TYPE_HASH_TABLE,
|
2014-07-29 13:22:07 +00:00
|
|
|
G_PARAM_READWRITE |
|
|
|
|
NM_SETTING_PARAM_SECRET |
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
2014-06-24 21:40:08 +00:00
|
|
|
_nm_setting_class_transform_property (parent_class, NM_SETTING_VPN_SECRETS,
|
2014-08-16 14:09:48 +00:00
|
|
|
G_VARIANT_TYPE ("a{ss}"),
|
2014-06-24 21:40:08 +00:00
|
|
|
_nm_utils_strdict_to_dbus,
|
|
|
|
_nm_utils_strdict_from_dbus);
|
2015-09-16 07:34:33 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* NMSettingVpn:timeout:
|
|
|
|
*
|
|
|
|
* Timeout for the VPN service to establish the connection. Some services
|
|
|
|
* may take quite a long time to connect.
|
|
|
|
* Value of 0 means a default timeout, which is 60 seconds (unless overriden
|
|
|
|
* by vpn.timeout in configuration file). Values greater than zero mean
|
|
|
|
* timeout in seconds.
|
|
|
|
*
|
|
|
|
* Since: 1.2
|
|
|
|
**/
|
|
|
|
g_object_class_install_property
|
|
|
|
(object_class, PROP_TIMEOUT,
|
|
|
|
g_param_spec_uint (NM_SETTING_VPN_TIMEOUT, "", "",
|
|
|
|
0, G_MAXUINT32, 0,
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
2014-07-24 12:53:33 +00:00
|
|
|
}
|