diff options
author | David Woodhouse <dwmw2@infradead.org> | 2023-05-11 12:17:43 +0100 |
---|---|---|
committer | David Woodhouse <dwmw2@infradead.org> | 2023-05-11 13:15:53 +0100 |
commit | f791b98284c3b6037e74b7e487aa02e6ad38a1cf (patch) | |
tree | a0c4c19011ea76198037819d36aa199a1088cac7 | |
parent | db7ea2e5d41b7bf51eedb1fd481c3a5072953829 (diff) | |
download | NetworkManager-f791b98284c3b6037e74b7e487aa02e6ad38a1cf.tar.gz |
libnmc-base: report explicit error if not gateway configured for openconnect
Rather than letting openconnect run, and whine that there's no gateway,
and making the user scroll up past the openconnect usage information,
give them an explicit error.
-rw-r--r-- | src/libnmc-base/nm-vpn-helpers.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/libnmc-base/nm-vpn-helpers.c b/src/libnmc-base/nm-vpn-helpers.c index 1edc70d7dc..1a43fbc1a0 100644 --- a/src/libnmc-base/nm-vpn-helpers.c +++ b/src/libnmc-base/nm-vpn-helpers.c @@ -261,8 +261,16 @@ nm_vpn_openconnect_authenticate_helper(NMSettingVpn *s_vpn, GPtrArray *secrets, int i, oc_argc = 0; /* Get gateway and port */ - gw = nm_setting_vpn_get_data_item(s_vpn, "gateway"); - port = gw ? strrchr(gw, ':') : NULL; + gw = nm_setting_vpn_get_data_item(s_vpn, "gateway"); + if (!gw) { + g_set_error(error, + NM_VPN_PLUGIN_ERROR, + NM_VPN_PLUGIN_ERROR_FAILED, + _("no gateway configured")); + return FALSE; + } + + port = strrchr(gw, ':'); path = nm_utils_file_search_in_paths("openconnect", "/usr/sbin/openconnect", |