diff options
author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2013-08-07 15:16:00 -0400 |
---|---|---|
committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2013-08-07 15:16:00 -0400 |
commit | 7015992b84290ea6f6d5a916a4e5577fa36dd4ee (patch) | |
tree | 78f6d6073579aa300edce9a011528fe41b62593f | |
parent | 4be890c1711c4ffb862bb314ecc1d6729ab85bc0 (diff) | |
download | infinitytier-7015992b84290ea6f6d5a916a4e5577fa36dd4ee.tar.gz infinitytier-7015992b84290ea6f6d5a916a4e5577fa36dd4ee.zip |
Make cli try to read auth token from global home if possible (unix-like systems)
-rw-r--r-- | cli.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -107,8 +107,20 @@ int main(int argc,char **argv) dotZeroTierAuthToken.push_back(ZT_PATH_SEPARATOR); dotZeroTierAuthToken.append(".zerotierOneAuthToken"); if (!Utils::readFile(dotZeroTierAuthToken.c_str(),authToken)) { +#ifndef __WINDOWS__ +#ifdef __APPLE__ + const char *systemAuthTokenPath = "/Library/Application Support/ZeroTier/One/authtoken.secret"; +#else + const char *systemAuthTokenPath = "/var/lib/zerotier-one/authtoken.secret"; +#endif + if (!Utils::readFile(systemAuthTokenPath,authToken)) { + fprintf(stdout,"FATAL ERROR: no token specified on command line and could not read '%s' or '%s'"ZT_EOL_S,dotZeroTierAuthToken.c_str(),systemAuthTokenPath); + return -2; + } +#else // __WINDOWS__ fprintf(stdout,"FATAL ERROR: no token specified on command line and could not read '%s'"ZT_EOL_S,dotZeroTierAuthToken.c_str()); return -2; +#endif // __WINDOWS__ } } } |