- logger(LOG_NOTICE, _("tincd %s (%s %s) starting, debug level %d"),
- VERSION, __DATE__, __TIME__, debug_level);
-
- xalloc_fail_func = memory_full;
-
- return true;
-}
-
-bool execute_script(const char *name, char **envp)
-{
-#ifdef HAVE_SYSTEM
- int status, len;
- struct stat s;
- char *scriptname;
-
- cp();
-
-#ifndef HAVE_MINGW
- len = asprintf(&scriptname, "\"%s/%s\"", confbase, name);
-#else
- len = asprintf(&scriptname, "\"%s/%s.bat\"", confbase, name);
-#endif
- if(len < 0)
- return false;
-
- scriptname[len - 1] = '\0';
-
- /* First check if there is a script */
-
- if(stat(scriptname + 1, &s))
- return true;
-
- ifdebug(STATUS) logger(LOG_INFO, _("Executing script %s"), name);
-
-#ifdef HAVE_PUTENV
- /* Set environment */
-
- while(*envp)
- putenv(*envp++);
-#endif
-
- scriptname[len - 1] = '\"';
- status = system(scriptname);
-
- free(scriptname);
-
- /* Unset environment? */
-
-#ifdef WEXITSTATUS
- if(status != -1) {
- if(WIFEXITED(status)) { /* Child exited by itself */
- if(WEXITSTATUS(status)) {
- logger(LOG_ERR, _("Script %s exited with non-zero status %d"),
- name, WEXITSTATUS(status));
- return false;
- }
- } else if(WIFSIGNALED(status)) { /* Child was killed by a signal */
- logger(LOG_ERR, _("Script %s was killed by signal %d (%s)"),
- name, WTERMSIG(status), strsignal(WTERMSIG(status)));
- return false;
- } else { /* Something strange happened */
- logger(LOG_ERR, _("Script %s terminated abnormally"), name);
- return false;