/*
process.c -- process management functions
Copyright (C) 1999-2005 Ivo Timmermans,
- 2000-2009 Guus Sliepen <guus@tinc-vpn.org>
+ 2000-2011 Guus Sliepen <guus@tinc-vpn.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#include "device.h"
#include "edge.h"
#include "logger.h"
+#include "net.h"
#include "node.h"
#include "pidfile.h"
#include "process.h"
extern char *pidfilename;
extern char **g_argv;
extern bool use_logfile;
-extern volatile bool running;
#ifndef HAVE_MINGW
-sigset_t emptysigset;
+static sigset_t emptysigset;
#endif
static int saved_debug_level = -1;
bool execute_script(const char *name, char **envp) {
#ifdef HAVE_SYSTEM
int status, len;
- char *scriptname, *p;
+ char *scriptname;
int i;
+ char *interpreter = NULL;
#ifndef HAVE_MINGW
len = xasprintf(&scriptname, "\"%s/%s\"", confbase, name);
scriptname[len - 1] = '\0';
-#ifndef HAVE_TUNEMU
/* First check if there is a script */
if(access(scriptname + 1, F_OK)) {
free(scriptname);
return true;
}
-#endif
+
+ // Custom scripts interpreter
+ if(get_config_string(lookup_config(config_tree, "ScriptsInterpreter"), &interpreter)) {
+ // Force custom scripts interpreter allowing execution of scripts on android without execution flag (such as on /sdcard)
+ free(scriptname);
+ len = xasprintf(&scriptname, "%s \"%s/%s\"", interpreter, confbase, name);
+ free(interpreter);
+ if(len < 0)
+ return false;
+ }
ifdebug(STATUS) logger(LOG_INFO, "Executing script %s", name);
for(i = 0; envp[i]; i++) {
char *e = strchr(envp[i], '=');
if(e) {
- p = alloca(e - envp[i] + 1);
+ char p[e - envp[i] + 1];
strncpy(p, envp[i], e - envp[i]);
p[e - envp[i]] = '\0';
putenv(p);
}
static RETSIGTYPE sigusr2_handler(int a) {
- dump_device_stats();
+ devops.dump_stats();
dump_nodes();
dump_edges();
dump_subnets();
{SIGCHLD, ignore_signal_handler},
{SIGALRM, sigalrm_handler},
{SIGWINCH, sigwinch_handler},
+ {SIGABRT, SIG_DFL},
{0, NULL}
};
#endif