projects
/
tinc
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix hash functions for keys whose size is not divisible by 4.
[tinc]
/
src
/
process.c
diff --git
a/src/process.c
b/src/process.c
index
aa6dc56
..
045c071
100644
(file)
--- a/
src/process.c
+++ b/
src/process.c
@@
-55,8
+55,6
@@
static SERVICE_STATUS_HANDLE statushandle = 0;
static bool install_service(void) {
char command[4096] = "\"";
static bool install_service(void) {
char command[4096] = "\"";
- char **argp;
- bool space;
SERVICE_DESCRIPTION description = {"Virtual Private Network daemon"};
manager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
SERVICE_DESCRIPTION description = {"Virtual Private Network daemon"};
manager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
@@
-74,8
+72,8
@@
static bool install_service(void) {
strncat(command, "\"", sizeof command - strlen(command));
strncat(command, "\"", sizeof command - strlen(command));
- for(argp = g_argv + 1; *argp; argp++) {
- space = strchr(*argp, ' ');
+ for(
char **
argp = g_argv + 1; *argp; argp++) {
+
char &
space = strchr(*argp, ' ');
strncat(command, " ", sizeof command - strlen(command));
if(space)
strncat(command, " ", sizeof command - strlen(command));
if(space)
@@
-212,7
+210,7
@@
bool detach(void) {
}
#else
if(!statushandle)
}
#else
if(!statushandle)
- exit(install_service());
+ exit(
!
install_service());
#endif
}
#endif
}
@@
-226,46
+224,40
@@
bool detach(void) {
bool execute_script(const char *name, char **envp) {
#ifdef HAVE_SYSTEM
bool execute_script(const char *name, char **envp) {
#ifdef HAVE_SYSTEM
- int status, len;
char *scriptname;
char *scriptname;
-
int i
;
+
char *command
;
-#ifndef HAVE_MINGW
- len = xasprintf(&scriptname, "\"%s/%s\"", confbase, name);
-#else
- len = xasprintf(&scriptname, "\"%s/%s.bat\"", confbase, name);
-#endif
- if(len < 0)
- return false;
+ xasprintf(&scriptname, "%s" SLASH "%s%s", confbase, name, scriptextension);
- scriptname[len - 1] = '\0';
-
-#ifndef HAVE_TUNEMU
/* First check if there is a script */
/* First check if there is a script */
- if(access(scriptname
+ 1
, F_OK)) {
+ if(access(scriptname, F_OK)) {
free(scriptname);
return true;
}
free(scriptname);
return true;
}
-#endif
logger(DEBUG_STATUS, LOG_INFO, "Executing script %s", name);
#ifdef HAVE_PUTENV
/* Set environment */
logger(DEBUG_STATUS, LOG_INFO, "Executing script %s", name);
#ifdef HAVE_PUTENV
/* Set environment */
- for(i = 0; envp[i]; i++)
+ for(i
nt i
= 0; envp[i]; i++)
putenv(envp[i]);
#endif
putenv(envp[i]);
#endif
- scriptname[len - 1] = '\"';
- status = system(scriptname);
+ if(scriptinterpreter)
+ xasprintf(&command, "%s \"%s\"", scriptinterpreter, scriptname);
+ else
+ xasprintf(&command, "\"%s\"", scriptname);
+
+ int status = system(command);
+ free(command);
free(scriptname);
/* Unset environment */
free(scriptname);
/* Unset environment */
- for(i = 0; envp[i]; i++) {
+ for(i
nt i
= 0; envp[i]; i++) {
char *e = strchr(envp[i], '=');
if(e) {
char p[e - envp[i] + 1];
char *e = strchr(envp[i], '=');
if(e) {
char p[e - envp[i] + 1];