diff options
| author | Michael Biebl <biebl@debian.org> | 2020-05-30 00:23:54 +0200 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2020-05-30 00:23:54 +0200 |
| commit | 45e8e1149027529194982212c804c0468aa01d98 (patch) | |
| tree | f3acb5e5824dd8b13f1a48bb516b0c92c5f052fd /libnm-core | |
| parent | d460892bbfece74fb6d3cd846bf6ef548290be41 (diff) | |
New upstream version 1.24.2 upstream/1.24.2
Diffstat (limited to 'libnm-core')
| -rw-r--r-- | libnm-core/nm-core-internal.h | 5 | ||||
| -rw-r--r-- | libnm-core/nm-setting-8021x.c | 66 | ||||
| -rw-r--r-- | libnm-core/nm-setting-ip-tunnel.c | 12 | ||||
| -rw-r--r-- | libnm-core/nm-utils.c | 15 | ||||
| -rw-r--r-- | libnm-core/tests/test-general.c | 2 | ||||
| -rw-r--r-- | libnm-core/tests/test-setting.c | 20 |
6 files changed, 79 insertions, 41 deletions
diff --git a/libnm-core/nm-core-internal.h b/libnm-core/nm-core-internal.h index ef9e982b..b9abac40 100644 --- a/libnm-core/nm-core-internal.h +++ b/libnm-core/nm-core-internal.h @@ -869,4 +869,9 @@ gboolean _nmtst_variant_attribute_spec_assert_sorted (const NMVariantAttributeSp const NMVariantAttributeSpec *_nm_variant_attribute_spec_find_binary_search (const NMVariantAttributeSpec *const*array, gsize len, const char *name); + +/*****************************************************************************/ + +gboolean _nm_ip_tunnel_mode_is_layer2 (NMIPTunnelMode mode); + #endif diff --git a/libnm-core/nm-setting-8021x.c b/libnm-core/nm-setting-8021x.c index ade34ff5..f6dbda63 100644 --- a/libnm-core/nm-setting-8021x.c +++ b/libnm-core/nm-setting-8021x.c @@ -3576,15 +3576,18 @@ nm_setting_802_1x_class_init (NMSetting8021xClass *klass) * Contains the CA certificate if used by the EAP method specified in the * #NMSetting8021x:eap property. * - * Certificate data is specified using a "scheme"; two are currently - * supported: blob and path. When using the blob scheme (which is backwards - * compatible with NM 0.7.x) this property should be set to the - * certificate's DER encoded data. When using the path scheme, this property - * should be set to the full UTF-8 encoded path of the certificate, prefixed - * with the string "file://" and ending with a terminating NUL byte. This - * property can be unset even if the EAP method supports CA certificates, + * Certificate data is specified using a "scheme"; three are currently + * supported: blob, path and pkcs#11 URL. When using the blob scheme this property + * should be set to the certificate's DER encoded data. When using the path + * scheme, this property should be set to the full UTF-8 encoded path of the + * certificate, prefixed with the string "file://" and ending with a terminating + * NUL byte. + * This property can be unset even if the EAP method supports CA certificates, * but this allows man-in-the-middle attacks and is NOT recommended. * + * Note that enabling NMSetting8021x:system-ca-certs will override this + * setting to use the built-in path, if the built-in path is not a directory. + * * Setting this property directly is discouraged; use the * nm_setting_802_1x_set_ca_cert() function instead. **/ @@ -3643,11 +3646,14 @@ nm_setting_802_1x_class_init (NMSetting8021xClass *klass) * UTF-8 encoded path to a directory containing PEM or DER formatted * certificates to be added to the verification chain in addition to the * certificate specified in the #NMSetting8021x:ca-cert property. + * + * If NMSetting8021x:system-ca-certs is enabled and the built-in CA + * path is an existing directory, then this setting is ignored. **/ /* ---ifcfg-rh--- * property: ca-path - * variable: (none) - * description: The property is not handled by ifcfg-rh plugin. + * variable: IEEE_8021X_CA_PATH(+) + * description: The search path for the certificate. * ---end--- */ obj_properties[PROP_CA_PATH] = @@ -3964,15 +3970,18 @@ nm_setting_802_1x_class_init (NMSetting8021xClass *klass) * in the #NMSetting8021x:phase2-auth or #NMSetting8021x:phase2-autheap * properties. * - * Certificate data is specified using a "scheme"; two are currently - * supported: blob and path. When using the blob scheme (which is backwards - * compatible with NM 0.7.x) this property should be set to the - * certificate's DER encoded data. When using the path scheme, this property - * should be set to the full UTF-8 encoded path of the certificate, prefixed - * with the string "file://" and ending with a terminating NUL byte. This - * property can be unset even if the EAP method supports CA certificates, + * Certificate data is specified using a "scheme"; three are currently + * supported: blob, path and pkcs#11 URL. When using the blob scheme this property + * should be set to the certificate's DER encoded data. When using the path + * scheme, this property should be set to the full UTF-8 encoded path of the + * certificate, prefixed with the string "file://" and ending with a terminating + * NUL byte. + * This property can be unset even if the EAP method supports CA certificates, * but this allows man-in-the-middle attacks and is NOT recommended. * + * Note that enabling NMSetting8021x:system-ca-certs will override this + * setting to use the built-in path, if the built-in path is not a directory. + * * Setting this property directly is discouraged; use the * nm_setting_802_1x_set_phase2_ca_cert() function instead. **/ @@ -4024,7 +4033,16 @@ nm_setting_802_1x_class_init (NMSetting8021xClass *klass) * UTF-8 encoded path to a directory containing PEM or DER formatted * certificates to be added to the verification chain in addition to the * certificate specified in the #NMSetting8021x:phase2-ca-cert property. + * + * If NMSetting8021x:system-ca-certs is enabled and the built-in CA + * path is an existing directory, then this setting is ignored. **/ + /* ---ifcfg-rh--- + * property: phase2-ca-path + * variable: IEEE_8021X_PHASE2_CA_PATH(+) + * description: The search path for the certificate. + * ---end--- + */ obj_properties[PROP_PHASE2_CA_PATH] = g_param_spec_string (NM_SETTING_802_1X_PHASE2_CA_PATH, "", "", NULL, @@ -4262,8 +4280,8 @@ nm_setting_802_1x_class_init (NMSetting8021xClass *klass) **/ /* ---ifcfg-rh--- * property: password-raw-flags - * variable: (none) - * description: The property is not handled by ifcfg-rh plugin. + * variable: IEEE_8021X_PASSWORD_RAW_FLAGS(+) + * description: The secret flags for password-raw. * ---end--- */ obj_properties[PROP_PASSWORD_RAW_FLAGS] = @@ -4451,8 +4469,8 @@ nm_setting_802_1x_class_init (NMSetting8021xClass *klass) **/ /* ---ifcfg-rh--- * property: pin - * variable: (none) - * description: The property is not handled by ifcfg-rh plugin. + * variable: IEEE_8021X_PIN(+) + * description: The pin secret used for EAP authentication methods. * ---end--- */ obj_properties[PROP_PIN] = @@ -4469,8 +4487,8 @@ nm_setting_802_1x_class_init (NMSetting8021xClass *klass) **/ /* ---ifcfg-rh--- * property: pin-flags - * variable: (none) - * description: The property is not handled by ifcfg-rh plugin. + * variable: IEEE_8021X_PIN_FLAGS(+) + * description: The secret flags for the pin property. * ---end--- */ obj_properties[PROP_PIN_FLAGS] = @@ -4495,8 +4513,8 @@ nm_setting_802_1x_class_init (NMSetting8021xClass *klass) **/ /* ---ifcfg-rh--- * property: system-ca-certs - * variable: (none) - * description: The property is not handled by ifcfg-rh plugin. + * variable: IEEE_8021X_SYSTEM_CA_CERTS(+) + * description: a boolean value. * ---end--- */ obj_properties[PROP_SYSTEM_CA_CERTS] = diff --git a/libnm-core/nm-setting-ip-tunnel.c b/libnm-core/nm-setting-ip-tunnel.c index f6690e8b..5db2dde5 100644 --- a/libnm-core/nm-setting-ip-tunnel.c +++ b/libnm-core/nm-setting-ip-tunnel.c @@ -291,6 +291,14 @@ nm_setting_ip_tunnel_get_flags (NMSettingIPTunnel *setting) /*****************************************************************************/ +gboolean +_nm_ip_tunnel_mode_is_layer2 (NMIPTunnelMode mode) +{ + return NM_IN_SET (mode, + NM_IP_TUNNEL_MODE_GRETAP, + NM_IP_TUNNEL_MODE_IP6GRETAP); +} + static gboolean verify (NMSetting *setting, NMConnection *connection, GError **error) { @@ -444,9 +452,7 @@ verify (NMSetting *setting, NMConnection *connection, GError **error) } if ( nm_connection_get_setting_wired (connection) - && !NM_IN_SET (priv->mode, - NM_IP_TUNNEL_MODE_GRETAP, - NM_IP_TUNNEL_MODE_IP6GRETAP)) { + && !_nm_ip_tunnel_mode_is_layer2 (priv->mode)) { g_set_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY, diff --git a/libnm-core/nm-utils.c b/libnm-core/nm-utils.c index 7391b0f0..fed3f110 100644 --- a/libnm-core/nm-utils.c +++ b/libnm-core/nm-utils.c @@ -4269,7 +4269,8 @@ nm_utils_hwaddr_matches (gconstpointer hwaddr1, hwaddr1 = buf1; hwaddr1_len = l; } else { - g_return_val_if_fail ((hwaddr2_len == -1 && hwaddr2) || (hwaddr2_len > 0 && hwaddr2_len <= NM_UTILS_HWADDR_LEN_MAX), FALSE); + g_return_val_if_fail ( hwaddr2_len == -1 + || (hwaddr2_len > 0 && hwaddr2_len <= NM_UTILS_HWADDR_LEN_MAX), FALSE); return FALSE; } } else { @@ -4301,9 +4302,17 @@ nm_utils_hwaddr_matches (gconstpointer hwaddr1, } } + if (G_UNLIKELY ( hwaddr1_len <= 0 + || hwaddr1_len > NM_UTILS_HWADDR_LEN_MAX)) { + /* Only valid addresses can compare equal. In particular, + * addresses that are too long or of zero bytes, never + * compare equal. */ + return FALSE; + } + if (hwaddr1_len == INFINIBAND_ALEN) { - hwaddr1 = (guint8 *)hwaddr1 + INFINIBAND_ALEN - 8; - hwaddr2 = (guint8 *)hwaddr2 + INFINIBAND_ALEN - 8; + hwaddr1 = &((guint8 *) hwaddr1)[INFINIBAND_ALEN - 8]; + hwaddr2 = &((guint8 *) hwaddr2)[INFINIBAND_ALEN - 8]; hwaddr1_len = 8; } diff --git a/libnm-core/tests/test-general.c b/libnm-core/tests/test-general.c index 138702e4..2b1f1e3d 100644 --- a/libnm-core/tests/test-general.c +++ b/libnm-core/tests/test-general.c @@ -4277,7 +4277,7 @@ test_hwaddr_equal (void) g_assert (nm_utils_hwaddr_matches (null_binary, sizeof (null_binary), null_binary, sizeof (null_binary))); g_assert (nm_utils_hwaddr_matches (null_binary, sizeof (null_binary), NULL, ETH_ALEN)); - g_assert (nm_utils_hwaddr_matches (NULL, -1, NULL, -1)); + g_assert (!nm_utils_hwaddr_matches (NULL, -1, NULL, -1)); g_assert (!nm_utils_hwaddr_matches (NULL, -1, string, -1)); g_assert (!nm_utils_hwaddr_matches (string, -1, NULL, -1)); g_assert (!nm_utils_hwaddr_matches (NULL, -1, null_string, -1)); diff --git a/libnm-core/tests/test-setting.c b/libnm-core/tests/test-setting.c index cb8f41fb..072be57a 100644 --- a/libnm-core/tests/test-setting.c +++ b/libnm-core/tests/test-setting.c @@ -2051,8 +2051,8 @@ test_tc_config_qdisc (void) nmtst_assert_success (qdisc1, error); g_assert_cmpstr (nm_tc_qdisc_get_kind (qdisc1), ==, "pfifo_fast"); - g_assert (nm_tc_qdisc_get_handle (qdisc1) == TC_H_MAKE (0x1234 << 16, 0x0000)); - g_assert (nm_tc_qdisc_get_parent (qdisc1) == TC_H_MAKE (0xfff1 << 16, 0x0001)); + g_assert (nm_tc_qdisc_get_handle (qdisc1) == TC_H_MAKE (0x1234u << 16, 0x0000u)); + g_assert (nm_tc_qdisc_get_parent (qdisc1) == TC_H_MAKE (0xfff1u << 16, 0x0001u)); str = nm_utils_tc_qdisc_to_str (qdisc1, &error); nmtst_assert_success (str, error); @@ -2133,12 +2133,12 @@ test_tc_config_tfilter (void) GError *error = NULL; tfilter1 = nm_tc_tfilter_new ("matchall", - TC_H_MAKE (0x1234 << 16, 0x0000), + TC_H_MAKE (0x1234u << 16, 0x0000u), &error); nmtst_assert_success (tfilter1, error); tfilter2 = nm_tc_tfilter_new ("matchall", - TC_H_MAKE (0x1234 << 16, 0x0000), + TC_H_MAKE (0x1234u << 16, 0x0000u), &error); nmtst_assert_success (tfilter2, error); @@ -2192,10 +2192,10 @@ test_tc_config_setting_valid (void) nmtst_assert_success (qdisc1, error); qdisc2 = nm_tc_qdisc_new ("pfifo_fast", - TC_H_MAKE (0xfff1 << 16, 0x0001), + TC_H_MAKE (0xfff1u << 16, 0x0001u), &error); nmtst_assert_success (qdisc2, error); - nm_tc_qdisc_set_handle (qdisc2, TC_H_MAKE (0x1234 << 16, 0x0000)); + nm_tc_qdisc_set_handle (qdisc2, TC_H_MAKE (0x1234u << 16, 0x0000u)); g_assert (nm_setting_tc_config_get_num_qdiscs (s_tc) == 0); g_assert (nm_setting_tc_config_add_qdisc (s_tc, qdisc1) == TRUE); @@ -2298,16 +2298,16 @@ test_tc_config_dbus (void) qdisc1 = nm_tc_qdisc_new ("fq_codel", TC_H_ROOT, &error); nmtst_assert_success (qdisc1, error); - nm_tc_qdisc_set_handle (qdisc1, TC_H_MAKE (0x1234 << 16, 0x0000)); + nm_tc_qdisc_set_handle (qdisc1, TC_H_MAKE (0x1234u << 16, 0x0000u)); nm_setting_tc_config_add_qdisc (NM_SETTING_TC_CONFIG (s_tc), qdisc1); qdisc2 = nm_tc_qdisc_new ("ingress", TC_H_INGRESS, &error); nmtst_assert_success (qdisc2, error); - nm_tc_qdisc_set_handle (qdisc2, TC_H_MAKE (TC_H_INGRESS, 0)); + nm_tc_qdisc_set_handle (qdisc2, TC_H_MAKE (TC_H_INGRESS, 0u)); nm_setting_tc_config_add_qdisc (NM_SETTING_TC_CONFIG (s_tc), qdisc2); tfilter1 = nm_tc_tfilter_new ("matchall", - TC_H_MAKE (0x1234 << 16, 0x0000), + TC_H_MAKE (0x1234u << 16, 0x0000u), &error); nmtst_assert_success (tfilter1, error); action = nm_tc_action_new ("drop", &error); @@ -2318,7 +2318,7 @@ test_tc_config_dbus (void) nm_tc_tfilter_unref (tfilter1); tfilter2 = nm_tc_tfilter_new ("matchall", - TC_H_MAKE (TC_H_INGRESS, 0), + TC_H_MAKE (TC_H_INGRESS, 0u), &error); nmtst_assert_success (tfilter2, error); action = nm_tc_action_new ("simple", &error); |