+/*
+ Execute the given script.
+ This function doesn't really belong here.
+*/
+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);
+
+ if((pid = fork()) < 0)
+ {
+ syslog(LOG_ERR, _("System call `%s' failed: %m"),
+ "fork");
+ return -1;
+ }
+
+ 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);
+ /* No return on success */
+
+ if(errno != ENOENT) /* Ignore if the file does not exist */
+ syslog(LOG_WARNING, _("Error executing `%s': %m"), scriptname);
+
+ /* No need to free things */
+ exit(0);
+}
+