Commit 6734620e authored by CeRiAl's avatar CeRiAl

Just push everything

parent 85a5abb6
......@@ -6,7 +6,7 @@ Tested on:
* ElementaryOS Freya
* Linux Mint Rebecca Cinnamon
$ sudo apt-get install build-essential autoconf libtool intltool ppp-dev git xl2tpd strongswan libglib2.0-dev libdbus-glib-1-dev libnm-util-dev libnm-glib-vpn-dev libgnome-keyring-dev libgtk-3-dev
$ sudo apt-get install build-essential autoconf libtool intltool ppp-dev git xl2tpd strongswan ipsec-tools libglib2.0-dev libdbus-glib-1-dev libnm-dev libnm-util-dev libnm-glib-vpn-dev libgnome-keyring-dev libgtk-3-dev
$ git clone https://git.cryptopath.org/cerial/NetworkManager-l2tp.git
$ cd NetworkManager-l2tp/
$ ./autogen.sh
......
......@@ -9,9 +9,14 @@ endif
dbusservicedir = $(sysconfdir)/dbus-1/system.d
dbusservice_DATA = nm-ipsec-l2tp-service.conf
nmvpnservicedir = $(sysconfdir)/NetworkManager/VPN
nmvpnservicedir = $(NM_VPN_SERVICE_DIR)
nmvpnservice_DATA = nm-ipsec-l2tp-service.name
if WITH_LIBNM_GLIB
nmvpnoldservicedir = $(sysconfdir)/NetworkManager/VPN
nmvpnoldservice_DATA = nm-ipsec-l2tp-service.name
endif
desktopfile = nm-ipsec-l2tp.desktop.in
iconfile = gnome-mime-application-x-ipsec-l2tp-settings.png
......
INCLUDES = -I${top_srcdir}
libexec_PROGRAMS = nm-ipsec-l2tp-auth-dialog
nm_ipsec_l2tp_auth_dialog_CPPFLAGS = \
$(NM_CFLAGS) \
$(GLIB_CFLAGS) \
$(GTK_CFLAGS) \
$(GNOMEKEYRING_CFLAGS) \
-Wno-error=deprecated-declarations \
-DICONDIR=\""$(datadir)/pixmaps"\" \
-DUIDIR=\""$(uidir)"\" \
-DBINDIR=\""$(bindir)"\" \
-DG_DISABLE_DEPRECATED \
nm_ipsec_l2tp_auth_dialog_CPPFLAGS = \
$(LIBNM_CFLAGS) \
$(GLIB_CFLAGS) \
$(GTK_CFLAGS) \
$(GNOMEKEYRING_CFLAGS) \
-I"${top_srcdir}/shared/" \
-Wno-error=deprecated-declarations \
-DICONDIR=\""$(datadir)/pixmaps"\" \
-DUIDIR=\""$(uidir)"\" \
-DBINDIR=\""$(bindir)"\" \
-DG_DISABLE_DEPRECATED \
-DVERSION=\"$(VERSION)\"
nm_ipsec_l2tp_auth_dialog_SOURCES = \
main.c \
vpn-password-dialog.c \
nm_ipsec_l2tp_auth_dialog_SOURCES = \
main.c \
vpn-password-dialog.c \
vpn-password-dialog.h
nm_ipsec_l2tp_auth_dialog_LDADD = \
$(NM_LIBS) \
$(GTK_LIBS) \
nm_ipsec_l2tp_auth_dialog_LDADD = \
$(LIBNM_LIBS) \
$(GTK_LIBS) \
$(GNOMEKEYRING_LIBS)
CLEANFILES = *~
......@@ -24,6 +24,8 @@
#include <config.h>
#endif
#include "nm-default.h"
#include <string.h>
#include <stdlib.h>
#include <errno.h>
......@@ -33,10 +35,14 @@
#include <gnome-keyring.h>
#include <gnome-keyring-memory.h>
#include <nm-setting-vpn.h>
#include <nm-vpn-plugin-utils.h>
//#include <libsecret/secret.h>
//#include <nm-setting-vpn.h>
//#include <NetworkManager.h>
//#include <nm-vpn-service-plugin.h>
#include "../src/nm-ipsec-l2tp-service-defines.h"
#include <src/nm-ipsec-l2tp-service.h>
#include "vpn-password-dialog.h"
#define KEYRING_UUID_TAG "connection-uuid"
......@@ -218,7 +224,7 @@ wait_for_quit (void)
g_string_free (str, TRUE);
}
int
int
main (int argc, char *argv[])
{
gboolean retry = FALSE, allow_interaction = FALSE, external_ui_mode = FALSE;
......@@ -257,13 +263,13 @@ main (int argc, char *argv[])
return 1;
}
if (!nm_vpn_plugin_utils_read_vpn_details (0, &data, &secrets)) {
if (!nm_vpn_service_plugin_read_vpn_details (0, &data, &secrets)) {
fprintf (stderr, "Failed to read '%s' (%s) data and secrets from stdin.\n",
vpn_name, vpn_uuid);
return 1;
}
nm_vpn_plugin_utils_get_secret_flags (secrets, NM_IPSEC_L2TP_KEY_PASSWORD, &pw_flags);
nm_vpn_service_plugin_get_secret_flags (secrets, NM_IPSEC_L2TP_KEY_PASSWORD, &pw_flags);
if (!get_secrets (vpn_uuid, vpn_name, retry, allow_interaction, external_ui_mode,
g_hash_table_lookup (secrets, NM_IPSEC_L2TP_KEY_PASSWORD),
......
......@@ -54,6 +54,9 @@ dnl
AC_ARG_WITH(gnome, AS_HELP_STRING([--without-gnome], [Build NetworkManager-ipsec-l2tp without GNOME support, e.g. vpn service only]))
AM_CONDITIONAL(WITH_GNOME, test x"$with_gnome" != xno)
AC_ARG_WITH(libnm-glib, AS_HELP_STRING([--without-libnm-glib], [Build NetworkManager-ipsec-l2tp without libnm-glib comatibility]))
AM_CONDITIONAL(WITH_LIBNM_GLIB, test x"$with_libnm_glib" != xno)
GETTEXT_PACKAGE=NetworkManager-ipsec-l2tp
AC_SUBST(GETTEXT_PACKAGE)
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [Gettext package])
......@@ -61,23 +64,12 @@ AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [Gettext package])
IT_PROG_INTLTOOL([0.35])
AM_GLIB_GNU_GETTEXT
PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.32)
# gio-unix will require glib and gio
PKG_CHECK_MODULES(GLIB, gio-unix-2.0 >= 2.32)
AC_SUBST(GLIB_CFLAGS)
AC_SUBST(GLIB_LIBS)
GLIB_CFLAGS="$GLIB_CFLAGS -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_32"
PKG_CHECK_MODULES(DBUS, dbus-glib-1 >= 0.74)
AC_SUBST(DBUS_GLIB_CFLAGS)
AC_SUBST(DBUS_GLIB_LIBS)
PKG_CHECK_MODULES(NM,
NetworkManager >= 0.9.8
libnm-util >= 0.9.8
libnm-glib >= 0.9.8
libnm-glib-vpn >= 0.9.8)
AC_SUBST(NM_CFLAGS)
AC_SUBST(NM_LIBS)
if test x"$with_gnome" != xno; then
PKG_CHECK_MODULES(GTK, gtk+-3.0 >= 3.4)
AC_SUBST(GTK_CFLAGS)
......@@ -87,6 +79,16 @@ if test x"$with_gnome" != xno; then
PKG_CHECK_MODULES(GNOMEKEYRING, gnome-keyring-1)
AC_SUBST(GNOMEKEYRING_CFLAGS)
AC_SUBST(GNOMEKEYRING_LIBS)
if test x"$with_libnm_glib" != xno; then
PKG_CHECK_MODULES(LIBNM_GLIB,
NetworkManager >= 1.1.0
libnm-util >= 1.1.0
libnm-glib >= 1.1.0
libnm-glib-vpn >= 1.1.0)
AC_SUBST(LIBNM_GLIB_CFLAGS)
AC_SUBST(LIBNM_GLIB_LIBS)
fi
fi
NM_COMPILER_WARNINGS
......@@ -99,6 +101,15 @@ if ! test x"$ac_distver" = x""; then
AC_DEFINE_UNQUOTED(DIST_VERSION, "$ac_distver", [Define the distribution version string])
fi
PKG_CHECK_MODULES(LIBNM, libnm >= 1.1.0)
LIBNM_CFLAGS="$LIBNM_CFLAGS -DNM_VERSION_MIN_REQUIRED=NM_VERSION_1_2"
LIBNM_CFLAGS="$LIBNM_CFLAGS -DNM_VERSION_MAX_ALLOWED=NM_VERSION_1_2"
NM_VPN_SERVICE_DIR=`$PKG_CONFIG --define-variable prefix='\${prefix}' --variable vpnservicedir libnm`
AC_SUBST(NM_VPN_SERVICE_DIR)
NM_COMPILER_WARNINGS
AC_CONFIG_FILES([
Makefile
src/Makefile
......
......@@ -3,6 +3,9 @@ name=ipsec-l2tp
service=org.freedesktop.NetworkManager.ipsec_l2tp
program=@LIBEXECDIR@/nm-ipsec-l2tp-service
[libnm]
plugin=@PLUGINDIR@/libnm-vpn-plugin-ipsec-l2tp.so
[GNOME]
auth-dialog=@LIBEXECDIR@/nm-ipsec-l2tp-auth-dialog
properties=@PLUGINDIR@/libnm-ipsec-l2tp-properties
......
# Slovenian translation for network-manager-ipsec-l2tp.
# Copyright (C) 2009 network-manager-ipsec-l2tp's COPYRIGHT HOLDER
# This file is distributed under the same license as the network-manager-ipsec-l2tp package.
# Copyright (C) 2009 network-manager-ipsec-l2tp's COPYRIGHT HOLDER
# This file is distributed under the same license as the network-manager-ipsec-l2tp package.
#
# Matej Urbančič <mateju@svn.gnome.org>, 2009 - 2010.
#
# Matej Urbančič <mateju@svn.gnome.org>, 2009 - 2010.
#
msgid ""
msgstr ""
"Project-Id-Version: network-manager-ipsec-l2tp master\n"
......
plugindir = $(libdir)/NetworkManager
plugin_LTLIBRARIES = libnm-ipsec-l2tp-properties.la
plugin_LTLIBRARIES = libnm-vpn-plugin-ipsec-l2tp.la
if WITH_LIBNM_GLIB
plugin_LTLIBRARIES += libnm-ipsec-l2tp-properties.la
endif
INCLUDES = -I${top_srcdir}
libnm_ipsec_l2tp_properties_la_SOURCES = \
libnm_vpn_plugin_ipsec_l2tp_la_SOURCES = \
nm-ipsec-l2tp.c \
nm-ipsec-l2tp.h \
ipsec-dialog.c \
ipsec-dialog.h \
advanced-dialog.c \
advanced-dialog.h \
import-export.c \
import-export.h
advanced-dialog.h
# import-export.c \
# import-export.h
libnm_ipsec_l2tp_properties_la_SOURCES = \
$(libnm_vpn_plugin_ipsec_l2tp_la_SOURCES)
uidir = $(datadir)/gnome-vpn-properties/l2tp
uidir = $(datadir)/gnome-vpn-properties/ipsec-l2tp
ui_DATA = nm-ipsec-l2tp-dialog.ui
libnm_ipsec_l2tp_properties_la_CFLAGS = \
$(GLIB_CFLAGS) \
$(GTK_CFLAGS) \
$(NM_CFLAGS) \
-DICONDIR=\""$(datadir)/pixmaps"\" \
-DUIDIR=\""$(uidir)"\" \
-DLOCALEDIR=\""$(datadir)/locale"\" \
-DG_DISABLE_DEPRECATED \
-DVERSION=\"$(VERSION)\"
common_CFLAGS = \
$(GLIB_CFLAGS) \
$(GTK_CFLAGS) \
-DICONDIR=\""$(datadir)/pixmaps"\" \
-DUIDIR=\""$(uidir)"\" \
-DLOCALEDIR=\""$(datadir)/locale"\" \
-DG_DISABLE_DEPRECATED \
-DVERSION=\"$(VERSION)\"
libnm_vpn_plugin_ipsec_l2tp_la_CFLAGS = \
$(common_CFLAGS) \
$(LIBNM_CFLAGS)
libnm_ipsec_l2tp_properties_la_CFLAGS = \
-DNM_IPSEC_L2TP_OLD \
$(common_CFLAGS) \
$(LIBNM_GLIB_CFLAGS)
libnm_vpn_plugin_ipsec_l2tp_la_LIBADD = \
$(GTK_LIBS) \
$(LIBNM_LIBS)
libnm_ipsec_l2tp_properties_la_LIBADD = \
$(GTK_LIBS) \
$(NM_LIBS)
$(GTK_LIBS) \
$(LIBNM_GLIB_LIBS)
libnm_vpn_plugin_ipsec_l2tp_la_LDFLAGS = \
-avoid-version
libnm_ipsec_l2tp_properties_la_LDFLAGS = \
-avoid-version
$(libnm_vpn_plugin_ipsec_l2tp_la_LDFLAGS)
CLEANFILES = *.bak *~
......
......@@ -35,12 +35,9 @@
#include <glib.h>
#include <glib/gi18n-lib.h>
#include <nm-connection.h>
#include <nm-setting-vpn.h>
#include "advanced-dialog.h"
#include "nm-ipsec-l2tp.h"
#include "../src/nm-ipsec-l2tp-service.h"
#include "../src/nm-ipsec-l2tp-service-defines.h"
#define COL_NAME 0
#define COL_VALUE 1
......@@ -66,8 +63,6 @@ static const char *advanced_keys[] = {
NM_IPSEC_L2TP_KEY_NOBSDCOMP,
NM_IPSEC_L2TP_KEY_NODEFLATE,
NM_IPSEC_L2TP_KEY_NO_VJ_COMP,
NM_IPSEC_L2TP_KEY_NO_PCOMP,
NM_IPSEC_L2TP_KEY_NO_ACCOMP,
NM_IPSEC_L2TP_KEY_LCP_ECHO_FAILURE,
NM_IPSEC_L2TP_KEY_LCP_ECHO_INTERVAL,
NULL
......@@ -91,11 +86,11 @@ advanced_dialog_new_hash_from_connection (NMConnection *connection,
GError **error)
{
GHashTable *hash;
NMSettingVPN *s_vpn;
NMSettingVpn *s_vpn;
hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
s_vpn = (NMSettingVPN *) nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN);
s_vpn = (NMSettingVpn *) nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN);
nm_setting_vpn_foreach_data_item (s_vpn, copy_values, hash);
return hash;
}
......@@ -282,7 +277,7 @@ auth_methods_setup (GtkBuilder *builder, GHashTable *hash)
value = g_hash_table_lookup (hash, NM_IPSEC_L2TP_KEY_REQUIRE_MPPE);
if (value && !strcmp (value, "yes"))
use_mppe = TRUE;
/* Or MPPE-128 */
value = g_hash_table_lookup (hash, NM_IPSEC_L2TP_KEY_REQUIRE_MPPE_128);
if (value && !strcmp (value, "yes"))
......@@ -468,18 +463,6 @@ advanced_dialog_new (GHashTable *hash)
if (value && !strcmp (value, "yes"))
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE);
widget = GTK_WIDGET (gtk_builder_get_object (builder,"ppp_usepcomp"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
value = g_hash_table_lookup (hash, NM_IPSEC_L2TP_KEY_NO_PCOMP);
if (value && !strcmp (value, "yes"))
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE);
widget = GTK_WIDGET (gtk_builder_get_object (builder, "ppp_useaccomp"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
value = g_hash_table_lookup (hash, NM_IPSEC_L2TP_KEY_NO_ACCOMP);
if (value && !strcmp (value, "yes"))
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE);
widget = GTK_WIDGET (gtk_builder_get_object (builder, "ppp_send_echo_packets"));
value = g_hash_table_lookup (hash, NM_IPSEC_L2TP_KEY_LCP_ECHO_INTERVAL);
if (value && strlen (value)) {
......@@ -554,14 +537,6 @@ advanced_dialog_new_hash_from_dialog (GtkWidget *dialog, GError **error)
if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
g_hash_table_insert (hash, g_strdup (NM_IPSEC_L2TP_KEY_NO_VJ_COMP), g_strdup ("yes"));
widget = GTK_WIDGET (gtk_builder_get_object (builder,"ppp_usepcomp"));
if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
g_hash_table_insert (hash, g_strdup (NM_IPSEC_L2TP_KEY_NO_PCOMP), g_strdup ("yes"));
widget = GTK_WIDGET (gtk_builder_get_object (builder, "ppp_useaccomp"));
if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
g_hash_table_insert (hash, g_strdup (NM_IPSEC_L2TP_KEY_NO_ACCOMP), g_strdup ("yes"));
widget = GTK_WIDGET (gtk_builder_get_object (builder, "ppp_send_echo_packets"));
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) {
g_hash_table_insert (hash, g_strdup (NM_IPSEC_L2TP_KEY_LCP_ECHO_FAILURE), g_strdup_printf ("%d", 5));
......
......@@ -19,13 +19,19 @@
*
**************************************************************************/
#ifndef _AUTH_HELPERS_H_
#define _AUTH_HELPERS_H_
#ifndef _ADVANCED_DIALOG_H_
#define _ADVANCED_DIALOG_H_
#include <glib.h>
#include <gtk/gtk.h>
#ifdef NM_IPSEC_L2TP_OLD
#define NM_VPN_LIBNM_COMPAT
#include <nm-connection.h>
#include <nm-setting-vpn.h>
#else /* !NM_IPSEC_L2TP_OLD */
#include <NetworkManager.h>
#endif
GtkWidget *advanced_dialog_new (GHashTable *hash);
......
......@@ -37,9 +37,9 @@
#include <glib/gi18n-lib.h>
#include <nm-setting-vpn.h>
#include <nm-setting-connection.h>
#include <nm-setting-ip4-config.h>
//#include <nm-setting-vpn.h>
//#include <nm-setting-connection.h>
//#include <nm-setting-ip4-config.h>
#include "import-export.h"
#include "nm-ipsec-l2tp.h"
......@@ -104,8 +104,6 @@ static VpnImportExportProperty vpn_properties[] = {
{ NM_IPSEC_L2TP_KEY_NOBSDCOMP, G_TYPE_BOOLEAN, FALSE },
{ NM_IPSEC_L2TP_KEY_NODEFLATE, G_TYPE_BOOLEAN, FALSE },
{ NM_IPSEC_L2TP_KEY_NO_VJ_COMP, G_TYPE_BOOLEAN, FALSE },
{ NM_IPSEC_L2TP_KEY_NO_PCOMP, G_TYPE_BOOLEAN, FALSE },
{ NM_IPSEC_L2TP_KEY_NO_ACCOMP, G_TYPE_BOOLEAN, FALSE },
{ NM_IPSEC_L2TP_KEY_LCP_ECHO_FAILURE, G_TYPE_UINT, FALSE },
{ NM_IPSEC_L2TP_KEY_LCP_ECHO_INTERVAL, G_TYPE_UINT, FALSE },
/* { NM_IPSEC_L2TP_KEY_PASSWORD"-flags", G_TYPE_UINT, FALSE }, */
......@@ -119,11 +117,11 @@ static VpnImportExportProperty vpn_properties[] = {
};
static VpnImportExportProperty ip4_properties[] = {
{ NM_SETTING_IP4_CONFIG_METHOD, G_TYPE_STRING, TRUE},
{ NM_SETTING_IP4_CONFIG_IGNORE_AUTO_ROUTES, G_TYPE_BOOLEAN, FALSE},
{ NM_SETTING_IP4_CONFIG_IGNORE_AUTO_DNS, G_TYPE_BOOLEAN, FALSE},
{ NM_SETTING_IP4_CONFIG_DHCP_SEND_HOSTNAME, G_TYPE_BOOLEAN, FALSE},
{ NM_SETTING_IP4_CONFIG_NEVER_DEFAULT, G_TYPE_BOOLEAN, FALSE},
{ NM_VPN_PLUGIN_IP4_CONFIG_METHOD, G_TYPE_STRING, TRUE},
{ NM_VPN_PLUGIN_IP4_CONFIG_IGNORE_AUTO_ROUTES, G_TYPE_BOOLEAN, FALSE},
{ NM_VPN_PLUGIN_IP4_CONFIG_IGNORE_AUTO_DNS, G_TYPE_BOOLEAN, FALSE},
{ NM_VPN_PLUGIN_IP4_CONFIG_DHCP_SEND_HOSTNAME, G_TYPE_BOOLEAN, FALSE},
{ NM_VPN_PLUGIN_IP4_CONFIG_NEVER_DEFAULT, G_TYPE_BOOLEAN, FALSE},
{ NULL, G_TYPE_NONE, FALSE }
/* NM_SETTING_IP4_CONFIG_DNS */
/* NM_SETTING_IP4_CONFIG_DNS_SEARCH */
......@@ -134,8 +132,8 @@ static void
ip4_import_error (GError **error, const char *message, const char *key, const char *val)
{
g_set_error (error,
IPSEC_L2TP_PLUGIN_UI_ERROR,
IPSEC_L2TP_PLUGIN_UI_ERROR_INVALID_PROPERTY,
IPSEC_L2TP_EDITOR_PLUGIN_ERROR,
IPSEC_L2TP_EDITOR_PLUGIN_ERROR_INVALID_PROPERTY,
message,
key,
val);
......@@ -165,8 +163,8 @@ import_ip4 (GKeyFile *keyfile, NMSettingIP4Config *s_ip4, GError **error)
continue;
g_set_error (error,
IPSEC_L2TP_PLUGIN_UI_ERROR,
IPSEC_L2TP_PLUGIN_UI_ERROR_MISSING_PROPERTY,
IPSEC_L2TP_EDITOR_PLUGIN_ERROR,
IPSEC_L2TP_EDITOR_PLUGIN_ERROR_MISSING_PROPERTY,
_("Required property %s missing"),
prop.name);
return FALSE;
......@@ -371,7 +369,7 @@ do_import (const char *path, GError **error)
{
NMConnection *connection = NULL;
NMSettingConnection *s_con;
NMSettingVPN *s_vpn;
NMSettingVpn *s_vpn;
NMSettingIP4Config *s_ip4;
GKeyFile *keyfile;
......@@ -381,13 +379,13 @@ do_import (const char *path, GError **error)
keyfile = g_key_file_new ();
if (!g_key_file_load_from_file (keyfile, path, 0, error)) {
g_set_error (error,
IPSEC_L2TP_PLUGIN_UI_ERROR,
IPSEC_L2TP_PLUGIN_UI_ERROR_FILE_NOT_IPSEC_L2TP,
IPSEC_L2TP_EDITOR_PLUGIN_ERROR,
IPSEC_L2TP_EDITOR_PLUGIN_ERROR_FILE_NOT_IPSEC_L2TP,
_("does not look like a IPSEC-L2TP VPN connection (parse failed)"));
return NULL;
}
connection = nm_connection_new ();
connection = nm_simple_connection_new ();
s_con = NM_SETTING_CONNECTION (nm_setting_connection_new ());
nm_connection_add_setting (connection, NM_SETTING (s_con));
......@@ -416,8 +414,8 @@ do_import (const char *path, GError **error)
continue;
g_set_error (error,
IPSEC_L2TP_PLUGIN_UI_ERROR,
IPSEC_L2TP_PLUGIN_UI_ERROR_MISSING_PROPERTY,
IPSEC_L2TP_EDITOR_PLUGIN_ERROR,
IPSEC_L2TP_EDITOR_PLUGIN_ERROR_MISSING_PROPERTY,
_("Required property %s missing"),
prop.name);
g_key_file_free (keyfile);
......@@ -434,8 +432,8 @@ do_import (const char *path, GError **error)
if (int_val == 0 && *error){
g_clear_error(error);
g_set_error (error,
IPSEC_L2TP_PLUGIN_UI_ERROR,
IPSEC_L2TP_PLUGIN_UI_ERROR_INVALID_PROPERTY,
IPSEC_L2TP_EDITOR_PLUGIN_ERROR,
IPSEC_L2TP_EDITOR_PLUGIN_ERROR_INVALID_PROPERTY,
_("Property %s can't be parsed as integer."),
prop.name);
g_key_file_free (keyfile);
......@@ -451,8 +449,8 @@ do_import (const char *path, GError **error)
if (!bool_val) {
g_clear_error(error);
g_set_error (error,
IPSEC_L2TP_PLUGIN_UI_ERROR,
IPSEC_L2TP_PLUGIN_UI_ERROR_INVALID_PROPERTY,
IPSEC_L2TP_EDITOR_PLUGIN_ERROR,
IPSEC_L2TP_EDITOR_PLUGIN_ERROR_INVALID_PROPERTY,
_("Property %s can't be parsed as boolean. Only 'true' and 'false' allowed."),
prop.name);
g_key_file_free (keyfile);
......@@ -595,7 +593,7 @@ gboolean
do_export (const char *path, NMConnection *connection, GError **error)
{
NMSettingConnection *s_con;
NMSettingVPN *s_vpn;
NMSettingVpn *s_vpn;
NMSettingIP4Config *s_ip4;
GKeyFile *export_file;
......@@ -607,7 +605,7 @@ do_export (const char *path, NMConnection *connection, GError **error)
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
s_ip4 = (NMSettingIP4Config *) nm_connection_get_setting (connection, NM_TYPE_SETTING_IP4_CONFIG);
s_vpn = (NMSettingVPN *) nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN);
s_vpn = (NMSettingVpn *) nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN);
export_file = g_key_file_new ();
......@@ -623,8 +621,8 @@ do_export (const char *path, NMConnection *connection, GError **error)
if (!value && prop.required){
g_key_file_free(export_file);
g_set_error(error,
IPSEC_L2TP_PLUGIN_UI_ERROR,
IPSEC_L2TP_PLUGIN_UI_ERROR_MISSING_PROPERTY,
IPSEC_L2TP_EDITOR_PLUGIN_ERROR,
IPSEC_L2TP_EDITOR_PLUGIN_ERROR_MISSING_PROPERTY,
_("Missing required property '%s'"),
prop.name);
return FALSE;
......@@ -653,8 +651,8 @@ do_export (const char *path, NMConnection *connection, GError **error)
if (!(file = fopen (path, "w"))) {
g_set_error(error,
IPSEC_L2TP_PLUGIN_UI_ERROR,
IPSEC_L2TP_PLUGIN_UI_ERROR_FILE_NOT_READABLE,
IPSEC_L2TP_EDITOR_PLUGIN_ERROR,
IPSEC_L2TP_EDITOR_PLUGIN_ERROR_FILE_NOT_READABLE,
_("Couldn't open file for writing."));
g_key_file_free (export_file);
return FALSE;
......
......@@ -23,7 +23,14 @@
#define _IMPORT_EXPORT_H_
#include <glib.h>
#ifdef NM_IPSEC_L2TP_OLD
#define NM_VPN_LIBNM_COMPAT
#include <nm-connection.h>
#include <nm-setting-vpn.h>
#else /* !NM_IPSEC_L2TP_OLD */
#include <NetworkManager.h>
#endif
NMConnection *do_import (const char *path, GError **error);
......
......@@ -34,12 +34,9 @@
#include <glib.h>
#include <glib/gi18n-lib.h>
#include <nm-connection.h>
#include <nm-setting-vpn.h>
#include "ipsec-dialog.h"
#include "nm-ipsec-l2tp.h"
#include "../src/nm-ipsec-l2tp-service.h"
#include "../src/nm-ipsec-l2tp-service-defines.h"
static const char *ipsec_keys[] = {
NM_IPSEC_L2TP_KEY_IPSEC_ENABLE,
......@@ -69,11 +66,11 @@ ipsec_dialog_new_hash_from_connection (NMConnection *connection,
GError **error)
{
GHashTable *hash;
NMSettingVPN *s_vpn;
NMSettingVpn *s_vpn;
hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
s_vpn = (NMSettingVPN *) nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN);
s_vpn = (NMSettingVpn *) nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN);
nm_setting_vpn_foreach_data_item (s_vpn, copy_values, hash);
return hash;
}
......
......@@ -25,7 +25,13 @@
#include <glib.h>
#include <gtk/gtk.h>
#ifdef NM_IPSEC_L2TP_OLD
#define NM_VPN_LIBNM_COMPAT
#include <nm-connection.h>
#include <nm-setting-vpn.h>
#else /* !NM_IPSEC_L2TP_OLD */
#include <NetworkManager.h>
#endif
GtkWidget *ipsec_dialog_new (GHashTable *hash);
......
This diff is collapsed.
......@@ -25,62 +25,45 @@
#include <glib-object.h>
typedef enum
{
IPSEC_L2TP_PLUGIN_UI_ERROR_UNKNOWN = 0,
IPSEC_L2TP_PLUGIN_UI_ERROR_INVALID_CONNECTION,
IPSEC_L2TP_PLUGIN_UI_ERROR_INVALID_PROPERTY,
IPSEC_L2TP_PLUGIN_UI_ERROR_MISSING_PROPERTY,
IPSEC_L2TP_PLUGIN_UI_ERROR_FILE_NOT_READABLE,
IPSEC_L2TP_PLUGIN_UI_ERROR_FILE_NOT_IPSEC_L2TP
} IPSecL2tpPluginUiError;
#define IPSEC_L2TP_TYPE_EDITOR_PLUGIN (ipsec_l2tp_editor_plugin_get_type ())
#define IPSEC_L2TP_EDITOR_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), IPSEC_L2TP_TYPE_EDITOR_PLUGIN, IPSecL2tpEditorPlugin))
#define IPSEC_L2TP_EDITOR_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), IPSEC_L2TP_TYPE_EDITOR_PLUGIN, IPSecL2tpEditorPluginClass))
#define IPSEC_L2TP_IS_EDITOR_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), IPSEC_L2TP_TYPE_EDITOR_PLUGIN))
#define IPSEC_L2TP_IS_EDITOR_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), IPSEC_L2TP_TYPE_EDITOR_PLUGIN))
#define IPSEC_L2TP_EDITOR_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), IPSEC_L2TP_TYPE_EDITOR_PLUGIN, IPSecL2tpEditorPluginClass))
#define IPSEC_L2TP_TYPE_PLUGIN_UI_ERROR (ipsec_l2tp_plugin_ui_error_get_type ())
GType ipsec_l2tp_plugin_ui_error_get_type (void);
typedef struct _IPSecL2tpEditorPlugin IPSecL2tpEditorPlugin;
typedef struct _IPSecL2tpEditorPluginClass IPSecL2tpEditorPluginClass;
#define IPSEC_L2TP_PLUGIN_UI_ERROR (ipsec_l2tp_plugin_ui_error_quark ())
GQuark ipsec_l2tp_plugin_ui_error_quark (void);
#define IPSEC_L2TP_TYPE_PLUGIN_UI (ipsec_l2tp_plugin_ui_get_type ())
#define IPSEC_L2TP_PLUGIN_UI(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), IPSEC_L2TP_TYPE_PLUGIN_UI, IPSecL2tpPluginUi))
#define IPSEC_L2TP_PLUGIN_UI_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), IPSEC_L2TP_TYPE_PLUGIN_UI, IPSecL2tpPluginUiClass))
#define IPSEC_L2TP_IS_PLUGIN_UI(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), IPSEC_L2TP_TYPE_PLUGIN_UI))
#define IPSEC_L2TP_IS_PLUGIN_UI_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), IPSEC_L2TP_TYPE_PLUGIN_UI))
#define IPSEC_L2TP_PLUGIN_UI_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), IPSEC_L2TP_TYPE_PLUGIN_UI, IPSecL2tpPluginUiClass))
typedef struct _IPSecL2tpPluginUi IPSecL2tpPluginUi;
typedef struct _IPSecL2tpPluginUiClass IPSecL2tpPluginUiClass;
struct _IPSecL2tpPluginUi {
struct _IPSecL2tpEditorPlugin {
GObject parent;
};
struct _IPSecL2tpPluginUiClass {
struct _IPSecL2tpEditorPluginClass {
GObjectClass parent;
};
GType ipsec_l2tp_plugin_ui_get_type (void);
GType ipsec_l2tp_editor_plugin_get_type (void);
#define IPSEC_L2TP_TYPE_PLUGIN_UI_WIDGET (ipsec_l2tp_plugin_ui_widget_get_type ())
#define IPSEC_L2TP_PLUGIN_UI_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), IPSEC_L2TP_TYPE_PLUGIN_UI_WIDGET, IPSecL2tpPluginUiWidget))
#define IPSEC_L2TP_PLUGIN_UI_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), IPSEC_L2TP_TYPE_PLUGIN_UI_WIDGET, IPSecL2tpPluginUiWidgetClass))
#define IPSEC_L2TP_IS_PLUGIN_UI_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), IPSEC_L2TP_TYPE_PLUGIN_UI_WIDGET))
#define IPSEC_L2TP_IS_PLUGIN_UI_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), IPSEC_L2TP_TYPE_PLUGIN_UI_WIDGET))
#define IPSEC_L2TP_PLUGIN_UI_WIDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), IPSEC_L2TP_TYPE_PLUGIN_UI_WIDGET, IPSecL2tpPluginUiWidgetClass))
#define IPSEC_L2TP_TYPE_EDITOR (ipsec_l2tp_editor_get_type ())
#define IPSEC_L2TP_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), IPSEC_L2TP_TYPE_EDITOR, IPSecL2tpEditor))
#define IPSEC_L2TP_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), IPSEC_L2TP_TYPE_EDITOR, IPSecL2tpEditorClass))
#define IPSEC_L2TP_IS_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), IPSEC_L2TP_TYPE_EDITOR))
#define IPSEC_L2TP_IS_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), IPSEC_L2TP_TYPE_EDITOR))
#define IPSEC_L2TP_EDITOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), IPSEC_L2TP_TYPE_EDITOR, IPSecL2tpEditorClass))
typedef struct _IPSecL2tpPluginUiWidget IPSecL2tpPluginUiWidget;
typedef struct _IPSecL2tpPluginUiWidgetClass IPSecL2tpPluginUiWidgetClass;
typedef struct _IPSecL2tpEditor IPSecL2tpEditor;
typedef struct _IPSecL2tpEditorClass IPSecL2tpEditorClass;
struct _IPSecL2tpPluginUiWidget {
struct _IPSecL2tpEditor {
GObject parent;
};
struct _IPSecL2tpPluginUiWidgetClass {
struct _IPSecL2tpEditorClass {
GObjectClass parent;
};
GType ipsec_l2tp_plugin_ui_widget_get_type (void);
GType ipsec_l2tp_editor_get_type (void);
#endif /* _NM_IPSEC_L2TP_H_ */
EXTRA_DIST = \
README \
nm-utils/gsystem-local-alloc.h \
nm-utils/nm-glib.h \
nm-utils/nm-macros-internal.h \
nm-utils/nm-vpn-plugin-utils.c \
nm-utils/nm-vpn-plugin-utils.h \
nm-service-defines.h \
nm-default.h
The files in the "shared/" directory are used by all components
inside the VPN plugin repository (src, properties, auth-dialog).
The files in shared/nm-utils are copied from NetworkManager
repository and used as is:
Do *not* modify these files locally so that they don't diverge
from their original. Fix/extend them in their respective origin
first, and re-import the files as a whole.
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/* NetworkManager -- Network link manager
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
* (C) Copyright 2015 Red Hat, Inc.
*/
#ifndef __NM_DEFAULT_H__
#define __NM_DEFAULT_H__
/* makefiles define NETWORKMANAGER_COMPILATION for compiling NetworkManager.
* Depending on which parts are compiled, different values are set. */
#define NM_NETWORKMANAGER_COMPILATION_DEFAULT 0x0001
#define NM_NETWORKMANAGER_COMPILATION_LIB_BASE 0x0002
#define NM_NETWORKMANAGER_COMPILATION_LIB_EDITOR 0x0004
#define NM_NETWORKMANAGER_COMPILATION_LIB (0x0002 | 0x0004)
#ifndef NETWORKMANAGER_COMPILATION
/* For convenience, we don't require our Makefile.am to define
* -DNETWORKMANAGER_COMPILATION. As we now include this internal header,
* we know we do a NETWORKMANAGER_COMPILATION. */
#define NETWORKMANAGER_COMPILATION NM_NETWORKMANAGER_COMPILATION_DEFAULT
#endif
/*****************************************************************************/
#ifndef ___CONFIG_H__
#define ___CONFIG_H__
#include <config.h>
#endif
/* always include these headers for our internal source files. */
#include "nm-utils/nm-glib.h"
#include "nm-utils/gsystem-local-alloc.h"
#include "nm-utils/nm-macros-internal.h"
#include "nm-version.h"
#include "nm-service-defines.h"
/*****************************************************************************/
#if ((NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_LIB)
#include <glib/gi18n-lib.h>
#else
#include <glib/gi18n.h>
#endif /* NM_NETWORKMANAGER_COMPILATION_LIB */
/*****************************************************************************/
#ifdef NM_VPN_OLD
#define NM_VPN_LIBNM_COMPAT
#include <nm-connection.h>
#include <nm-setting-connection.h>
#include <nm-setting-8021x.h>
#include <nm-setting-ip4-config.h>
#include <nm-setting-vpn.h>
#include <nm-utils.h>
#include <nm-vpn-plugin-ui-interface.h>
#define NMV_EDITOR_PLUGIN_ERROR NM_SETTING_VPN_ERROR
#define NMV_EDITOR_PLUGIN_ERROR_FAILED NM_SETTING_VPN_ERROR_UNKNOWN
#define NMV_EDITOR_PLUGIN_ERROR_INVALID_PROPERTY NM_SETTING_VPN_ERROR_INVALID_PROPERTY
#define NMV_EDITOR_PLUGIN_ERROR_FILE_NOT_VPN NM_SETTING_VPN_ERROR_UNKNOWN
#define NMV_EDITOR_PLUGIN_ERROR_FILE_NOT_READABLE NM_SETTING_VPN_ERROR_UNKNOWN
#else /* !NM_VPN_OLD */
#include <NetworkManager.h>
#define NMV_EDITOR_PLUGIN_ERROR NM_CONNECTION_ERROR
#define NMV_EDITOR_PLUGIN_ERROR_FAILED NM_CONNECTION_ERROR_FAILED
#define NMV_EDITOR_PLUGIN_ERROR_INVALID_PROPERTY NM_CONNECTION_ERROR_INVALID_PROPERTY
#define NMV_EDITOR_PLUGIN_ERROR_FILE_NOT_VPN NM_CONNECTION_ERROR_FAILED
#define NMV_EDITOR_PLUGIN_ERROR_FILE_NOT_READABLE NM_CONNECTION_ERROR_FAILED
#endif /* NM_VPN_OLD */
/*****************************************************************************/
#if (NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_LIB_EDITOR
#ifdef NM_VPN_OLD
#include <nm-ui-utils.h>
#else /* NM_VPN_OLD */
#include <nma-ui-utils.h>
#endif /* NM_VPN_OLD */
#endif /* NM_NETWORKMANAGER_COMPILATION_LIB_EDITOR */
/*****************************************************************************/
#endif /* __NM_DEFAULT_H__ */
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/* nm-pptp-service - PPTP VPN integration with NetworkManager
*
* Dan Williams <dcbw@redhat.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright 2008, 2014 Red Hat, Inc.
*/
#ifndef __NM_SERVICE_DEFINES_H__
#define __NM_SERVICE_DEFINES_H__
#define NM_DBUS_SERVICE_PPTP "org.freedesktop.NetworkManager.pptp"
/* For the NM <-> VPN plugin service */
#define NM_DBUS_INTERFACE_PPTP "org.freedesktop.NetworkManager.pptp"
#define NM_DBUS_PATH_PPTP "/org/freedesktop/NetworkManager/pptp"
/* For the VPN plugin service <-> PPP plugin */
#define NM_DBUS_INTERFACE_PPTP_PPP "org.freedesktop.NetworkManager.pptp.ppp"
#define NM_DBUS_PATH_PPTP_PPP "/org/freedesktop/NetworkManager/pptp/ppp"
#define NM_PPTP_KEY_GATEWAY "gateway"
#define NM_PPTP_KEY_USER "user"
#define NM_PPTP_KEY_PASSWORD "password"
#define NM_PPTP_KEY_DOMAIN "domain"
#define NM_PPTP_KEY_REFUSE_EAP "refuse-eap"
#define NM_PPTP_KEY_REFUSE_PAP "refuse-pap"
#define NM_PPTP_KEY_REFUSE_CHAP "refuse-chap"
#define NM_PPTP_KEY_REFUSE_MSCHAP "refuse-mschap"
#define NM_PPTP_KEY_REFUSE_MSCHAPV2 "refuse-mschapv2"
#define NM_PPTP_KEY_REQUIRE_MPPE "require-mppe"
#define NM_PPTP_KEY_REQUIRE_MPPE_40 "require-mppe-40"
#define NM_PPTP_KEY_REQUIRE_MPPE_128 "require-mppe-128"
#define NM_PPTP_KEY_MPPE_STATEFUL "mppe-stateful"
#define NM_PPTP_KEY_NOBSDCOMP "nobsdcomp"
#define NM_PPTP_KEY_NODEFLATE "nodeflate"
#define NM_PPTP_KEY_NO_VJ_COMP "no-vj-comp"
#define NM_PPTP_KEY_LCP_ECHO_FAILURE "lcp-echo-failure"
#define NM_PPTP_KEY_LCP_ECHO_INTERVAL "lcp-echo-interval"
#define NM_PPTP_KEY_UNIT_NUM "unit"
#endif /* __NM_SERVICE_DEFINES_H__ */
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
*
* Copyright (C) 2012 Colin Walters <walters@verbum.org>.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GSYSTEM_LOCAL_ALLOC_H__
#define __GSYSTEM_LOCAL_ALLOC_H__
#include <gio/gio.h>
G_BEGIN_DECLS
#define GS_DEFINE_CLEANUP_FUNCTION(Type, name, func) \
static inline void name (void *v) \
{ \
func (*(Type*)v); \
}
#define GS_DEFINE_CLEANUP_FUNCTION0(Type, name, func) \
static inline void name (void *v) \
{ \
if (*(Type*)v) \
func (*(Type*)v); \
}
/* These functions shouldn't be invoked directly;
* they are stubs that:
* 1) Take a pointer to the location (typically itself a pointer).
* 2) Provide %NULL-safety where it doesn't exist already (e.g. g_object_unref)
*/
/**
* gs_free:
*
* Call g_free() on a variable location when it goes out of scope.
*/
#define gs_free __attribute__ ((cleanup(gs_local_free)))
GS_DEFINE_CLEANUP_FUNCTION(void*, gs_local_free, g_free)
/**
* gs_unref_object:
*
* Call g_object_unref() on a variable location when it goes out of
* scope. Note that unlike g_object_unref(), the variable may be
* %NULL.
*/
#define gs_unref_object __attribute__ ((cleanup(gs_local_obj_unref)))
GS_DEFINE_CLEANUP_FUNCTION0(GObject*, gs_local_obj_unref, g_object_unref)
/**
* gs_unref_variant:
*
* Call g_variant_unref() on a variable location when it goes out of
* scope. Note that unlike g_variant_unref(), the variable may be
* %NULL.
*/
#define gs_unref_variant __attribute__ ((cleanup(gs_local_variant_unref)))
GS_DEFINE_CLEANUP_FUNCTION0(GVariant*, gs_local_variant_unref, g_variant_unref)
/**
* gs_free_variant_iter:
*
* Call g_variant_iter_free() on a variable location when it goes out of
* scope.
*/
#define gs_free_variant_iter __attribute__ ((cleanup(gs_local_variant_iter_free)))
GS_DEFINE_CLEANUP_FUNCTION0(GVariantIter*, gs_local_variant_iter_free, g_variant_iter_free)
/**
* gs_free_variant_builder:
*
* Call g_variant_builder_unref() on a variable location when it goes out of
* scope.
*/
#define gs_unref_variant_builder __attribute__ ((cleanup(gs_local_variant_builder_unref)))
GS_DEFINE_CLEANUP_FUNCTION0(GVariantBuilder*, gs_local_variant_builder_unref, g_variant_builder_unref)
/**
* gs_unref_array:
*
* Call g_array_unref() on a variable location when it goes out of
* scope. Note that unlike g_array_unref(), the variable may be
* %NULL.
*/
#define gs_unref_array __attribute__ ((cleanup(gs_local_array_unref)))
GS_DEFINE_CLEANUP_FUNCTION0(GArray*, gs_local_array_unref, g_array_unref)
/**
* gs_unref_ptrarray:
*
* Call g_ptr_array_unref() on a variable location when it goes out of
* scope. Note that unlike g_ptr_array_unref(), the variable may be
* %NULL.
*/
#define gs_unref_ptrarray __attribute__ ((cleanup(gs_local_ptrarray_unref)))
GS_DEFINE_CLEANUP_FUNCTION0(GPtrArray*, gs_local_ptrarray_unref, g_ptr_array_unref)
/**
* gs_unref_hashtable:
*
* Call g_hash_table_unref() on a variable location when it goes out
* of scope. Note that unlike g_hash_table_unref(), the variable may
* be %NULL.
*/
#define gs_unref_hashtable __attribute__ ((cleanup(gs_local_hashtable_unref)))
GS_DEFINE_CLEANUP_FUNCTION0(GHashTable*, gs_local_hashtable_unref, g_hash_table_unref)
/**
* gs_free_list:
*
* Call g_list_free() on a variable location when it goes out
* of scope.
*/
#define gs_free_list __attribute__ ((cleanup(gs_local_free_list)))
GS_DEFINE_CLEANUP_FUNCTION(GList*, gs_local_free_list, g_list_free)
/**
* gs_free_slist:
*
* Call g_slist_free() on a variable location when it goes out
* of scope.
*/
#define gs_free_slist __attribute__ ((cleanup(gs_local_free_slist)))
GS_DEFINE_CLEANUP_FUNCTION(GSList*, gs_local_free_slist, g_slist_free)
/**
* gs_free_checksum:
*
* Call g_checksum_free() on a variable location when it goes out
* of scope. Note that unlike g_checksum_free(), the variable may
* be %NULL.
*/
#define gs_free_checksum __attribute__ ((cleanup(gs_local_checksum_free)))
GS_DEFINE_CLEANUP_FUNCTION0(GChecksum*, gs_local_checksum_free, g_checksum_free)
/**
* gs_unref_bytes:
*
* Call g_bytes_unref() on a variable location when it goes out
* of scope. Note that unlike g_bytes_unref(), the variable may
* be %NULL.
*/
#define gs_unref_bytes __attribute__ ((cleanup(gs_local_bytes_unref)))
GS_DEFINE_CLEANUP_FUNCTION0(GBytes*, gs_local_bytes_unref, g_bytes_unref)
/**
* gs_strfreev:
*
* Call g_strfreev() on a variable location when it goes out of scope.
*/
#define gs_strfreev __attribute__ ((cleanup(gs_local_strfreev)))
GS_DEFINE_CLEANUP_FUNCTION(char**, gs_local_strfreev, g_strfreev)
/**
* gs_free_error:
*
* Call g_error_free() on a variable location when it goes out of scope.
*/
#define gs_free_error __attribute__ ((cleanup(gs_local_free_error)))
GS_DEFINE_CLEANUP_FUNCTION0(GError*, gs_local_free_error, g_error_free)
/**
* gs_unref_keyfile:
*
* Call g_key_file_unref() on a variable location when it goes out of scope.
*/
#define gs_unref_keyfile __attribute__ ((cleanup(gs_local_keyfile_unref)))
GS_DEFINE_CLEANUP_FUNCTION0(GKeyFile*, gs_local_keyfile_unref, g_key_file_unref)
static inline void
gs_cleanup_close_fdp (int *fdp)
{
int fd;
g_assert (fdp);
fd = *fdp;
if (fd != -1)
(void) close (fd);
}
/**
* gs_fd_close:
*
* Call close() on a variable location when it goes out of scope.
*/
#define gs_fd_close __attribute__((cleanup(gs_cleanup_close_fdp)))
G_END_DECLS
#endif
This diff is collapsed.
This diff is collapsed.
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
* Copyright 2016 Red Hat, Inc.
*/
#include "nm-default.h"
#include "nm-vpn-plugin-utils.h"
#include <dlfcn.h>
/*****************************************************************************/
NMVpnEditor *
nm_vpn_plugin_utils_load_editor (const char *module_name,
const char *factory_name,
NMVpnPluginUtilsEditorFactory editor_factory,
NMVpnEditorPlugin *editor_plugin,
NMConnection *connection,
gpointer user_data,
GError **error)
{
static struct {
gpointer factory;
void *dl_module;
char *module_name;
char *factory_name;
} cached = { 0 };
NMVpnEditor *editor;
g_return_val_if_fail (module_name && g_path_is_absolute (module_name), NULL);
g_return_val_if_fail (factory_name && factory_name[0], NULL);
g_return_val_if_fail (editor_factory, NULL);
g_return_val_if_fail (NM_IS_VPN_EDITOR_PLUGIN (editor_plugin), NULL);
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
g_return_val_if_fail (!error || !*error, NULL);
/* we really expect this function to be called with unchanging @module_name
* and @factory_name. And we only want to load the module once, hence it would
* be more complicated to accept changing @module_name/@factory_name arguments.
*
* The reason for only loading once is that due to glib types, we cannot create a
* certain type-name more then once, so loading the same module or another version
* of the same module will fail horribly as both try to create a GType with the same
* name.
*
* Only support loading once, any future calls will reuse the handle. To simplify
* that, we enforce that the @factory_name and @module_name is the same. */
if (cached.factory) {
g_return_val_if_fail (cached.dl_module, NULL);
g_return_val_if_fail (cached.factory_name && nm_streq0 (cached.factory_name, factory_name), NULL);
g_return_val_if_fail (cached.module_name && nm_streq0 (cached.module_name, module_name), NULL);
} else {
gpointer factory;
void *dl_module;
dl_module = dlopen (module_name, RTLD_LAZY | RTLD_LOCAL);
if (!dl_module) {
if (!g_file_test (module_name, G_FILE_TEST_EXISTS)) {
g_set_error (error,
G_FILE_ERROR,
G_FILE_ERROR_NOENT,
_("missing plugin file \"%s\""), module_name);
return NULL;
}
g_set_error (error,
NM_CONNECTION_ERROR,
NM_CONNECTION_ERROR_FAILED,
_("cannot load editor plugin: %s"), dlerror ());
return NULL;
}
factory = dlsym (dl_module, factory_name);
if (!factory) {
g_set_error (error,
NM_CONNECTION_ERROR,
NM_CONNECTION_ERROR_FAILED,
_("cannot load factory %s from plugin: %s"),
factory_name, dlerror ());
dlclose (dl_module);
return NULL;
}
/* we cannot ever unload the module because it creates glib types, which
* cannot be unregistered.
*
* Thus we just leak the dl_module handle indefinitely. */
cached.factory = factory;
cached.dl_module = dl_module;
cached.module_name = g_strdup (module_name);
cached.factory_name = g_strdup (factory_name);
}
editor = editor_factory (cached.factory,
editor_plugin,
connection,
user_data,
error);
if (!editor) {
if (error && !*error ) {
g_set_error_literal (error,
NM_CONNECTION_ERROR,
NM_CONNECTION_ERROR_FAILED,
_("unknown error creating editor instance"));
g_return_val_if_reached (NULL);
}
return NULL;
}
g_return_val_if_fail (NM_IS_VPN_EDITOR (editor), NULL);
return editor;
}
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
* Copyright 2016 Red Hat, Inc.
*/
#ifndef __NM_VPN_PLUGIN_UTILS_H__
#define __NM_VPN_PLUGIN_UTILS_H__
#include <NetworkManager.h>
typedef NMVpnEditor *(NMVpnPluginUtilsEditorFactory) (gpointer factory,
NMVpnEditorPlugin *editor_plugin,
NMConnection *connection,
gpointer user_data,
GError **error);
NMVpnEditor *nm_vpn_plugin_utils_load_editor (const char *module_name,
const char *factory_name,
NMVpnPluginUtilsEditorFactory editor_factory,
NMVpnEditorPlugin *editor_plugin,
NMConnection *connection,
gpointer user_data,
GError **error);
#endif /* __NM_VPN_PLUGIN_UTILS_H__ */
INCLUDES = -I${top_srcdir}
AM_CPPFLAGS = \
$(DBUS_GLIB_CFLAGS) \
$(GLIB_CFLAGS) \
$(NM_CFLAGS) \
-DG_DISABLE_DEPRECATED \
-DBINDIR=\"$(bindir)\" \
-DPREFIX=\""$(prefix)"\" \
-DSYSCONFDIR=\""$(sysconfdir)"\" \
-DNM_VERSION="\"$(VERSION)\"" \
-DLIBDIR=\""$(libdir)"\" \
-DLIBEXECDIR=\""$(libexecdir)"\" \
-DLOCALSTATEDIR=\""$(localstatedir)"\" \
-DDATADIR=\"$(datadir)\" \
-DNM_IPSEC_L2TP_LOCALEDIR=\"$(datadir)/locale\" \
-DPLUGINDIR=\"$(PPPD_PLUGIN_DIR)\"
AM_CPPFLAGS = \
$(GLIB_CFLAGS) \
$(LIBNM_CFLAGS) \
-DG_DISABLE_DEPRECATED \
-DBINDIR=\"$(bindir)\" \
-DPREFIX=\""$(prefix)"\" \
-DSYSCONFDIR=\""$(sysconfdir)"\" \
-DNM_VERSION="\"$(VERSION)\"" \
-DLIBDIR=\""$(libdir)"\" \
-DLIBEXECDIR=\""$(libexecdir)"\" \
-DLOCALSTATEDIR=\""$(localstatedir)"\" \
-DDATADIR=\"$(datadir)\" \
-DNM_IPSEC_L2TP_LOCALEDIR=\"$(datadir)/locale\" \
-DPLUGINDIR=\"$(PPPD_PLUGIN_DIR)\"
libexec_PROGRAMS = nm-ipsec-l2tp-service
nm_ipsec_l2tp_service_SOURCES = \
nm-ipsec-l2tp-service.c \
nm-ipsec-l2tp-service.h
nm-ipsec-l2tp-service.c \
nm-ipsec-l2tp-service.h \
nm-ipsec-l2tp-service-defines.h
nm-ipsec-l2tp-pppd-service-glue.h: $(top_srcdir)/src/nm-ipsec-l2tp-pppd-service.xml
dbus-binding-tool --prefix=nm_ipsec_l2tp_pppd_service --mode=glib-server --output=$@ $<
# D-Bus stuff
noinst_LTLIBRARIES = libnm-ipsec-l2tp-pppd-service-dbus.la
nm_ipsec_l2tp_service_LDADD = \
$(DBUS_GLIB_LIBS) \
$(GLIB_LIBS) \
$(NM_LIBS)
nodist_libnm_ipsec_l2tp_pppd_service_dbus_la_SOURCES = \
nm-ipsec-l2tp-pppd-service-dbus.c \
nm-ipsec-l2tp-pppd-service-dbus.h
libnm_ipsec_l2tp_pppd_service_dbus_la_CPPFLAGS = $(filter-out -DGLIB_VERSION_MAX_ALLOWED%,$(AM_CPPFLAGS))
nm-ipsec-l2tp-pppd-service-dbus.h: $(top_srcdir)/src/nm-ipsec-l2tp-pppd-service.xml
$(AM_V_GEN) gdbus-codegen \
--generate-c-code $(basename $@) \
--c-namespace NMDBus \
--interface-prefix org.freedesktop \
$<
nm-ipsec-l2tp-pppd-service-dbus.c:
@true
nm_ipsec_l2tp_service_LDADD = \
$(GLIB_LIBS) \
$(LIBNM_LIBS) \
libnm-ipsec-l2tp-pppd-service-dbus.la
pppd_plugindir = $(PPPD_PLUGIN_DIR)
pppd_plugin_LTLIBRARIES = nm-ipsec-l2tp-pppd-plugin.la
nm_ipsec_l2tp_pppd_plugin_la_SOURCES = \
nm-ipsec-l2tp-pppd-plugin.c \
nm_ipsec_l2tp_pppd_plugin_la_SOURCES = \
nm-ipsec-l2tp-pppd-plugin.c \
nm-ppp-status.h
nm_ipsec_l2tp_pppd_plugin_la_CPPFLAGS = \
$(DBUS_GLIB_CFLAGS) \
$(GLIB_CFLAGS) \
$(NM_CFLAGS)
nm_ipsec_l2tp_pppd_plugin_la_CPPFLAGS = \
$(GLIB_CFLAGS) \
$(LIBNM_CFLAGS)
nm_ipsec_l2tp_pppd_plugin_la_LDFLAGS = -module -avoid-version
nm_ipsec_l2tp_pppd_plugin_la_LDFLAGS = \
-module -avoid-version
nm_ipsec_l2tp_pppd_plugin_la_LIBADD = \
$(DBUS_GLIB_LIBS) \
$(GLIB_LIBS) \
$(NM_LIBS)
nm_ipsec_l2tp_pppd_plugin_la_LIBADD = \
$(GLIB_LIBS) \
$(LIBNM_LIBS)
BUILT_SOURCES = nm-ipsec-l2tp-pppd-service-glue.h
BUILT_SOURCES = nm-ipsec-l2tp-pppd-service-dbus.h nm-ipsec-l2tp-pppd-service-dbus.c
CLEANFILES = $(BUILT_SOURCES)
......
......@@ -28,20 +28,18 @@
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <glib.h>
#include <glib-object.h>
#include <dbus/dbus-glib.h>
#include <dlfcn.h>
//#include <glib.h>
#include <gio/gio.h>
#include "nm-ppp-status.h"
#include <nm-utils.h>
#include "nm-ipsec-l2tp-service.h"
#include "nm-ppp-status.h"
int plugin_init (void);
char pppd_version[] = VERSION;
static DBusGProxy *proxy = NULL;
static GDBusProxy *proxy = NULL;
static void
nm_phasechange (void *data, int arg)
......@@ -49,7 +47,7 @@ nm_phasechange (void *data, int arg)
NMPPPStatus ppp_status = NM_PPP_STATUS_UNKNOWN;
char *ppp_phase;
g_return_if_fail (DBUS_IS_G_PROXY (proxy));
g_return_if_fail (G_IS_DBUS_PROXY (proxy));
switch (arg) {
case PHASE_DEAD:
......@@ -116,127 +114,104 @@ nm_phasechange (void *data, int arg)
ppp_phase);
if (ppp_status != NM_PPP_STATUS_UNKNOWN) {
dbus_g_proxy_call_no_reply (proxy, "SetState",
G_TYPE_UINT, ppp_status,
G_TYPE_INVALID,
G_TYPE_INVALID);
g_dbus_proxy_call (proxy,
"SetState",
g_variant_new ("(u)", ppp_status),
G_DBUS_CALL_FLAGS_NONE, -1,
NULL,
NULL, NULL);
}
}
static GValue *
str_to_gvalue (const char *str)
{
GValue *val;
val = g_slice_new0 (GValue);
g_value_init (val, G_TYPE_STRING);
g_value_set_string (val, str);
return val;
}
static GValue *
uint_to_gvalue (guint32 i)
{
GValue *val;
val = g_slice_new0 (GValue);
g_value_init (val, G_TYPE_UINT);
g_value_set_uint (val, i);
return val;
}
static void
value_destroy (gpointer data)
{
GValue *val = (GValue *) data;
g_value_unset (val);
g_slice_free (GValue, val);
}
static void
nm_ip_up (void *data, int arg)
{
guint32 pppd_made_up_address = htonl (0x0a404040 + ifunit);
ipcp_options opts = ipcp_gotoptions[0];
ipcp_options peer_opts = ipcp_hisoptions[0];
GHashTable *hash;
GArray *array;
GValue *val;
GVariantBuilder builder;
g_return_if_fail (DBUS_IS_G_PROXY (proxy));
g_return_if_fail (G_IS_DBUS_PROXY (proxy));
g_message ("nm-ipsec-l2tp-ppp-plugin: (%s): ip-up event", __func__);
if (!opts.ouraddr) {
g_warning ("nm-ipsec-l2tp-ppp-plugin: (%s): didn't receive an internal IP from pppd!", __func__);
nm_phasechange (NULL, PHASE_DEAD);
return;
}
hash = g_hash_table_new_full (g_str_hash, g_str_equal,
NULL, value_destroy);
g_variant_builder_init (&builder, G_VARIANT_TYPE_VARDICT);
g_hash_table_insert (hash, NM_VPN_PLUGIN_IP4_CONFIG_TUNDEV,
str_to_gvalue (ifname));
g_variant_builder_add (&builder, "{sv}",
NM_VPN_PLUGIN_IP4_CONFIG_TUNDEV,
g_variant_new_string (ifname));
g_variant_builder_add (&builder, "{sv}",
NM_VPN_PLUGIN_IP4_CONFIG_ADDRESS,
g_variant_new_uint32 (opts.ouraddr));
/* Prefer the peer options remote address first, _unless_ pppd made the
* address up, at which point prefer the local options remote address,
* and if that's not right, use the made-up address as a last resort.
*/
if (peer_opts.hisaddr && (peer_opts.hisaddr != pppd_made_up_address)) {
g_hash_table_insert (hash, NM_VPN_PLUGIN_IP4_CONFIG_PTP,
uint_to_gvalue (peer_opts.hisaddr));
g_variant_builder_add (&builder, "{sv}",
NM_VPN_PLUGIN_IP4_CONFIG_PTP,
g_variant_new_uint32 (peer_opts.hisaddr));
} else if (opts.hisaddr) {
g_hash_table_insert (hash, NM_VPN_PLUGIN_IP4_CONFIG_PTP,
uint_to_gvalue (opts.hisaddr));
g_variant_builder_add (&builder, "{sv}",
NM_VPN_PLUGIN_IP4_CONFIG_PTP,
g_variant_new_uint32 (opts.hisaddr));
} else if (peer_opts.hisaddr == pppd_made_up_address) {
/* As a last resort, use the made-up address */
g_hash_table_insert (hash, NM_VPN_PLUGIN_IP4_CONFIG_PTP,
uint_to_gvalue (peer_opts.hisaddr));
g_variant_builder_add (&builder, "{sv}",
NM_VPN_PLUGIN_IP4_CONFIG_PTP,
g_variant_new_uint32 (peer_opts.ouraddr));
}
g_hash_table_insert (hash, NM_VPN_PLUGIN_IP4_CONFIG_ADDRESS,
uint_to_gvalue (opts.ouraddr));
g_hash_table_insert (hash, NM_VPN_PLUGIN_IP4_CONFIG_PREFIX, uint_to_gvalue (32));
g_variant_builder_add (&builder, "{sv}",
NM_VPN_PLUGIN_IP4_CONFIG_PREFIX,
g_variant_new_uint32 (32));
if (opts.dnsaddr[0] || opts.dnsaddr[1]) {
array = g_array_new (FALSE, FALSE, sizeof (guint32));
guint32 dns[2];
int len = 0;
if (opts.dnsaddr[0])
g_array_append_val (array, opts.dnsaddr[0]);
dns[len++] = opts.dnsaddr[0];
if (opts.dnsaddr[1])
g_array_append_val (array, opts.dnsaddr[1]);
val = g_slice_new0 (GValue);
g_value_init (val, DBUS_TYPE_G_UINT_ARRAY);
g_value_set_boxed (val, array);
dns[len++] = opts.dnsaddr[1];
g_hash_table_insert (hash, NM_VPN_PLUGIN_IP4_CONFIG_DNS, val);
g_variant_builder_add (&builder, "{sv}",
NM_VPN_PLUGIN_IP4_CONFIG_DNS,
g_variant_new_fixed_array (G_VARIANT_TYPE_UINT32,
dns, len, sizeof (guint32)));
}
/* Default MTU to 1400, which is also what Windows XP/Vista use */
g_hash_table_insert (hash, NM_VPN_PLUGIN_IP4_CONFIG_MTU, uint_to_gvalue (1400));
g_variant_builder_add (&builder, "{sv}",
NM_VPN_PLUGIN_IP4_CONFIG_MTU,
g_variant_new_uint32 (1400));
g_message ("nm-ipsec-l2tp-ppp-plugin: (%s): sending Ip4Config to NetworkManager-ipsec-l2tp...", __func__);
dbus_g_proxy_call_no_reply (proxy, "SetIp4Config",
DBUS_TYPE_G_MAP_OF_VARIANT, hash, G_TYPE_INVALID,
G_TYPE_INVALID);
g_hash_table_destroy (hash);
g_dbus_proxy_call (proxy,
"SetIp4Config",
g_variant_new ("(a{sv})", &builder),
G_DBUS_CALL_FLAGS_NONE, -1,
NULL,
NULL, NULL);
}
static int
get_chap_check(void)
get_chap_check (void)
{
return 1;
}
static int
get_pap_check(void)
get_pap_check (void)
{
return 1;
}
......@@ -244,45 +219,47 @@ get_pap_check(void)
static int
get_credentials (char *username, char *password)
{
char *my_username = NULL;
char *my_password = NULL;
const char *my_username = NULL;
const char *my_password = NULL;
size_t len;
GVariant *ret;
GError *err = NULL;
if (username && !password) {
if (!password) {
/* pppd is checking pap support; return 1 for supported */
g_return_val_if_fail (username, -1);
return 1;
}
g_return_val_if_fail (DBUS_IS_G_PROXY (proxy), -1);
g_return_val_if_fail (username, -1);
g_return_val_if_fail (G_IS_DBUS_PROXY (proxy), -1);
g_message ("nm-ipsec-l2tp-ppp-plugin: (%s): passwd-hook, requesting credentials...", __func__);
dbus_g_proxy_call (proxy, "NeedSecrets", &err,
G_TYPE_INVALID,
G_TYPE_STRING, &my_username,
G_TYPE_STRING, &my_password,
G_TYPE_INVALID);
if (err) {
ret = g_dbus_proxy_call_sync (proxy,
"NeedSecrets",
NULL,
G_DBUS_CALL_FLAGS_NONE, -1,
NULL, &err);
if (!ret) {
g_warning ("nm-ipsec-l2tp-ppp-plugin: (%s): could not get secrets: (%d) %s",
__func__,
err ? err->code : -1,
err->message ? err->message : "(unknown)");
__func__,
err ? err->code : -1,
err->message ? err->message : "(unknown)");
g_error_free (err);
return -1;
}
g_message ("nm-ipsec-l2tp-ppp-plugin: (%s): got credentials from NetworkManager-ipsec-l2tp", __func__);
g_variant_get (ret, "(&s&s)", &my_username, &my_password);
if (my_username) {
len = strlen (my_username) + 1;
len = len < MAXNAMELEN ? len : MAXNAMELEN;
strncpy (username, my_username, len);
username[len - 1] = '\0';
g_free (my_username);
}
if (my_password) {
......@@ -291,17 +268,17 @@ get_credentials (char *username, char *password)
strncpy (password, my_password, len);
password[len - 1] = '\0';
g_free (my_password);
}
g_variant_unref (ret);
return 1;
}
static void
nm_exit_notify (void *data, int arg)
{
g_return_if_fail (DBUS_IS_G_PROXY (proxy));
g_return_if_fail (G_IS_DBUS_PROXY (proxy));
g_message ("nm-ipsec-l2tp-ppp-plugin: (%s): cleaning up", __func__);
......@@ -312,7 +289,7 @@ nm_exit_notify (void *data, int arg)
int
plugin_init (void)
{
DBusGConnection *bus;
GDBusConnection *bus;
GError *err = NULL;
#if !GLIB_CHECK_VERSION (2, 35, 0)
......@@ -321,22 +298,22 @@ plugin_init (void)
g_message ("nm-ipsec-l2tp-ppp-plugin: (%s): initializing", __func__);
bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &err);
bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &err);
if (!bus) {
g_warning ("nm-ipsec-l2tp-pppd-plugin: (%s): couldn't connect to system bus: (%d) %s",
__func__,
err ? err->code : -1,
err && err->message ? err->message : "(unknown)");
__func__,
err ? err->code : -1,
err && err->message ? err->message : "(unknown)");
g_error_free (err);
return -1;
}
proxy = dbus_g_proxy_new_for_name (bus,
NM_DBUS_SERVICE_IPSEC_L2TP_PPP,
NM_DBUS_PATH_IPSEC_L2TP_PPP,
NM_DBUS_INTERFACE_IPSEC_L2TP_PPP);
dbus_g_connection_unref (bus);
proxy = g_dbus_proxy_new_sync (bus, G_DBUS_CALL_FLAGS_NONE, NULL,
NM_DBUS_SERVICE_IPSEC_L2TP_PPP,
NM_DBUS_PATH_IPSEC_L2TP_PPP,
NM_DBUS_INTERFACE_IPSEC_L2TP_PPP,
NULL, &err);
g_object_unref (bus);
chap_passwd_hook = get_credentials;
chap_check_hook = get_chap_check;
......
This diff is collapsed.
/*
* Generated by gdbus-codegen 2.48.1. DO NOT EDIT.
*
* The license of this code is the same as for the source it was derived from.
*/
#ifndef __NM_IPSEC_L2TP_PPPD_SERVICE_DBUS_H__
#define __NM_IPSEC_L2TP_PPPD_SERVICE_DBUS_H__
#include <gio/gio.h>
G_BEGIN_DECLS
/* ------------------------------------------------------------------------ */
/* Declarations for org.freedesktop.NetworkManager.ipsec_l2tp.ppp */
#define NMDBUS_TYPE_NETWORK_MANAGER_IPSEC_L2TP_PPP (nmdbus_network_manager_ipsec_l2tp_ppp_get_type ())
#define NMDBUS_NETWORK_MANAGER_IPSEC_L2TP_PPP(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), NMDBUS_TYPE_NETWORK_MANAGER_IPSEC_L2TP_PPP, NMDBusNetworkManagerIpsec_l2tpPpp))
#define NMDBUS_IS_NETWORK_MANAGER_IPSEC_L2TP_PPP(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), NMDBUS_TYPE_NETWORK_MANAGER_IPSEC_L2TP_PPP))
#define NMDBUS_NETWORK_MANAGER_IPSEC_L2TP_PPP_GET_IFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE ((o), NMDBUS_TYPE_NETWORK_MANAGER_IPSEC_L2TP_PPP, NMDBusNetworkManagerIpsec_l2tpPppIface))
struct _NMDBusNetworkManagerIpsec_l2tpPpp;
typedef struct _NMDBusNetworkManagerIpsec_l2tpPpp NMDBusNetworkManagerIpsec_l2tpPpp;
typedef struct _NMDBusNetworkManagerIpsec_l2tpPppIface NMDBusNetworkManagerIpsec_l2tpPppIface;
struct _NMDBusNetworkManagerIpsec_l2tpPppIface
{
GTypeInterface parent_iface;
gboolean (*handle_need_secrets) (
NMDBusNetworkManagerIpsec_l2tpPpp *object,
GDBusMethodInvocation *invocation);
gboolean (*handle_set_ip4_config) (
NMDBusNetworkManagerIpsec_l2tpPpp *object,
GDBusMethodInvocation *invocation,
GVariant *arg_config);
gboolean (*handle_set_state) (
NMDBusNetworkManagerIpsec_l2tpPpp *object,
GDBusMethodInvocation *invocation,
guint arg_state);
};
GType nmdbus_network_manager_ipsec_l2tp_ppp_get_type (void) G_GNUC_CONST;
GDBusInterfaceInfo *nmdbus_network_manager_ipsec_l2tp_ppp_interface_info (void);
guint nmdbus_network_manager_ipsec_l2tp_ppp_override_properties (GObjectClass *klass, guint property_id_begin);
/* D-Bus method call completion functions: */
void nmdbus_network_manager_ipsec_l2tp_ppp_complete_need_secrets (
NMDBusNetworkManagerIpsec_l2tpPpp *object,
GDBusMethodInvocation *invocation,
const gchar *username,
const gchar *password);
void nmdbus_network_manager_ipsec_l2tp_ppp_complete_set_ip4_config (
NMDBusNetworkManagerIpsec_l2tpPpp *object,
GDBusMethodInvocation *invocation);
void nmdbus_network_manager_ipsec_l2tp_ppp_complete_set_state (
NMDBusNetworkManagerIpsec_l2tpPpp *object,
GDBusMethodInvocation *invocation);
/* D-Bus method calls: */
void nmdbus_network_manager_ipsec_l2tp_ppp_call_need_secrets (
NMDBusNetworkManagerIpsec_l2tpPpp *proxy,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean nmdbus_network_manager_ipsec_l2tp_ppp_call_need_secrets_finish (
NMDBusNetworkManagerIpsec_l2tpPpp *proxy,
gchar **out_username,
gchar **out_password,
GAsyncResult *res,
GError **error);
gboolean nmdbus_network_manager_ipsec_l2tp_ppp_call_need_secrets_sync (
NMDBusNetworkManagerIpsec_l2tpPpp *proxy,
gchar **out_username,
gchar **out_password,
GCancellable *cancellable,
GError **error);
void nmdbus_network_manager_ipsec_l2tp_ppp_call_set_ip4_config (
NMDBusNetworkManagerIpsec_l2tpPpp *proxy,
GVariant *arg_config,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean nmdbus_network_manager_ipsec_l2tp_ppp_call_set_ip4_config_finish (
NMDBusNetworkManagerIpsec_l2tpPpp *proxy,
GAsyncResult *res,
GError **error);
gboolean nmdbus_network_manager_ipsec_l2tp_ppp_call_set_ip4_config_sync (
NMDBusNetworkManagerIpsec_l2tpPpp *proxy,
GVariant *arg_config,
GCancellable *cancellable,
GError **error);
void nmdbus_network_manager_ipsec_l2tp_ppp_call_set_state (
NMDBusNetworkManagerIpsec_l2tpPpp *proxy,
guint arg_state,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean nmdbus_network_manager_ipsec_l2tp_ppp_call_set_state_finish (
NMDBusNetworkManagerIpsec_l2tpPpp *proxy,
GAsyncResult *res,
GError **error);
gboolean nmdbus_network_manager_ipsec_l2tp_ppp_call_set_state_sync (
NMDBusNetworkManagerIpsec_l2tpPpp *proxy,
guint arg_state,
GCancellable *cancellable,
GError **error);
/* ---- */
#define NMDBUS_TYPE_NETWORK_MANAGER_IPSEC_L2TP_PPP_PROXY (nmdbus_network_manager_ipsec_l2tp_ppp_proxy_get_type ())
#define NMDBUS_NETWORK_MANAGER_IPSEC_L2TP_PPP_PROXY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), NMDBUS_TYPE_NETWORK_MANAGER_IPSEC_L2TP_PPP_PROXY, NMDBusNetworkManagerIpsec_l2tpPppProxy))
#define NMDBUS_NETWORK_MANAGER_IPSEC_L2TP_PPP_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), NMDBUS_TYPE_NETWORK_MANAGER_IPSEC_L2TP_PPP_PROXY, NMDBusNetworkManagerIpsec_l2tpPppProxyClass))
#define NMDBUS_NETWORK_MANAGER_IPSEC_L2TP_PPP_PROXY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), NMDBUS_TYPE_NETWORK_MANAGER_IPSEC_L2TP_PPP_PROXY, NMDBusNetworkManagerIpsec_l2tpPppProxyClass))
#define NMDBUS_IS_NETWORK_MANAGER_IPSEC_L2TP_PPP_PROXY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), NMDBUS_TYPE_NETWORK_MANAGER_IPSEC_L2TP_PPP_PROXY))
#define NMDBUS_IS_NETWORK_MANAGER_IPSEC_L2TP_PPP_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), NMDBUS_TYPE_NETWORK_MANAGER_IPSEC_L2TP_PPP_PROXY))
typedef struct _NMDBusNetworkManagerIpsec_l2tpPppProxy NMDBusNetworkManagerIpsec_l2tpPppProxy;
typedef struct _NMDBusNetworkManagerIpsec_l2tpPppProxyClass NMDBusNetworkManagerIpsec_l2tpPppProxyClass;
typedef struct _NMDBusNetworkManagerIpsec_l2tpPppProxyPrivate NMDBusNetworkManagerIpsec_l2tpPppProxyPrivate;
struct _NMDBusNetworkManagerIpsec_l2tpPppProxy
{
/*< private >*/
GDBusProxy parent_instance;
NMDBusNetworkManagerIpsec_l2tpPppProxyPrivate *priv;
};
struct _NMDBusNetworkManagerIpsec_l2tpPppProxyClass
{
GDBusProxyClass parent_class;
};
GType nmdbus_network_manager_ipsec_l2tp_ppp_proxy_get_type (void) G_GNUC_CONST;
#if GLIB_CHECK_VERSION(2, 44, 0)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (NMDBusNetworkManagerIpsec_l2tpPppProxy, g_object_unref)
#endif
void nmdbus_network_manager_ipsec_l2tp_ppp_proxy_new (
GDBusConnection *connection,
GDBusProxyFlags flags,
const gchar *name,
const gchar *object_path,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
NMDBusNetworkManagerIpsec_l2tpPpp *nmdbus_network_manager_ipsec_l2tp_ppp_proxy_new_finish (
GAsyncResult *res,
GError **error);
NMDBusNetworkManagerIpsec_l2tpPpp *nmdbus_network_manager_ipsec_l2tp_ppp_proxy_new_sync (
GDBusConnection *connection,
GDBusProxyFlags flags,
const gchar *name,
const gchar *object_path,
GCancellable *cancellable,
GError **error);
void nmdbus_network_manager_ipsec_l2tp_ppp_proxy_new_for_bus (
GBusType bus_type,
GDBusProxyFlags flags,
const gchar *name,
const gchar *object_path,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
NMDBusNetworkManagerIpsec_l2tpPpp *nmdbus_network_manager_ipsec_l2tp_ppp_proxy_new_for_bus_finish (
GAsyncResult *res,
GError **error);
NMDBusNetworkManagerIpsec_l2tpPpp *nmdbus_network_manager_ipsec_l2tp_ppp_proxy_new_for_bus_sync (
GBusType bus_type,
GDBusProxyFlags flags,
const gchar *name,
const gchar *object_path,
GCancellable *cancellable,
GError **error);
/* ---- */
#define NMDBUS_TYPE_NETWORK_MANAGER_IPSEC_L2TP_PPP_SKELETON (nmdbus_network_manager_ipsec_l2tp_ppp_skeleton_get_type ())
#define NMDBUS_NETWORK_MANAGER_IPSEC_L2TP_PPP_SKELETON(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), NMDBUS_TYPE_NETWORK_MANAGER_IPSEC_L2TP_PPP_SKELETON, NMDBusNetworkManagerIpsec_l2tpPppSkeleton))
#define NMDBUS_NETWORK_MANAGER_IPSEC_L2TP_PPP_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), NMDBUS_TYPE_NETWORK_MANAGER_IPSEC_L2TP_PPP_SKELETON, NMDBusNetworkManagerIpsec_l2tpPppSkeletonClass))
#define NMDBUS_NETWORK_MANAGER_IPSEC_L2TP_PPP_SKELETON_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), NMDBUS_TYPE_NETWORK_MANAGER_IPSEC_L2TP_PPP_SKELETON, NMDBusNetworkManagerIpsec_l2tpPppSkeletonClass))
#define NMDBUS_IS_NETWORK_MANAGER_IPSEC_L2TP_PPP_SKELETON(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), NMDBUS_TYPE_NETWORK_MANAGER_IPSEC_L2TP_PPP_SKELETON))
#define NMDBUS_IS_NETWORK_MANAGER_IPSEC_L2TP_PPP_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), NMDBUS_TYPE_NETWORK_MANAGER_IPSEC_L2TP_PPP_SKELETON))
typedef struct _NMDBusNetworkManagerIpsec_l2tpPppSkeleton NMDBusNetworkManagerIpsec_l2tpPppSkeleton;
typedef struct _NMDBusNetworkManagerIpsec_l2tpPppSkeletonClass NMDBusNetworkManagerIpsec_l2tpPppSkeletonClass;
typedef struct _NMDBusNetworkManagerIpsec_l2tpPppSkeletonPrivate NMDBusNetworkManagerIpsec_l2tpPppSkeletonPrivate;
struct _NMDBusNetworkManagerIpsec_l2tpPppSkeleton
{
/*< private >*/
GDBusInterfaceSkeleton parent_instance;
NMDBusNetworkManagerIpsec_l2tpPppSkeletonPrivate *priv;
};
struct _NMDBusNetworkManagerIpsec_l2tpPppSkeletonClass
{
GDBusInterfaceSkeletonClass parent_class;
};
GType nmdbus_network_manager_ipsec_l2tp_ppp_skeleton_get_type (void) G_GNUC_CONST;
#if GLIB_CHECK_VERSION(2, 44, 0)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (NMDBusNetworkManagerIpsec_l2tpPppSkeleton, g_object_unref)
#endif
NMDBusNetworkManagerIpsec_l2tpPpp *nmdbus_network_manager_ipsec_l2tp_ppp_skeleton_new (void);
G_END_DECLS
#endif /* __NM_IPSEC_L2TP_PPPD_SERVICE_DBUS_H__ */
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/* nm-ipsec-l2tp-service - IPSec-L2TP VPN integration with NetworkManager
*
* Dan Williams <dcbw@redhat.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright 2008, 2014 Red Hat, Inc.
*/
#ifndef NM_IPSEC_L2TP_SERVICE_DEFINES_H
#define NM_IPSEC_L2TP_SERVICE_DEFINES_H
#define NM_DBUS_SERVICE_IPSEC_L2TP_PPP "org.freedesktop.NetworkManager.ipsec_l2tp-ppp"
#define NM_DBUS_INTERFACE_IPSEC_L2TP_PPP "org.freedesktop.NetworkManager.ipsec_l2tp.ppp"
#define NM_DBUS_PATH_IPSEC_L2TP_PPP "/org/freedesktop/NetworkManager/ipsec_l2tp/ppp"
/* For the NM <-> VPN plugin service */
#define NM_DBUS_SERVICE_IPSEC_L2TP "org.freedesktop.NetworkManager.ipsec_l2tp"
#define NM_DBUS_INTERFACE_IPSEC_L2TP "org.freedesktop.NetworkManager.ipsec_l2tp"
#define NM_DBUS_PATH_IPSEC_L2TP "/org/freedesktop/NetworkManager/ipsec_l2tp"
#define NM_IPSEC_L2TP_KEY_GATEWAY "gateway"
#define NM_IPSEC_L2TP_KEY_USER "user"
#define NM_IPSEC_L2TP_KEY_PASSWORD "password"
#define NM_IPSEC_L2TP_KEY_DOMAIN "domain"
#define NM_IPSEC_L2TP_KEY_REFUSE_EAP "refuse-eap"
#define NM_IPSEC_L2TP_KEY_REFUSE_PAP "refuse-pap"
#define NM_IPSEC_L2TP_KEY_REFUSE_CHAP "refuse-chap"
#define NM_IPSEC_L2TP_KEY_REFUSE_MSCHAP "refuse-mschap"
#define NM_IPSEC_L2TP_KEY_REFUSE_MSCHAPV2 "refuse-mschapv2"
#define NM_IPSEC_L2TP_KEY_REQUIRE_MPPE "require-mppe"
#define NM_IPSEC_L2TP_KEY_REQUIRE_MPPE_40 "require-mppe-40"
#define NM_IPSEC_L2TP_KEY_REQUIRE_MPPE_128 "require-mppe-128"
#define NM_IPSEC_L2TP_KEY_MPPE_STATEFUL "mppe-stateful"
#define NM_IPSEC_L2TP_KEY_NOBSDCOMP "nobsdcomp"
#define NM_IPSEC_L2TP_KEY_NODEFLATE "nodeflate"
#define NM_IPSEC_L2TP_KEY_NO_VJ_COMP "no-vj-comp"
#define NM_IPSEC_L2TP_KEY_LCP_ECHO_FAILURE "lcp-echo-failure"
#define NM_IPSEC_L2TP_KEY_LCP_ECHO_INTERVAL "lcp-echo-interval"
#define NM_IPSEC_L2TP_KEY_UNIT_NUM "unit"
#define NM_IPSEC_L2TP_KEY_IPSEC_ENABLE "ipsec-enabled"
#define NM_IPSEC_L2TP_KEY_IPSEC_GATEWAY_ID "ipsec-gateway-id"
#define NM_IPSEC_L2TP_KEY_IPSEC_GROUP_NAME "ipsec-group-name"
#define NM_IPSEC_L2TP_KEY_IPSEC_PSK "ipsec-psk"
#define NM_IPSEC_L2TP_KEY_IPSEC_RSA "ipsec-rsa"
#define NM_IPSEC_L2TP_KEY_IPSEC_RSA_PW "ipsec-rsa-pw"
#endif /* NM_IPSEC_L2TP_SERVICE_DEFINES_H */
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment