summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2022-03-19 00:49:09 +0100
committerThomas Haller <thaller@redhat.com>2022-03-29 11:52:37 +0200
commita3aec9dc5ca1a69043a2b60522595dc31127a4f1 (patch)
treed96c2d42b00a73b7580d1d33846937c36ee324f8
parentd5ee67981c16c7bcb464b92f5981d101f254b4e1 (diff)
downloadNetworkManager-a3aec9dc5ca1a69043a2b60522595dc31127a4f1.tar.gz
libnm/802-1x: reuse verify_identity() in verify_ttls() implementation
-rw-r--r--src/libnm-core-impl/nm-setting-8021x.c72
1 files changed, 28 insertions, 44 deletions
diff --git a/src/libnm-core-impl/nm-setting-8021x.c b/src/libnm-core-impl/nm-setting-8021x.c
index 1f2db8fc33..a9cafde1c2 100644
--- a/src/libnm-core-impl/nm-setting-8021x.c
+++ b/src/libnm-core-impl/nm-setting-8021x.c
@@ -2615,6 +2615,33 @@ need_secrets_tls(NMSetting8021x *self, GPtrArray *secrets, gboolean phase2)
}
static gboolean
+verify_identity(NMSetting8021x *self, gboolean phase2, GError **error)
+{
+ NMSetting8021xPrivate *priv = NM_SETTING_802_1X_GET_PRIVATE(self);
+
+ if (nm_str_is_empty(priv->identity)) {
+ if (!priv->identity) {
+ g_set_error_literal(error,
+ NM_CONNECTION_ERROR,
+ NM_CONNECTION_ERROR_MISSING_PROPERTY,
+ _("property is missing"));
+ } else {
+ g_set_error_literal(error,
+ NM_CONNECTION_ERROR,
+ NM_CONNECTION_ERROR_INVALID_PROPERTY,
+ _("property is empty"));
+ }
+ g_prefix_error(error,
+ "%s.%s: ",
+ NM_SETTING_802_1X_SETTING_NAME,
+ NM_SETTING_802_1X_IDENTITY);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static gboolean
verify_tls(NMSetting8021x *self, gboolean phase2, GError **error)
{
NMSetting8021xPrivate *priv = NM_SETTING_802_1X_GET_PRIVATE(self);
@@ -2689,24 +2716,8 @@ verify_ttls(NMSetting8021x *self, gboolean phase2, GError **error)
{
NMSetting8021xPrivate *priv = NM_SETTING_802_1X_GET_PRIVATE(self);
- if (nm_str_is_empty(priv->identity)) {
- if (!priv->identity) {
- g_set_error_literal(error,
- NM_CONNECTION_ERROR,
- NM_CONNECTION_ERROR_MISSING_PROPERTY,
- _("property is missing"));
- } else {
- g_set_error_literal(error,
- NM_CONNECTION_ERROR,
- NM_CONNECTION_ERROR_INVALID_PROPERTY,
- _("property is empty"));
- }
- g_prefix_error(error,
- "%s.%s: ",
- NM_SETTING_802_1X_SETTING_NAME,
- NM_SETTING_802_1X_IDENTITY);
+ if (!verify_identity(self, phase2, error))
return FALSE;
- }
if ((!priv->phase2_auth && !priv->phase2_autheap)
|| (priv->phase2_auth && priv->phase2_autheap)) {
@@ -2726,33 +2737,6 @@ verify_ttls(NMSetting8021x *self, gboolean phase2, GError **error)
return TRUE;
}
-static gboolean
-verify_identity(NMSetting8021x *self, gboolean phase2, GError **error)
-{
- NMSetting8021xPrivate *priv = NM_SETTING_802_1X_GET_PRIVATE(self);
-
- if (nm_str_is_empty(priv->identity)) {
- if (!priv->identity) {
- g_set_error_literal(error,
- NM_CONNECTION_ERROR,
- NM_CONNECTION_ERROR_MISSING_PROPERTY,
- _("property is missing"));
- } else {
- g_set_error_literal(error,
- NM_CONNECTION_ERROR,
- NM_CONNECTION_ERROR_INVALID_PROPERTY,
- _("property is empty"));
- }
- g_prefix_error(error,
- "%s.%s: ",
- NM_SETTING_802_1X_SETTING_NAME,
- NM_SETTING_802_1X_IDENTITY);
- return FALSE;
- }
-
- return TRUE;
-}
-
static void
need_secrets_phase2(NMSetting8021x *self, GPtrArray *secrets, gboolean phase2)
{