From 0545e70bd58051a048730543684d3ac06cedfd09 Mon Sep 17 00:00:00 2001 From: Michael Adams Date: Thu, 10 Sep 2020 12:42:11 -0700 Subject: [PATCH] Added error messages to use admin/sudo/root --- .gitignore | 2 +- one.cpp | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 584bdb6c1..2143346ff 100755 --- a/.gitignore +++ b/.gitignore @@ -33,7 +33,6 @@ Thumbs.db /ext/installfiles/windows/Prerequisites /ext/installfiles/windows/*-cache /ZeroTier One.msi -/windows/.vs *.vcxproj.backup /windows/TapDriver6/Win7Debug /windows/TapDriver6/win7Release @@ -42,6 +41,7 @@ Thumbs.db enc_temp_folder /windows/copyutil/bin /windows/copyutil/obj +.vs/ # *nix/Mac build droppings /build-* diff --git a/one.cpp b/one.cpp index 20cdebfed..8b5ed4cf7 100644 --- a/one.cpp +++ b/one.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c)2019 ZeroTier, Inc. + * Copyright (c)2020 ZeroTier, Inc. * * Use of this software is governed by the Business Source License included * in the LICENSE.TXT file in the project's root directory. @@ -85,7 +85,7 @@ using namespace ZeroTier; static OneService *volatile zt1Service = (OneService *)0; #define PROGRAM_NAME "ZeroTier One" -#define COPYRIGHT_NOTICE "Copyright (c) 2019 ZeroTier, Inc." +#define COPYRIGHT_NOTICE "Copyright (c) 2020 ZeroTier, Inc." #define LICENSE_GRANT "Licensed under the ZeroTier BSL 1.1 (see LICENSE.txt)" /****************************************************************************/ @@ -232,9 +232,12 @@ static int cli(int argc,char **argv) if (!homeDir.length()) homeDir = OneService::platformDefaultHomePath(); + // TODO: cleanup this logic + // A lot of generic CLI errors land here; missing admin rights cause a bit of this. if ((!port)||(!authToken.length())) { if (!homeDir.length()) { fprintf(stderr,"%s: missing port or authentication token and no home directory specified to auto-detect" ZT_EOL_S,argv[0]); + fprintf(stderr, "If you did not, please run this command as an Administrator / sudo / Root user. Thanks!"); return 2; } @@ -244,6 +247,7 @@ static int cli(int argc,char **argv) port = Utils::strToUInt(portStr.c_str()); if ((port == 0)||(port > 0xffff)) { fprintf(stderr,"%s: missing port and zerotier-one.port not found in %s" ZT_EOL_S,argv[0],homeDir.c_str()); + fprintf(stderr, "If you did not, please run this command as an Administrator / sudo / Root user. Thanks!"); return 2; } } @@ -266,6 +270,7 @@ static int cli(int argc,char **argv) #endif if (!authToken.length()) { fprintf(stderr,"%s: missing authentication token and authtoken.secret not found (or readable) in %s" ZT_EOL_S,argv[0],homeDir.c_str()); + fprintf(stderr, "If you did not, please run this command as an Administrator / sudo / Root user. Thanks!"); return 2; } } @@ -1316,6 +1321,7 @@ static BOOL WINAPI _winConsoleCtrlHandler(DWORD dwCtrlType) return FALSE; } +// TODO: revisit this with https://support.microsoft.com/en-us/help/947709/how-to-use-the-netsh-advfirewall-firewall-context-instead-of-the-netsh static void _winPokeAHole() { char myPath[MAX_PATH]; @@ -1690,7 +1696,7 @@ int main(int argc,char **argv) ptmp.append(*pi); if ((*pi != ".")&&(*pi != "..")) { if (!OSUtils::mkdir(ptmp)) - throw std::runtime_error("home path does not exist, and could not create"); + throw std::runtime_error("home path does not exist, and could not create. Please verify local system permissions."); } } }