projects
/
tinc
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add the ability to set a firewall mark on sockets.
[tinc]
/
src
/
tincctl.c
diff --git
a/src/tincctl.c
b/src/tincctl.c
index
cd2d3d8
..
79762e3
100644
(file)
--- a/
src/tincctl.c
+++ b/
src/tincctl.c
@@
-722,19
+722,20
@@
static bool remove_service(void) {
SC_HANDLE manager = NULL;
SC_HANDLE service = NULL;
SERVICE_STATUS status = {0};
SC_HANDLE manager = NULL;
SC_HANDLE service = NULL;
SERVICE_STATUS status = {0};
+ bool success = false;
manager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
if(!manager) {
fprintf(stderr, "Could not open service manager: %s\n", winerror(GetLastError()));
manager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
if(!manager) {
fprintf(stderr, "Could not open service manager: %s\n", winerror(GetLastError()));
-
return false
;
+
goto exit
;
}
service = OpenService(manager, identname, SERVICE_ALL_ACCESS);
if(!service) {
fprintf(stderr, "Could not open %s service: %s\n", identname, winerror(GetLastError()));
}
service = OpenService(manager, identname, SERVICE_ALL_ACCESS);
if(!service) {
fprintf(stderr, "Could not open %s service: %s\n", identname, winerror(GetLastError()));
-
return false
;
+
goto exit
;
}
if(!ControlService(service, SERVICE_CONTROL_STOP, &status)) {
}
if(!ControlService(service, SERVICE_CONTROL_STOP, &status)) {
@@
-745,12
+746,26
@@
static bool remove_service(void) {
if(!DeleteService(service)) {
fprintf(stderr, "Could not remove %s service: %s\n", identname, winerror(GetLastError()));
if(!DeleteService(service)) {
fprintf(stderr, "Could not remove %s service: %s\n", identname, winerror(GetLastError()));
-
return false
;
+
goto exit
;
}
}
-
fprintf(stderr, "%s service removed\n", identname)
;
+
success = true
;
- return true;
+exit:
+
+ if(service) {
+ CloseServiceHandle(service);
+ }
+
+ if(manager) {
+ CloseServiceHandle(manager);
+ }
+
+ if(success) {
+ fprintf(stderr, "%s service removed\n", identname);
+ }
+
+ return success;
}
#endif
}
#endif
@@
-1013,7
+1028,7
@@
static int cmd_start(int argc, char *argv[]) {
#endif
// Pass all log messages from the umbilical to stderr.
#endif
// Pass all log messages from the umbilical to stderr.
- // A nul-byte right before closure means tincd started succesfully.
+ // A nul-byte right before closure means tincd started succes
s
fully.
bool failure = true;
char buf[1024];
ssize_t len;
bool failure = true;
char buf[1024];
ssize_t len;
@@
-1680,6
+1695,7
@@
const var_t variables[] = {
{"Ed25519PrivateKeyFile", VAR_SERVER},
{"ExperimentalProtocol", VAR_SERVER},
{"Forwarding", VAR_SERVER},
{"Ed25519PrivateKeyFile", VAR_SERVER},
{"ExperimentalProtocol", VAR_SERVER},
{"Forwarding", VAR_SERVER},
+ {"FWMark", VAR_SERVER},
{"GraphDumpFile", VAR_SERVER | VAR_OBSOLETE},
{"Hostnames", VAR_SERVER},
{"IffOneQueue", VAR_SERVER},
{"GraphDumpFile", VAR_SERVER | VAR_OBSOLETE},
{"Hostnames", VAR_SERVER},
{"IffOneQueue", VAR_SERVER},
@@
-1859,7
+1875,7
@@
static int cmd_config(int argc, char *argv[]) {
}
}
}
}
- /* Change "add" into "set" for variables that do not allow multiple occurences.
+ /* Change "add" into "set" for variables that do not allow multiple occur
r
ences.
Turn on warnings when it seems variables might be removed unintentionally. */
if(action == 1 && !(variables[i].type & VAR_MULTIPLE)) {
Turn on warnings when it seems variables might be removed unintentionally. */
if(action == 1 && !(variables[i].type & VAR_MULTIPLE)) {