Let tincctl use the NETNAME environment variable if no -n option is given.
[tinc] / src / tincctl.c
index f0515c9..d1df07b 100644 (file)
@@ -138,6 +138,12 @@ static bool parse_options(int argc, char **argv) {
                }
        }
 
+       if(!netname) {
+               netname = getenv("NETNAME");
+               if(netname)
+                       netname = xstrdup(netname);
+       }
+
        return true;
 }
 
@@ -577,7 +583,7 @@ int main(int argc, char *argv[]) {
 #endif
                if (slash++) {
                        c = xmalloc((slash - argv[0]) + sizeof("tincd"));
-                       sprintf(c, "%.*stincd", slash - argv[0], argv[0]);
+                       sprintf(c, "%.*stincd", (int)(slash - argv[0]), argv[0]);
                }
                else
                        c = "tincd";