X-Git-Url: https://tinc-vpn.org/git/browse?p=tinc;a=blobdiff_plain;f=src%2Fnet.c;h=016b86ad6207e19603f3f2d64972a63a521bf14a;hp=f8f84bcd3b900fac5709b9425b302e6da1dd2fbe;hb=15246df85d6171c92478541a835effb96d6085c4;hpb=ed0bf283e37642f9f7673f664713a16d916bd70f diff --git a/src/net.c b/src/net.c index f8f84bcd..016b86ad 100644 --- a/src/net.c +++ b/src/net.c @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: net.c,v 1.35.4.60 2000/11/04 11:49:57 guus Exp $ + $Id: net.c,v 1.35.4.64 2000/11/04 15:32:05 zarq Exp $ */ #include "config.h" @@ -86,10 +86,7 @@ int execute_script(const char* name) { char *scriptname; pid_t pid; - char **env; - extern char **environment; /* From tincd.c; contains our env */ - - asprintf(&scriptname, "%s/%s", confbase, name); + char *s; if((pid = fork()) < 0) { @@ -100,16 +97,34 @@ int execute_script(const char* name) if(pid) { - free(scriptname); return 0; } /* Child here */ - env = xmalloc(sizeof(environment) + 1 * sizeof(char*)); - memcpy(&(env[1]), environment, sizeof(environment)); - asprintf(&(env[0]), "IFNAME=%s", interface_name); - execle(scriptname, NULL, env); + asprintf(&scriptname, "%s/%s", confbase, name); + asprintf(&s, "IFNAME=%s", interface_name); + putenv(s); + free(s); + + if(netname) + { + asprintf(&s, "NETNAME=%s", netname); + putenv(s); + free(s); + } + else + { + unsetenv("NETNAME"); + } + + if(chdir(confbase) < 0) + { + syslog(LOG_ERR, _("Couldn't chdir to `%s': %m"), + confbase); + } + + execl(scriptname, NULL); /* No return on success */ if(errno != ENOENT) /* Ignore if the file does not exist */