mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-30 21:20:10 +01:00
* Generalised pppd oriented implementation.
* General configuration. * Runs pppd async. (allows pppd to fork a child) * Fixed missing files at compile. git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1805 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
parent
93b722d574
commit
4dda72e66a
18 changed files with 553 additions and 383 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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@
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
Makefile.in
|
||||
Makefile
|
||||
nm-pptp-auth-dialog
|
||||
nm-ppp-auth-dialog
|
||||
|
|
|
|||
|
|
@ -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) \
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
])
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
16
vpn-daemons/pptp/nm-ppp-starter.conf
Normal file
16
vpn-daemons/pptp/nm-ppp-starter.conf
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
<!DOCTYPE busconfig PUBLIC
|
||||
"-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
|
||||
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
|
||||
<busconfig>
|
||||
<policy user="root">
|
||||
<allow own="org.freedesktop.NetworkManager.ppp_starter"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager.ppp_starter"/>
|
||||
<allow send_interface="org.freedesktop.NetworkManager.ppp_starter"/>
|
||||
</policy>
|
||||
<policy context="default">
|
||||
<deny own="org.freedesktop.NetworkManager.ppp_starter"/>
|
||||
<deny send_destination="org.freedesktop.NetworkManager.ppp_starter"/>
|
||||
<deny send_interface="org.freedesktop.NetworkManager.ppp_starter"/>
|
||||
</policy>
|
||||
</busconfig>
|
||||
|
||||
8
vpn-daemons/pptp/nm-ppp-starter.name.in
Normal file
8
vpn-daemons/pptp/nm-ppp-starter.name.in
Normal file
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
<!DOCTYPE busconfig PUBLIC
|
||||
"-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
|
||||
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
|
||||
<busconfig>
|
||||
<policy user="root">
|
||||
<allow own="org.freedesktop.NetworkManager.pptp"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager.pptp"/>
|
||||
<allow send_interface="org.freedesktop.NetworkManager.pptp"/>
|
||||
</policy>
|
||||
<policy context="default">
|
||||
<deny own="org.freedesktop.NetworkManager.pptp"/>
|
||||
<deny send_destination="org.freedesktop.NetworkManager.pptp"/>
|
||||
<deny send_interface="org.freedesktop.NetworkManager.pptp"/>
|
||||
</policy>
|
||||
</busconfig>
|
||||
|
||||
|
|
@ -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
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
Makefile.in
|
||||
Makefile
|
||||
nm-pptp-service
|
||||
nm-pptp-service-pptp-helper
|
||||
nm-ppp-starter
|
||||
nm-pppd-plugin
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -1,4 +1,4 @@
|
|||
/* nm-pptp-service - pptp integration with NetworkManager
|
||||
/* nm-ppp-starter - pptp (and other ppp) integration with NetworkManager
|
||||
*
|
||||
* Antony J Mee <eemynotna at gmail dot com>
|
||||
* Based on openvpn work by Tim Niemueller <tim@niemueller.de>
|
||||
|
|
@ -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
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
/* nm-pptp-service - pptp integration with NetworkManager
|
||||
/* nm-pptp-service - pptp (and other pppd) integration with NetworkManager
|
||||
*
|
||||
* Antony J Mee <eemynotna at gmail dot com>
|
||||
*
|
||||
|
|
@ -21,8 +21,9 @@
|
|||
|
||||
#include "pppd/fsm.h"
|
||||
#include "pppd/ipcp.h"
|
||||
#include "static_credentials.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <glib.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
|
@ -36,8 +37,8 @@
|
|||
#include <dbus/dbus-glib.h>
|
||||
#include <NetworkManager/NetworkManager.h>
|
||||
|
||||
#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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* nm-ppp-service - pptp integration with NetworkManager
|
||||
/* nm-ppp-starter - pptp (and other ppp) integration with NetworkManager
|
||||
*
|
||||
* Antony J Mee <eemynotna at gmail dot com>
|
||||
* Based on openvpn work by Tim Niemueller <tim@niemueller.de>
|
||||
|
|
@ -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"
|
||||
Loading…
Add table
Reference in a new issue