diff --git a/vpn-daemons/pptp/.cvsignore b/vpn-daemons/pptp/.cvsignore
index a294769b0e..f8b78243fd 100644
--- a/vpn-daemons/pptp/.cvsignore
+++ b/vpn-daemons/pptp/.cvsignore
@@ -1,6 +1,6 @@
Makefile
Makefile.in
-NetworkManager-pptp*.tar.gz
+NetworkManager-ppp*.tar.gz
aclocal.m4
autom4te.cache
compile
@@ -23,8 +23,8 @@ libtool
ltmain.sh
missing
mkinstalldirs
-nm-pptp-service.name
-nm-pptp.desktop
+nm-ppp-starter.name
+nm-ppp.desktop
stamp-h1
COPYING
INSTALL
diff --git a/vpn-daemons/pptp/Makefile.am b/vpn-daemons/pptp/Makefile.am
index cfd71261b5..1cf4407dc7 100644
--- a/vpn-daemons/pptp/Makefile.am
+++ b/vpn-daemons/pptp/Makefile.am
@@ -3,13 +3,13 @@ AUTOMAKE_OPTIONS = foreign
SUBDIRS = src auth-dialog properties po
dbusservicedir = $(sysconfdir)/dbus-1/system.d
-dbusservice_DATA = nm-pptp-service.conf
+dbusservice_DATA = nm-ppp-starter.conf
nmvpnservicedir = $(sysconfdir)/NetworkManager/VPN
-nmvpnservice_DATA = nm-pptp-service.name
+nmvpnservice_DATA = nm-ppp-starter.name
desktopdir = $(datadir)/applications
-desktop_in_files = nm-pptp.desktop.in
+desktop_in_files = nm-ppp.desktop.in
desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
@INTLTOOL_DESKTOP_RULE@
diff --git a/vpn-daemons/pptp/auth-dialog/.cvsignore b/vpn-daemons/pptp/auth-dialog/.cvsignore
index 60aac6c80f..4f2ce42628 100644
--- a/vpn-daemons/pptp/auth-dialog/.cvsignore
+++ b/vpn-daemons/pptp/auth-dialog/.cvsignore
@@ -1,3 +1,3 @@
Makefile.in
Makefile
-nm-pptp-auth-dialog
+nm-ppp-auth-dialog
diff --git a/vpn-daemons/pptp/auth-dialog/Makefile.am b/vpn-daemons/pptp/auth-dialog/Makefile.am
index 6698147e82..b0aebb23a7 100644
--- a/vpn-daemons/pptp/auth-dialog/Makefile.am
+++ b/vpn-daemons/pptp/auth-dialog/Makefile.am
@@ -1,8 +1,8 @@
INCLUDES = -I${top_srcdir} -I${top_srcdir}/utils
-libexec_PROGRAMS = nm-pptp-auth-dialog
+libexec_PROGRAMS = nm-ppp-auth-dialog
-nm_pptp_auth_dialog_CPPFLAGS = \
+nm_ppp_auth_dialog_CPPFLAGS = \
$(GTHREAD_CFLAGS) \
$(GTK_CFLAGS) \
$(LIBGNOMEUI_CFLAGS) \
@@ -18,13 +18,13 @@ nm_pptp_auth_dialog_CPPFLAGS = \
-DVERSION=\"$(VERSION)\" \
$(NULL)
-nm_pptp_auth_dialog_SOURCES = \
+nm_ppp_auth_dialog_SOURCES = \
main.c \
gnome-two-password-dialog.c \
gnome-two-password-dialog.h \
$(NULL)
-nm_pptp_auth_dialog_LDADD = \
+nm_ppp_auth_dialog_LDADD = \
$(GTK_LIBS) \
$(LIBGNOMEUI_LIBS) \
$(GNOMEKEYRING_LIBS) \
diff --git a/vpn-daemons/pptp/auth-dialog/main.c b/vpn-daemons/pptp/auth-dialog/main.c
index cc759cd496..ebc487f2f6 100644
--- a/vpn-daemons/pptp/auth-dialog/main.c
+++ b/vpn-daemons/pptp/auth-dialog/main.c
@@ -31,7 +31,7 @@
#include "gnome-two-password-dialog.h"
-#define VPN_SERVICE "org.freedesktop.NetworkManager.pptp"
+#define VPN_SERVICE "org.freedesktop.NetworkManager.ppp_starter"
static GSList *
lookup_pass (const char *vpn_name, const char *vpn_service, gboolean *is_session)
@@ -161,7 +161,7 @@ get_passwords (const char *vpn_name, const char *vpn_service, gboolean retry)
}
prompt = g_strdup_printf (_("You need to authenticate to access the Virtual Private Network '%s'."), vpn_name);
- dialog = gnome_two_password_dialog_new (_("Authenticate PPTP VPN"), prompt, NULL, NULL, FALSE);
+ dialog = gnome_two_password_dialog_new (_("Authenticate VPN"), prompt, NULL, NULL, FALSE);
g_free (prompt);
gnome_two_password_dialog_set_show_userpass_buttons (GNOME_TWO_PASSWORD_DIALOG (dialog), FALSE);
@@ -249,7 +249,7 @@ main (int argc, char *argv[])
passwords = NULL;
- context = g_option_context_new ("- pptp auth dialog");
+ context = g_option_context_new ("- ppp auth dialog");
g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
g_option_context_add_group (context, gtk_get_option_group (TRUE));
g_option_context_parse (context, &argc, &argv, &error);
@@ -264,7 +264,7 @@ main (int argc, char *argv[])
goto out;
}
- gnome_program_init ("nm-pptp-auth-dialog", VERSION, LIBGNOMEUI_MODULE,
+ gnome_program_init ("nm-ppp-auth-dialog", VERSION, LIBGNOMEUI_MODULE,
argc, argv,
GNOME_PARAM_NONE);
diff --git a/vpn-daemons/pptp/configure.in b/vpn-daemons/pptp/configure.in
index 9a7a4ed29b..1476669a89 100644
--- a/vpn-daemons/pptp/configure.in
+++ b/vpn-daemons/pptp/configure.in
@@ -1,6 +1,6 @@
AC_PREREQ(2.52)
-AC_INIT(NetworkManager-pptp, 0.6.9, eemynotna@gmail.com, NetworkManager-pptp)
+AC_INIT(NetworkManager-ppp_vpn, 0.7.0, eemynotna@gmail.com, NetworkManager-ppp_vpn)
AC_CONFIG_AUX_DIR(.)
AM_INIT_AUTOMAKE([subdir-objects])
AM_MAINTAINER_MODE
@@ -38,7 +38,7 @@ AC_CHECK_FUNCS(select socket uname)
ALL_LINGUAS="da sv"
AC_SUBST(ALL_LINGUAS)
-GETTEXT_PACKAGE=NetworkManager-pptp
+GETTEXT_PACKAGE=NetworkManager-ppp_vpn
AC_SUBST(GETTEXT_PACKAGE)
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [Gettext package])
@@ -128,5 +128,5 @@ src/Makefile
auth-dialog/Makefile
properties/Makefile
po/Makefile.in
-nm-pptp-service.name
+nm-ppp-starter.name
])
diff --git a/vpn-daemons/pptp/doc/example-pptp-system-wide-connection.sh b/vpn-daemons/pptp/doc/example-pptp-system-wide-connection.sh
index e74dd01074..19f79ef081 100755
--- a/vpn-daemons/pptp/doc/example-pptp-system-wide-connection.sh
+++ b/vpn-daemons/pptp/doc/example-pptp-system-wide-connection.sh
@@ -6,11 +6,11 @@
# gconfd daemons after the script has run (logging in and out will
# suffice)
-NAME="pptp-system-wide"
-ESCAPED_NAME="pptp-system-wide"
+NAME="ppp-system-wide"
+ESCAPED_NAME="ppp-system-wide"
REMOTE="1.2.3.4"
# must be either yes or no
-USEMPPE="no"
+USEMPPE="yes"
IPSEC_ROUTES="[172.16.0.0/16,192.168.4.0/24]"
@@ -19,7 +19,7 @@ GCONF_PATH="/system/networking/vpn_connections/$ESCAPED_NAME"
GCONFTOOL2_OPTS="--direct --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory"
gconftool-2 $GCONFTOOL2_OPTS --type string --set $GCONF_PATH/name "$NAME"
-gconftool-2 $GCONFTOOL2_OPTS --type string --set $GCONF_PATH/service_name "org.freedesktop.NetworkManager.pptp"
-gconftool-2 $GCONFTOOL2_OPTS --type list --list-type=string --set $GCONF_PATH/vpn_data ["remote","$REMOTE","require-mppe",$USEMPPE]
+gconftool-2 $GCONFTOOL2_OPTS --type string --set $GCONF_PATH/service_name "org.freedesktop.NetworkManager.ppp_starter"
+gconftool-2 $GCONFTOOL2_OPTS --type list --list-type=string --set $GCONF_PATH/vpn_data ["pptp-remote","$REMOTE","encrypt-mppe",$USEMPPE]
gconftool-2 $GCONFTOOL2_OPTS --type list --list-type=string --set $GCONF_PATH/routes $IPSEC_ROUTES
diff --git a/vpn-daemons/pptp/nm-ppp-starter.conf b/vpn-daemons/pptp/nm-ppp-starter.conf
new file mode 100644
index 0000000000..8289c2a5f6
--- /dev/null
+++ b/vpn-daemons/pptp/nm-ppp-starter.conf
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/vpn-daemons/pptp/nm-ppp-starter.name.in b/vpn-daemons/pptp/nm-ppp-starter.name.in
new file mode 100644
index 0000000000..30251f8feb
--- /dev/null
+++ b/vpn-daemons/pptp/nm-ppp-starter.name.in
@@ -0,0 +1,8 @@
+[VPN Connection]
+name=ppp
+service=org.freedesktop.NetworkManager.ppp_starter
+program=@BINDIR@/nm-ppp-starter
+
+[GNOME]
+auth-dialog=@LIBEXECDIR@/nm-ppp-auth-dialog
+properties=@LIBDIR@/libnm-ppp-properties
diff --git a/vpn-daemons/pptp/nm-pptp.desktop.in b/vpn-daemons/pptp/nm-ppp.desktop.in
similarity index 51%
rename from vpn-daemons/pptp/nm-pptp.desktop.in
rename to vpn-daemons/pptp/nm-ppp.desktop.in
index 1f83ec1b9e..def9f072ff 100644
--- a/vpn-daemons/pptp/nm-pptp.desktop.in
+++ b/vpn-daemons/pptp/nm-ppp.desktop.in
@@ -1,12 +1,12 @@
[Desktop Entry]
Encoding=UTF-8
-_Name=VPN Connection Manager (PPTP)
-_GenericName=VPN Connection Manager (PPTP)
+_Name=VPN Connection Manager (PPP generic)
+_GenericName=VPN Connection Manager (PPP generic)
_Comment=Add, Remove, and Edit VPN Connections
-Exec=nm-vpn-properties --import-service org.freedesktop.NetworkManager.pptp --import-file %f
-Icon=gnome-mime-application-x-pptp-settings
+Exec=nm-vpn-properties --import-service org.freedesktop.NetworkManager.ppp_starter --import-file %f
+Icon=gnome-mime-application-x-ppp-settings
Terminal=false
Type=Application
DocPath=
Categories=GNOME;Application;Network;
-MimeType=application/x-pptp-settings
+MimeType=application/x-ppp-settings
diff --git a/vpn-daemons/pptp/nm-pptp-service.conf b/vpn-daemons/pptp/nm-pptp-service.conf
deleted file mode 100644
index 7bc31614c2..0000000000
--- a/vpn-daemons/pptp/nm-pptp-service.conf
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/vpn-daemons/pptp/nm-pptp-service.name.in b/vpn-daemons/pptp/nm-pptp-service.name.in
deleted file mode 100644
index a7f23c6489..0000000000
--- a/vpn-daemons/pptp/nm-pptp-service.name.in
+++ /dev/null
@@ -1,8 +0,0 @@
-[VPN Connection]
-name=pptp
-service=org.freedesktop.NetworkManager.pptp
-program=@BINDIR@/nm-pptp-service
-
-[GNOME]
-auth-dialog=@LIBEXECDIR@/nm-pptp-auth-dialog
-properties=@LIBDIR@/libnm-pptp-properties
diff --git a/vpn-daemons/pptp/src/.cvsignore b/vpn-daemons/pptp/src/.cvsignore
index 7cb5018284..64998e1076 100644
--- a/vpn-daemons/pptp/src/.cvsignore
+++ b/vpn-daemons/pptp/src/.cvsignore
@@ -1,4 +1,4 @@
Makefile.in
Makefile
-nm-pptp-service
-nm-pptp-service-pptp-helper
+nm-ppp-starter
+nm-pppd-plugin
diff --git a/vpn-daemons/pptp/src/Makefile.am b/vpn-daemons/pptp/src/Makefile.am
index 51ff4bdc91..6bd7169b58 100644
--- a/vpn-daemons/pptp/src/Makefile.am
+++ b/vpn-daemons/pptp/src/Makefile.am
@@ -16,14 +16,14 @@ AM_CPPFLAGS = \
-DDATADIR=\"$(datadir)\" \
-fPIC
-bin_PROGRAMS = nm-pptp-service
+bin_PROGRAMS = nm-ppp-starter
pppdplugindir = $(libdir)/pppd/2.4.3
pppdplugin_PROGRAMS = nm-pppd-plugin.so
-nm_pptp_service_SOURCES = \
- nm-pptp-service.c \
- nm-pptp-service.h \
+nm_ppp_starter_SOURCES = \
+ nm-ppp-starter.c \
+ nm-ppp-starter.h \
nm-utils.c \
nm-utils.h \
pppd/fsm.h \
@@ -32,13 +32,15 @@ nm_pptp_service_SOURCES = \
pppd/pppd.h
-nm_pptp_service_LDADD = \
+nm_ppp_starter_LDADD = \
$(DBUS_LIBS) \
$(GTHREAD_LIBS)
nm_pppd_plugin_so_SOURCES = \
- nm-pppd-plugin.c
+ nm-pppd-plugin.c \
+ nm-pppd-plugin.h \
+ nm-ppp-starter.h
nm_pppd_plugin_so_LDFLAGS = \
-shared
diff --git a/vpn-daemons/pptp/src/nm-pptp-service.c b/vpn-daemons/pptp/src/nm-ppp-starter.c
similarity index 59%
rename from vpn-daemons/pptp/src/nm-pptp-service.c
rename to vpn-daemons/pptp/src/nm-ppp-starter.c
index 41f41697b2..149fe7afa1 100644
--- a/vpn-daemons/pptp/src/nm-pptp-service.c
+++ b/vpn-daemons/pptp/src/nm-ppp-starter.c
@@ -1,4 +1,4 @@
-/* nm-pptp-service - pptp integration with NetworkManager
+/* nm-ppp-starter - pptp (and other ppp) integration with NetworkManager
*
* Antony J Mee
* Based on openvpn work by Tim Niemueller
@@ -46,7 +46,7 @@
#include
#include
-#include "nm-pptp-service.h"
+#include "nm-ppp-starter.h"
#include "nm-utils.h"
@@ -64,9 +64,9 @@ static const char *pppd_binary_paths[] =
NULL
};
-#define NM_PPTP_HELPER_PATH "nm-pppd-plugin.so"
+#define NM_PPP_HELPER_PATH "nm-pppd-plugin.so"
-typedef struct NmPPTPData
+typedef struct NmPPPData
{
GMainLoop *loop;
DBusConnection *con;
@@ -78,11 +78,12 @@ typedef struct NmPPTPData
struct in_addr ip4_vpn_gateway;
char **auth_items;
int num_auth_items;
-} NmPPTPData;
+ gboolean debug;
+} NmPPPData;
-static gboolean nm_pptp_dbus_handle_stop_vpn (NmPPTPData *data);
-static gboolean nm_pptp_store_auth_info (NmPPTPData *data,
+static gboolean nm_ppp_dbus_handle_stop_vpn (NmPPPData *data);
+static gboolean nm_ppp_store_auth_info (NmPPPData *data,
char **auth_items, int num_auth_items);
@@ -113,12 +114,12 @@ static DBusMessage *nm_dbus_create_error_message (DBusMessage *message, const ch
/*
- * nm_pptp_dbus_signal_failure
+ * nm_ppp_dbus_signal_failure
*
* Signal the bus that some VPN operation failed.
*
*/
-static void nm_pptp_dbus_signal_failure (NmPPTPData *data, const char *signal)
+static void nm_ppp_dbus_signal_failure (NmPPPData *data, const char *signal)
{
DBusMessage *message;
const char *error_msg = NULL;
@@ -131,7 +132,7 @@ static void nm_pptp_dbus_signal_failure (NmPPTPData *data, const char *signal)
if (!error_msg)
return;
- if (!(message = dbus_message_new_signal (NM_DBUS_PATH_PPTP, NM_DBUS_INTERFACE_PPTP, signal)))
+ if (!(message = dbus_message_new_signal (NM_DBUS_PATH_PPP_STARTER, NM_DBUS_INTERFACE_PPP_STARTER, signal)))
{
nm_warning ("Not enough memory for new dbus message!");
return;
@@ -146,39 +147,39 @@ static void nm_pptp_dbus_signal_failure (NmPPTPData *data, const char *signal)
/*
- * nm_pptp_dbus_signal_state_change
+ * nm_ppp_dbus_signal_state_change
*
* Signal the bus that our state changed.
*
*/
-static void nm_pptp_dbus_signal_state_change (NmPPTPData *data, NMVPNState old_state)
+static void nm_ppp_dbus_signal_state_change (NmPPPData *data, NMVPNState old_state)
{
DBusMessage *message;
g_return_if_fail (data != NULL);
- if (!(message = dbus_message_new_signal (NM_DBUS_PATH_PPTP, NM_DBUS_INTERFACE_PPTP, NM_DBUS_VPN_SIGNAL_STATE_CHANGE)))
+ if (!(message = dbus_message_new_signal (NM_DBUS_PATH_PPP_STARTER, NM_DBUS_INTERFACE_PPP_STARTER, NM_DBUS_VPN_SIGNAL_STATE_CHANGE)))
{
- nm_warning ("nm_pptp_dbus_signal_state_change(): Not enough memory for new dbus message!");
+ nm_warning ("nm_ppp_dbus_signal_state_change(): Not enough memory for new dbus message!");
return;
}
dbus_message_append_args (message, DBUS_TYPE_UINT32, &old_state, DBUS_TYPE_UINT32, &(data->state), DBUS_TYPE_INVALID);
if (!dbus_connection_send (data->con, message, NULL))
- nm_warning ("nm_pptp_dbus_signal_state_change(): Could not raise the signal!");
+ nm_warning ("nm_ppp_dbus_signal_state_change(): Could not raise the signal!");
dbus_message_unref (message);
}
/*
- * nm_pptp_set_state
+ * nm_ppp_set_state
*
* Set our state and make sure to signal the bus.
*
*/
-static void nm_pptp_set_state (NmPPTPData *data, NMVPNState new_state)
+static void nm_ppp_set_state (NmPPPData *data, NMVPNState new_state)
{
NMVPNState old_state;
@@ -186,23 +187,23 @@ static void nm_pptp_set_state (NmPPTPData *data, NMVPNState new_state)
old_state = data->state;
- nm_info("PPTP State change: %d -> %d",old_state,new_state);
+ nm_info("PPP State change: %d -> %d",old_state,new_state);
if (old_state != new_state)
{
data->state = new_state;
- nm_pptp_dbus_signal_state_change (data, old_state);
+ nm_ppp_dbus_signal_state_change (data, old_state);
}
}
/*
- * nm_pptp_quit_timer_cb
+ * nm_ppp_quit_timer_cb
*
- * Callback to quit nm-pptp-service after a certain period of time.
+ * Callback to quit nm-ppp-starter after a certain period of time.
*
*/
-static gboolean nm_pptp_quit_timer_cb (NmPPTPData *data)
+static gboolean nm_ppp_quit_timer_cb (NmPPPData *data)
{
data->quit_timer = 0;
@@ -215,28 +216,28 @@ static gboolean nm_pptp_quit_timer_cb (NmPPTPData *data)
/*
- * nm_pptp_schedule_quit_timer
+ * nm_ppp_schedule_quit_timer
*
- * If pptp isn't running, and we haven't been asked to do anything in a while,
+ * If ppp isn't running, and we haven't been asked to do anything in a while,
* then we just exit since NetworkManager will re-launch us later.
*
*/
-static void nm_pptp_schedule_quit_timer (NmPPTPData *data, guint interval)
+static void nm_ppp_schedule_quit_timer (NmPPPData *data, guint interval)
{
g_return_if_fail (data != NULL);
if (data->quit_timer == 0)
- data->quit_timer = g_timeout_add (interval, (GSourceFunc) nm_pptp_quit_timer_cb, data);
+ data->quit_timer = g_timeout_add (interval, (GSourceFunc) nm_ppp_quit_timer_cb, data);
}
/*
- * nm_pptp_cancel_quit_timer
+ * nm_ppp_cancel_quit_timer
*
* Cancel a quit timer that we've scheduled before.
*
*/
-static void nm_pptp_cancel_quit_timer (NmPPTPData *data)
+static void nm_ppp_cancel_quit_timer (NmPPPData *data)
{
g_return_if_fail (data != NULL);
@@ -246,49 +247,49 @@ static void nm_pptp_cancel_quit_timer (NmPPTPData *data)
/*
- * nm_pptp_helper_timer_cb
+ * nm_ppp_helper_timer_cb
*
* If we haven't received the IP4 config info from the helper before the timeout
- * occurs, we kill pptp
+ * occurs, we kill pppd
*
*/
-static gboolean nm_pptp_helper_timer_cb (NmPPTPData *data)
+static gboolean nm_ppp_helper_timer_cb (NmPPPData *data)
{
data->helper_timer = 0;
g_return_val_if_fail (data != NULL, FALSE);
- nm_pptp_dbus_signal_failure (data, NM_DBUS_VPN_SIGNAL_CONNECT_FAILED);
- nm_pptp_dbus_handle_stop_vpn (data);
+ nm_ppp_dbus_signal_failure (data, NM_DBUS_VPN_SIGNAL_CONNECT_FAILED);
+ nm_ppp_dbus_handle_stop_vpn (data);
return FALSE;
}
/*
- * nm_pptp_schedule_helper_timer
+ * nm_ppp_schedule_helper_timer
*
- * Once pptp is running, we wait for the helper to return the IP4 configuration
+ * Once ppp is running, we wait for the helper to return the IP4 configuration
* information to us. If we don't receive that information within 7 seconds,
- * we kill pptp
+ * we kill pppd
*
*/
-static void nm_pptp_schedule_helper_timer (NmPPTPData *data)
+static void nm_ppp_schedule_helper_timer (NmPPPData *data)
{
g_return_if_fail (data != NULL);
if (data->helper_timer == 0)
- data->helper_timer = g_timeout_add (10000, (GSourceFunc) nm_pptp_helper_timer_cb, data);
+ data->helper_timer = g_timeout_add (10000, (GSourceFunc) nm_ppp_helper_timer_cb, data);
}
/*
- * nm_pptp_cancel_helper_timer
+ * nm_ppp_cancel_helper_timer
*
* Cancel a helper timer that we've scheduled before.
*
*/
-static void nm_pptp_cancel_helper_timer (NmPPTPData *data)
+static void nm_ppp_cancel_helper_timer (NmPPPData *data)
{
g_return_if_fail (data != NULL);
@@ -296,31 +297,32 @@ static void nm_pptp_cancel_helper_timer (NmPPTPData *data)
g_source_remove (data->helper_timer);
}
-
/*
- * pptp_watch_cb
+ * pppd_start_watch_cb
*
- * Watch our child pptp process and get notified of events from it.
+ * Watch our child ppp process and get notified of events from it.
*
*/
-static void pptp_watch_cb (GPid pid, gint status, gpointer user_data)
+static void pppd_start_watch_cb (GPid pid, gint status, gpointer user_data)
{
guint error = -1;
+ guint status2;
- NmPPTPData *data = (NmPPTPData *)user_data;
+ NmPPPData *data = (NmPPPData *)user_data;
+ nm_warning ("pppd_start_watch_cb: entered");
if (WIFEXITED (status))
{
error = WEXITSTATUS (status);
if (error != 0)
- nm_warning ("pptp exited with error code %d", error);
+ nm_warning ("pppd exited with error code %d", error);
}
else if (WIFSTOPPED (status))
- nm_warning ("pptp stopped unexpectedly with signal %d", WSTOPSIG (status));
+ nm_warning ("pppd stopped unexpectedly with signal %d", WSTOPSIG (status));
else if (WIFSIGNALED (status))
- nm_warning ("pptp died with signal %d", WTERMSIG (status));
+ nm_warning ("pppd died with signal %d", WTERMSIG (status));
else
- nm_warning ("pptp died from an unknown cause");
+ nm_warning ("pppd died from an unknown cause");
/* Reap child if needed. */
waitpid (data->pid, NULL, WNOHANG);
@@ -330,40 +332,93 @@ static void pptp_watch_cb (GPid pid, gint status, gpointer user_data)
switch (error)
{
case 2: /* Couldn't log in due to bad user/pass */
- nm_pptp_dbus_signal_failure (data, NM_DBUS_VPN_SIGNAL_LOGIN_FAILED);
+ nm_ppp_dbus_signal_failure (data, NM_DBUS_VPN_SIGNAL_LOGIN_FAILED);
break;
case 1: /* Other error (couldn't bind to address, etc) */
- nm_pptp_dbus_signal_failure (data, NM_DBUS_VPN_SIGNAL_CONNECT_FAILED);
+ nm_ppp_dbus_signal_failure (data, NM_DBUS_VPN_SIGNAL_CONNECT_FAILED);
+ break;
+
+ default:
+ return;
+ break;
+ }
+
+ nm_ppp_set_state (data, NM_VPN_STATE_STOPPED);
+ nm_ppp_schedule_quit_timer (data, 10000);
+}
+
+
+/*
+ * pppd_forked_watch_cb
+ *
+ * Watch our child ppp process and get notified of events from it.
+ *
+ */
+static void pppd_forked_watch_cb (GPid pid, gint status, gpointer user_data)
+{
+ guint error = -1;
+ guint status2;
+
+ NmPPPData *data = (NmPPPData *)user_data;
+ nm_warning ("ppp_forked_watch_cb: entered");
+
+ if (WIFEXITED (status))
+ {
+ error = WEXITSTATUS (status);
+ if (error != 0)
+ nm_warning ("ppp exited with error code %d", error);
+ }
+ else if (WIFSTOPPED (status))
+ nm_warning ("ppp stopped unexpectedly with signal %d", WSTOPSIG (status));
+ else if (WIFSIGNALED (status))
+ nm_warning ("ppp died with signal %d", WTERMSIG (status));
+ else
+ nm_warning ("ppp died from an unknown cause");
+
+ /* Reap child if needed. */
+ waitpid (data->pid, NULL, WNOHANG);
+ data->pid = 0;
+
+ /* Must be after data->state is set since signals use data->state */
+ switch (error)
+ {
+ case 2: /* Couldn't log in due to bad user/pass */
+ nm_ppp_dbus_signal_failure (data, NM_DBUS_VPN_SIGNAL_LOGIN_FAILED);
+ break;
+
+ case 1: /* Other error (couldn't bind to address, etc) */
+ nm_ppp_dbus_signal_failure (data, NM_DBUS_VPN_SIGNAL_CONNECT_FAILED);
break;
default:
break;
}
- nm_pptp_set_state (data, NM_VPN_STATE_STOPPED);
- nm_pptp_schedule_quit_timer (data, 10000);
+ nm_ppp_set_state (data, NM_VPN_STATE_STOPPED);
+ nm_ppp_schedule_quit_timer (data, 10000);
}
/*
- * nm_pptp_start_vpn_binary
+ * nm_ppp_start_vpn_binary
*
- * Start the pptp binary with a set of arguments and a config file.
+ * Start the ppp binary with a set of arguments and a config file.
*
*/
-static gint nm_pptp_start_pptp_binary (NmPPTPData *data, char **data_items, const int num_items)
+static gint nm_ppp_start_ppp_binary (NmPPPData *data, char **data_items, const int num_items)
{
GPid pid;
const char ** pptp_binary = NULL;
const char ** pppd_binary = NULL;
struct hostent *hostinfo = NULL;
- GPtrArray * pptp_argv;
+ GPtrArray * ppp_argv;
GError * error = NULL;
- GSource * pptp_watch;
gint stdin_fd = -1;
+ GSource * pppd_watch;
int i = 0;
char * pppd_pty = NULL;
+ char * cmdline = NULL;
g_return_val_if_fail (data != NULL, -1);
@@ -399,12 +454,12 @@ static gint nm_pptp_start_pptp_binary (NmPPTPData *data, char **data_items, cons
return -1;
}
- pptp_argv = g_ptr_array_new ();
- g_ptr_array_add (pptp_argv, (gpointer) (*pppd_binary));
+ ppp_argv = g_ptr_array_new ();
+ g_ptr_array_add (ppp_argv, (gpointer) (*pppd_binary));
- // First pptp parameter is the PPTP server
+ // First ppp parameter is the PPTP server
for (i = 0; i < num_items; ++i) {
- if ( strcmp( data_items[i], "remote" ) == 0) {
+ if ( strcmp( data_items[i], "pptp-remote" ) == 0) {
hostinfo = gethostbyname(data_items[++i]);
if (!hostinfo) {
nm_info ("Could not resolve VPN servers IP.");
@@ -417,73 +472,103 @@ static gint nm_pptp_start_pptp_binary (NmPPTPData *data, char **data_items, cons
pppd_pty = g_strdup_printf ("%s %s --nolaunchpppd", (*pptp_binary), data->str_ip4_vpn_gateway);
// nm_info ("Starting pppd with pty %s",pppd_pty);
- g_ptr_array_add (pptp_argv, (gpointer) "pty");
- g_ptr_array_add (pptp_argv, (gpointer) pppd_pty);
+ g_ptr_array_add (ppp_argv, (gpointer) "pty");
+ g_ptr_array_add (ppp_argv, (gpointer) pppd_pty);
}
}
- g_ptr_array_add (pptp_argv, (gpointer) "nodetach");
- g_ptr_array_add (pptp_argv, (gpointer) "lock");
- g_ptr_array_add (pptp_argv, (gpointer) "noauth");
- g_ptr_array_add (pptp_argv, (gpointer) "nobsdcomp");
- g_ptr_array_add (pptp_argv, (gpointer) "nodeflate");
-// g_ptr_array_add (pptp_argv, (gpointer) "ipparam");
-// g_ptr_array_add (pptp_argv, (gpointer) "nm-pptp-service");
- g_ptr_array_add (pptp_argv, (gpointer) "mtu");
- g_ptr_array_add (pptp_argv, (gpointer) "1000");
- g_ptr_array_add (pptp_argv, (gpointer) "mru");
- g_ptr_array_add (pptp_argv, (gpointer) "1000");
- g_ptr_array_add (pptp_argv, (gpointer) "lcp-echo-failure");
- g_ptr_array_add (pptp_argv, (gpointer) "10");
- g_ptr_array_add (pptp_argv, (gpointer) "lcp-echo-interval");
- g_ptr_array_add (pptp_argv, (gpointer) "10");
+// g_ptr_array_add (ppp_argv, (gpointer) "nodetach");
+ g_ptr_array_add (ppp_argv, (gpointer) "ipparam");
+ g_ptr_array_add (ppp_argv, (gpointer) "NetworkManager");
// Set the username...
for (i = 0; i < num_items; ++i) {
-/* if ( strcmp( data_items[i], "username" ) == 0) {
- g_ptr_array_add (pptp_argv, (gpointer) "user");
- g_ptr_array_add (pptp_argv, (gpointer) data_items[++i]);
- } else */ if ( strcmp( data_items[i], "remote" ) == 0) {
- g_ptr_array_add (pptp_argv, (gpointer) "remotename");
- g_ptr_array_add (pptp_argv, (gpointer) data_items[++i]);
+ if ( strcmp( data_items[i], "pptp-remote" ) == 0) {
+ g_ptr_array_add (ppp_argv, (gpointer) "remotename");
+ g_ptr_array_add (ppp_argv, (gpointer) data_items[++i]);
+ } else if ( (strcmp( data_items[i], "ppp-lock" ) == 0) &&
+ (strcmp( data_items[++i], "yes" ) == 0) ) {
+ g_ptr_array_add (ppp_argv, (gpointer) "lock");
+ } else if ( (strcmp( data_items[i], "ppp-auth-peer" ) == 0) &&
+ (strcmp( data_items[++i], "no" ) == 0) ) {
+ g_ptr_array_add (ppp_argv, (gpointer) "noauth");
+ } else if ( (strcmp( data_items[i], "compress-bsd" ) == 0) &&
+ (strcmp( data_items[++i], "no" ) == 0) ) {
+ g_ptr_array_add (ppp_argv, (gpointer) "nobsdcomp");
+ } else if ( (strcmp( data_items[i], "compress-deflate" ) == 0) &&
+ (strcmp( data_items[++i], "no" ) == 0) ) {
+ g_ptr_array_add (ppp_argv, (gpointer) "nodeflate");
+ } else if ( (strcmp( data_items[i], "mru" ) == 0) &&
+ (strlen( data_items[++i] ) > 0) ) {
+ g_ptr_array_add (ppp_argv, (gpointer) "mru");
+ g_ptr_array_add (ppp_argv, (gpointer) data_items[i]);
+ } else if ( (strcmp( data_items[i], "mtu" ) == 0) &&
+ (strlen( data_items[++i] ) > 0) ) {
+ g_ptr_array_add (ppp_argv, (gpointer) "mtu");
+ g_ptr_array_add (ppp_argv, (gpointer) data_items[i]);
+ } else if ( (strcmp( data_items[i], "lcp-echo-failure" ) == 0) &&
+ (strlen( data_items[++i] ) > 0) ) {
+ g_ptr_array_add (ppp_argv, (gpointer) "lcp-echo-failure");
+ g_ptr_array_add (ppp_argv, (gpointer) data_items[i]);
+ } else if ( (strcmp( data_items[i], "lcp-echo-interval" ) == 0) &&
+ (strlen( data_items[++i] ) > 0) ) {
+ g_ptr_array_add (ppp_argv, (gpointer) "lcp-echo-interval");
+ g_ptr_array_add (ppp_argv, (gpointer) data_items[i]);
} else if ( (strcmp( data_items[i], "encrypt-mppe" ) == 0) &&
(strcmp( data_items[++i], "yes" ) == 0) ) {
- g_ptr_array_add (pptp_argv, (gpointer) "require-mppe");
- } else if ( (strcmp( data_items[i], "comp-mppc" ) == 0) &&
+ g_ptr_array_add (ppp_argv, (gpointer) "require-mppe");
+ } else if ( (strcmp( data_items[i], "encrypt-mppe" ) == 0) &&
(strcmp( data_items[++i], "yes" ) == 0) ) {
- g_ptr_array_add (pptp_argv, (gpointer) "require-mppc");
+ g_ptr_array_add (ppp_argv, (gpointer) "require-mppe");
+ } else if ( (strcmp( data_items[i], "encrypt-mppe" ) == 0) &&
+ (strcmp( data_items[++i], "yes" ) == 0) ) {
+ g_ptr_array_add (ppp_argv, (gpointer) "require-mppe");
+ } else if ( (strcmp( data_items[i], "compress-mppc" ) == 0) &&
+ (strcmp( data_items[++i], "yes" ) == 0) ) {
+ g_ptr_array_add (ppp_argv, (gpointer) "require-mppc");
+ } else if ( (strcmp( data_items[i], "usepeerdns" ) == 0) &&
+ (strcmp( data_items[++i], "yes" ) == 0) ) {
+ g_ptr_array_add (ppp_argv, (gpointer) "usepeerdns");
+// } else if ( (strcmp( data_items[i], "usepeerdns-overtunnel" ) == 0) &&
+// (strcmp( data_items[++i], "yes" ) != 0) ) {
+// g_ptr_array_add (ppp_argv, (gpointer) "usepeeddns-overtunnel");
+ } else if ( (strcmp( data_items[i], "ppp-debug" ) == 0) &&
+ (strcmp( data_items[++i], "yes" ) == 0) ) {
+ data->debug=TRUE;
}
}
- g_ptr_array_add (pptp_argv, (gpointer) "usepeerdns");
+ if (data->debug) g_ptr_array_add (ppp_argv, (gpointer) "debug");
- g_ptr_array_add (pptp_argv, (gpointer) "plugin");
- g_ptr_array_add (pptp_argv, (gpointer) NM_PPTP_HELPER_PATH);
+ g_ptr_array_add (ppp_argv, (gpointer) "plugin");
+ g_ptr_array_add (ppp_argv, (gpointer) NM_PPP_HELPER_PATH);
- g_ptr_array_add (pptp_argv, NULL);
+ g_ptr_array_add (ppp_argv, NULL);
- if (!g_spawn_async_with_pipes (NULL, (char **) pptp_argv->pdata, NULL,
+ if (data->debug)
+ {
+ cmdline=g_strjoinv(" ",(char **) ppp_argv->pdata);
+ nm_info("Running pppd with commandline:\n '%s'",cmdline);
+ g_free(cmdline);
+ }
+
+ if (!g_spawn_async_with_pipes (NULL, (char **) ppp_argv->pdata, NULL,
G_SPAWN_DO_NOT_REAP_CHILD, NULL, NULL, &pid, &stdin_fd,
NULL, NULL, &error))
{
- g_ptr_array_free (pptp_argv, TRUE);
+ g_ptr_array_free (ppp_argv, TRUE);
g_free(pppd_pty);
- nm_warning ("pptp failed to start. error: '%s'", error->message);
+ nm_warning ("pppd failed to start. error: '%s'", error->message);
g_error_free(error);
return -1;
}
- g_ptr_array_free (pptp_argv, TRUE);
+ g_ptr_array_free (ppp_argv, TRUE);
g_free(pppd_pty);
- nm_info ("pptp started with pid %d", pid);
-
- data->pid = pid;
- pptp_watch = g_child_watch_source_new (pid);
- g_source_set_callback (pptp_watch, (GSourceFunc) pptp_watch_cb, data, NULL);
- g_source_attach (pptp_watch, NULL);
- g_source_unref (pptp_watch);
-
- nm_pptp_schedule_helper_timer (data);
+ pppd_watch = g_child_watch_source_new (pid);
+ g_source_set_callback (pppd_watch, (GSourceFunc) pppd_start_watch_cb, data, NULL);
+ g_source_attach (pppd_watch, NULL);
+ g_source_unref (pppd_watch);
return stdin_fd;
}
@@ -504,18 +589,32 @@ typedef struct Option
} Option;
/*
- * nm_pptp_config_options_validate
+ * nm_ppp_config_options_validate
*
* Make sure the config options are sane
*
*/
-static gboolean nm_pptp_config_options_validate (char **data_items, int num_items)
+static gboolean nm_ppp_config_options_validate (char **data_items, int num_items)
{
Option allowed_opts[] = {
- { "remote", OPT_TYPE_ADDRESS },
- { "username", OPT_TYPE_ASCII },
- { "comp-mppc", OPT_TYPE_ASCII },
- { "encrypt-mppe", OPT_TYPE_ASCII },
+ { "ppp-connection-type", OPT_TYPE_ASCII },
+ { "pptp-remote", OPT_TYPE_ADDRESS },
+ { "phone-number", OPT_TYPE_ADDRESS },
+ { "usepeerdns", OPT_TYPE_ASCII },
+ { "usepeerdns-overtunnel", OPT_TYPE_ASCII },
+ { "compress-mppc", OPT_TYPE_ASCII },
+ { "compress-bsd", OPT_TYPE_ASCII },
+ { "compress-deflate", OPT_TYPE_ASCII },
+ { "encrypt-mppe", OPT_TYPE_ASCII },
+ { "ppp-auth-peer", OPT_TYPE_ASCII },
+ { "ppp-lock", OPT_TYPE_ASCII },
+ { "mtu", OPT_TYPE_ASCII },
+ { "mru", OPT_TYPE_ASCII },
+ { "lcp-echo-failure", OPT_TYPE_ASCII },
+ { "lcp-echo-interval", OPT_TYPE_ASCII },
+ { "ppp-debug", OPT_TYPE_ASCII },
+ { "use-routes", OPT_TYPE_ASCII },
+ { "routes", OPT_TYPE_ASCII },
{ NULL, OPT_TYPE_UNKNOWN } };
unsigned int i;
@@ -542,16 +641,16 @@ static gboolean nm_pptp_config_options_validate (char **data_items, int num_item
/* Find the option in the allowed list */
for (t = 0; t < sizeof (allowed_opts) / sizeof (Option); t++)
- {
- opt = &allowed_opts[t];
- if (opt->name && !strcmp (opt->name, data_items[i]))
- break;
- }
+ {
+ opt = &allowed_opts[t];
+ if (opt->name && (strcmp (opt->name, data_items[i])==0))
+ break;
+ }
if (!opt->name) /* not found */
- {
- nm_warning ("VPN option '%s' is not allowed.", data_items[i]);
- return FALSE;
- }
+ {
+ nm_warning ("VPN option '%s' is not allowed.", data_items[i]);
+ return FALSE;
+ }
/* Don't allow control characters at all */
len = strlen (opt_value);
@@ -589,37 +688,47 @@ static gboolean nm_pptp_config_options_validate (char **data_items, int num_item
}
/*
- * nm_pptp_store_auth_info
+ * nm_ppp_store_auth_info
*
* Decode and temporarily store the authentication info provided.
*
*/
-static gboolean nm_pptp_store_auth_info (NmPPTPData *data,
+static gboolean nm_ppp_store_auth_info (NmPPPData *data,
char **auth_items, int num_auth_items)
{
-// nm_warning("nm_pptp_store_auth_info: enter");
+ char *cmdline;
+ int i;
+// nm_warning("nm_ppp_store_auth_info: enter");
+ g_return_val_if_fail (data != NULL, FALSE);
g_return_val_if_fail (auth_items != NULL, FALSE);
g_return_val_if_fail (num_auth_items >= 1, FALSE);
- if ((data->auth_items=g_strdupv(auth_items))==NULL)
- {
+ data->auth_items = (char **)g_new0(char *, num_auth_items);
+ g_return_val_if_fail (data->auth_items != NULL, FALSE);
+
+ for (i=0;iauth_items[i]=g_strdup(auth_items[i]);
+ if ((data->auth_items=g_strdupv(auth_items))==NULL) {
+ for (--i;i>=0;i--) {
+ g_free(data->auth_items[i]);
+ }
+ g_free(data->auth_items);
data->num_auth_items=-1;
-// nm_warning("nm_pptp_store_auth_info: failed");
return FALSE;
- }
+ }
+ }
data->num_auth_items=num_auth_items;
-// nm_warning("nm_pptp_store_auth_info: done");
return TRUE;
}
/*
- * nm_pptp_dbus_handle_start_vpn
+ * nm_ppp_dbus_handle_start_vpn
*
* Parse message arguments and start the VPN connection.
*
*/
-static gboolean nm_pptp_dbus_handle_start_vpn (DBusMessage *message, NmPPTPData *data)
+static gboolean nm_ppp_dbus_handle_start_vpn (DBusMessage *message, NmPPPData *data)
{
char ** data_items = NULL;
int num_items = -1;
@@ -631,12 +740,12 @@ static gboolean nm_pptp_dbus_handle_start_vpn (DBusMessage *message, NmPPTPData
const char * user_name = NULL;
DBusError error;
gboolean success = FALSE;
- gint pptp_fd = -1;
+ gint pppd_fd = -1;
g_return_val_if_fail (message != NULL, FALSE);
g_return_val_if_fail (data != NULL, FALSE);
- nm_pptp_set_state (data, NM_VPN_STATE_STARTING);
+ nm_ppp_set_state (data, NM_VPN_STATE_STARTING);
dbus_error_init (&error);
if (!dbus_message_get_args (message, &error,
@@ -648,25 +757,25 @@ static gboolean nm_pptp_dbus_handle_start_vpn (DBusMessage *message, NmPPTPData
DBUS_TYPE_INVALID))
{
nm_warning ("Could not process the request because its arguments were invalid. dbus said: '%s'", error.message);
- nm_pptp_dbus_signal_failure (data, NM_DBUS_VPN_SIGNAL_VPN_CONFIG_BAD);
+ nm_ppp_dbus_signal_failure (data, NM_DBUS_VPN_SIGNAL_VPN_CONFIG_BAD);
dbus_error_free (&error);
goto out;
}
- if (!nm_pptp_config_options_validate (data_items, num_items))
+ if (!nm_ppp_config_options_validate (data_items, num_items))
{
- nm_pptp_dbus_signal_failure (data, NM_DBUS_VPN_SIGNAL_VPN_CONFIG_BAD);
+ nm_ppp_dbus_signal_failure (data, NM_DBUS_VPN_SIGNAL_VPN_CONFIG_BAD);
goto out;
}
- if (!nm_pptp_store_auth_info (data, auth_items, num_auth_items))
+ if (!nm_ppp_store_auth_info (data, auth_items, num_auth_items))
{
- nm_pptp_dbus_signal_failure (data, NM_DBUS_VPN_SIGNAL_LOGIN_FAILED);
+ nm_ppp_dbus_signal_failure (data, NM_DBUS_VPN_SIGNAL_LOGIN_FAILED);
goto out;
}
/* Now we can finally try to activate the VPN */
- if ((pptp_fd = nm_pptp_start_pptp_binary (data, data_items, num_items)) >= 0)
+ if ( (pppd_fd=nm_ppp_start_ppp_binary (data, data_items, num_items)) >= 0)
{
success = TRUE;
}
@@ -676,56 +785,56 @@ out:
dbus_free_string_array (auth_items);
dbus_free_string_array (user_routes);
if (!success)
- nm_pptp_set_state (data, NM_VPN_STATE_STOPPED);
+ nm_ppp_set_state (data, NM_VPN_STATE_STOPPED);
return success;
}
/*
- * nm_pptp_dbus_handle_stop_vpn
+ * nm_ppp_dbus_handle_stop_vpn
*
* Stop the running pppd dameon.
*
*/
-static gboolean nm_pptp_dbus_handle_stop_vpn (NmPPTPData *data)
+static gboolean nm_ppp_dbus_handle_stop_vpn (NmPPPData *data)
{
g_return_val_if_fail (data != NULL, FALSE);
if (data->pid > 0)
{
- nm_pptp_set_state (data, NM_VPN_STATE_STOPPING);
+ nm_ppp_set_state (data, NM_VPN_STATE_STOPPING);
kill (data->pid, SIGTERM);
nm_info ("Terminated pppd with PID %d.", data->pid);
data->pid = 0;
- nm_pptp_set_state (data, NM_VPN_STATE_STOPPED);
- nm_pptp_schedule_quit_timer (data, 10000);
+ nm_ppp_set_state (data, NM_VPN_STATE_STOPPED);
+ nm_ppp_schedule_quit_timer (data, 10000);
}
return TRUE;
}
/*
- * nm_pptp_dbus_handle_chap_check
+ * nm_ppp_dbus_handle_chap_check
*
* Stop the running pppd dameon.
*
*/
-static gboolean nm_pptp_dbus_handle_chap_check (NmPPTPData *data)
+static gboolean nm_ppp_dbus_handle_chap_check (NmPPPData *data)
{
g_return_val_if_fail (data != NULL, FALSE);
if (data->pid > 0)
{
- nm_pptp_set_state (data, NM_VPN_STATE_STOPPING);
+ nm_ppp_set_state (data, NM_VPN_STATE_STOPPING);
kill (data->pid, SIGTERM);
nm_info ("Terminated pppd with PID %d.", data->pid);
data->pid = 0;
- nm_pptp_set_state (data, NM_VPN_STATE_STOPPED);
- nm_pptp_schedule_quit_timer (data, 10000);
+ nm_ppp_set_state (data, NM_VPN_STATE_STOPPED);
+ nm_ppp_schedule_quit_timer (data, 10000);
}
return TRUE;
@@ -733,12 +842,12 @@ static gboolean nm_pptp_dbus_handle_chap_check (NmPPTPData *data)
/*
- * nm_pptp_dbus_start_vpn
+ * nm_ppp_dbus_start_vpn
*
* Begin a VPN connection.
*
*/
-static DBusMessage *nm_pptp_dbus_start_vpn (DBusConnection *con, DBusMessage *message, NmPPTPData *data)
+static DBusMessage *nm_ppp_dbus_start_vpn (DBusConnection *con, DBusMessage *message, NmPPPData *data)
{
DBusMessage *reply = NULL;
@@ -749,23 +858,23 @@ static DBusMessage *nm_pptp_dbus_start_vpn (DBusConnection *con, DBusMessage *me
switch (data->state)
{
case NM_VPN_STATE_STARTING:
- reply = nm_dbus_create_error_message (message, NM_DBUS_INTERFACE_PPTP, NM_DBUS_VPN_STARTING_IN_PROGRESS,
+ reply = nm_dbus_create_error_message (message, NM_DBUS_INTERFACE_PPP_STARTER, NM_DBUS_VPN_STARTING_IN_PROGRESS,
"Could not process the request because the VPN connection is already being started.");
break;
case NM_VPN_STATE_STARTED:
- reply = nm_dbus_create_error_message (message, NM_DBUS_INTERFACE_PPTP, NM_DBUS_VPN_ALREADY_STARTED,
+ reply = nm_dbus_create_error_message (message, NM_DBUS_INTERFACE_PPP_STARTER, NM_DBUS_VPN_ALREADY_STARTED,
"Could not process the request because a VPN connection was already active.");
break;
case NM_VPN_STATE_STOPPING:
- reply = nm_dbus_create_error_message (message, NM_DBUS_INTERFACE_PPTP, NM_DBUS_VPN_STOPPING_IN_PROGRESS,
+ reply = nm_dbus_create_error_message (message, NM_DBUS_INTERFACE_PPP_STARTER, NM_DBUS_VPN_STOPPING_IN_PROGRESS,
"Could not process the request because the VPN connection is being stopped.");
break;
case NM_VPN_STATE_STOPPED:
- nm_pptp_cancel_quit_timer (data);
- nm_pptp_dbus_handle_start_vpn (message, data);
+ nm_ppp_cancel_quit_timer (data);
+ nm_ppp_dbus_handle_start_vpn (message, data);
reply = dbus_message_new_method_return (message);
break;
@@ -779,12 +888,12 @@ static DBusMessage *nm_pptp_dbus_start_vpn (DBusConnection *con, DBusMessage *me
/*
- * nm_pptp_dbus_stop_vpn
+ * nm_ppp_dbus_stop_vpn
*
* Terminate a VPN connection.
*
*/
-static DBusMessage *nm_pptp_dbus_stop_vpn (DBusConnection *con, DBusMessage *message, NmPPTPData *data)
+static DBusMessage *nm_ppp_dbus_stop_vpn (DBusConnection *con, DBusMessage *message, NmPPPData *data)
{
DBusMessage *reply = NULL;
@@ -795,18 +904,18 @@ static DBusMessage *nm_pptp_dbus_stop_vpn (DBusConnection *con, DBusMessage *mes
switch (data->state)
{
case NM_VPN_STATE_STOPPING:
- reply = nm_dbus_create_error_message (message, NM_DBUS_INTERFACE_PPTP, NM_DBUS_VPN_STOPPING_IN_PROGRESS,
+ reply = nm_dbus_create_error_message (message, NM_DBUS_INTERFACE_PPP_STARTER, NM_DBUS_VPN_STOPPING_IN_PROGRESS,
"Could not process the request because the VPN connection is already being stopped.");
break;
case NM_VPN_STATE_STOPPED:
- reply = nm_dbus_create_error_message (message, NM_DBUS_INTERFACE_PPTP, NM_DBUS_VPN_ALREADY_STOPPED,
+ reply = nm_dbus_create_error_message (message, NM_DBUS_INTERFACE_PPP_STARTER, NM_DBUS_VPN_ALREADY_STOPPED,
"Could not process the request because no VPN connection was active.");
break;
case NM_VPN_STATE_STARTING:
case NM_VPN_STATE_STARTED:
- nm_pptp_dbus_handle_stop_vpn (data);
+ nm_ppp_dbus_handle_stop_vpn (data);
reply = dbus_message_new_method_return (message);
break;
@@ -820,12 +929,12 @@ static DBusMessage *nm_pptp_dbus_stop_vpn (DBusConnection *con, DBusMessage *mes
/*
- * nm_pptp_dbus_get_state
+ * nm_ppp_dbus_get_state
*
* Return some state information to NetworkManager.
*
*/
-static DBusMessage *nm_pptp_dbus_get_state (DBusConnection *con, DBusMessage *message, NmPPTPData *data)
+static DBusMessage *nm_ppp_dbus_get_state (DBusConnection *con, DBusMessage *message, NmPPPData *data)
{
DBusMessage *reply = NULL;
@@ -840,19 +949,52 @@ static DBusMessage *nm_pptp_dbus_get_state (DBusConnection *con, DBusMessage *me
}
/*
- * nm_pptp_dbus_get_auth_info
+ * nm_ppp_dbus_notify_pid
+ *
+ * Recieve the pid of the PPPD process from the PPPD plugin.
+ *
+ */
+static void nm_ppp_dbus_notify_pid (DBusConnection *con, DBusMessage *message, NmPPPData *data)
+{
+ GSource * pppd_watch;
+
+ g_return_if_fail (data != NULL);
+ g_return_if_fail (con != NULL);
+ g_return_if_fail (message != NULL);
+
+ if(!dbus_message_get_args (message, NULL,
+ DBUS_TYPE_UINT32, &(data->pid),
+ DBUS_TYPE_INVALID)) {
+ nm_warning ("PPPD plugin did not send a valid process ID");
+ dbus_message_unref (message);
+ return;
+ }
+ dbus_message_unref (message);
+
+ nm_info ("nm-ppp-starter: pppd spawned pid %d", data->pid);
+
+ pppd_watch = g_child_watch_source_new (data->pid);
+ g_source_set_callback (pppd_watch, (GSourceFunc) pppd_forked_watch_cb, data, NULL);
+ g_source_attach (pppd_watch, NULL);
+ g_source_unref (pppd_watch);
+
+ nm_ppp_schedule_helper_timer (data);
+
+}
+
+/*
+ * nm_ppp_dbus_get_auth_info
*
* Pass authentication information to the PPPD plugin.
*
*/
-static DBusMessage *nm_pptp_dbus_get_auth_info (DBusConnection *con, DBusMessage *message, NmPPTPData *data)
+static DBusMessage *nm_ppp_dbus_get_auth_info (DBusConnection *con, DBusMessage *message, NmPPPData *data)
{
DBusMessage *reply = NULL;
g_return_val_if_fail (data != NULL, NULL);
g_return_val_if_fail (con != NULL, NULL);
g_return_val_if_fail (message != NULL, NULL);
- nm_info("Attempting getAuthInfo reply");
if (data->auth_items==NULL) {
nm_warning("Authentication not recieved yet. Sending 'NONE'.");
@@ -862,7 +1004,6 @@ static DBusMessage *nm_pptp_dbus_get_auth_info (DBusConnection *con, DBusMessage
// g_return_val_if_fail (data->auth_items != NULL, NULL);
// g_return_val_if_fail (data->num_auth_items >= 1, NULL);
- nm_info("Building getAuthInfo reply");
if ((reply = dbus_message_new_method_return (message)))
dbus_message_append_args (reply,
DBUS_TYPE_STRING, &(data->auth_items[0]),
@@ -873,19 +1014,17 @@ static DBusMessage *nm_pptp_dbus_get_auth_info (DBusConnection *con, DBusMessage
if (!reply)
nm_info("Build of getAuthInfo reply failed ");
- nm_info("Should reply ");
-
return reply;
}
/*
- * nm_pptp_dbus_process_helper_config_error
- *
+ * nm_ppp_dbus_process_helper_config_error
+
* Signal the bus that the helper could not get all the configuration information
* it needed.
*
*/
-static void nm_pptp_dbus_process_helper_config_error (DBusConnection *con, DBusMessage *message, NmPPTPData *data)
+static void nm_ppp_dbus_process_helper_config_error (DBusConnection *con, DBusMessage *message, NmPPPData *data)
{
char *error_item;
@@ -899,22 +1038,22 @@ static void nm_pptp_dbus_process_helper_config_error (DBusConnection *con, DBusM
if (dbus_message_get_args (message, NULL, DBUS_TYPE_STRING, &error_item, DBUS_TYPE_INVALID))
{
- nm_warning ("pptp helper did not receive adequate configuration information from pppd. It is missing '%s'.", error_item);
- nm_pptp_dbus_signal_failure (data, NM_DBUS_VPN_SIGNAL_IP_CONFIG_BAD);
+ nm_warning ("ppp helper did not receive adequate configuration information from pppd. It is missing '%s'.", error_item);
+ nm_ppp_dbus_signal_failure (data, NM_DBUS_VPN_SIGNAL_IP_CONFIG_BAD);
}
- nm_pptp_cancel_helper_timer (data);
- nm_pptp_dbus_handle_stop_vpn (data);
+ nm_ppp_cancel_helper_timer (data);
+ nm_ppp_dbus_handle_stop_vpn (data);
}
/*
- * nm_pptp_dbus_process_helper_ip4_config
+ * nm_ppp_dbus_process_helper_ip4_config
*
* Signal the bus
*
*/
-static void nm_pptp_dbus_process_helper_ip4_config (DBusConnection *con, DBusMessage *message, NmPPTPData *data)
+static void nm_ppp_dbus_process_helper_ip4_config (DBusConnection *con, DBusMessage *message, NmPPPData *data)
{
guint32 ip4_vpn_gateway;
char * tundev;
@@ -945,7 +1084,7 @@ static void nm_pptp_dbus_process_helper_ip4_config (DBusConnection *con, DBusMes
g_strfreev (data->auth_items);
data->num_auth_items=-1;
- nm_pptp_cancel_helper_timer (data);
+ nm_ppp_cancel_helper_timer (data);
if (dbus_message_get_args(message, NULL,
DBUS_TYPE_STRING, &tundev,
@@ -976,13 +1115,13 @@ static void nm_pptp_dbus_process_helper_ip4_config (DBusConnection *con, DBusMes
if (ip4_nbns_len==2) ip4_nbns[1]=ip4_nbns2;
}
- if (!(signal = dbus_message_new_signal (NM_DBUS_PATH_PPTP, NM_DBUS_INTERFACE_PPTP, NM_DBUS_VPN_SIGNAL_IP4_CONFIG)))
+ if (!(signal = dbus_message_new_signal (NM_DBUS_PATH_PPP_STARTER, NM_DBUS_INTERFACE_PPP_STARTER, NM_DBUS_VPN_SIGNAL_IP4_CONFIG)))
{
nm_warning ("Not enough memory for new dbus message!");
goto out;
}
- /* PPTP does not care about the MSS */
+ /* PPP does not care about the MSS */
mss = 0;
ip4_vpn_gateway=data->ip4_vpn_gateway.s_addr;
@@ -1006,7 +1145,7 @@ static void nm_pptp_dbus_process_helper_ip4_config (DBusConnection *con, DBusMes
}
dbus_message_unref (signal);
- nm_pptp_set_state (data, NM_VPN_STATE_STARTED);
+ nm_ppp_set_state (data, NM_VPN_STATE_STARTED);
success = TRUE;
}
@@ -1016,21 +1155,21 @@ out:
if (!success)
{
- nm_warning ("Received invalid IP4 Config information from helper, terminating pptp.");
- nm_pptp_dbus_handle_stop_vpn (data);
+ nm_warning ("Received invalid IP4 Config information from helper, terminating pppd.");
+ nm_ppp_dbus_handle_stop_vpn (data);
}
}
/*
- * nm_pptp_dbus_message_handler
+ * nm_ppp_dbus_message_handler
*
* Handle requests for our services.
*
*/
-static DBusHandlerResult nm_pptp_dbus_message_handler (DBusConnection *con, DBusMessage *message, void *user_data)
+static DBusHandlerResult nm_ppp_dbus_message_handler (DBusConnection *con, DBusMessage *message, void *user_data)
{
- NmPPTPData *data = (NmPPTPData *)user_data;
+ NmPPPData *data = (NmPPPData *)user_data;
const char *method;
const char *path;
DBusMessage *reply = NULL;
@@ -1043,29 +1182,31 @@ static DBusHandlerResult nm_pptp_dbus_message_handler (DBusConnection *con, DBus
method = dbus_message_get_member (message);
path = dbus_message_get_path (message);
- /* nm_info ("nm_pptp_dbus_message_handler() got method '%s' for path '%s'.", method, path); */
+ /* nm_info ("nm_ppp_dbus_message_handler() got method '%s' for path '%s'.", method, path); */
/* If we aren't ready to accept dbus messages, don't */
if ((data->state == NM_VPN_STATE_INIT) || (data->state == NM_VPN_STATE_SHUTDOWN))
{
nm_warning ("Received dbus messages but couldn't handle them due to INIT or SHUTDOWN states.");
- reply = nm_dbus_create_error_message (message, NM_DBUS_INTERFACE_PPTP, NM_DBUS_VPN_WRONG_STATE,
+ reply = nm_dbus_create_error_message (message, NM_DBUS_INTERFACE_PPP_STARTER, NM_DBUS_VPN_WRONG_STATE,
"Could not process the request due to current state of STATE_INIT or STATE_SHUTDOWN.");
goto reply;
}
if (strcmp ("startConnection", method) == 0)
- reply = nm_pptp_dbus_start_vpn (con, message, data);
+ reply = nm_ppp_dbus_start_vpn (con, message, data);
else if (strcmp ("stopConnection", method) == 0)
- reply = nm_pptp_dbus_stop_vpn (con, message, data);
+ reply = nm_ppp_dbus_stop_vpn (con, message, data);
else if (strcmp ("getState", method) == 0)
- reply = nm_pptp_dbus_get_state (con, message, data);
+ reply = nm_ppp_dbus_get_state (con, message, data);
else if (strcmp ("signalConfigError", method) == 0)
- nm_pptp_dbus_process_helper_config_error (con, message, data);
+ nm_ppp_dbus_process_helper_config_error (con, message, data);
else if (strcmp ("signalIP4Config", method) == 0)
- nm_pptp_dbus_process_helper_ip4_config (con, message, data);
+ nm_ppp_dbus_process_helper_ip4_config (con, message, data);
+ else if (strcmp ("notifyPID", method) == 0)
+ nm_ppp_dbus_notify_pid (con, message, data);
else if (strcmp ("getAuthInfo", method) == 0)
- reply = nm_pptp_dbus_get_auth_info (con, message, data);
+ reply = nm_ppp_dbus_get_auth_info (con, message, data);
else
handled = FALSE;
@@ -1081,15 +1222,15 @@ static DBusHandlerResult nm_pptp_dbus_message_handler (DBusConnection *con, DBus
/*
- * nm_pptp_dbus_filter
+ * nm_ppp_dbus_filter
*
* Handle signals from the bus, like NetworkManager network state
* signals.
*
*/
-static DBusHandlerResult nm_pptp_dbus_filter (DBusConnection *con, DBusMessage *message, void *user_data)
+static DBusHandlerResult nm_ppp_dbus_filter (DBusConnection *con, DBusMessage *message, void *user_data)
{
- NmPPTPData *data = (NmPPTPData *)user_data;
+ NmPPPData *data = (NmPPPData *)user_data;
gboolean handled = FALSE;
DBusError error;
@@ -1119,7 +1260,7 @@ static DBusHandlerResult nm_pptp_dbus_filter (DBusConnection *con, DBusMessage *
else if ((old_owner_good && !new_owner_good) && (strcmp (service, NM_DBUS_SERVICE) == 0)) /* Equivalent to old ServiceDeleted signal */
{
/* If NM goes away, we don't stick around */
- nm_pptp_dbus_handle_stop_vpn (data);
+ nm_ppp_dbus_handle_stop_vpn (data);
g_main_loop_quit (data->loop);
}
}
@@ -1127,7 +1268,7 @@ static DBusHandlerResult nm_pptp_dbus_filter (DBusConnection *con, DBusMessage *
else if (dbus_message_is_signal (message, NM_DBUS_INTERFACE, "DeviceNoLongerActive"))
{
/* If the active device goes down our VPN is certainly not going to work. */
- nm_pptp_dbus_handle_stop_vpn (data);
+ nm_ppp_dbus_handle_stop_vpn (data);
}
return (handled ? DBUS_HANDLER_RESULT_HANDLED : DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
@@ -1135,16 +1276,16 @@ static DBusHandlerResult nm_pptp_dbus_filter (DBusConnection *con, DBusMessage *
/*
- * nm_pptp_dbus_init
+ * nm_ppp_dbus_init
*
* Grab our connection to the system bus, return NULL if anything goes wrong.
*
*/
-DBusConnection *nm_pptp_dbus_init (NmPPTPData *data)
+DBusConnection *nm_ppp_dbus_init (NmPPPData *data)
{
DBusConnection *connection = NULL;
DBusError error;
- DBusObjectPathVTable vtable = { NULL, &nm_pptp_dbus_message_handler, NULL, NULL, NULL, NULL };
+ DBusObjectPathVTable vtable = { NULL, &nm_ppp_dbus_message_handler, NULL, NULL, NULL, NULL };
g_return_val_if_fail (data != NULL, NULL);
@@ -1159,20 +1300,20 @@ DBusConnection *nm_pptp_dbus_init (NmPPTPData *data)
dbus_connection_setup_with_g_main (connection, NULL);
dbus_error_init (&error);
- dbus_bus_request_name (connection, NM_DBUS_SERVICE_PPTP, 0, &error);
+ dbus_bus_request_name (connection, NM_DBUS_SERVICE_PPP_STARTER, 0, &error);
if (dbus_error_is_set (&error))
{
nm_warning ("Could not acquire the dbus service. dbus_bus_request_name() says: '%s'", error.message);
goto out;
}
- if (!dbus_connection_register_object_path (connection, NM_DBUS_PATH_PPTP, &vtable, data))
+ if (!dbus_connection_register_object_path (connection, NM_DBUS_PATH_PPP_STARTER, &vtable, data))
{
- nm_warning ("Could not register a dbus handler for nm-pptp-service. Not enough memory?");
+ nm_warning ("Could not register a dbus handler for nm-ppp-starter. Not enough memory?");
return NULL;
}
- if (!dbus_connection_add_filter (connection, nm_pptp_dbus_filter, data, NULL))
+ if (!dbus_connection_add_filter (connection, nm_ppp_dbus_filter, data, NULL))
return NULL;
dbus_error_init (&error);
@@ -1202,11 +1343,11 @@ out:
return connection;
}
-NmPPTPData *vpn_data = NULL;
+NmPPPData *vpn_data = NULL;
static void sigterm_handler (int signum)
{
- nm_info ("nm-pptp-service caught SIGINT/SIGTERM");
+ nm_info ("nm-ppp-starter caught SIGINT/SIGTERM");
g_main_loop_quit (vpn_data->loop);
}
@@ -1220,18 +1361,20 @@ int main( int argc, char *argv[] )
{
struct sigaction action;
sigset_t block_mask;
+ int i;
g_type_init ();
if (!g_thread_supported ())
g_thread_init (NULL);
- vpn_data = g_malloc0 (sizeof (NmPPTPData));
+ vpn_data = g_malloc0 (sizeof (NmPPPData));
+ vpn_data->debug = FALSE;
vpn_data->state = NM_VPN_STATE_INIT;
vpn_data->loop = g_main_loop_new (NULL, FALSE);
- if (!(vpn_data->con = nm_pptp_dbus_init (vpn_data)))
+ if (!(vpn_data->con = nm_ppp_dbus_init (vpn_data)))
exit (1);
action.sa_handler = sigterm_handler;
@@ -1241,14 +1384,17 @@ int main( int argc, char *argv[] )
sigaction (SIGINT, &action, NULL);
sigaction (SIGTERM, &action, NULL);
- nm_pptp_set_state (vpn_data, NM_VPN_STATE_STOPPED);
+ nm_ppp_set_state (vpn_data, NM_VPN_STATE_STOPPED);
g_main_loop_run (vpn_data->loop);
- nm_pptp_dbus_handle_stop_vpn (vpn_data);
+ nm_ppp_dbus_handle_stop_vpn (vpn_data);
g_main_loop_unref (vpn_data->loop);
- g_strfreev (vpn_data->auth_items);
+ for (i=0;inum_auth_items;i++) {
+ g_free(vpn_data->auth_items[i]);
+ }
+ g_free((char *)vpn_data->auth_items);
g_free (vpn_data->str_ip4_vpn_gateway);
g_free (vpn_data);
diff --git a/vpn-daemons/pptp/src/nm-pptp-service.h b/vpn-daemons/pptp/src/nm-ppp-starter.h
similarity index 71%
rename from vpn-daemons/pptp/src/nm-pptp-service.h
rename to vpn-daemons/pptp/src/nm-ppp-starter.h
index 4adf2de656..e904bf4809 100644
--- a/vpn-daemons/pptp/src/nm-pptp-service.h
+++ b/vpn-daemons/pptp/src/nm-ppp-starter.h
@@ -1,4 +1,4 @@
-/* nm-pptp-service - pptp integration with NetworkManager
+/* nm-ppp-starter - pptp (and other ppp) integration with NetworkManager
*
* Antony J Mee
* Based on openvpn work by Tim Niemueller
@@ -20,11 +20,11 @@
*
*/
-#ifndef NM_PPTP_SERVICE_H
-#define NM_PPTP_SERVICE_H
+#ifndef NM_PPP_SERVICE_H
+#define NM_PPP_SERVICE_H
-#define NM_DBUS_SERVICE_PPTP "org.freedesktop.NetworkManager.pptp"
-#define NM_DBUS_INTERFACE_PPTP "org.freedesktop.NetworkManager.pptp"
-#define NM_DBUS_PATH_PPTP "/org/freedesktop/NetworkManager/pptp"
+#define NM_DBUS_SERVICE_PPP_STARTER "org.freedesktop.NetworkManager.ppp_starter"
+#define NM_DBUS_INTERFACE_PPP_STARTER "org.freedesktop.NetworkManager.ppp_starter"
+#define NM_DBUS_PATH_PPP_STARTER "/org/freedesktop/NetworkManager/ppp_starter"
#endif
diff --git a/vpn-daemons/pptp/src/nm-pppd-plugin.c b/vpn-daemons/pptp/src/nm-pppd-plugin.c
index 779ba1144a..c3d236f0a8 100644
--- a/vpn-daemons/pptp/src/nm-pppd-plugin.c
+++ b/vpn-daemons/pptp/src/nm-pppd-plugin.c
@@ -1,4 +1,4 @@
-/* nm-pptp-service - pptp integration with NetworkManager
+/* nm-pptp-service - pptp (and other pppd) integration with NetworkManager
*
* Antony J Mee
*
@@ -21,8 +21,9 @@
#include "pppd/fsm.h"
#include "pppd/ipcp.h"
-#include "static_credentials.h"
+#include
+#include
#include
#include
#include
@@ -36,8 +37,8 @@
#include
#include
-#include "nm-pptp-service.h"
-#include "nm-ppp-service.h"
+#include "nm-ppp-starter.h"
+#include "nm-pppd-plugin.h"
#include "nm-utils.h"
typedef struct NmPPPData
@@ -47,6 +48,7 @@ typedef struct NmPPPData
char *auth_type;
char *username;
char *password;
+ int pppd_pid;
} NmPPPData;
char pppd_version[] = PPPD_VERSION;
@@ -55,31 +57,33 @@ NmPPPData plugin_data;
int plugin_init();
-void pptp_ip_up(void *opaque, int arg);
-void pptp_ip_down(void *opaque, int arg);
-void pptp_exit_notify(void *opaque, int arg);
+void nm_ip_up(void *opaque, int arg);
+void nm_ip_down(void *opaque, int arg);
+void nm_exit_notify(void *opaque, int arg);
-int pptp_chap_passwd_hook(char *user, char *passwd);
-int pptp_chap_check_hook(void);
+int nm_chap_passwd_hook(char *user, char *passwd);
+int nm_chap_check_hook(void);
+void nm_notify_pid (NmPPPData *data);
void send_config_error (DBusConnection *con, const char *item);
-gboolean pptp_get_auth_items (NmPPPData *data);
-gboolean pptp_store_auth_info (NmPPPData *data, char **auth_items, int num_auth_items);
-gboolean pptp_dbus_prepare_connection(NmPPPData *data);
-static DBusHandlerResult pptp_dbus_message_handler (DBusConnection *con, DBusMessage *message, void *user_data);
-void pptp_dbus_kill_connection(NmPPPData *data);
+gboolean nm_get_auth_items (NmPPPData *data);
+gboolean nm_store_auth_info (NmPPPData *data, char **auth_items, int num_auth_items);
+gboolean nm_dbus_prepare_connection(NmPPPData *data);
+static DBusHandlerResult nm_dbus_message_handler (DBusConnection *con, DBusMessage *message, void *user_data);
+void nm_dbus_kill_connection(NmPPPData *data);
-gboolean pptp_dbus_prepare_connection(NmPPPData *data)
+gboolean nm_dbus_prepare_connection(NmPPPData *data)
{
DBusMessage * message = NULL;
DBusError error;
DBusObjectPathVTable vtable = { NULL,
- &pptp_dbus_message_handler,
+ &nm_dbus_message_handler,
NULL, NULL, NULL, NULL };
g_return_val_if_fail (data != NULL, FALSE);
if (data->con != NULL) return TRUE;
+
dbus_error_init (&error);
data->con = dbus_bus_get (DBUS_BUS_SYSTEM, &error);
if ((data->con == NULL) || dbus_error_is_set (&error))
@@ -89,20 +93,20 @@ gboolean pptp_dbus_prepare_connection(NmPPPData *data)
}
dbus_connection_set_exit_on_disconnect (data->con, FALSE);
- dbus_error_init (&error);
- dbus_bus_request_name (data->con, NM_DBUS_SERVICE_PPP, 0, &error);
- if (dbus_error_is_set (&error))
- {
- nm_warning ("Could not acquire the dbus service. dbus_bus_request_name() says: '%s'", error.message);
- goto out;
- }
+// dbus_error_init (&error);
+// dbus_bus_request_name (data->con, NM_DBUS_SERVICE_PPP, 0, &error);
+// if (dbus_error_is_set (&error))
+// {
+// nm_warning ("Could not acquire the dbus service. dbus_bus_request_name() says: '%s'", error.message);
+// goto out;
+// }
- if (!dbus_connection_register_object_path (data->con, NM_DBUS_PATH_PPP, &vtable, data))
- {
- nm_warning ("Could not register a dbus handler for nm-ppp-service. Not enough memory?");
- dbus_connection_unref(data->con);
- data->con = NULL;
- }
+// if (!dbus_connection_register_object_path (data->con, NM_DBUS_PATH_PPP, &vtable, data))
+// {
+// nm_warning ("Could not register a dbus handler for nm-ppp-service. Not enough memory?");
+// dbus_connection_unref(data->con);
+// data->con = NULL;
+// }
out:
if (dbus_error_is_set (&error))
{
@@ -113,7 +117,7 @@ out:
return TRUE;
}
-void pptp_dbus_kill_connection(NmPPPData *data)
+void nm_dbus_kill_connection(NmPPPData *data)
{
g_return_if_fail (data != NULL);
@@ -124,12 +128,12 @@ void pptp_dbus_kill_connection(NmPPPData *data)
}
/*
- * pptp_dbus_message_handler
+ * nm_dbus_message_handler
*
* Handle requests for our services.
*
*/
-static DBusHandlerResult pptp_dbus_message_handler (DBusConnection *con, DBusMessage *message, void *user_data)
+static DBusHandlerResult nm_dbus_message_handler (DBusConnection *con, DBusMessage *message, void *user_data)
{
NmPPPData *data = (NmPPPData *)user_data;
const char *method;
@@ -144,31 +148,9 @@ static DBusHandlerResult pptp_dbus_message_handler (DBusConnection *con, DBusMes
method = dbus_message_get_member (message);
path = dbus_message_get_path (message);
- nm_info ("pptp_dbus_message_handler() got method '%s' for path '%s'.", method, path);
+ nm_info ("nm_dbus_message_handler() got method '%s' for path '%s'.", method, path);
-// /* If we aren't ready to accept dbus messages, don't */
-// if ((data->state == NM_VPN_STATE_INIT) || (data->state == NM_VPN_STATE_SHUTDOWN))
-// {
-// nm_warning ("Received dbus messages but couldn't handle them due to INIT or SHUTDOWN states.");
-// reply = nm_dbus_create_error_message (message, NM_DBUS_INTERFACE_PPTP, NM_DBUS_VPN_WRONG_STATE,
-// "Could not process the request due to current state of STATE_INIT or STATE_SHUTDOWN.");
-// goto reply;
-// }
-//
-// if (strcmp ("startConnection", method) == 0)
-// reply = nm_pptp_dbus_start_vpn (con, message, data);
-// else if (strcmp ("stopConnection", method) == 0)
-// reply = nm_pptp_dbus_stop_vpn (con, message, data);
-// else if (strcmp ("getState", method) == 0)
-// reply = nm_pptp_dbus_get_state (con, message, data);
-// else if (strcmp ("signalConfigError", method) == 0)
-// nm_pptp_dbus_process_helper_config_error (con, message, data);
-// else if (strcmp ("signalIP4Config", method) == 0)
-// nm_pptp_dbus_process_helper_ip4_config (con, message, data);
-// else if (strcmp ("getAuthInfo", method) == 0)
-// nm_pptp_dbus_get_auth_info (con, message, data);
-// else
- handled = FALSE;
+ handled = FALSE;
reply:
if (reply)
@@ -181,61 +163,64 @@ static DBusHandlerResult pptp_dbus_message_handler (DBusConnection *con, DBusMes
}
-int pptp_chap_check_hook(void)
+int nm_chap_check_hook(void)
{
- if (! pptp_get_auth_items (&plugin_data))
+ plugin_data.pppd_pid=getpid();
+ nm_notify_pid (&plugin_data);
+
+ if (! nm_get_auth_items (&plugin_data))
{
return 0;
}
if (strcmp("CHAP",plugin_data.auth_type)!=0)
{
- info("nm-pptp: No CHAP authentication available!");
+ info("nm-pppd-plugin: No CHAP authentication available!");
return 0;
}
- info("nm-pptp: CHAP check hook.");
+ info("nm-pppd-plugin: CHAP check hook.");
return 1;
}
-int pptp_chap_passwd_hook(char *user, char *passwd)
+int nm_chap_passwd_hook(char *user, char *passwd)
{
- info("nm-pptp: CHAP credentials requested.");
+ info("nm-pppd-plugin: CHAP credentials requested.");
if (user == NULL)
{
- info("nm-pptp: pppd didn't provide username buffer");
+ info("nm-pppd-plugin: pppd didn't provide username buffer");
return -1;
}
if (passwd == NULL)
{
- info("nm-pptp: pppd didn't provide password buffer");
+ info("nm-pppd-plugin: pppd didn't provide password buffer");
return -1;
}
if (plugin_data.username == NULL)
{
- info("nm-pptp: CHAP username not set");
+ info("nm-pppd-plugin: CHAP username not set");
return -1;
}
if (plugin_data.password == NULL)
{
- info("nm-pptp: CHAP password not set");
+ info("nm-pppd-plugin: CHAP password not set");
return -1;
}
if (strlen(plugin_data.username) >= MAXNAMELEN)
{
- info("nm-pptp: CHAP username too long!");
+ info("nm-pppd-plugin: CHAP username too long!");
return -1;
}
if (strlen(plugin_data.password) >= MAXSECRETLEN)
{
- info("nm-pptp: CHAP password too long!");
+ info("nm-pppd-plugin: CHAP password too long!");
return -1;
}
@@ -243,7 +228,7 @@ int pptp_chap_passwd_hook(char *user, char *passwd)
user[MAXNAMELEN-1]='\0';
strcpy(passwd, plugin_data.password);
passwd[MAXSECRETLEN-1]='\0';
-// info("nm-pptp: CHAP authenticating as '%s' with '%s'",user,passwd);
+// info("nm-pppd-plugin: CHAP authenticating as '%s' with '%s'",user,passwd);
//
// Forget the username and password?
//
@@ -253,21 +238,21 @@ int pptp_chap_passwd_hook(char *user, char *passwd)
return 0;
}
-void pptp_exit_notify(void *opaque, int arg)
+void nm_exit_notify(void *opaque, int arg)
{
NmPPPData *data = (NmPPPData *)opaque;
- pptp_dbus_kill_connection(data);
+ nm_dbus_kill_connection(data);
}
-void pptp_ip_down(void *opaque, int arg)
+void nm_ip_down(void *opaque, int arg)
{
DBusConnection *con = (DBusConnection *)opaque;
return;
}
-void pptp_ip_up(void *opaque, int arg)
+void nm_ip_up(void *opaque, int arg)
{
NmPPPData *data = (NmPPPData *)opaque;
DBusConnection *con = data->con;
@@ -286,18 +271,19 @@ void pptp_ip_up(void *opaque, int arg)
guint32 uint_ip4_ptp_address = 0;
guint32 uint_ip4_netmask = 0xFFFFFFFF; /* Default mask of 255.255.255.255 */
guint32 i=0;
+
g_return_if_fail (con != NULL);
if (ipcp_gotoptions[ifunit].ouraddr==0) {
- info ("nm-pptp-service-pptp-helper didn't receive an Internal IP4 Address from pptp.");
+ info ("nm-pppd-plugin: didn't receive an Internal IP4 Address from ppp.");
send_config_error (con, "IP4 Address");
return;
}
uint_ip4_address=ipcp_gotoptions[ifunit].ouraddr;
- if (!(message = dbus_message_new_method_call (NM_DBUS_SERVICE_PPTP, NM_DBUS_PATH_PPTP, NM_DBUS_INTERFACE_PPTP, "signalIP4Config")))
+ if (!(message = dbus_message_new_method_call (NM_DBUS_SERVICE_PPP_STARTER, NM_DBUS_PATH_PPP_STARTER, NM_DBUS_INTERFACE_PPP_STARTER, "signalIP4Config")))
{
- info ("send_config_error(): Couldn't allocate the dbus message");
+ nm_warning ("send_config_error(): Couldn't allocate the dbus message");
return;
}
@@ -324,7 +310,7 @@ void pptp_ip_up(void *opaque, int arg)
}
if (ifname==NULL) {
- info ("nm-pptp-service-pptp-helper didn't receive a tunnel device name.");
+ info ("nm-pppd-plugin: didn't receive a tunnel device name.");
send_config_error (con, "IP4 Address");
}
str_ifname = g_strdup(ifname);
@@ -344,13 +330,13 @@ void pptp_ip_up(void *opaque, int arg)
DBUS_TYPE_INVALID);
if (!dbus_connection_send (con, message, NULL)) {
- info ("pptp_ip_up(): could not send dbus message");
+ info ("nm_ip_up(): could not send dbus message");
dbus_message_unref (message);
- g_strdup(str_ifname);
+ g_free(str_ifname);
return;
}
- g_strdup(str_ifname);
+ g_free(str_ifname);
dbus_message_unref (message);
return;
}
@@ -359,7 +345,7 @@ void pptp_ip_up(void *opaque, int arg)
/*
* send_config_error
*
- * Notify nm-pptp-service of a config error from 'pptp'.
+ * Notify nm-ppp-starter of a config error from pppd.
*
*/
void send_config_error (DBusConnection *con, const char *item)
@@ -369,7 +355,7 @@ void send_config_error (DBusConnection *con, const char *item)
g_return_if_fail (con != NULL);
g_return_if_fail (item != NULL);
- if (!(message = dbus_message_new_method_call (NM_DBUS_SERVICE_PPTP, NM_DBUS_PATH_PPTP, NM_DBUS_INTERFACE_PPTP, "signalConfigError")))
+ if (!(message = dbus_message_new_method_call (NM_DBUS_SERVICE_PPP_STARTER, NM_DBUS_PATH_PPP_STARTER, NM_DBUS_INTERFACE_PPP_STARTER, "signalConfigError")))
{
nm_warning ("send_config_error(): Couldn't allocate the dbus message");
return;
@@ -384,12 +370,47 @@ void send_config_error (DBusConnection *con, const char *item)
/*
- * pptp_get_auth_items
+ * nm_notify_pid
*
- * Request credentials from PPTP service.
+ * Let the pppd starter service know our PID
+ * so that pppd may be killed later.
*
*/
-gboolean pptp_get_auth_items (NmPPPData *data)
+void nm_notify_pid (NmPPPData *data)
+{
+ DBusConnection *con;
+ DBusMessage *message = NULL;
+
+ if (!nm_dbus_prepare_connection(data))
+ return;
+
+ con = data->con;
+ if (!(message = dbus_message_new_method_call (NM_DBUS_SERVICE_PPP_STARTER, NM_DBUS_PATH_PPP_STARTER, NM_DBUS_INTERFACE_PPP_STARTER, "notifyPID")))
+ {
+ nm_warning ("nm-pppd-plugin: Couldn't allocate the notifyPID dbus message");
+ return;
+ }
+
+ dbus_message_append_args (message,
+ DBUS_TYPE_UINT32, &(data->pppd_pid),
+ DBUS_TYPE_INVALID);
+
+ if (!dbus_connection_send (con, message, NULL)) {
+ info ("nm_ip_up(): could not send dbus message");
+ dbus_message_unref (message);
+ return;
+ }
+
+// nm_warning("Sent notify message: %d",data->pppd_pid);
+ dbus_message_unref (message);
+}
+/*
+ * nm_get_auth_items
+ *
+ * Request credentials from PPP_STARTER service.
+ *
+ */
+gboolean nm_get_auth_items (NmPPPData *data)
{
DBusConnection *con;
int num_auth_items = -1;
@@ -398,15 +419,15 @@ gboolean pptp_get_auth_items (NmPPPData *data)
DBusMessage *message = NULL;
DBusMessage *reply = NULL;
- if (!pptp_dbus_prepare_connection(data))
+ if (!nm_dbus_prepare_connection(data))
return FALSE;
con = data->con;
g_return_val_if_fail (con != NULL,FALSE);
- if (!(message = dbus_message_new_method_call (NM_DBUS_SERVICE_PPTP, NM_DBUS_PATH_PPTP, NM_DBUS_INTERFACE_PPTP, "getAuthInfo")))
+ if (!(message = dbus_message_new_method_call (NM_DBUS_SERVICE_PPP_STARTER, NM_DBUS_PATH_PPP_STARTER, NM_DBUS_INTERFACE_PPP_STARTER, "getAuthInfo")))
{
- nm_warning("nm-pptp: failed to create getAuthInfo message.");
+ nm_warning("nm-pppd-plugin: failed to create getAuthInfo message.");
return FALSE;
}
@@ -414,7 +435,7 @@ gboolean pptp_get_auth_items (NmPPPData *data)
dbus_message_unref (message);
if (!reply)
{
- info("nm-pptp: no reply to getAuthInfo message.");
+ info("nm-pppd-plugin: no reply to getAuthInfo message.");
return FALSE;
}
@@ -430,7 +451,7 @@ gboolean pptp_get_auth_items (NmPPPData *data)
}
num_auth_items=3;
- if (!pptp_store_auth_info (data, auth_items, num_auth_items))
+ if (!nm_store_auth_info (data, auth_items, num_auth_items))
{
//dbus_free_string_array (auth_items);
dbus_message_unref (reply);
@@ -443,19 +464,19 @@ gboolean pptp_get_auth_items (NmPPPData *data)
}
/*
- * pptp_store_auth_info
+ * nm_store_auth_info
*
* Decode and temporarily store the authentication info provided.
*
*/
-gboolean pptp_store_auth_info (NmPPPData *data, char **auth_items, int num_auth_items)
+gboolean nm_store_auth_info (NmPPPData *data, char **auth_items, int num_auth_items)
{
int i=0;
g_return_val_if_fail (auth_items != NULL, FALSE);
g_return_val_if_fail (num_auth_items >= 1, FALSE);
- nm_warning ("PPTP will authenticate using '%s'.", auth_items[0]);
+ nm_warning ("PPPD will authenticate using '%s'.", auth_items[0]);
if (strcmp ("CHAP", auth_items[0]) == 0) {
g_return_val_if_fail (num_auth_items >= 3, FALSE);
@@ -471,7 +492,7 @@ gboolean pptp_store_auth_info (NmPPPData *data, char **auth_items, int num_auth_
if (data->password!=NULL) g_free(data->password);
data->auth_type=g_strdup(auth_items[0]);
} else {
- nm_warning ("PPTP authentication type '%s' is not allowed.", auth_items[0]);
+ nm_warning ("PPPD authentication type '%s' is not allowed.", auth_items[0]);
return FALSE;
}
@@ -503,14 +524,15 @@ int plugin_init()
// dbus_error_free (&error);
// add_options(ppp_options);
- chap_check_hook = pptp_chap_check_hook;
- chap_passwd_hook = pptp_chap_passwd_hook;
- add_notifier(&ip_down_notifier, pptp_ip_down, (void *) &plugin_data);
- add_notifier(&ip_up_notifier, pptp_ip_up, (void *) &plugin_data);
- add_notifier(&exitnotify, pptp_exit_notify, (void *) &plugin_data);
+ chap_check_hook = nm_chap_check_hook;
+ chap_passwd_hook = nm_chap_passwd_hook;
- info("nm-pptp: plugin initialized.");
+ add_notifier(&ip_down_notifier, nm_ip_down, (void *) &plugin_data);
+ add_notifier(&ip_up_notifier, nm_ip_up, (void *) &plugin_data);
+ add_notifier(&exitnotify, nm_exit_notify, (void *) &plugin_data);
+
+ info("nm-pppd-plugin: plugin initialized.");
return 0;
}
diff --git a/vpn-daemons/pptp/src/nm-ppp-service.h b/vpn-daemons/pptp/src/nm-pppd-plugin.h
similarity index 89%
rename from vpn-daemons/pptp/src/nm-ppp-service.h
rename to vpn-daemons/pptp/src/nm-pppd-plugin.h
index 17248afd27..76803da1b8 100644
--- a/vpn-daemons/pptp/src/nm-ppp-service.h
+++ b/vpn-daemons/pptp/src/nm-pppd-plugin.h
@@ -1,4 +1,4 @@
-/* nm-ppp-service - pptp integration with NetworkManager
+/* nm-ppp-starter - pptp (and other ppp) integration with NetworkManager
*
* Antony J Mee
* Based on openvpn work by Tim Niemueller
@@ -20,8 +20,8 @@
*
*/
-#ifndef NM_PPP_SERVICE_H
-#define NM_PPP_SERVICE_H
+#ifndef NM_PPPD_PLUGIN_H
+#define NM_PPPD_PLUGIN_H
#define NM_DBUS_SERVICE_PPP "org.freedesktop.NetworkManager.ppp"
#define NM_DBUS_INTERFACE_PPP "org.freedesktop.NetworkManager.ppp"