File novell-nortelplugins-get_dev.patch of Package novell-nortelplugins
Index: novell-nortelplugins-0.1.3/nortel/cli/adminport.c
===================================================================
--- novell-nortelplugins-0.1.3.orig/nortel/cli/adminport.c
+++ novell-nortelplugins-0.1.3/nortel/cli/adminport.c
@@ -15,6 +15,7 @@
#include <arpa/nameser.h>
#include <resolv.h>
+#include "config.h"
/* from racoon */
#include "racoon/admin.h"
#include "racoon/evt.h"
@@ -34,6 +35,8 @@
#define TURNPIKE_INTERFACE_VERSION 1
+#define IPALIASDOWN LIB_LOAD_PATH"/ipalias down"
+#define IPADDR_CFGFILE "/var/tmp/ipcfg"
static void cleanup_socket(int sock);
static int nortel_construct_message (char *sendBuf, short msgType, void *gp);
@@ -235,6 +238,35 @@ static int sendPluginMessageToAdminPort(
return 0;
}
+static int setenv_dev (char *filename)
+{
+ FILE *fp = NULL;
+ char line[1024] = {0};
+ char *tmp = NULL;
+ char devname[256] = {0};
+
+ fp = fopen (filename, "r");
+ if (fp) {
+ while (fgets (line, 1024, fp) != NULL) {
+ tmp = strstr (line, "VIRTUALDEV");
+ if (tmp) {
+ strcpy (devname, tmp + 11);
+ break;
+ }
+ }
+ // dismiss the line break '\n'
+ tmp = strchr (devname, '\n');
+ if (tmp)
+ *tmp = '\0';
+
+ setenv("VIRTUALDEV", devname, 1);
+
+ fclose (fp);
+ }
+
+ return 0;
+}
+
static int parse_message_from_admin_port(char *buf, void *gp)
{
char *currptr;
@@ -325,10 +357,21 @@ static int parse_message_from_admin_port
setenv("reason","connect",1);
setenv("domain_names",domain_names,1);
//system("nm-novellvpnc-service-vpnc-helper");
- if (-1 == system(pInfo->ifInfo.upscript)) {
- printf("Run script (%s) failed!\n",
- pInfo->ifInfo.upscript);
+ if (pInfo->ifInfo.upscript_len > 0) {
+ // down the interface, the NM call the vpnc, so they have permission
+ //if (-1 == system(IPALIASDOWN)) {
+ // printf("Run script(%s) failed.\n", IPALIASDOWN);
+ //}
+
+ setenv_dev (IPADDR_CFGFILE);
+
+ // NM will set the ip address, netmask and DNS
+ if (-1 == system(pInfo->ifInfo.upscript)) {
+ printf("Run script (%s) failed!\n",
+ pInfo->ifInfo.upscript);
+ }
}
+
//printf(_("Successfully started the vpnc helper. Env reason set to connect\n"));
bufLen = nortel_construct_message (sendBuf, ADMIN_REPLACE_SAINFO, gp);