diff options
| author | Michael Biebl <biebl@debian.org> | 2011-10-28 23:04:16 +0200 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2011-10-28 23:04:16 +0200 |
| commit | 485d149fe80915d94ed49ea6c2c0552cf7a3e79a (patch) | |
| tree | 6a48492b46b8c1e3df1c58626c28f05a978c61f7 /libnm-util | |
| parent | 263bf4c0c89bb88dc995acd9a6a2de9095fbd461 (diff) | |
Imported Upstream version 0.9.1.95 upstream/0.9.1.95
Diffstat (limited to 'libnm-util')
| -rw-r--r-- | libnm-util/Makefile.am | 2 | ||||
| -rw-r--r-- | libnm-util/Makefile.in | 10 | ||||
| -rw-r--r-- | libnm-util/libnm-util.ver | 3 | ||||
| -rw-r--r-- | libnm-util/nm-connection.c | 90 | ||||
| -rw-r--r-- | libnm-util/nm-connection.h | 6 | ||||
| -rw-r--r-- | libnm-util/nm-param-spec-specialized.c | 7 | ||||
| -rw-r--r-- | libnm-util/nm-setting-gsm.c | 2 | ||||
| -rw-r--r-- | libnm-util/nm-setting-serial.c | 5 | ||||
| -rw-r--r-- | libnm-util/nm-setting-vpn.c | 25 | ||||
| -rw-r--r-- | libnm-util/nm-setting.c | 59 | ||||
| -rw-r--r-- | libnm-util/nm-setting.h | 26 | ||||
| -rw-r--r-- | libnm-util/nm-utils.c | 10 | ||||
| -rw-r--r-- | libnm-util/tests/Makefile.in | 8 | ||||
| -rw-r--r-- | libnm-util/tests/certs/Makefile.in | 8 |
14 files changed, 235 insertions, 26 deletions
diff --git a/libnm-util/Makefile.am b/libnm-util/Makefile.am index 0a29e9c5..1327565a 100644 --- a/libnm-util/Makefile.am +++ b/libnm-util/Makefile.am @@ -69,7 +69,7 @@ libnm_util_la_LIBADD = $(GLIB_LIBS) $(DBUS_LIBS) $(UUID_LIBS) SYMBOL_VIS_FILE=$(srcdir)/libnm-util.ver libnm_util_la_LDFLAGS = -Wl,--version-script=$(SYMBOL_VIS_FILE) \ - -version-info "2:0:0" + -version-info "4:0:2" if WITH_GNUTLS libnm_util_la_SOURCES += crypto_gnutls.c diff --git a/libnm-util/Makefile.in b/libnm-util/Makefile.in index d251ea8c..188b0a5e 100644 --- a/libnm-util/Makefile.in +++ b/libnm-util/Makefile.in @@ -314,8 +314,16 @@ LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ LIBICONV = @LIBICONV@ LIBINTL = @LIBINTL@ LIBM = @LIBM@ +LIBNL1_CFLAGS = @LIBNL1_CFLAGS@ +LIBNL1_LIBS = @LIBNL1_LIBS@ +LIBNL2_CFLAGS = @LIBNL2_CFLAGS@ +LIBNL2_LIBS = @LIBNL2_LIBS@ +LIBNL3_CFLAGS = @LIBNL3_CFLAGS@ +LIBNL3_LIBS = @LIBNL3_LIBS@ LIBNL_CFLAGS = @LIBNL_CFLAGS@ LIBNL_LIBS = @LIBNL_LIBS@ +LIBNL_ROUTE3_CFLAGS = @LIBNL_ROUTE3_CFLAGS@ +LIBNL_ROUTE3_LIBS = @LIBNL_ROUTE3_LIBS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ @@ -492,7 +500,7 @@ libnm_util_la_LIBADD = $(GLIB_LIBS) $(DBUS_LIBS) $(UUID_LIBS) \ $(am__append_3) $(am__append_6) SYMBOL_VIS_FILE = $(srcdir)/libnm-util.ver libnm_util_la_LDFLAGS = -Wl,--version-script=$(SYMBOL_VIS_FILE) \ - -version-info "2:0:0" + -version-info "4:0:2" libnm_util_includedir = $(includedir)/NetworkManager diff --git a/libnm-util/libnm-util.ver b/libnm-util/libnm-util.ver index 6052c275..53c2482e 100644 --- a/libnm-util/libnm-util.ver +++ b/libnm-util/libnm-util.ver @@ -2,6 +2,7 @@ global: nm_connection_add_setting; nm_connection_clear_secrets; + nm_connection_clear_secrets_with_flags; nm_connection_compare; nm_connection_create_setting; nm_connection_diff; @@ -31,6 +32,7 @@ global: nm_connection_get_setting_wireless_security; nm_connection_get_type; nm_connection_get_uuid; + nm_connection_is_type; nm_connection_lookup_setting_type; nm_connection_lookup_setting_type_by_quark; nm_connection_need_secrets; @@ -174,6 +176,7 @@ global: nm_setting_cdma_get_username; nm_setting_cdma_new; nm_setting_clear_secrets; + nm_setting_clear_secrets_with_flags; nm_setting_compare; nm_setting_connection_add_permission; nm_setting_connection_error_get_type; diff --git a/libnm-util/nm-connection.c b/libnm-util/nm-connection.c index 91fc3afa..cdc3b81f 100644 --- a/libnm-util/nm-connection.c +++ b/libnm-util/nm-connection.c @@ -127,7 +127,7 @@ enum { enum { SECRETS_UPDATED, - + SECRETS_CLEARED, LAST_SIGNAL }; @@ -950,12 +950,6 @@ nm_connection_need_secrets (NMConnection *connection, return name; } -static void -clear_setting_secrets (gpointer key, gpointer data, gpointer user_data) -{ - nm_setting_clear_secrets (NM_SETTING (data)); -} - /** * nm_connection_clear_secrets: * @connection: the #NMConnection @@ -966,12 +960,42 @@ clear_setting_secrets (gpointer key, gpointer data, gpointer user_data) void nm_connection_clear_secrets (NMConnection *connection) { - NMConnectionPrivate *priv; + GHashTableIter iter; + NMSetting *setting; g_return_if_fail (NM_IS_CONNECTION (connection)); - priv = NM_CONNECTION_GET_PRIVATE (connection); - g_hash_table_foreach (priv->settings, clear_setting_secrets, NULL); + g_hash_table_iter_init (&iter, NM_CONNECTION_GET_PRIVATE (connection)->settings); + while (g_hash_table_iter_next (&iter, NULL, (gpointer) &setting)) + nm_setting_clear_secrets (setting); + + g_signal_emit (connection, signals[SECRETS_CLEARED], 0); +} + +/** + * nm_connection_clear_secrets_with_flags: + * @connection: the #NMConnection + * @func: (scope call): function to be called to determine whether a + * specific secret should be cleared or not + * @user_data: caller-supplied data passed to @func + * + * Clears and frees secrets determined by @func. + **/ +void +nm_connection_clear_secrets_with_flags (NMConnection *connection, + NMSettingClearSecretsWithFlagsFn func, + gpointer user_data) +{ + GHashTableIter iter; + NMSetting *setting; + + g_return_if_fail (NM_IS_CONNECTION (connection)); + + g_hash_table_iter_init (&iter, NM_CONNECTION_GET_PRIVATE (connection)->settings); + while (g_hash_table_iter_next (&iter, NULL, (gpointer) &setting)) + nm_setting_clear_secrets_with_flags (setting, func, user_data); + + g_signal_emit (connection, signals[SECRETS_CLEARED], 0); } /** @@ -1027,6 +1051,37 @@ nm_connection_to_hash (NMConnection *connection, NMSettingHashFlags flags) } /** + * nm_connection_is_type: + * @connection: the #NMConnection + * @type: a setting name to check the connection's type against (like + * %NM_SETTING_WIRELESS_SETTING_NAME or %NM_SETTING_WIRED_SETTING_NAME) + * + * A convenience function to check if the given @connection is a particular + * type (ie wired, wifi, ppp, etc). Checks the #NMSettingConnection:type + * property of the connection and matches that against @type. + * + * Returns: %TRUE if the connection is of the given @type, %FALSE if not + **/ +gboolean +nm_connection_is_type (NMConnection *connection, const char *type) +{ + NMSettingConnection *s_con; + const char *type2; + + g_return_val_if_fail (connection != NULL, FALSE); + g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE); + g_return_val_if_fail (type != NULL, FALSE); + + s_con = nm_connection_get_setting_connection (connection); + g_assert (s_con); + + type2 = nm_setting_connection_get_connection_type (s_con); + g_assert (type2); + + return !strcmp (type2, type); +} + +/** * nm_connection_for_each_setting_value: * @connection: the #NMConnection * @func: (scope call): user-supplied function called for each setting's property @@ -1609,5 +1664,20 @@ nm_connection_class_init (NMConnectionClass *klass) g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING); + + /** + * NMConnection::secrets-cleared: + * @connection: the object on which the signal is emitted + * + * The ::secrets-cleared signal is emitted when the secrets of a connection + * are cleared. + */ + signals[SECRETS_CLEARED] = + g_signal_new ("secrets-cleared", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + 0, NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); } diff --git a/libnm-util/nm-connection.h b/libnm-util/nm-connection.h index 3cd18747..069dc84c 100644 --- a/libnm-util/nm-connection.h +++ b/libnm-util/nm-connection.h @@ -147,6 +147,10 @@ const char * nm_connection_need_secrets (NMConnection *connection, void nm_connection_clear_secrets (NMConnection *connection); +void nm_connection_clear_secrets_with_flags (NMConnection *connection, + NMSettingClearSecretsWithFlagsFn func, + gpointer user_data); + gboolean nm_connection_update_secrets (NMConnection *connection, const char *setting_name, GHashTable *secrets, @@ -157,6 +161,8 @@ void nm_connection_set_path (NMConnection *connection, const char * nm_connection_get_path (NMConnection *connection); +gboolean nm_connection_is_type (NMConnection *connection, const char *type); + void nm_connection_for_each_setting_value (NMConnection *connection, NMSettingValueIterFn func, gpointer user_data); diff --git a/libnm-util/nm-param-spec-specialized.c b/libnm-util/nm-param-spec-specialized.c index 7e921bca..82ec6a40 100644 --- a/libnm-util/nm-param-spec-specialized.c +++ b/libnm-util/nm-param-spec-specialized.c @@ -19,11 +19,12 @@ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301 USA. * - * (C) Copyright 2007 - 2010 Red Hat, Inc. + * (C) Copyright 2007 - 2011 Red Hat, Inc. * (C) Copyright 2007 - 2008 Novell, Inc. */ #include "nm-param-spec-specialized.h" +#include "nm-glib-compat.h" struct _NMParamSpecSpecialized { GParamSpec parent; @@ -92,8 +93,8 @@ _gvalues_compare_fixed (const GValue *value1, const GValue *value2) switch (G_VALUE_TYPE (value1)) { case G_TYPE_CHAR: { - gchar val1 = g_value_get_char (value1); - gchar val2 = g_value_get_char (value2); + gchar val1 = g_value_get_schar (value1); + gchar val2 = g_value_get_schar (value2); if (val1 != val2) ret = val1 < val2 ? -1 : val1 > val2; break; diff --git a/libnm-util/nm-setting-gsm.c b/libnm-util/nm-setting-gsm.c index 7033541b..80d3fd31 100644 --- a/libnm-util/nm-setting-gsm.c +++ b/libnm-util/nm-setting-gsm.c @@ -768,7 +768,7 @@ nm_setting_gsm_class_init (NMSettingGsmClass *setting_class) g_object_class_install_property (object_class, PROP_HOME_ONLY, g_param_spec_boolean (NM_SETTING_GSM_HOME_ONLY, - "PIN", + "Home Only", "When TRUE, only connections to the home network will " "be allowed. Connections to roaming networks will " "not be made.", diff --git a/libnm-util/nm-setting-serial.c b/libnm-util/nm-setting-serial.c index 7ed15e9e..24e6253e 100644 --- a/libnm-util/nm-setting-serial.c +++ b/libnm-util/nm-setting-serial.c @@ -26,6 +26,7 @@ #include <string.h> #include "nm-setting-serial.h" +#include "nm-glib-compat.h" /** * SECTION:nm-setting-serial @@ -214,7 +215,7 @@ set_property (GObject *object, guint prop_id, priv->bits = g_value_get_uint (value); break; case PROP_PARITY: - priv->parity = g_value_get_char (value); + priv->parity = g_value_get_schar (value); break; case PROP_STOPBITS: priv->stopbits = g_value_get_uint (value); @@ -242,7 +243,7 @@ get_property (GObject *object, guint prop_id, g_value_set_uint (value, nm_setting_serial_get_bits (setting)); break; case PROP_PARITY: - g_value_set_char (value, nm_setting_serial_get_parity (setting)); + g_value_set_schar (value, nm_setting_serial_get_parity (setting)); break; case PROP_STOPBITS: g_value_set_uint (value, nm_setting_serial_get_stopbits (setting)); diff --git a/libnm-util/nm-setting-vpn.c b/libnm-util/nm-setting-vpn.c index 50091cb9..755c1a45 100644 --- a/libnm-util/nm-setting-vpn.c +++ b/libnm-util/nm-setting-vpn.c @@ -612,6 +612,30 @@ compare_property (NMSetting *setting, } static void +clear_secrets_with_flags (NMSetting *setting, + GParamSpec *pspec, + NMSettingClearSecretsWithFlagsFn func, + gpointer user_data) +{ + NMSettingVPNPrivate *priv = NM_SETTING_VPN_GET_PRIVATE (setting); + GHashTableIter iter; + const char *secret; + + if (priv->secrets == NULL) + return; + + /* 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); + } +} + +static void destroy_one_secret (gpointer data) { char *secret = (char *) data; @@ -733,6 +757,7 @@ nm_setting_vpn_class_init (NMSettingVPNClass *setting_class) 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 */ /** diff --git a/libnm-util/nm-setting.c b/libnm-util/nm-setting.c index 3573f888..2b3bdc58 100644 --- a/libnm-util/nm-setting.c +++ b/libnm-util/nm-setting.c @@ -308,8 +308,8 @@ nm_setting_get_name (NMSetting *setting) /** * nm_setting_verify: * @setting: the #NMSetting to verify - * @all_settings: a #GSList of all settings in the connection from which @setting - * came + * @all_settings: (element-type NMSetting): a #GSList of all settings + * in the connection from which @setting came * @error: location to store error, or %NULL * * Validates the setting. Each setting's properties have allowed values, and @@ -648,6 +648,60 @@ nm_setting_clear_secrets (NMSetting *setting) g_free (property_specs); } +static void +clear_secrets_with_flags (NMSetting *setting, + GParamSpec *pspec, + NMSettingClearSecretsWithFlagsFn func, + gpointer user_data) +{ + GValue value = { 0 }; + NMSettingSecretFlags flags = NM_SETTING_SECRET_FLAG_NONE; + + /* Clear the secret if the user function says to do so */ + nm_setting_get_secret_flags (setting, pspec->name, &flags, NULL); + if (func (setting, pspec->name, flags, user_data) == TRUE) { + g_value_init (&value, pspec->value_type); + g_param_value_set_default (pspec, &value); + g_object_set_property (G_OBJECT (setting), pspec->name, &value); + g_value_unset (&value); + } +} + +/** + * nm_setting_clear_secrets_with_flags: + * @setting: the #NMSetting + * @func: (scope call): function to be called to determine whether a + * specific secret should be cleared or not + * @user_data: caller-supplied data passed to @func + * + * Clears and frees secrets determined by @func. + **/ +void +nm_setting_clear_secrets_with_flags (NMSetting *setting, + NMSettingClearSecretsWithFlagsFn func, + gpointer user_data) +{ + GParamSpec **property_specs; + guint n_property_specs; + guint i; + + g_return_if_fail (setting); + g_return_if_fail (NM_IS_SETTING (setting)); + g_return_if_fail (func != NULL); + + property_specs = g_object_class_list_properties (G_OBJECT_GET_CLASS (setting), &n_property_specs); + for (i = 0; i < n_property_specs; i++) { + if (property_specs[i]->flags & NM_SETTING_PARAM_SECRET) { + NM_SETTING_GET_CLASS (setting)->clear_secrets_with_flags (setting, + property_specs[i], + func, + user_data); + } + } + + g_free (property_specs); +} + /** * nm_setting_need_secrets: * @setting: the #NMSetting @@ -1029,6 +1083,7 @@ nm_setting_class_init (NMSettingClass *setting_class) setting_class->get_secret_flags = get_secret_flags; setting_class->set_secret_flags = set_secret_flags; setting_class->compare_property = compare_property; + setting_class->clear_secrets_with_flags = clear_secrets_with_flags; /* Properties */ diff --git a/libnm-util/nm-setting.h b/libnm-util/nm-setting.h index e21efd81..3edf2a1f 100644 --- a/libnm-util/nm-setting.h +++ b/libnm-util/nm-setting.h @@ -150,6 +150,21 @@ typedef struct { GObject parent; } NMSetting; + +/** + * NMSettingClearSecretsWithFlagsFn: + * @setting: The setting for which secrets are being iterated + * @secret: The secret's name + * @flags: The secret's flags, eg %NM_SETTING_SECRET_FLAG_AGENT_OWNED + * @user_data: User data passed to nm_connection_clear_secrets_with_flags() + * + * Returns: %TRUE to clear the secret, %FALSE to not clear the secret + */ +typedef gboolean (*NMSettingClearSecretsWithFlagsFn) (NMSetting *setting, + const char *secret, + NMSettingSecretFlags flags, + gpointer user_data); + typedef struct { GObjectClass parent; @@ -183,10 +198,14 @@ typedef struct { const GParamSpec *prop_spec, NMSettingCompareFlags flags); + void (*clear_secrets_with_flags) (NMSetting *setting, + GParamSpec *pspec, + NMSettingClearSecretsWithFlagsFn func, + gpointer user_data); + /* Padding for future expansion */ void (*_reserved1) (void); void (*_reserved2) (void); - void (*_reserved3) (void); } NMSettingClass; /** @@ -269,6 +288,11 @@ char *nm_setting_to_string (NMSetting *setting); /* Secrets */ void nm_setting_clear_secrets (NMSetting *setting); + +void nm_setting_clear_secrets_with_flags (NMSetting *setting, + NMSettingClearSecretsWithFlagsFn func, + gpointer user_data); + GPtrArray *nm_setting_need_secrets (NMSetting *setting); gboolean nm_setting_update_secrets (NMSetting *setting, GHashTable *secrets, diff --git a/libnm-util/nm-utils.c b/libnm-util/nm-utils.c index d8bcf349..9d4418e4 100644 --- a/libnm-util/nm-utils.c +++ b/libnm-util/nm-utils.c @@ -490,7 +490,7 @@ nm_utils_gvalue_hash_dup (GHashTable *hash) } /** - * nm_utils_slist_free: + * nm_utils_slist_free: (skip) * @list: a #GSList * @elem_destroy_fn: user function called for each element in @list * @@ -1373,7 +1373,7 @@ nm_utils_ip4_addresses_from_gvalue (const GValue *value) /** * nm_utils_ip4_addresses_to_gvalue: - * @list: a list of #NMIP4Address objects + * @list: (element-type NMIP4Address): a list of #NMIP4Address objects * @value: a pointer to a #GValue into which to place the converted addresses, * which should be unset by the caller (when no longer needed) with * g_value_unset(). @@ -1456,7 +1456,7 @@ nm_utils_ip4_routes_from_gvalue (const GValue *value) /** * nm_utils_ip4_routes_to_gvalue: - * @list: a list of #NMIP4Route objects + * @list: (element-type NMIP4Route): a list of #NMIP4Route objects * @value: a pointer to a #GValue into which to place the converted routes, * which should be unset by the caller (when no longer needed) with * g_value_unset(). @@ -1664,7 +1664,7 @@ nm_utils_ip6_addresses_from_gvalue (const GValue *value) /** * nm_utils_ip6_addresses_to_gvalue: - * @list: a list of #NMIP6Address objects + * @list: (element-type NMIP6Address): a list of #NMIP6Address objects * @value: a pointer to a #GValue into which to place the converted addresses, * which should be unset by the caller (when no longer needed) with * g_value_unset(). @@ -1786,7 +1786,7 @@ nm_utils_ip6_routes_from_gvalue (const GValue *value) /** * nm_utils_ip6_routes_to_gvalue: - * @list: a list of #NMIP6Route objects + * @list: (element-type NMIP6Route): a list of #NMIP6Route objects * @value: a pointer to a #GValue into which to place the converted routes, * which should be unset by the caller (when no longer needed) with * g_value_unset(). diff --git a/libnm-util/tests/Makefile.in b/libnm-util/tests/Makefile.in index c4919ffc..b8aa1791 100644 --- a/libnm-util/tests/Makefile.in +++ b/libnm-util/tests/Makefile.in @@ -250,8 +250,16 @@ LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ LIBICONV = @LIBICONV@ LIBINTL = @LIBINTL@ LIBM = @LIBM@ +LIBNL1_CFLAGS = @LIBNL1_CFLAGS@ +LIBNL1_LIBS = @LIBNL1_LIBS@ +LIBNL2_CFLAGS = @LIBNL2_CFLAGS@ +LIBNL2_LIBS = @LIBNL2_LIBS@ +LIBNL3_CFLAGS = @LIBNL3_CFLAGS@ +LIBNL3_LIBS = @LIBNL3_LIBS@ LIBNL_CFLAGS = @LIBNL_CFLAGS@ LIBNL_LIBS = @LIBNL_LIBS@ +LIBNL_ROUTE3_CFLAGS = @LIBNL_ROUTE3_CFLAGS@ +LIBNL_ROUTE3_LIBS = @LIBNL_ROUTE3_LIBS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ diff --git a/libnm-util/tests/certs/Makefile.in b/libnm-util/tests/certs/Makefile.in index 5149078b..b0fbee9e 100644 --- a/libnm-util/tests/certs/Makefile.in +++ b/libnm-util/tests/certs/Makefile.in @@ -161,8 +161,16 @@ LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ LIBICONV = @LIBICONV@ LIBINTL = @LIBINTL@ LIBM = @LIBM@ +LIBNL1_CFLAGS = @LIBNL1_CFLAGS@ +LIBNL1_LIBS = @LIBNL1_LIBS@ +LIBNL2_CFLAGS = @LIBNL2_CFLAGS@ +LIBNL2_LIBS = @LIBNL2_LIBS@ +LIBNL3_CFLAGS = @LIBNL3_CFLAGS@ +LIBNL3_LIBS = @LIBNL3_LIBS@ LIBNL_CFLAGS = @LIBNL_CFLAGS@ LIBNL_LIBS = @LIBNL_LIBS@ +LIBNL_ROUTE3_CFLAGS = @LIBNL_ROUTE3_CFLAGS@ +LIBNL_ROUTE3_LIBS = @LIBNL_ROUTE3_LIBS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ |