X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=src%2Fprocess.c;h=362b678c714a27bd38652ca866a041ec561266e3;hb=6dfdb323612184529b4b83c1be914dda8262de47;hp=aa6dc5609857ed64871d4f9f8028c7aed4f48472;hpb=1d9dacb1f26971e19463b5501c2410c57f780ecb;p=meshlink diff --git a/src/process.c b/src/process.c index aa6dc560..362b678c 100644 --- a/src/process.c +++ b/src/process.c @@ -212,7 +212,7 @@ bool detach(void) { } #else if(!statushandle) - exit(install_service()); + exit(!install_service()); #endif } @@ -229,11 +229,12 @@ bool execute_script(const char *name, char **envp) { int status, len; char *scriptname; int i; + char *interpreter = NULL; #ifndef HAVE_MINGW - len = xasprintf(&scriptname, "\"%s/%s\"", confbase, name); + len = xasprintf(&scriptname, "\"%s" SLASH "%s\"", confbase, name); #else - len = xasprintf(&scriptname, "\"%s/%s.bat\"", confbase, name); + len = xasprintf(&scriptname, "\"%s" SLASH "%s.bat\"", confbase, name); #endif if(len < 0) return false; @@ -249,8 +250,19 @@ bool execute_script(const char *name, char **envp) { } #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; + } + logger(DEBUG_STATUS, LOG_INFO, "Executing script %s", name); + #ifdef HAVE_PUTENV /* Set environment */