X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;ds=sidebyside;f=src%2Ftincd.c;h=9879ecb6c6dfe6a63c2e07396ddb1f2f810293bd;hb=09a8ff649cc7aa51d291c89e1556526a6265cc81;hp=3cbac4ba25f5daa4a29b2f0189dc8b466aff035a;hpb=19be9cf7150858311f7898fa3fb525d692d02f64;p=tinc diff --git a/src/tincd.c b/src/tincd.c index 3cbac4ba..9879ecb6 100644 --- a/src/tincd.c +++ b/src/tincd.c @@ -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(netname && !strcmp(netname, ".")) { + free(netname); + netname = NULL; + } + return true; } @@ -382,11 +390,6 @@ int main(int argc, char **argv) { openlogger("tinc", use_logfile?LOGMODE_FILE:LOGMODE_STDERR); - if(!event_init()) { - logger(DEBUG_ALWAYS, LOG_ERR, "Error initializing libevent!"); - return 1; - } - g_argv = argv; if(getenv("LISTEN_PID") && atoi(getenv("LISTEN_PID")) == getpid()) @@ -439,6 +442,11 @@ int main2(int argc, char **argv) { } #endif + if(!event_init()) { + logger(DEBUG_ALWAYS, LOG_ERR, "Error initializing libevent!"); + return 1; + } + /* Setup sockets and open device. */ if(!setup_network())