X-Git-Url: https://tinc-vpn.org/git/browse?p=tinc;a=blobdiff_plain;f=src%2Fprocess.c;h=d81fdd693608d9f11b5b9fe465ada80a7c55fef4;hp=c989532e26be0f14888e298354e0a88571cdb6fc;hb=96f5d98fc299a53fcdad304a56eb3a77a2c229e7;hpb=863349638beb1eaab09e2a3d537c20a7913aef30 diff --git a/src/process.c b/src/process.c index c989532e..d81fdd69 100644 --- a/src/process.c +++ b/src/process.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: process.c,v 1.1.2.65 2003/08/08 14:48:33 guus Exp $ + $Id: process.c,v 1.1.2.68 2003/08/08 19:56:11 guus Exp $ */ #include "system.h" @@ -84,6 +84,7 @@ static SERVICE_STATUS_HANDLE statushandle = 0; bool install_service(void) { char command[4096] = ""; char **argp; + bool space; manager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); if(!manager) { @@ -98,8 +99,16 @@ bool install_service(void) { strncat(command, program_name, sizeof(command)); for(argp = g_argv + 1; *argp; argp++) { + space = strchr(*argp, ' '); strncat(command, " ", sizeof(command)); + + if(space) + strncat(command, "\"", sizeof(command)); + strncat(command, *argp, sizeof(command)); + + if(space) + strncat(command, "\"", sizeof(command)); } service = CreateService(manager, identname, identname, @@ -357,19 +366,23 @@ bool execute_script(const char *name, char **envp) cp(); - asprintf(&scriptname, "%s/%s", confbase, name); + asprintf(&scriptname, "\"%s/%s\"", confbase, name); +#ifndef HAVE_MINGW /* First check if there is a script */ if(stat(scriptname, &s)) return true; + ifdebug(STATUS) logger(LOG_INFO, _("Executing script %s"), name); +#endif + +#ifdef HAVE_PUTENV /* Set environment */ while(*envp) putenv(*envp++); - - ifdebug(STATUS) logger(LOG_INFO, _("Executing script %s"), name); +#endif status = system(scriptname); @@ -377,6 +390,7 @@ bool execute_script(const char *name, char **envp) /* Unset environment? */ +#ifdef WEXITSTATUS if(status != -1) { if(WIFEXITED(status)) { /* Child exited by itself */ if(WEXITSTATUS(status)) { @@ -398,6 +412,7 @@ bool execute_script(const char *name, char **envp) strerror(errno)); return false; } +#endif #endif return true; }