Hacking network-manager-pptp to support PAP
- From: Technetium <tc technetium gmail com>
- To: networkmanager-list gnome org
- Subject: Hacking network-manager-pptp to support PAP
- Date: Fri, 14 Sep 2007 17:37:53 +0800
Hi
I've a created a simple patch on network-manager-pptp to support PAP.
It is based on source code of network-manager-pptp_0.6.3.
It is a dirty hack. But it is useful until PAP is officially supported.
Regards,
Tc
diff -Naur oldn/src/nm-pppd-plugin.c newn/src/nm-pppd-plugin.c
--- oldn/src/nm-pppd-plugin.c 2006-08-18 13:56:58.000000000 +0800
+++ newn/src/nm-pppd-plugin.c 2007-09-15 03:32:04.000000000 +0800
@@ -505,6 +505,78 @@
return TRUE;
}
+int nm_pap_passwd_hook(char *user, char *passwd)
+{
+ info("nm-pppd-plugin: PAP credentials requested.");
+
+ plugin_data.pppd_pid=getpid();
+ nm_notify_pid (&plugin_data);
+
+ if (! nm_get_auth_items (&plugin_data))
+ {
+ return 0;
+ }
+
+ info(plugin_data.username);
+ info("nm-pppd-plugin: PAP auth info fetched.");
+
+ if (user == NULL)
+ {
+ info("nm-pppd-plugin: pppd didn't provide username buffer");
+ return -1;
+ }
+
+ /*if (passwd == NULL)
+ {
+ info("nm-pppd-plugin: pppd didn't provide password buffer, may be it is a test run");
+ strcpy(user, plugin_data.username);
+ user[MAXNAMELEN-1]='\0';
+ return 0;
+ }*/
+
+ if (plugin_data.username == NULL)
+ {
+ info("nm-pppd-plugin: CHAP username not set");
+ return -1;
+ }
+
+ if (plugin_data.password == NULL)
+ {
+ info("nm-pppd-plugin: CHAP password not set");
+ return -1;
+ }
+
+ if (strlen(plugin_data.username) >= MAXNAMELEN)
+ {
+ info("nm-pppd-plugin: CHAP username too long!");
+ return -1;
+ }
+
+ if (strlen(plugin_data.password) >= MAXSECRETLEN)
+ {
+ info("nm-pppd-plugin: CHAP password too long!");
+ return -1;
+ }
+
+ strcpy(user, plugin_data.username);
+
+ user[MAXNAMELEN-1]='\0';
+ if (passwd != NULL) {
+ strcpy(passwd, plugin_data.password);
+ passwd[MAXSECRETLEN-1]='\0';
+ } else {
+ info("nm-pppd-plugin: pppd didn't provide password buffer, may be it is a test run");
+ }
+// info("nm-pppd-plugin: CHAP authenticating as '%s' with '%s'",user,passwd);
+//
+// Forget the username and password?
+//
+// if (plugin_data.username!=NULL) g_free(plugin_data.username);
+// if (plugin_data.password!=NULL) g_free(plugin_data.password);
+
+ return 1;
+}
+
int plugin_init()
{
// DBusConnection * con = NULL;
@@ -532,7 +604,7 @@
chap_check_hook = nm_chap_check_hook;
chap_passwd_hook = nm_chap_passwd_hook;
-
+ pap_passwd_hook = nm_pap_passwd_hook;
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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]