From: Borg Date: Mon, 23 Jun 2014 21:13:03 +0000 (+0200) Subject: Fixed scripts calling under Win32. X-Git-Tag: release-1.0.25~11 X-Git-Url: https://tinc-vpn.org/git/browse?a=commitdiff_plain;h=4d53b075d85d7517730109c92cb7c7b09bf69dee;p=tinc Fixed scripts calling under Win32. When using 'ScriptsInterpreter' variable, we incorrectly checked for '.bat' ending scripts while later building scriptname without extension. --- diff --git a/src/process.c b/src/process.c index e487e348..51c9e2a0 100644 --- a/src/process.c +++ b/src/process.c @@ -349,15 +349,19 @@ bool detach(void) { bool execute_script(const char *name, char **envp) { #ifdef HAVE_SYSTEM - int status, len; char *scriptname; - int i; char *interpreter = NULL; + config_t *cfg_interpreter; + int status, len, i; + cfg_interpreter = lookup_config(config_tree, "ScriptsInterpreter"); #ifndef HAVE_MINGW len = xasprintf(&scriptname, "\"%s/%s\"", confbase, name); #else - len = xasprintf(&scriptname, "\"%s/%s.bat\"", confbase, name); + if(cfg_interpreter) + len = xasprintf(&scriptname, "\"%s/%s\"", confbase, name); + else + len = xasprintf(&scriptname, "\"%s/%s.bat\"", confbase, name); #endif if(len < 0) return false; @@ -365,14 +369,13 @@ bool execute_script(const char *name, char **envp) { scriptname[len - 1] = '\0'; /* First check if there is a script */ - if(access(scriptname + 1, F_OK)) { free(scriptname); return true; } // Custom scripts interpreter - if(get_config_string(lookup_config(config_tree, "ScriptsInterpreter"), &interpreter)) { + if(get_config_string(cfg_interpreter, &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);