diff options
| author | Michael Biebl <biebl@debian.org> | 2018-06-04 00:08:31 +0200 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2018-06-04 00:08:31 +0200 |
| commit | 0dd9df69fdbd475c48a0c8d5b0a1882550fe7321 (patch) | |
| tree | 249cf25643b1fe408e10679bb61613bc6540e894 /libnm-core | |
| parent | 2e94a3b93171ab3fb95bf689aab1664d23988809 (diff) | |
| parent | 04bc9e1cd3544445d883ad29ea108c1645c8e7b7 (diff) | |
Update upstream source from tag 'upstream/1.11.4'
Update to upstream version '1.11.4' with Debian dir d0638aa2e32d5bae4e8daa021b9a66b7c4d6647e
Diffstat (limited to 'libnm-core')
42 files changed, 307 insertions, 213 deletions
diff --git a/libnm-core/meson.build b/libnm-core/meson.build index bba84406..7b143706 100644 --- a/libnm-core/meson.build +++ b/libnm-core/meson.build @@ -131,17 +131,19 @@ deps = [ dl_dep, libudev_dep, shared_dep, - uuid_dep + uuid_dep, + shared_c_siphash_dep, ] cflags = [ '-DG_LOG_DOMAIN="@0@"'.format(libnm_name), '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIBNM_CORE', '-DLIBEXECDIR="@0@"'.format(nm_libexecdir), - '-DLOCALEDIR="@0@"'.format(nm_localedir), + '-DNMLOCALEDIR="@0@"'.format(nm_localedir), '-DNMCONFDIR="@0@"'.format(nm_pkgconfdir), '-DNMLIBDIR="@0@"'.format(nm_pkglibdir), - '-DNMPLUGINDIR="@0@"'.format(nm_pkglibdir) + '-DNMPLUGINDIR="@0@"'.format(nm_plugindir), + '-DNMVPNDIR="@0@"'.format(nm_vpndir) ] if enable_json_validation @@ -149,9 +151,15 @@ if enable_json_validation deps += jansson_dep endif +libnm_core_sources_all = libnm_core_sources +libnm_core_sources_all += libnm_core_enum +libnm_core_sources_all += shared_nm_utils_nm_meta_setting_c +libnm_core_sources_all += shared_files_libnm_core +libnm_core_sources_all += [version_header] + libnm_core = static_library( 'nm-core', - sources: libnm_core_sources + libnm_core_enum + shared_sources + [version_header], + sources: libnm_core_sources_all, dependencies: deps, c_args: cflags ) @@ -159,7 +167,10 @@ libnm_core = static_library( nm_core_dep = declare_dependency( sources: libnm_core_enum[1], include_directories: libnm_core_inc, - dependencies: shared_dep + dependencies: [ + shared_dep, + shared_c_siphash_dep, + ], ) enums_to_docbook = join_paths(meson.source_root(), 'tools', 'enums-to-docbook.pl') diff --git a/libnm-core/nm-connection.c b/libnm-core/nm-connection.c index 868fb109..790e98b8 100644 --- a/libnm-core/nm-connection.c +++ b/libnm-core/nm-connection.c @@ -515,7 +515,6 @@ nm_connection_compare (NMConnection *a, return TRUE; } - static gboolean diff_one_connection (NMConnection *a, NMConnection *b, @@ -1531,7 +1530,7 @@ nm_connection_update_secrets (NMConnection *connection, g_signal_handlers_block_by_func (setting, (GCallback) setting_changed_cb, connection); success_detail = _nm_setting_update_secrets (setting, - setting_dict ? setting_dict : secrets, + setting_dict ?: secrets, error); g_signal_handlers_unblock_by_func (setting, (GCallback) setting_changed_cb, connection); diff --git a/libnm-core/nm-core-internal.h b/libnm-core/nm-core-internal.h index 7260ebfd..cace423a 100644 --- a/libnm-core/nm-core-internal.h +++ b/libnm-core/nm-core-internal.h @@ -35,7 +35,6 @@ #error Cannot use this header. #endif - #include "nm-connection.h" #include "nm-core-enum-types.h" #include "nm-setting-8021x.h" @@ -117,7 +116,6 @@ */ #define NM_SETTING_COMPARE_FLAG_NONE ((NMSettingCompareFlags) 0) - #define NM_SETTING_SECRET_FLAGS_ALL \ (NM_SETTING_SECRET_FLAG_NONE | \ NM_SETTING_SECRET_FLAG_AGENT_OWNED | \ @@ -212,6 +210,7 @@ guint8 *_nm_utils_hwaddr_aton (const char *asc, gpointer buffer, gsize buffer_le const char *nm_utils_hwaddr_ntoa_buf (gconstpointer addr, gsize addr_len, gboolean upper_case, char *buf, gsize buf_len); char *_nm_utils_bin2str (gconstpointer addr, gsize length, gboolean upper_case); +void _nm_utils_bin2str_full (gconstpointer addr, gsize length, const char delimiter, gboolean upper_case, char *out); GSList * _nm_utils_hash_values_to_slist (GHashTable *hash); diff --git a/libnm-core/nm-dbus-interface.h b/libnm-core/nm-dbus-interface.h index 6c1e97fe..ba31a379 100644 --- a/libnm-core/nm-dbus-interface.h +++ b/libnm-core/nm-dbus-interface.h @@ -296,7 +296,6 @@ typedef enum { /*< flags >*/ NM_WIFI_DEVICE_CAP_FREQ_5GHZ = 0x00000400, } NMDeviceWifiCapabilities; - /** * NM80211ApFlags: * @NM_802_11_AP_FLAGS_NONE: access point has no special capabilities @@ -832,7 +831,6 @@ typedef enum { NM_IP_TUNNEL_MODE_VTI6 = 9, } NMIPTunnelMode; - /** * NMCheckpointCreateFlags: * @NM_CHECKPOINT_CREATE_FLAG_NONE: no flags diff --git a/libnm-core/nm-dbus-utils.c b/libnm-core/nm-dbus-utils.c index ea7bf783..8389bf36 100644 --- a/libnm-core/nm-dbus-utils.c +++ b/libnm-core/nm-dbus-utils.c @@ -174,7 +174,6 @@ _nm_dbus_signal_connect_data (GDBusProxy *proxy, * Returns: the signal handler ID, as with _nm_signal_connect_data(). */ - static void typecheck_response (GVariant **response, const GVariantType *reply_type, diff --git a/libnm-core/nm-keyfile-internal.h b/libnm-core/nm-keyfile-internal.h index 157b9fe8..d6a14711 100644 --- a/libnm-core/nm-keyfile-internal.h +++ b/libnm-core/nm-keyfile-internal.h @@ -94,7 +94,6 @@ typedef struct { const char *message; } NMKeyfileReadTypeDataWarn; - NMConnection *nm_keyfile_read (GKeyFile *keyfile, const char *keyfile_name, const char *base_dir, @@ -149,7 +148,6 @@ typedef struct { NMSetting8021x *setting; } NMKeyfileWriteTypeDataCert; - GKeyFile *nm_keyfile_write (NMConnection *connection, NMKeyfileWriteHandler handler, void *user_data, @@ -165,5 +163,4 @@ gboolean _nm_keyfile_a_contains_all_in_b (GKeyFile *kf_a, GKeyFile *kf_b); gboolean _nm_keyfile_equals (GKeyFile *kf_a, GKeyFile *kf_b, gboolean consider_order); gboolean _nm_keyfile_has_values (GKeyFile *keyfile); - #endif /* __NM_KEYFILE_INTERNAL_H__ */ diff --git a/libnm-core/nm-keyfile-utils.c b/libnm-core/nm-keyfile-utils.c index dc24a5e9..5000b583 100644 --- a/libnm-core/nm-keyfile-utils.c +++ b/libnm-core/nm-keyfile-utils.c @@ -106,7 +106,7 @@ nm_keyfile_plugin_kf_set_##stype##_list (GKeyFile *kf, \ const char *alias; \ \ alias = nm_keyfile_plugin_get_alias_for_setting_name (group); \ - g_key_file_set_##stype##_list (kf, alias ? alias : group, key, list, length); \ + g_key_file_set_##stype##_list (kf, alias ?: group, key, list, length); \ } DEFINE_KF_LIST_WRAPPER(integer, gint*, gint); @@ -170,7 +170,7 @@ nm_keyfile_plugin_kf_set_##stype (GKeyFile *kf, \ const char *alias; \ \ alias = nm_keyfile_plugin_get_alias_for_setting_name (group); \ - g_key_file_set_##stype (kf, alias ? alias : group, key, value); \ + g_key_file_set_##stype (kf, alias ?: group, key, value); \ } DEFINE_KF_WRAPPER(string, gchar*, const gchar*); @@ -179,7 +179,6 @@ DEFINE_KF_WRAPPER(uint64, guint64, guint64); DEFINE_KF_WRAPPER(boolean, gboolean, gboolean); DEFINE_KF_WRAPPER(value, gchar*, const gchar*); - gchar ** nm_keyfile_plugin_kf_get_keys (GKeyFile *kf, const char *group, @@ -288,7 +287,6 @@ _nm_keyfile_a_contains_all_in_b (GKeyFile *kf_a, GKeyFile *kf_b) return TRUE; } - static gboolean _nm_keyfile_equals_ordered (GKeyFile *kf_a, GKeyFile *kf_b) { diff --git a/libnm-core/nm-keyfile.c b/libnm-core/nm-keyfile.c index 40bf89da..5c94c35c 100644 --- a/libnm-core/nm-keyfile.c +++ b/libnm-core/nm-keyfile.c @@ -112,7 +112,7 @@ setting_alias_parser (KeyfileReaderInfo *info, NMSetting *setting, const char *k if (s) { key_setting_name = nm_keyfile_plugin_get_setting_name_for_alias (s); g_object_set (G_OBJECT (setting), - key, key_setting_name ? key_setting_name : s, + key, key_setting_name ?: s, NULL); g_free (s); } @@ -313,7 +313,6 @@ read_field (char **current, const char **out_err_str, const char *characters, co #define DIGITS "0123456789" #define DELIMITERS "/;," - /* The following IPv4 and IPv6 address formats are supported: * * address (DEPRECATED) @@ -359,7 +358,7 @@ read_one_ip_address_or_route (KeyfileReaderInfo *info, gs_free char *value = NULL; gs_free char *value_orig = NULL; -#define VALUE_ORIG() (value_orig ? value_orig : (value_orig = nm_keyfile_plugin_kf_get_string (info->keyfile, setting_name, key_name, NULL))) +#define VALUE_ORIG() (value_orig ?: (value_orig = nm_keyfile_plugin_kf_get_string (info->keyfile, setting_name, key_name, NULL))) value = nm_keyfile_plugin_kf_get_string (info->keyfile, setting_name, key_name, NULL); if (!value) @@ -583,7 +582,6 @@ ip_address_or_route_parser (KeyfileReaderInfo *info, NMSetting *setting, const c gs_free IPAddrRouteBuildListData *build_list = NULL; gsize i_build_list, build_list_len = 0; - keys = nm_keyfile_plugin_kf_get_keys (info->keyfile, setting_name, &keys_len, NULL); if (keys_len == 0) @@ -1365,7 +1363,7 @@ parity_parser (KeyfileReaderInfo *info, NMSetting *setting, const char *key) default: handle_warn (info, key, NM_KEYFILE_WARN_SEVERITY_WARN, _("invalid parity value '%s'"), - str_val ? str_val : ""); + str_val ?: ""); return; } @@ -1508,7 +1506,7 @@ setting_alias_writer (KeyfileWriterInfo *info, nm_keyfile_plugin_kf_set_string (info->keyfile, nm_setting_get_name (setting), key, - alias ? alias : str); + alias ?: str); } static void diff --git a/libnm-core/nm-setting-8021x.c b/libnm-core/nm-setting-8021x.c index 98e12ca8..3b4240e6 100644 --- a/libnm-core/nm-setting-8021x.c +++ b/libnm-core/nm-setting-8021x.c @@ -1686,7 +1686,6 @@ nm_setting_802_1x_remove_phase2_altsubject_match (NMSetting8021x *setting, guint g_object_notify (G_OBJECT (setting), NM_SETTING_802_1X_PHASE2_ALTSUBJECT_MATCHES); } - /** * nm_setting_802_1x_remove_phase2_altsubject_match_by_value: * @setting: the #NMSetting8021x @@ -3060,7 +3059,6 @@ static void need_secrets_phase2 (NMSetting8021x *self, GPtrArray *secrets, gboolean phase2); - typedef void (*EAPMethodNeedSecretsFunc) (NMSetting8021x *self, GPtrArray *secrets, gboolean phase2); @@ -3126,7 +3124,6 @@ need_secrets_phase2 (NMSetting8021x *self, } } - static GPtrArray * need_secrets (NMSetting *setting) { @@ -4423,9 +4420,6 @@ nm_setting_802_1x_class_init (NMSetting8021xClass *setting_class) G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); - - - /** * NMSetting8021x:phase2-client-cert-password: * diff --git a/libnm-core/nm-setting-8021x.h b/libnm-core/nm-setting-8021x.h index e1631e2d..986d0488 100644 --- a/libnm-core/nm-setting-8021x.h +++ b/libnm-core/nm-setting-8021x.h @@ -280,7 +280,6 @@ gboolean nm_setting_802_1x_set_phase2_ca_cert (NMSetting8 NMSetting8021xCKFormat *out_format, GError **error); - NM_AVAILABLE_IN_1_8 const char * nm_setting_802_1x_get_phase2_ca_cert_password (NMSetting8021x *setting); NM_AVAILABLE_IN_1_8 diff --git a/libnm-core/nm-setting-adsl.c b/libnm-core/nm-setting-adsl.c index 8be288b6..c2eb5db4 100644 --- a/libnm-core/nm-setting-adsl.c +++ b/libnm-core/nm-setting-adsl.c @@ -206,7 +206,7 @@ verify (NMSetting *setting, NMConnection *connection, GError **error) NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY, _("'%s' is not a valid value for the property"), - priv->protocol ? priv->protocol : "(null)"); + priv->protocol ?: "(null)"); g_prefix_error (error, "%s.%s: ", NM_SETTING_ADSL_SETTING_NAME, NM_SETTING_ADSL_PROTOCOL); return FALSE; } diff --git a/libnm-core/nm-setting-connection.c b/libnm-core/nm-setting-connection.c index 40153c0f..f8f1b017 100644 --- a/libnm-core/nm-setting-connection.c +++ b/libnm-core/nm-setting-connection.c @@ -288,7 +288,6 @@ nm_setting_connection_get_connection_type (NMSettingConnection *setting) return NM_SETTING_CONNECTION_GET_PRIVATE (setting)->type; } - /** * nm_setting_connection_get_num_permissions: * @setting: the #NMSettingConnection @@ -1077,7 +1076,7 @@ verify (NMSetting *setting, NMConnection *connection, GError **error) } if ( priv->mdns < NM_SETTING_CONNECTION_MDNS_DEFAULT - || priv->mdns > NM_SETTING_CONNECTION_MDNS_RESOLVE) { + || priv->mdns > NM_SETTING_CONNECTION_MDNS_YES) { g_set_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY, @@ -1536,7 +1535,10 @@ nm_setting_connection_class_init (NMSettingConnectionClass *setting_class) /** * NMSettingConnection:stable-id: * - * Token to generate stable IDs for the connection. + * This represents the identity of the connection used for various purposes. + * It allows to configure multiple profiles to share the identity. Also, + * the stable-id can contain placeholders that are substituted dynamically and + * deterministically depending on the context. * * The stable-id is used for generating IPv6 stable private addresses * with ipv6.addr-gen-mode=stable-privacy. It is also used to seed the @@ -1544,26 +1546,28 @@ nm_setting_connection_class_init (NMSettingConnectionClass *setting_class) * and wifi.cloned-mac-address=stable. It is also used as DHCP client * identifier with ipv4.dhcp-client-id=stable. * - * Note that also the interface name of the activating connection and a - * per-host secret key is included into the address generation so that the - * same stable-id on different hosts/devices yields different addresses. - * - * If the value is unset, an ID unique for the connection is used. - * Specifying a stable-id allows multiple connections to generate the - * same addresses. Another use is to generate IDs at runtime via - * dynamic substitutions. + * Note that depending on the context where it is used, other parameters are + * also seeded into the generation algorithm. For example, a per-host key + * is commonly also included, so that different systems end up generating + * different IDs. Or with ipv6.addr-gen-mode=stable-privacy, also the device's + * name is included, so that different interfaces yield different addresses. * * The '$' character is treated special to perform dynamic substitutions - * at runtime. Currently supported are "${CONNECTION}", "${BOOT}", "${RANDOM}". - * These effectively create unique IDs per-connection, per-boot, or every time. + * at runtime. Currently supported are "${CONNECTION}", "${DEVICE}", + * "${BOOT}", "${RANDOM}". + * These effectively create unique IDs per-connection, per-device, per-boot, + * or every time. Note that "${DEVICE}" corresponds the the interface name of the + * device. * Any unrecognized patterns following '$' are treated verbatim, however * are reserved for future use. You are thus advised to avoid '$' or * escape it as "$$". - * For example, set it to "${CONNECTION}/${BOOT}" to create a unique id for - * this connection that changes with every reboot. + * For example, set it to "${CONNECTION}-${BOOT}-${DEVICE}" to create a unique id for + * this connection that changes with every reboot and differs depending on the + * interface where the profile activates. * - * Note that two connections only use the same effective id if - * their stable-id is also identical before performing dynamic substitutions. + * If the value is unset, a global connection default is consulted. If the + * value is still unset, the default is similar to "${CONNECTION}" and uses + * a unique, fixed ID for the connection. * * Since: 1.4 **/ @@ -1731,7 +1735,6 @@ nm_setting_connection_class_init (NMSettingConnectionClass *setting_class) NM_SETTING_PARAM_FUZZY_IGNORE | G_PARAM_STATIC_STRINGS)); - /** * NMSettingConnection:autoconnect-retries: * diff --git a/libnm-core/nm-setting-dcb.h b/libnm-core/nm-setting-dcb.h index d2a364a2..51a883fb 100644 --- a/libnm-core/nm-setting-dcb.h +++ b/libnm-core/nm-setting-dcb.h @@ -70,7 +70,6 @@ typedef enum { /*< flags >*/ */ #define NM_SETTING_DCB_FCOE_MODE_VN2VN "vn2vn" - /* Properties */ #define NM_SETTING_DCB_APP_FCOE_FLAGS "app-fcoe-flags" #define NM_SETTING_DCB_APP_FCOE_PRIORITY "app-fcoe-priority" diff --git a/libnm-core/nm-setting-ip-config.c b/libnm-core/nm-setting-ip-config.c index a695051f..c7f8c555 100644 --- a/libnm-core/nm-setting-ip-config.c +++ b/libnm-core/nm-setting-ip-config.c @@ -2963,24 +2963,34 @@ nm_setting_ip_config_class_init (NMSettingIPConfigClass *setting_class) /** * NMSettingIPConfig:dns-priority: * - * Intra-connection DNS priority. + * DNS servers priority. * - * The relative priority to be used when determining the order of DNS - * servers in resolv.conf. A lower value means that servers will be on top - * of the file. Zero selects the default value, which is 50 for VPNs and - * 100 for other connections. Note that the priority is to order DNS - * settings for multiple active connections. It does not disambiguate - * multiple DNS servers within the same connection profile. For that, - * just specify the DNS servers in the desired order. - * When multiple devices have configurations with the same priority, the - * one with an active default route will be preferred. - * Note that when using dns=dnsmasq the order is meaningless - * since dnsmasq forwards queries to all known servers at the same time. + * The relative priority for DNS servers specified by this setting. A lower + * value is better (higher priority). Zero selects the default value, which + * is 50 for VPNs and 100 for other connections. * - * Negative values have the special effect of excluding other configurations - * with a greater priority value; so in presence of at least a negative - * priority, only DNS servers from connections with the lowest priority - * value will be used. + * Note that the priority is to order DNS settings for multiple active + * connections. It does not disambiguate multiple DNS servers within the + * same connection profile. + * + * When using dns=default, servers with higher priority will be on top of + * resolv.conf. To prioritize a given server over another one within the + * same connection, just specify them in the desired order. When multiple + * devices have configurations with the same priority, the one with an + * active default route will be preferred. Negative values have the special + * effect of excluding other configurations with a greater priority value; + * so in presence of at least a negative priority, only DNS servers from + * connections with the lowest priority value will be used. + * + * When using a DNS resolver that supports split-DNS as dns=dnsmasq or + * dns=systemd-resolved, each connection is used to query domains in its + * search list. Queries for domains not present in any search list are + * routed through connections having the '~.' special wildcard domain, which + * is added automatically to connections with the default route (or can be + * added manually). When multiple connections specify the same domain, the + * one with the highest priority (lowest numerical value) wins. If a + * connection specifies a domain which is subdomain of another domain with a + * negative DNS priority value, the subdomain is ignored. * * Since: 1.4 **/ diff --git a/libnm-core/nm-setting-ip-config.h b/libnm-core/nm-setting-ip-config.h index 69b9a6d2..8b3c85de 100644 --- a/libnm-core/nm-setting-ip-config.h +++ b/libnm-core/nm-setting-ip-config.h @@ -72,7 +72,6 @@ void nm_ip_address_set_attribute (NMIPAddress *address, const char *name, GVariant *value); - typedef struct NMIPRoute NMIPRoute; GType nm_ip_route_get_type (void); diff --git a/libnm-core/nm-setting-ip4-config.c b/libnm-core/nm-setting-ip4-config.c index 8eadd0f7..0c668d8c 100644 --- a/libnm-core/nm-setting-ip4-config.c +++ b/libnm-core/nm-setting-ip4-config.c @@ -524,7 +524,6 @@ ip4_route_data_set (NMSetting *setting, return TRUE; } - static void nm_setting_ip4_config_class_init (NMSettingIP4ConfigClass *ip4_class) { @@ -726,7 +725,7 @@ nm_setting_ip4_config_class_init (NMSettingIP4ConfigClass *ip4_class) * type of links. * * The special value "stable" is supported to generate a type 0 client identifier based - * on the stable-id (see connection.stable-id). + * on the stable-id (see connection.stable-id) and a per-host key. * * If unset, a globally configured default is used. If still unset, the * client-id from the last lease is reused. diff --git a/libnm-core/nm-setting-ip6-config.c b/libnm-core/nm-setting-ip6-config.c index ca3e3c51..7c2b45f2 100644 --- a/libnm-core/nm-setting-ip6-config.c +++ b/libnm-core/nm-setting-ip6-config.c @@ -63,7 +63,6 @@ typedef struct { char *token; } NMSettingIP6ConfigPrivate; - enum { PROP_0, PROP_IP6_PRIVACY, @@ -281,7 +280,6 @@ verify (NMSetting *setting, NMConnection *connection, GError **error) return TRUE; } - static void nm_setting_ip6_config_init (NMSettingIP6Config *setting) { @@ -792,7 +790,6 @@ nm_setting_ip6_config_class_init (NMSettingIP6ConfigClass *ip6_class) NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS)); - /* IP6-specific property overrides */ /* ---dbus--- diff --git a/libnm-core/nm-setting-ovs-interface.c b/libnm-core/nm-setting-ovs-interface.c index f06db32a..73e1cfc6 100644 --- a/libnm-core/nm-setting-ovs-interface.c +++ b/libnm-core/nm-setting-ovs-interface.c @@ -244,7 +244,6 @@ normalize: return TRUE; } - static int verify (NMSetting *setting, NMConnection *connection, GError **error) { diff --git a/libnm-core/nm-setting-ovs-port.c b/libnm-core/nm-setting-ovs-port.c index 456e3fbc..72722b15 100644 --- a/libnm-core/nm-setting-ovs-port.c +++ b/libnm-core/nm-setting-ovs-port.c @@ -436,7 +436,6 @@ nm_setting_ovs_port_class_init (NMSettingOvsPortClass *setting_class) NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS)); - /** * NMSettingOvsPort:bond-updelay: * diff --git a/libnm-core/nm-setting-private.h b/libnm-core/nm-setting-private.h index 6c50178d..863ea9f3 100644 --- a/libnm-core/nm-setting-private.h +++ b/libnm-core/nm-setting-private.h @@ -58,7 +58,6 @@ gboolean _nm_setting_clear_secrets_with_flags (NMSetting *setting, NMSettingClearSecretsWithFlagsFn func, gpointer user_data); - /* The property of the #NMSetting should be considered during comparisons that * use the %NM_SETTING_COMPARE_FLAG_INFERRABLE flag. Properties that don't have * this flag, are ignored when doing an infrerrable comparison. This flag should diff --git a/libnm-core/nm-setting-serial.c b/libnm-core/nm-setting-serial.c index e0da89aa..e86988b5 100644 --- a/libnm-core/nm-setting-serial.c +++ b/libnm-core/nm-setting-serial.c @@ -51,7 +51,6 @@ typedef struct { guint64 send_delay; } NMSettingSerialPrivate; - enum { PROP_0, PROP_BAUD, diff --git a/libnm-core/nm-setting-tc-config.c b/libnm-core/nm-setting-tc-config.c index 0fea8868..e801e4fd 100644 --- a/libnm-core/nm-setting-tc-config.c +++ b/libnm-core/nm-setting-tc-config.c @@ -1423,7 +1423,6 @@ _tfilters_from_variant (GVariant *value) action_var = g_variant_lookup_value (tfilter_var, "action", G_VARIANT_TYPE_VARDICT); - if (action_var) { if (!g_variant_lookup (action_var, "kind", "&s", &action_kind)) { //g_warning ("Ignoring tfilter with invalid action"); diff --git a/libnm-core/nm-setting-tc-config.h b/libnm-core/nm-setting-tc-config.h index 4496046e..6296b1ab 100644 --- a/libnm-core/nm-setting-tc-config.h +++ b/libnm-core/nm-setting-tc-config.h @@ -49,7 +49,6 @@ gboolean nm_tc_qdisc_equal (NMTCQdisc *qdisc, NM_AVAILABLE_IN_1_12 NMTCQdisc *nm_tc_qdisc_dup (NMTCQdisc *qdisc); - NM_AVAILABLE_IN_1_12 const char *nm_tc_qdisc_get_kind (NMTCQdisc *qdisc); NM_AVAILABLE_IN_1_12 @@ -80,7 +79,6 @@ gboolean nm_tc_action_equal (NMTCAction *action, NM_AVAILABLE_IN_1_12 NMTCAction *nm_tc_action_dup (NMTCAction *action); - NM_AVAILABLE_IN_1_12 const char *nm_tc_action_get_kind (NMTCAction *action); @@ -129,7 +127,6 @@ NMTCAction *nm_tc_tfilter_get_action (NMTCTfilter *tfilter); NM_AVAILABLE_IN_1_12 void nm_tc_tfilter_set_action (NMTCTfilter *tfilter, NMTCAction *action); - #define NM_TYPE_SETTING_TC_CONFIG (nm_setting_tc_config_get_type ()) #define NM_SETTING_TC_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTING_TC_CONFIG, NMSettingTCConfig)) #define NM_SETTING_TC_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SETTING_TC_CONFIG, NMSettingTCConfigClass)) diff --git a/libnm-core/nm-setting-team-port.c b/libnm-core/nm-setting-team-port.c index ad954277..b902b822 100644 --- a/libnm-core/nm-setting-team-port.c +++ b/libnm-core/nm-setting-team-port.c @@ -80,7 +80,6 @@ static const _NMUtilsTeamPropertyKeys _prop_to_keys[LAST_PROP] = { [PROP_LINK_WATCHERS] = { "link_watch", NULL, NULL, 0 } }; - /** * nm_setting_team_port_new: * diff --git a/libnm-core/nm-setting-team.c b/libnm-core/nm-setting-team.c index 86fbdb01..f49a04da 100644 --- a/libnm-core/nm-setting-team.c +++ b/libnm-core/nm-setting-team.c @@ -1304,7 +1304,6 @@ finalize (GObject *object) G_OBJECT_CLASS (nm_setting_team_parent_class)->finalize (object); } - #define JSON_TO_VAL(typ, id) _nm_utils_json_extract_##typ (priv->config, _prop_to_keys[id], FALSE) static void diff --git a/libnm-core/nm-setting-team.h b/libnm-core/nm-setting-team.h index 492b2a66..cd766d8e 100644 --- a/libnm-core/nm-setting-team.h +++ b/libnm-core/nm-setting-team.h @@ -52,7 +52,6 @@ typedef enum { /*< flags >*/ #define NM_TEAM_LINK_WATCHER_ARP_PING "arp_ping" #define NM_TEAM_LINK_WATCHER_NSNA_PING "nsna_ping" - typedef struct NMTeamLinkWatcher NMTeamLinkWatcher; GType nm_team_link_watcher_get_type (void); @@ -102,7 +101,6 @@ const char *nm_team_link_watcher_get_source_host (NMTeamLinkWatcher *watcher); NM_AVAILABLE_IN_1_12 NMTeamLinkWatcherArpPingFlags nm_team_link_watcher_get_flags (NMTeamLinkWatcher *watcher); - #define NM_TYPE_SETTING_TEAM (nm_setting_team_get_type ()) #define NM_SETTING_TEAM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTING_TEAM, NMSettingTeam)) #define NM_SETTING_TEAM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SETTING_TEAM, NMSettingTeamClass)) @@ -154,7 +152,6 @@ NMTeamLinkWatcherArpPingFlags nm_team_link_watcher_get_flags (NMTeamLinkWatcher #define NM_SETTING_TEAM_RUNNER_SYS_PRIO_DEFAULT 65535 #define NM_SETTING_TEAM_RUNNER_AGG_SELECT_POLICY_DEFAULT NM_SETTING_TEAM_RUNNER_AGG_SELECT_POLICY_LACP_PRIO - /** * NMSettingTeam: * diff --git a/libnm-core/nm-setting-user.h b/libnm-core/nm-setting-user.h index 38e97a93..5a2e2cfd 100644 --- a/libnm-core/nm-setting-user.h +++ b/libnm-core/nm-setting-user.h @@ -57,7 +57,6 @@ const char *nm_setting_user_get_data (NMSettingUser *setting, const NM_AVAILABLE_IN_1_8 gboolean nm_setting_user_set_data (NMSettingUser *setting, const char *key, const char *val, GError **error); - NM_AVAILABLE_IN_1_8 gboolean nm_setting_user_check_key (const char *key, GError **error); NM_AVAILABLE_IN_1_8 diff --git a/libnm-core/nm-setting-vpn.h b/libnm-core/nm-setting-vpn.h index 1f1576fd..be14e7c0 100644 --- a/libnm-core/nm-setting-vpn.h +++ b/libnm-core/nm-setting-vpn.h @@ -109,7 +109,6 @@ NM_AVAILABLE_IN_1_12 const char ** nm_setting_vpn_get_secret_keys (NMSettingVpn *setting, guint *out_length); - NM_AVAILABLE_IN_1_2 guint32 nm_setting_vpn_get_timeout (NMSettingVpn *setting); diff --git a/libnm-core/nm-setting-wireless.c b/libnm-core/nm-setting-wireless.c index 0a3915bf..38948dee 100644 --- a/libnm-core/nm-setting-wireless.c +++ b/libnm-core/nm-setting-wireless.c @@ -1548,6 +1548,9 @@ nm_setting_wireless_class_init (NMSettingWirelessClass *setting_wireless_class) * probe-scanning the SSID for more reliable network discovery. However, * these workarounds expose inherent insecurities with hidden SSID networks, * and thus hidden SSID networks should be used with caution. + * + * Note that marking the network as hidden may be a privacy issue for you, as + * the explicit probe-scans may be distinctly recognizable on the air. **/ /* ---ifcfg-rh--- * property: hidden diff --git a/libnm-core/nm-setting.c b/libnm-core/nm-setting.c index 4c76ed31..218f0dad 100644 --- a/libnm-core/nm-setting.c +++ b/libnm-core/nm-setting.c @@ -682,7 +682,6 @@ set_property_from_dbus (const NMSettingProperty *property, return TRUE; } - /** * _nm_setting_to_dbus: * @setting: the #NMSetting diff --git a/libnm-core/nm-setting.h b/libnm-core/nm-setting.h index bf3f8e56..47a2fdc1 100644 --- a/libnm-core/nm-setting.h +++ b/libnm-core/nm-setting.h @@ -51,7 +51,6 @@ G_BEGIN_DECLS /* Note: all non-glib GParamFlags bits are reserved by NetworkManager */ - #define NM_SETTING_NAME "name" /** @@ -130,7 +129,6 @@ typedef enum { /* Higher flags like 0x80000000 and 0x40000000 are used internally as private flags */ } NMSettingCompareFlags; - /** * NMSettingMacRandomization: * @NM_SETTING_MAC_RANDOMIZATION_DEFAULT: the default value, which unless @@ -146,7 +144,6 @@ typedef enum { NM_SETTING_MAC_RANDOMIZATION_ALWAYS, } NMSettingMacRandomization; - /** * NMSetting: * @@ -157,7 +154,6 @@ struct _NMSetting { GObject parent; }; - /** * NMSettingClearSecretsWithFlagsFn: * @setting: The setting for which secrets are being iterated @@ -233,7 +229,6 @@ typedef void (*NMSettingValueIterFn) (NMSetting *setting, GParamFlags flags, gpointer user_data); - GType nm_setting_get_type (void); GType nm_setting_lookup_type (const char *name); diff --git a/libnm-core/nm-utils.c b/libnm-core/nm-utils.c index a535b679..eb65f8db 100644 --- a/libnm-core/nm-utils.c +++ b/libnm-core/nm-utils.c @@ -136,7 +136,6 @@ static const struct IsoLangToEncodings isoLangEntries2[] = LANG_ENCODINGS (NULL, NULL) }; - static GHashTable * langToEncodings5 = NULL; static GHashTable * langToEncodings2 = NULL; @@ -250,7 +249,7 @@ _nm_utils_init (void) g_error ("libnm-util symbols detected; Mixing libnm with libnm-util/libnm-glib is not supported"); g_module_close (self); - bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); + bindtextdomain (GETTEXT_PACKAGE, NMLOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); _nm_dbus_errors_init (); @@ -2237,7 +2236,6 @@ nm_utils_tc_qdisc_to_str (NMTCQdisc *qdisc, GError **error) return g_string_free (string, FALSE); } - static gboolean _tc_read_common_opts (const char *str, guint32 *handle, @@ -3038,7 +3036,6 @@ _nm_utils_check_file (const char *filename, return TRUE; } - gboolean _nm_utils_check_module_file (const char *name, int check_owner, @@ -3688,8 +3685,8 @@ nm_utils_hwaddr_aton (const char *asc, gpointer buffer, gsize length) return buffer; } -static void -_bin2str (gconstpointer addr, gsize length, const char delimiter, gboolean upper_case, char *out) +void +_nm_utils_bin2str_full (gconstpointer addr, gsize length, const char delimiter, gboolean upper_case, char *out) { const guint8 *in = addr; const char *LOOKUP = upper_case ? "0123456789ABCDEF" : "0123456789abcdef"; @@ -3739,7 +3736,7 @@ nm_utils_bin2hexstr (gconstpointer src, gsize len, int final_len) g_return_val_if_fail (final_len < 0 || (gsize) final_len < buflen, NULL); result = g_malloc (buflen); - _bin2str (src, len, '\0', FALSE, result); + _nm_utils_bin2str_full (src, len, '\0', FALSE, result); /* Cut converted key off at the correct length for this cipher type */ if (final_len >= 0 && (gsize) final_len < buflen) @@ -3766,7 +3763,7 @@ nm_utils_hwaddr_ntoa (gconstpointer addr, gsize length) g_return_val_if_fail (length > 0, g_strdup ("")); result = g_malloc (length * 3); - _bin2str (addr, length, ':', TRUE, result); + _nm_utils_bin2str_full (addr, length, ':', TRUE, result); return result; } @@ -3779,7 +3776,7 @@ nm_utils_hwaddr_ntoa_buf (gconstpointer addr, gsize addr_len, gboolean upper_cas if (buf_len < addr_len * 3) g_return_val_if_reached (NULL); - _bin2str (addr, addr_len, ':', upper_case, buf); + _nm_utils_bin2str_full (addr, addr_len, ':', upper_case, buf); return buf; } @@ -3802,7 +3799,7 @@ _nm_utils_bin2str (gconstpointer addr, gsize length, gboolean upper_case) g_return_val_if_fail (length > 0, g_strdup ("")); result = g_malloc (length * 3); - _bin2str (addr, length, ':', upper_case, result); + _nm_utils_bin2str_full (addr, length, ':', upper_case, result); return result; } @@ -3830,9 +3827,11 @@ nm_utils_hwaddr_valid (const char *asc, gssize length) if (!hwaddr_aton (asc, buf, length, &l)) return FALSE; return length == l; - } else if (length == -1) { + } else if (length == -1) return !!hwaddr_aton (asc, buf, sizeof (buf), &l); - } else + else if (length == 0) + return FALSE; + else g_return_val_if_reached (FALSE); } @@ -4321,7 +4320,7 @@ nm_utils_inet_ntop (int addr_family, gconstpointer addr, char *dst) s = inet_ntop (addr_family, addr, - dst ? dst : _nm_utils_inet_ntop_buffer, + dst ?: _nm_utils_inet_ntop_buffer, addr_family == AF_INET6 ? INET6_ADDRSTRLEN : INET_ADDRSTRLEN); nm_assert (s); return s; @@ -4347,7 +4346,7 @@ nm_utils_inet_ntop (int addr_family, gconstpointer addr, char *dst) const char * nm_utils_inet4_ntop (in_addr_t inaddr, char *dst) { - return inet_ntop (AF_INET, &inaddr, dst ? dst : _nm_utils_inet_ntop_buffer, + return inet_ntop (AF_INET, &inaddr, dst ?: _nm_utils_inet_ntop_buffer, INET_ADDRSTRLEN); } @@ -4373,7 +4372,7 @@ const char * nm_utils_inet6_ntop (const struct in6_addr *in6addr, char *dst) { g_return_val_if_fail (in6addr, NULL); - return inet_ntop (AF_INET6, in6addr, dst ? dst : _nm_utils_inet_ntop_buffer, + return inet_ntop (AF_INET6, in6addr, dst ?: _nm_utils_inet_ntop_buffer, INET6_ADDRSTRLEN); } @@ -5018,7 +5017,6 @@ _json_team_add_defaults (json_t *json, json_object_set_new (json_element, "name", json_string (runner)); } - if (nm_streq (runner, NM_SETTING_TEAM_RUNNER_ACTIVEBACKUP)) { _json_add_object (json, "notify_peers", "count", NULL, json_integer (NM_SETTING_TEAM_NOTIFY_PEERS_COUNT_ACTIVEBACKUP_DEFAULT)); @@ -5305,7 +5303,6 @@ fail: return NULL; } - /** * nm_utils_is_json_object: * @str: the JSON string to test @@ -5421,7 +5418,6 @@ out: return ret; } - GValue * _nm_utils_team_config_get (const char *conf, const char *key, diff --git a/libnm-core/nm-vpn-dbus-interface.h b/libnm-core/nm-vpn-dbus-interface.h index 9c9bc297..4ef80f1d 100644 --- a/libnm-core/nm-vpn-dbus-interface.h +++ b/libnm-core/nm-vpn-dbus-interface.h @@ -60,7 +60,6 @@ #define NM_DBUS_VPN_BAD_ARGUMENTS "BadArguments" #define NM_DBUS_VPN_INTERACTIVE_NOT_SUPPORTED "InteractiveNotSupported" - /* * VPN daemon signals */ @@ -95,7 +94,6 @@ typedef enum { NM_VPN_SERVICE_STATE_STOPPED } NMVpnServiceState; - /** * NMVpnConnectionState: * @NM_VPN_CONNECTION_STATE_UNKNOWN: The state of the VPN connection is @@ -216,7 +214,6 @@ typedef enum { */ #define NM_VPN_PLUGIN_CAN_PERSIST "can-persist" - /*** Ip4Config ***/ /* uint32: IP address of the internal gateway of the subnet the VPN interface is @@ -273,7 +270,6 @@ typedef enum { #define NM_VPN_PLUGIN_IP4_CONFIG_MTU NM_VPN_PLUGIN_CONFIG_MTU #define NM_VPN_PLUGIN_IP4_CONFIG_TUNDEV NM_VPN_PLUGIN_CONFIG_TUNDEV - /*** Ip6Config ***/ /* array of uint8: IP address of the internal gateway of the subnet the VPN interface is diff --git a/libnm-core/nm-vpn-editor-plugin.c b/libnm-core/nm-vpn-editor-plugin.c index 32e2a4ed..d690d9b0 100644 --- a/libnm-core/nm-vpn-editor-plugin.c +++ b/libnm-core/nm-vpn-editor-plugin.c @@ -262,7 +262,7 @@ _nm_vpn_editor_plugin_load (const char *plugin_name, if (do_file_checks) { if ( !strchr (plugin_name, '/') && !g_str_has_suffix (plugin_name, ".la")) { - plugin_filename_free = g_module_build_path (NMPLUGINDIR, plugin_name); + plugin_filename_free = g_module_build_path (NMVPNDIR, plugin_name); plugin_filename = plugin_filename_free; } } diff --git a/libnm-core/nm-vpn-editor-plugin.h b/libnm-core/nm-vpn-editor-plugin.h index 0f910e36..0bdd9298 100644 --- a/libnm-core/nm-vpn-editor-plugin.h +++ b/libnm-core/nm-vpn-editor-plugin.h @@ -47,7 +47,6 @@ typedef NMVpnEditorPlugin * (*NMVpnEditorPluginFactory) (GError **error); NMVpnEditorPlugin *nm_vpn_editor_plugin_factory (GError **error); #endif - /*****************************************************************************/ /* Editor plugin interface */ /*****************************************************************************/ diff --git a/libnm-core/nm-vpn-plugin-info.c b/libnm-core/nm-vpn-plugin-info.c index 115c397f..79542279 100644 --- a/libnm-core/nm-vpn-plugin-info.c +++ b/libnm-core/nm-vpn-plugin-info.c @@ -933,7 +933,6 @@ nm_vpn_plugin_info_supports_multiple (NMVpnPluginInfo *self) return _nm_utils_ascii_str_to_bool (s, FALSE); } - /** * nm_vpn_plugin_info_get_aliases: * @self: plugin info instance diff --git a/libnm-core/tests/meson.build b/libnm-core/tests/meson.build index 6e8a2493..2eeadd88 100644 --- a/libnm-core/tests/meson.build +++ b/libnm-core/tests/meson.build @@ -29,18 +29,16 @@ test_units = [ test_cert_dir = join_paths(meson.current_source_dir(), 'certs') -cflags = [ - '-DNETWORKMANAGER_COMPILATION_TEST', - '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIBNM_CORE', - '-DTEST_CERT_DIR="@0@"'.format(test_cert_dir), -] - foreach test_unit: test_units exe = executable( 'libnm-core-' + test_unit, [test_unit + '.c'] + enum, dependencies: nm_core_dep, - c_args: cflags, + c_args: [ + '-DNETWORKMANAGER_COMPILATION_TEST', + '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIBNM_CORE', + ] + + nm_build_cflags, link_with: libnm_core ) test( diff --git a/libnm-core/tests/test-crypto.c b/libnm-core/tests/test-crypto.c index 0c2ef48a..fb99ffea 100644 --- a/libnm-core/tests/test-crypto.c +++ b/libnm-core/tests/test-crypto.c @@ -35,6 +35,8 @@ #include "nm-utils/nm-test-utils.h" +#define TEST_CERT_DIR NM_BUILD_SRCDIR"/libnm-core/tests/certs" + #if 0 static const char *pem_rsa_key_begin = "-----BEGIN RSA PRIVATE KEY-----"; static const char *pem_rsa_key_end = "-----END RSA PRIVATE KEY-----"; diff --git a/libnm-core/tests/test-general.c b/libnm-core/tests/test-general.c index 544eb3c0..3b9debd9 100644 --- a/libnm-core/tests/test-general.c +++ b/libnm-core/tests/test-general.c @@ -26,6 +26,7 @@ #include <string.h> #include "nm-utils/c-list-util.h" +#include "nm-utils/nm-enum-utils.h" #include "nm-utils.h" #include "nm-setting-private.h" @@ -6328,105 +6329,219 @@ test_nm_utils_ptrarray_find_binary_search_with_duplicates (void) } /*****************************************************************************/ + static void -test_nm_utils_enum_from_str_do (GType type, const char *str, - gboolean exp_result, int exp_flags, - const char *exp_err_token) +_test_nm_utils_enum_to_str_do_full (GType type, + int flags, + const char *exp_str, + const NMUtilsEnumValueInfo *value_infos) { - int flags = 1; - char *err_token = NULL; + gs_free char *str = NULL; + int flags2; + gs_free char *err_token = NULL; gboolean result; - result = nm_utils_enum_from_str (type, str, &flags, &err_token); + g_assert (exp_str); - g_assert (result == exp_result); - g_assert_cmpint (flags, ==, exp_flags); - g_assert_cmpstr (err_token, ==, exp_err_token); + str = _nm_utils_enum_to_str_full (type, flags, ", ", value_infos); + g_assert_cmpstr (str, ==, exp_str); + + if (!value_infos) { + gs_free char *str2 = NULL; - g_free (err_token); + str2 = nm_utils_enum_to_str (type, flags); + g_assert_cmpstr (str2, ==, exp_str); + } + + result = _nm_utils_enum_from_str_full (type, str, &flags2, &err_token, value_infos); + g_assert (result == TRUE); + g_assert_cmpint (flags2, ==, flags); + g_assert_cmpstr (err_token, ==, NULL); } +#define _test_nm_utils_enum_to_str_do(...) _test_nm_utils_enum_to_str_do_full (__VA_ARGS__, NULL) + static void -test_nm_utils_enum_to_str_do (GType type, int flags, const char *exp_str) +_test_nm_utils_enum_from_str_do_full (GType type, + const char *str, + gboolean exp_result, + int exp_flags, + const char *exp_err_token, + const NMUtilsEnumValueInfo *value_infos) { - char *str; + int flags; + gs_free char *err_token = NULL; + gboolean result; - str = nm_utils_enum_to_str (type, flags); - g_assert_cmpstr (str, ==, exp_str); - g_free (str); + result = _nm_utils_enum_from_str_full (type, str, &flags, &err_token, value_infos); + + g_assert (result == exp_result); + g_assert_cmpint (flags, ==, exp_flags); + g_assert_cmpstr (err_token, ==, exp_err_token); + + if (!value_infos) { + int flags2; + gs_free char *err_token2 = NULL; + gboolean result2; + + result2 = nm_utils_enum_from_str (type, str, &flags2, &err_token2); + g_assert (result2 == exp_result); + g_assert_cmpint (flags2, ==, exp_flags); + g_assert_cmpstr (err_token2, ==, exp_err_token); + } + + if (result) { + int flags2; + gs_free char *str2 = NULL; + gs_free char *err_token2 = NULL; + + str2 = _nm_utils_enum_to_str_full (type, flags, ", ", value_infos); + g_assert (str2); + + result = _nm_utils_enum_from_str_full (type, str2, &flags2, &err_token2, value_infos); + g_assert (result == TRUE); + g_assert_cmpint (flags2, ==, flags); + g_assert_cmpstr (err_token, ==, NULL); + } } +#define _test_nm_utils_enum_from_str_do(...) _test_nm_utils_enum_from_str_do_full(__VA_ARGS__, NULL) + static void -test_nm_utils_enum_get_values_do (GType type, int from, int to, const char *exp_str) +_test_nm_utils_enum_get_values_do (GType type, int from, int to, const char *exp_str) { - const char **strv; - char *str; + gs_free const char **strv = NULL; + gs_free char *str = NULL; + + g_assert (exp_str); strv = nm_utils_enum_get_values (type, from, to); g_assert (strv); str = g_strjoinv (",", (char **) strv); g_assert_cmpstr (str, ==, exp_str); - g_free (str); - g_free (strv); } - -static void test_nm_utils_enum (void) +static void +test_nm_utils_enum (void) { GType bool_enum = nm_test_general_bool_enum_get_type(); GType meta_flags = nm_test_general_meta_flags_get_type(); GType color_flags = nm_test_general_color_flags_get_type(); + static const NMUtilsEnumValueInfo color_value_infos[] = { + { + .nick = "nick-4d", + .value = 0x4D, + }, + { + .nick = "nick-5", + .value = 5, + }, + { + .nick = "nick-red", + .value = NM_TEST_GENERAL_COLOR_FLAGS_RED, + }, + { 0 }, + }; - test_nm_utils_enum_to_str_do (bool_enum, NM_TEST_GENERAL_BOOL_ENUM_YES, "yes"); - test_nm_utils_enum_to_str_do (bool_enum, NM_TEST_GENERAL_BOOL_ENUM_UNKNOWN, "unknown"); - test_nm_utils_enum_to_str_do (bool_enum, NM_TEST_GENERAL_BOOL_ENUM_INVALID, "4"); - test_nm_utils_enum_to_str_do (bool_enum, NM_TEST_GENERAL_BOOL_ENUM_67, "67"); - test_nm_utils_enum_to_str_do (bool_enum, NM_TEST_GENERAL_BOOL_ENUM_46, "64"); - - test_nm_utils_enum_to_str_do (meta_flags, NM_TEST_GENERAL_META_FLAGS_NONE, "none"); - test_nm_utils_enum_to_str_do (meta_flags, NM_TEST_GENERAL_META_FLAGS_BAZ, "baz"); - test_nm_utils_enum_to_str_do (meta_flags, NM_TEST_GENERAL_META_FLAGS_FOO | - NM_TEST_GENERAL_META_FLAGS_BAR | - NM_TEST_GENERAL_META_FLAGS_BAZ, "foo, bar, baz"); - test_nm_utils_enum_to_str_do (meta_flags, 0xFF, "foo, bar, baz, 0xf8"); - test_nm_utils_enum_to_str_do (meta_flags, NM_TEST_GENERAL_META_FLAGS_0x8, "0x8"); - test_nm_utils_enum_to_str_do (meta_flags, NM_TEST_GENERAL_META_FLAGS_0x4, "0x10"); - - test_nm_utils_enum_to_str_do (color_flags, NM_TEST_GENERAL_COLOR_FLAGS_RED, "red"); - test_nm_utils_enum_to_str_do (color_flags, NM_TEST_GENERAL_COLOR_FLAGS_WHITE, "0x1"); - test_nm_utils_enum_to_str_do (color_flags, NM_TEST_GENERAL_COLOR_FLAGS_RED | - NM_TEST_GENERAL_COLOR_FLAGS_GREEN, "red, green"); - - test_nm_utils_enum_from_str_do (bool_enum, "", FALSE, 0, NULL); - test_nm_utils_enum_from_str_do (bool_enum, " ", FALSE, 0, NULL); - test_nm_utils_enum_from_str_do (bool_enum, "invalid", FALSE, 0, "invalid"); - test_nm_utils_enum_from_str_do (bool_enum, "yes", TRUE, NM_TEST_GENERAL_BOOL_ENUM_YES, NULL); - test_nm_utils_enum_from_str_do (bool_enum, "no", TRUE, NM_TEST_GENERAL_BOOL_ENUM_NO, NULL); - test_nm_utils_enum_from_str_do (bool_enum, "yes,no", FALSE, 0, "yes,no"); - - test_nm_utils_enum_from_str_do (meta_flags, "", TRUE, 0, NULL); - test_nm_utils_enum_from_str_do (meta_flags, " ", TRUE, 0, NULL); - test_nm_utils_enum_from_str_do (meta_flags, "foo", TRUE, NM_TEST_GENERAL_META_FLAGS_FOO, NULL); - test_nm_utils_enum_from_str_do (meta_flags, "foo,baz", TRUE, NM_TEST_GENERAL_META_FLAGS_FOO | - NM_TEST_GENERAL_META_FLAGS_BAZ, NULL); - test_nm_utils_enum_from_str_do (meta_flags, "foo, baz", TRUE, NM_TEST_GENERAL_META_FLAGS_FOO | + _test_nm_utils_enum_to_str_do (bool_enum, NM_TEST_GENERAL_BOOL_ENUM_YES, "yes"); + _test_nm_utils_enum_to_str_do (bool_enum, NM_TEST_GENERAL_BOOL_ENUM_UNKNOWN, "unknown"); + _test_nm_utils_enum_to_str_do (bool_enum, NM_TEST_GENERAL_BOOL_ENUM_INVALID, "4"); + _test_nm_utils_enum_to_str_do (bool_enum, NM_TEST_GENERAL_BOOL_ENUM_67, "67"); + _test_nm_utils_enum_to_str_do (bool_enum, NM_TEST_GENERAL_BOOL_ENUM_46, "64"); + + _test_nm_utils_enum_to_str_do (meta_flags, NM_TEST_GENERAL_META_FLAGS_NONE, "none"); + _test_nm_utils_enum_to_str_do (meta_flags, NM_TEST_GENERAL_META_FLAGS_BAZ, "baz"); + _test_nm_utils_enum_to_str_do (meta_flags, NM_TEST_GENERAL_META_FLAGS_FOO | + NM_TEST_GENERAL_META_FLAGS_BAR | + NM_TEST_GENERAL_META_FLAGS_BAZ, "foo, bar, baz"); + _test_nm_utils_enum_to_str_do (meta_flags, 0xFF, "foo, bar, baz, 0xf8"); + _test_nm_utils_enum_to_str_do (meta_flags, NM_TEST_GENERAL_META_FLAGS_0x8, "0x8"); + _test_nm_utils_enum_to_str_do (meta_flags, NM_TEST_GENERAL_META_FLAGS_0x4, "0x10"); + + _test_nm_utils_enum_to_str_do (color_flags, NM_TEST_GENERAL_COLOR_FLAGS_RED, "red"); + _test_nm_utils_enum_to_str_do (color_flags, NM_TEST_GENERAL_COLOR_FLAGS_WHITE, "0x1"); + _test_nm_utils_enum_to_str_do (color_flags, NM_TEST_GENERAL_COLOR_FLAGS_RED | + NM_TEST_GENERAL_COLOR_FLAGS_GREEN, "red, green"); + + _test_nm_utils_enum_to_str_do_full (color_flags, + NM_TEST_GENERAL_COLOR_FLAGS_RED + | NM_TEST_GENERAL_COLOR_FLAGS_GREEN, + "nick-red, green", + color_value_infos); + + _test_nm_utils_enum_to_str_do_full (color_flags, + 0x4D + | NM_TEST_GENERAL_COLOR_FLAGS_RED + | NM_TEST_GENERAL_COLOR_FLAGS_GREEN, + "nick-4d", + color_value_infos); + + _test_nm_utils_enum_to_str_do_full (color_flags, + 5 + | NM_TEST_GENERAL_COLOR_FLAGS_GREEN, + "nick-5, green", + color_value_infos); + + _test_nm_utils_enum_from_str_do (bool_enum, "", FALSE, 0, NULL); + _test_nm_utils_enum_from_str_do (bool_enum, " ", FALSE, 0, NULL); + _test_nm_utils_enum_from_str_do (bool_enum, "invalid", FALSE, 0, "invalid"); + _test_nm_utils_enum_from_str_do (bool_enum, "yes", TRUE, NM_TEST_GENERAL_BOOL_ENUM_YES, NULL); + _test_nm_utils_enum_from_str_do (bool_enum, "no", TRUE, NM_TEST_GENERAL_BOOL_ENUM_NO, NULL); + _test_nm_utils_enum_from_str_do (bool_enum, "yes,no", FALSE, 0, "yes,no"); + + _test_nm_utils_enum_from_str_do (meta_flags, "", TRUE, 0, NULL); + _test_nm_utils_enum_from_str_do (meta_flags, " ", TRUE, 0, NULL); + _test_nm_utils_enum_from_str_do (meta_flags, "foo", TRUE, NM_TEST_GENERAL_META_FLAGS_FOO, NULL); + _test_nm_utils_enum_from_str_do (meta_flags, "foo,baz", TRUE, NM_TEST_GENERAL_META_FLAGS_FOO | NM_TEST_GENERAL_META_FLAGS_BAZ, NULL); - test_nm_utils_enum_from_str_do (meta_flags, "foo,,bar", TRUE, NM_TEST_GENERAL_META_FLAGS_FOO | - NM_TEST_GENERAL_META_FLAGS_BAR, NULL); - test_nm_utils_enum_from_str_do (meta_flags, "foo,baz,quux,bar", FALSE, 0, "quux"); - test_nm_utils_enum_from_str_do (meta_flags, "foo,0x6", TRUE, NM_TEST_GENERAL_META_FLAGS_FOO | 0x6, NULL); - test_nm_utils_enum_from_str_do (meta_flags, "0x30,0x08,foo", TRUE, 0x39, NULL); - - test_nm_utils_enum_from_str_do (color_flags, "green", TRUE, NM_TEST_GENERAL_COLOR_FLAGS_GREEN, NULL); - test_nm_utils_enum_from_str_do (color_flags, "blue,red", TRUE, NM_TEST_GENERAL_COLOR_FLAGS_BLUE | - NM_TEST_GENERAL_COLOR_FLAGS_RED, NULL); - test_nm_utils_enum_from_str_do (color_flags, "blue,white", FALSE, 0, "white"); - - test_nm_utils_enum_get_values_do (bool_enum, 0, G_MAXINT, "no,yes,maybe,unknown,67,64"); - test_nm_utils_enum_get_values_do (bool_enum, NM_TEST_GENERAL_BOOL_ENUM_YES, - NM_TEST_GENERAL_BOOL_ENUM_MAYBE, "yes,maybe"); - test_nm_utils_enum_get_values_do (meta_flags, 0, G_MAXINT, "none,foo,bar,baz,0x8,0x10"); - test_nm_utils_enum_get_values_do (color_flags, 0, G_MAXINT, "blue,red,green"); + _test_nm_utils_enum_from_str_do (meta_flags, "foo, baz", TRUE, NM_TEST_GENERAL_META_FLAGS_FOO | + NM_TEST_GENERAL_META_FLAGS_BAZ, NULL); + _test_nm_utils_enum_from_str_do (meta_flags, "foo,,bar", TRUE, NM_TEST_GENERAL_META_FLAGS_FOO | + NM_TEST_GENERAL_META_FLAGS_BAR, NULL); + _test_nm_utils_enum_from_str_do (meta_flags, "foo,baz,quux,bar", FALSE, 0, "quux"); + _test_nm_utils_enum_from_str_do (meta_flags, "foo,0x6", TRUE, NM_TEST_GENERAL_META_FLAGS_FOO | 0x6, NULL); + _test_nm_utils_enum_from_str_do (meta_flags, "0x30,0x08,foo", TRUE, 0x39, NULL); + + _test_nm_utils_enum_from_str_do (color_flags, "green", TRUE, NM_TEST_GENERAL_COLOR_FLAGS_GREEN, NULL); + _test_nm_utils_enum_from_str_do (color_flags, "blue,red", TRUE, NM_TEST_GENERAL_COLOR_FLAGS_BLUE | + NM_TEST_GENERAL_COLOR_FLAGS_RED, NULL); + _test_nm_utils_enum_from_str_do (color_flags, "blue,white", FALSE, 0, "white"); + + _test_nm_utils_enum_from_str_do_full (color_flags, + "nick-red", + TRUE, + NM_TEST_GENERAL_COLOR_FLAGS_RED, + NULL, + color_value_infos); + + _test_nm_utils_enum_from_str_do_full (color_flags, + "0x4D", + TRUE, + 0x4D, + NULL, + color_value_infos); + + _test_nm_utils_enum_from_str_do_full (color_flags, + "green,nick-4d", + TRUE, + 0x4D + | NM_TEST_GENERAL_COLOR_FLAGS_GREEN, + NULL, + color_value_infos); + + _test_nm_utils_enum_from_str_do_full (color_flags, + "nick-4d,nick-red,nick-5,green,nick-red", + TRUE, + 0x4D + | NM_TEST_GENERAL_COLOR_FLAGS_GREEN, + NULL, + color_value_infos); + + _test_nm_utils_enum_get_values_do (bool_enum, 0, G_MAXINT, "no,yes,maybe,unknown,67,64"); + _test_nm_utils_enum_get_values_do (bool_enum, NM_TEST_GENERAL_BOOL_ENUM_YES, + NM_TEST_GENERAL_BOOL_ENUM_MAYBE, "yes,maybe"); + _test_nm_utils_enum_get_values_do (meta_flags, 0, G_MAXINT, "none,foo,bar,baz,0x8,0x10"); + _test_nm_utils_enum_get_values_do (color_flags, 0, G_MAXINT, "blue,red,green"); } /*****************************************************************************/ @@ -6724,7 +6839,6 @@ test_nm_in_strset (void) _ASSERT (3, !NM_IN_STRSET_SE ("a", G(NULL), G("b"), G("b"))); _ASSERT (3, !NM_IN_STRSET_SE (NULL, G("a"), G("b"), G("b"))); - _ASSERT (3, NM_IN_STRSET ("a", G(NULL), G("b"), G("a"), N("a"))); _ASSERT (4, NM_IN_STRSET ("a", G(NULL), G("b"), G("c"), G("a"))); _ASSERT (4, !NM_IN_STRSET ("a", G(NULL), G("b"), G("c"), G("d"))); @@ -6875,6 +6989,22 @@ test_nm_set_out (void) /*****************************************************************************/ +static void +test_get_start_time_for_pid (void) +{ + guint64 x_start_time; + char x_state; + pid_t x_ppid; + + x_start_time = nm_utils_get_start_time_for_pid (getpid (), &x_state, &x_ppid); + + g_assert (x_start_time > 0); + g_assert (x_ppid == getppid ()); + g_assert (!NM_IN_SET (x_state, '\0', ' ')); +} + +/*****************************************************************************/ + NMTST_DEFINE (); int main (int argc, char **argv) @@ -7028,6 +7158,8 @@ int main (int argc, char **argv) g_test_add_func ("/core/general/route_attributes/parse", test_route_attributes_parse); g_test_add_func ("/core/general/route_attributes/format", test_route_attributes_format); + g_test_add_func ("/core/general/get_start_time_for_pid", test_get_start_time_for_pid); + return g_test_run (); } diff --git a/libnm-core/tests/test-keyfile.c b/libnm-core/tests/test-keyfile.c index 543ca629..672c72b6 100644 --- a/libnm-core/tests/test-keyfile.c +++ b/libnm-core/tests/test-keyfile.c @@ -33,7 +33,7 @@ #include "nm-utils/nm-test-utils.h" - +#define TEST_CERT_DIR NM_BUILD_SRCDIR"/libnm-core/tests/certs" #define TEST_WIRED_TLS_CA_CERT TEST_CERT_DIR"/test-ca-cert.pem" #define TEST_WIRED_TLS_PRIVKEY TEST_CERT_DIR"/test-key-and-cert.pem" @@ -203,7 +203,6 @@ _nm_keyfile_read (GKeyFile *keyfile, return con; } - static void _keyfile_convert (NMConnection **con, GKeyFile **keyfile, @@ -412,14 +411,12 @@ test_8021x_cert (void) g_assert_no_error (error); g_assert (success); - /* test reseting ca-cert to different values and see whether we can write/read. */ nm_connection_add_setting (con, NM_SETTING (s_8021x)); nmtst_assert_connection_verifies_and_normalizable (con); nmtst_connection_normalize (con); - _test_8021x_cert_check (con, scheme, full_TEST_WIRED_TLS_CA_CERT, -1); scheme = NM_SETTING_802_1X_CK_SCHEME_BLOB; @@ -457,7 +454,6 @@ test_8021x_cert_read (void) "/test_8021x_cert_read/test0", NULL); CLEAR (&con, &keyfile); - keyfile = _keyfile_load_from_data ( "[connection]\n" "type=ethernet" @@ -480,7 +476,6 @@ test_8021x_cert_read (void) _keyfile_convert (&con, &keyfile, "/test_8021x_cert_read/test2", NULL, NULL, NULL, NULL, NULL, TRUE); CLEAR (&con, &keyfile); - keyfile = _keyfile_load_from_data ( "[connection]\n" "type=802-3-ethernet\n" @@ -523,7 +518,6 @@ test_8021x_cert_read (void) g_assert_cmpint (strlen (nm_setting_802_1x_get_private_key_path (s_8021x)), ==, 505); CLEAR (&con, &keyfile); - keyfile = _keyfile_load_from_data ( "[connection]\n" "type=802-3-ethernet\n" @@ -549,7 +543,6 @@ test_8021x_cert_read (void) _assert_gbytes (nm_setting_802_1x_get_private_key_blob (s_8021x), "hallo", -1); CLEAR (&con, &keyfile); - keyfile = _keyfile_load_from_data ( "[connection]\n" "type=802-3-ethernet\n" @@ -575,7 +568,6 @@ test_8021x_cert_read (void) _assert_gbytes (nm_setting_802_1x_get_private_key_blob (s_8021x), "abc.deR\0", 8); CLEAR (&con, &keyfile); - keyfile = _keyfile_load_from_data ( "[connection]\n" "type=802-3-ethernet\n" diff --git a/libnm-core/tests/test-secrets.c b/libnm-core/tests/test-secrets.c index 5961b6fc..d31c43d2 100644 --- a/libnm-core/tests/test-secrets.c +++ b/libnm-core/tests/test-secrets.c @@ -40,7 +40,8 @@ #include "nm-utils/nm-test-utils.h" -#define TEST_NEED_SECRETS_EAP_TLS_CA_CERT TEST_CERT_DIR "/test_ca_cert.pem" +#define TEST_CERT_DIR NM_BUILD_SRCDIR"/libnm-core/tests/certs" +#define TEST_NEED_SECRETS_EAP_TLS_CA_CERT TEST_CERT_DIR "/test_ca_cert.pem" #define TEST_NEED_SECRETS_EAP_TLS_CLIENT_CERT TEST_CERT_DIR "/test_key_and_cert.pem" #define TEST_NEED_SECRETS_EAP_TLS_PRIVATE_KEY TEST_CERT_DIR "/test_key_and_cert.pem" @@ -259,7 +260,6 @@ make_tls_phase2_connection (const char *detail, NMSetting8021xCKScheme scheme) &error); nmtst_assert_success (success, error); - /* IP4 setting */ s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new (); nm_connection_add_setting (connection, NM_SETTING (s_ip4)); diff --git a/libnm-core/tests/test-setting.c b/libnm-core/tests/test-setting.c index d0e0b377..6c5c6ad9 100644 --- a/libnm-core/tests/test-setting.c +++ b/libnm-core/tests/test-setting.c @@ -37,6 +37,8 @@ #include "nm-utils/nm-test-utils.h" +#define TEST_CERT_DIR NM_BUILD_SRCDIR"/libnm-core/tests/certs" + /*****************************************************************************/ static void @@ -599,7 +601,6 @@ test_bond_normalize (void) NM_SETTING_DCB_FLAG_ADVERTISE | \ NM_SETTING_DCB_FLAG_WILLING) - static void test_dcb_flags_valid (void) { @@ -943,7 +944,6 @@ _test_team_config_sync (const char *team_config, g_assert (nm_setting_verify ((NMSetting *) s_team, NULL, NULL)); } - static void test_runner_roundrobin_sync_from_config (void) { @@ -1183,7 +1183,6 @@ _test_team_port_config_sync (const char *team_port_config, g_assert (nm_setting_verify ((NMSetting *) s_team_port, NULL, NULL)); } - static void test_team_port_default (void) { |