Allow "none" for Cipher and Digest again.
[tinc] / src / net_setup.c
index 35cd3f7..6157993 100644 (file)
@@ -38,6 +38,7 @@
 #include "protocol.h"
 #include "route.h"
 #include "rsa.h"
+#include "script.h"
 #include "subnet.h"
 #include "utils.h"
 #include "xalloc.h"
@@ -410,17 +411,18 @@ char *get_name(void) {
 
        if(*name == '$') {
                char *envname = getenv(name + 1);
+               char hostname[32] = "";
                if(!envname) {
                        if(strcmp(name + 1, "HOST")) {
                                logger(DEBUG_ALWAYS, LOG_ERR, "Invalid Name: environment variable %s does not exist\n", name + 1);
                                return false;
                        }
-                       char envname[32];
-                       if(gethostname(envname, 32)) {
+                       if(gethostname(hostname, sizeof hostname) || !*hostname) {
                                logger(DEBUG_ALWAYS, LOG_ERR, "Could not get hostname: %s\n", strerror(errno));
                                return false;
                        }
-                       envname[31] = 0;
+                       hostname[31] = 0;
+                       envname = hostname;
                }
                free(name);
                name = xstrdup(envname);
@@ -631,6 +633,8 @@ bool setup_myself_reloadable(void) {
                keylifetime = 3600;
 
        get_config_int(lookup_config(config_tree, "AutoConnect"), &autoconnect);
+       if(autoconnect < 0)
+               autoconnect = 0;
 
        get_config_bool(lookup_config(config_tree, "DisableBuggyPeers"), &disablebuggypeers);
 
@@ -743,7 +747,9 @@ static bool setup_myself(void) {
        if(!get_config_string(lookup_config(config_tree, "Cipher"), &cipher))
                cipher = xstrdup("blowfish");
 
-       if(!(myself->incipher = cipher_open_by_name(cipher))) {
+       if(!strcasecmp(cipher, "none")) {
+               myself->incipher = NULL;
+       } else if(!(myself->incipher = cipher_open_by_name(cipher))) {
                logger(DEBUG_ALWAYS, LOG_ERR, "Unrecognized cipher type!");
                return false;
        }
@@ -765,7 +771,9 @@ static bool setup_myself(void) {
        if(!get_config_string(lookup_config(config_tree, "Digest"), &digest))
                digest = xstrdup("sha1");
 
-       if(!(myself->indigest = digest_open_by_name(digest, maclength))) {
+       if(!strcasecmp(digest, "none")) {
+               myself->indigest = NULL;
+       } else if(!(myself->indigest = digest_open_by_name(digest, maclength))) {
                logger(DEBUG_ALWAYS, LOG_ERR, "Unrecognized digest type!");
                return false;
        }