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.67 2003/08/08 19:43:47 guus Exp $
*/
#include "system.h"
bool install_service(void) {
char command[4096] = "";
char **argp;
+ bool space;
manager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
if(!manager) {
strncat(command, program_name, sizeof(command));
for(argp = g_argv + 1; *argp; argp++) {
- strncat(command, " ", sizeof(command));
+ space = strchr(*argp, ' ');
+ strncat(command, space?" \"":" ", sizeof(command));
strncat(command, *argp, sizeof(command));
+ if(space)
+ strncat(command, "\"", sizeof(command));
}
service = CreateService(manager, identname, identname,
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
+
/* Set environment */
while(*envp)
putenv(*envp++);
- ifdebug(STATUS) logger(LOG_INFO, _("Executing script %s"), name);
-
status = system(scriptname);
free(scriptname);
/* Unset environment? */
+#ifdef WEXITSTATUS
if(status != -1) {
if(WIFEXITED(status)) { /* Child exited by itself */
if(WEXITSTATUS(status)) {
strerror(errno));
return false;
}
+#endif
#endif
return true;
}