Releasing 1.1pre16.
[tinc] / src / tincctl.c
index 4803d6c..cf19d48 100644 (file)
@@ -1,6 +1,6 @@
 /*
     tincctl.c -- Controlling a running tincd
-    Copyright (C) 2007-2017 Guus Sliepen <guus@tinc-vpn.org>
+    Copyright (C) 2007-2018 Guus Sliepen <guus@tinc-vpn.org>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -92,7 +92,7 @@ static struct option const long_options[] = {
 static void version(void) {
        printf("%s version %s (built %s %s, protocol %d.%d)\n", PACKAGE,
               BUILD_VERSION, BUILD_DATE, BUILD_TIME, PROT_MAJOR, PROT_MINOR);
-       printf("Copyright (C) 1998-2017 Ivo Timmermans, Guus Sliepen and others.\n"
+       printf("Copyright (C) 1998-2018 Ivo Timmermans, Guus Sliepen and others.\n"
               "See the AUTHORS file for a complete list.\n\n"
               "tinc comes with ABSOLUTELY NO WARRANTY.  This is free software,\n"
               "and you are welcome to redistribute it under certain conditions;\n"
@@ -722,19 +722,20 @@ static bool remove_service(void) {
        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()));
-               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()));
-               return false;
+               goto exit;
        }
 
        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()));
-               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
 
@@ -842,7 +857,7 @@ bool connect_tincd(bool verbose) {
 
        if(getaddrinfo(host, port, &hints, &res) || !res) {
                if(verbose) {
-                       fprintf(stderr, "Cannot resolve %s port %s: %s", host, port, sockstrerror(sockerrno));
+                       fprintf(stderr, "Cannot resolve %s port %s: %s\n", host, port, sockstrerror(sockerrno));
                }
 
                return false;
@@ -863,7 +878,7 @@ bool connect_tincd(bool verbose) {
 
        if(ioctlsocket(fd, FIONBIO, &arg) != 0) {
                if(verbose) {
-                       fprintf(stderr, "ioctlsocket failed: %s", sockstrerror(sockerrno));
+                       fprintf(stderr, "System call `%s' failed: %s\n", "ioctlsocket", sockstrerror(sockerrno));
                }
        }
 
@@ -1013,7 +1028,7 @@ static int cmd_start(int argc, char *argv[]) {
 #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 successfully.
        bool failure = true;
        char buf[1024];
        ssize_t len;
@@ -1157,7 +1172,7 @@ static int dump_invitations(void) {
                buf[0] = 0;
 
                if(!fgets(buf, sizeof(buf), f)) {
-                       fprintf(stderr, "Invalid invitation file %s", fname);
+                       fprintf(stderr, "Invalid invitation file %s\n", fname);
                        fclose(f);
                        continue;
                }
@@ -1171,7 +1186,7 @@ static int dump_invitations(void) {
                }
 
                if(strncmp(buf, "Name = ", 7) || !check_id(buf + 7)) {
-                       fprintf(stderr, "Invalid invitation file %s", fname);
+                       fprintf(stderr, "Invalid invitation file %s\n", fname);
                        continue;
                }
 
@@ -1680,6 +1695,7 @@ const var_t variables[] = {
        {"Ed25519PrivateKeyFile", VAR_SERVER},
        {"ExperimentalProtocol", VAR_SERVER},
        {"Forwarding", VAR_SERVER},
+       {"FWMark", 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 occurrences.
                   Turn on warnings when it seems variables might be removed unintentionally. */
 
                if(action == 1 && !(variables[i].type & VAR_MULTIPLE)) {