Have tincd and tincctl use the same method of determining netname.
authorGuus Sliepen <guus@tinc-vpn.org>
Sat, 21 Jul 2012 13:15:04 +0000 (15:15 +0200)
committerGuus Sliepen <guus@tinc-vpn.org>
Sat, 21 Jul 2012 13:15:04 +0000 (15:15 +0200)
src/tincctl.c
src/tincd.c

index a3688ecaebc420bd4dde901d1df4f21984cc03ef..f547639a8460232443b2a2baf8689b8148b5d823 100644 (file)
@@ -187,11 +187,15 @@ static bool parse_options(int argc, char **argv) {
                }
        }
 
-       if(!netname) {
-               netname = getenv("NETNAME");
-               if(netname)
-                       netname = xstrdup(netname);
-       }
+        if(!netname && (netname = getenv("NETNAME")))
+                netname = xstrdup(netname);
+
+        /* netname "." is special: a "top-level name" */
+
+        if(!strcmp(netname, ".")) {
+                free(netname);
+                netname = NULL;
+        }
 
        return true;
 }
index 9f65bbeacf8f85d54c6221c41756649d70714d92..85aee39f2172ac1072edf1f6d2c85ab876bf30f5 100644 (file)
@@ -177,9 +177,7 @@ static bool parse_options(int argc, char **argv) {
                                break;
 
                        case 'n':                               /* net name given */
-                               /* netname "." is special: a "top-level name" */
-                               netname = strcmp(optarg, ".") != 0 ?
-                                               xstrdup(optarg) : NULL;
+                               netname = xstrdup(optarg);
                                break;
 
                        case 'o':                               /* option */
@@ -228,6 +226,16 @@ static bool parse_options(int argc, char **argv) {
                }
        }
 
+       if(!netname && (netname = getenv("NETNAME")))
+               netname = xstrdup(netname);
+
+       /* netname "." is special: a "top-level name" */
+
+       if(!strcmp(netname, ".")) {
+               free(netname);
+               netname = NULL;
+       }
+
        return true;
 }