diff --git a/clients/cli/Makefile.am b/clients/cli/Makefile.am index eef99cba71..2f394098a9 100644 --- a/clients/cli/Makefile.am +++ b/clients/cli/Makefile.am @@ -14,7 +14,9 @@ AM_CPPFLAGS = \ $(GLIB_CFLAGS) \ -DG_LOG_DOMAIN=\""nmcli"\" \ -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ - -DNMCLI_LOCALEDIR=\"$(datadir)/locale\" + -DNMCLI_LOCALEDIR=\"$(datadir)/locale\" \ + -DNMCONFDIR=\"$(nmconfdir)\" \ + -DNMLIBDIR=\"$(libdir)\" nmcli_SOURCES = \ agent.c \ @@ -38,6 +40,8 @@ nmcli_SOURCES = \ \ $(srcdir)/../common/nm-secret-agent-simple.c \ $(srcdir)/../common/nm-secret-agent-simple.h \ + $(srcdir)/../common/nm-vpn-helpers.c \ + $(srcdir)/../common/nm-vpn-helpers.h \ $(NULL) nmcli_LDADD = \ diff --git a/clients/common/nm-secret-agent-simple.c b/clients/common/nm-secret-agent-simple.c index 8e43c376cb..d8cfdce008 100644 --- a/clients/common/nm-secret-agent-simple.c +++ b/clients/common/nm-secret-agent-simple.c @@ -39,6 +39,7 @@ #include #include +#include "nm-vpn-helpers.h" #include "nm-secret-agent-simple.h" G_DEFINE_TYPE (NMSecretAgentSimple, nm_secret_agent_simple, NM_TYPE_SECRET_AGENT_OLD) @@ -338,53 +339,6 @@ add_pppoe_secrets (NMSecretAgentSimpleRequest *request, return TRUE; } -struct { - const char *name; - const char *ui_name; -} typedef VpnPasswordName; - -static const VpnPasswordName * -vpn_get_secret_names (const char *vpn_type) -{ - const char *type; - static VpnPasswordName generic_vpn_secrets[] = { {"password", N_("Password")}, {NULL, NULL} }; - static VpnPasswordName vpnc_secrets[] = { {"Xauth password", N_("Password")}, - {"IPSec secret", N_("Group password")}, - {NULL, NULL} }; - static VpnPasswordName swan_secrets[] = { {"xauthpassword", N_("Password")}, - {"pskvalue", N_("Group password")}, - {NULL, NULL} }; - static VpnPasswordName openconnect_secrets[] = { {"gateway", N_("Gateway")}, - {"cookie", N_("Cookie")}, - {"gwcert", N_("Gateway certificate hash")}, - {NULL, NULL} }; - - if (!vpn_type) - return NULL; - - if (g_str_has_prefix (vpn_type, NM_DBUS_INTERFACE)) - type = vpn_type + strlen (NM_DBUS_INTERFACE) + 1; - else - type = vpn_type; - - if ( !g_strcmp0 (type, "openvpn") - || !g_strcmp0 (type, "pptp") - || !g_strcmp0 (type, "iodine") - || !g_strcmp0 (type, "ssh") - || !g_strcmp0 (type, "l2tp") - || !g_strcmp0 (type, "fortisslvpn")) - return generic_vpn_secrets; - else if (!g_strcmp0 (type, "vpnc")) - return vpnc_secrets; - else if ( !g_strcmp0 (type, "openswan") - || !g_strcmp0 (type, "libreswan") - || !g_strcmp0 (type, "strongswan")) - return swan_secrets; - else if (!g_strcmp0 (type, "openconnect")) - return openconnect_secrets; - return NULL; -} - static NMSettingSecretFlags get_vpn_secret_flags (NMSettingVpn *s_vpn, const char *secret_name) { @@ -464,7 +418,7 @@ add_vpn_secrets (NMSecretAgentSimpleRequest *request, *msg = g_strdup (tmp); /* Now add what client thinks might be required, because hints may be empty or incomplete */ - p = secret_names = vpn_get_secret_names (nm_setting_vpn_get_service_type (s_vpn)); + p = secret_names = nm_vpn_get_secret_names (nm_setting_vpn_get_service_type (s_vpn)); while (p && p->name) { add_vpn_secret_helper (secrets, s_vpn, p->name, _(p->ui_name)); p++; diff --git a/clients/common/nm-vpn-helpers.c b/clients/common/nm-vpn-helpers.c index eaa0917158..121b87a129 100644 --- a/clients/common/nm-vpn-helpers.c +++ b/clients/common/nm-vpn-helpers.c @@ -28,9 +28,9 @@ #include #include #include +#include #include -#include "nm-vpn-editor-plugin.h" #include "nm-vpn-helpers.h" @@ -225,3 +225,46 @@ nm_vpn_supports_ipv6 (NMConnection *connection) capabilities = nm_vpn_editor_plugin_get_capabilities (plugin); return (capabilities & NM_VPN_EDITOR_PLUGIN_CAPABILITY_IPV6) != 0; } + +const VpnPasswordName * +nm_vpn_get_secret_names (const char *vpn_type) +{ + const char *type; + static VpnPasswordName generic_vpn_secrets[] = { {"password", N_("Password")}, {NULL, NULL} }; + static VpnPasswordName vpnc_secrets[] = { {"Xauth password", N_("Password")}, + {"IPSec secret", N_("Group password")}, + {NULL, NULL} }; + static VpnPasswordName swan_secrets[] = { {"xauthpassword", N_("Password")}, + {"pskvalue", N_("Group password")}, + {NULL, NULL} }; + static VpnPasswordName openconnect_secrets[] = { {"gateway", N_("Gateway")}, + {"cookie", N_("Cookie")}, + {"gwcert", N_("Gateway certificate hash")}, + {NULL, NULL} }; + + if (!vpn_type) + return NULL; + + if (g_str_has_prefix (vpn_type, NM_DBUS_INTERFACE)) + type = vpn_type + strlen (NM_DBUS_INTERFACE) + 1; + else + type = vpn_type; + + if ( !g_strcmp0 (type, "openvpn") + || !g_strcmp0 (type, "pptp") + || !g_strcmp0 (type, "iodine") + || !g_strcmp0 (type, "ssh") + || !g_strcmp0 (type, "l2tp") + || !g_strcmp0 (type, "fortisslvpn")) + return generic_vpn_secrets; + else if (!g_strcmp0 (type, "vpnc")) + return vpnc_secrets; + else if ( !g_strcmp0 (type, "openswan") + || !g_strcmp0 (type, "libreswan") + || !g_strcmp0 (type, "strongswan")) + return swan_secrets; + else if (!g_strcmp0 (type, "openconnect")) + return openconnect_secrets; + return NULL; +} + diff --git a/clients/common/nm-vpn-helpers.h b/clients/common/nm-vpn-helpers.h index 7ec21a71e2..50e1251004 100644 --- a/clients/common/nm-vpn-helpers.h +++ b/clients/common/nm-vpn-helpers.h @@ -20,14 +20,21 @@ #define __NM_VPN_HELPERS_H__ #include -#include +#include #include +struct { + const char *name; + const char *ui_name; +} typedef VpnPasswordName; + GSList *nm_vpn_get_plugins (GError **error); NMVpnEditorPlugin *nm_vpn_get_plugin_by_service (const char *service); gboolean nm_vpn_supports_ipv6 (NMConnection *connection); +const VpnPasswordName * nm_vpn_get_secret_names (const char *vpn_type); + #endif /* __NM_VPN_HELPERS_H__ */ diff --git a/clients/tui/Makefile.am b/clients/tui/Makefile.am index f6d93be2b4..a84fcdffe3 100644 --- a/clients/tui/Makefile.am +++ b/clients/tui/Makefile.am @@ -18,6 +18,8 @@ AM_CPPFLAGS= \ -DG_LOG_DOMAIN=\""nmtui"\" \ -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ -DLOCALEDIR=\""$(localedir)"\" \ + -DNMCONFDIR=\"$(nmconfdir)\" \ + -DNMLIBDIR=\"$(libdir)\" \ $(NULL) bin_PROGRAMS = nmtui @@ -116,6 +118,8 @@ nmtui_SOURCES = \ nmt-widget-list.h \ $(srcdir)/../common/nm-secret-agent-simple.c \ $(srcdir)/../common/nm-secret-agent-simple.h \ + $(srcdir)/../common/nm-vpn-helpers.c \ + $(srcdir)/../common/nm-vpn-helpers.h \ $(NULL) nmtui_LDADD = \ diff --git a/po/POTFILES.in b/po/POTFILES.in index 6c09b21ff0..19ef9df384 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -12,6 +12,7 @@ clients/cli/settings.c clients/cli/utils.c clients/common/nm-polkit-listener.c clients/common/nm-secret-agent-simple.c +clients/common/nm-vpn-helpers.c clients/nm-online.c clients/tui/newt/nmt-newt-utils.c clients/tui/nm-editor-utils.c