diff options
author | Adam Ierymenko <adam.ierymenko@zerotier.com> | 2017-03-14 14:40:17 -0700 |
---|---|---|
committer | Adam Ierymenko <adam.ierymenko@zerotier.com> | 2017-03-14 14:40:17 -0700 |
commit | 533baf921fcb6dee8268faa2f09f77baaf9f4ad0 (patch) | |
tree | 497256aaf6c63b1fbd3e89406bc92ffeb86792f5 | |
parent | c1c26ec73ab22e9344d807ffd1f564d46f65196a (diff) | |
download | infinitytier-533baf921fcb6dee8268faa2f09f77baaf9f4ad0.tar.gz infinitytier-533baf921fcb6dee8268faa2f09f77baaf9f4ad0.zip |
Software update cleanup, and a fix for updates on Windows.
-rw-r--r-- | ext/installfiles/windows/ZeroTier One.aip | 13 | ||||
-rw-r--r-- | one.cpp | 7 | ||||
-rw-r--r-- | service/SoftwareUpdater.cpp | 42 | ||||
-rw-r--r-- | service/SoftwareUpdater.hpp | 5 | ||||
-rw-r--r-- | version.h | 7 | ||||
-rw-r--r-- | windows/ZeroTierOne/ZeroTierOne.vcxproj | 4 |
6 files changed, 24 insertions, 54 deletions
diff --git a/ext/installfiles/windows/ZeroTier One.aip b/ext/installfiles/windows/ZeroTier One.aip index e799ffc9..c8b4ead2 100644 --- a/ext/installfiles/windows/ZeroTier One.aip +++ b/ext/installfiles/windows/ZeroTier One.aip @@ -27,10 +27,10 @@ <ROW Property="CTRLS" Value="2"/> <ROW Property="MSIFASTINSTALL" MultiBuildValue="DefaultBuild:2"/> <ROW Property="Manufacturer" Value="ZeroTier, Inc."/> - <ROW Property="ProductCode" Value="1033:{99A3C357-A412-4230-AFFF-E9205222FDF3} " Type="16"/> + <ROW Property="ProductCode" Value="1033:{519CBD97-6F32-4B1F-B1D0-E6BD9D1B406A} " Type="16"/> <ROW Property="ProductLanguage" Value="1033"/> <ROW Property="ProductName" Value="ZeroTier One"/> - <ROW Property="ProductVersion" Value="1.1.19" Type="32"/> + <ROW Property="ProductVersion" Value="1.2.0" Type="32"/> <ROW Property="REBOOT" MultiBuildValue="DefaultBuild:ReallySuppress"/> <ROW Property="RUNAPPLICATION" Value="1" Type="4"/> <ROW Property="SecureCustomProperties" Value="OLDPRODUCTS;AI_NEWERPRODUCTFOUND;AI_SETUPEXEPATH;SETUPEXEDIR"/> @@ -60,7 +60,7 @@ <ROW Directory="x86_Dir" Directory_Parent="tapwindows_Dir" DefaultDir="x86"/> </COMPONENT> <COMPONENT cid="caphyon.advinst.msicomp.MsiCompsComponent"> - <ROW Component="AI_CustomARPName" ComponentId="{5E2F0984-B6F7-4037-9407-662F90522113}" Directory_="APPDIR" Attributes="4" KeyPath="DisplayName" Options="1"/> + <ROW Component="AI_CustomARPName" ComponentId="{3214E018-0892-440D-AA99-59E6E9460A0D}" Directory_="APPDIR" Attributes="4" KeyPath="DisplayName" Options="1"/> <ROW Component="AI_DisableModify" ComponentId="{020DCABD-5D56-49B9-AF48-F07F0B55E590}" Directory_="APPDIR" Attributes="4" KeyPath="NoModify" Options="1"/> <ROW Component="AI_ExePath" ComponentId="{8E02B36C-7A19-429B-A93E-77A9261AC918}" Directory_="APPDIR" Attributes="4" KeyPath="AI_ExePath"/> <ROW Component="Hardcodet.Wpf.TaskbarNotification.dll" ComponentId="{BEA825AF-2555-44AF-BE40-47FFC16DCBA6}" Directory_="APPDIR" Attributes="0" KeyPath="Hardcodet.Wpf.TaskbarNotification.dll"/> @@ -104,6 +104,9 @@ <ROW PersistentRow="segoeuii.ttf" Type="0" Condition="1"/> <ROW PersistentRow="segoeuiz.ttf" Type="0" Condition="1"/> </COMPONENT> + <COMPONENT cid="caphyon.advinst.msicomp.BootstrOptComponent"> + <ROW BootstrOptKey="GlobalOptions" GeneralOptions="qh" DownloadFolder="[AppDataFolder][|Manufacturer]\[|ProductName]\prerequisites" EulaPathLocId="*" IntroTextPathLocId="*"/> + </COMPONENT> <COMPONENT cid="caphyon.advinst.msicomp.BuildComponent"> <ROW BuildKey="DefaultBuild" BuildName="MSI" BuildOrder="1" BuildType="1" PackageFolder="..\..\.." PackageFileName="ZeroTier One" Languages="en" InstallationType="4" ExtUI="true" UseLargeSchema="true"/> <ROW BuildKey="ExeBuild" BuildName="update" BuildOrder="2" BuildType="1" PackageFolder="..\..\.." PackageFileName="ZeroTier One" Languages="en" InstallationType="2" CabsLocation="1" CompressCabs="false" UseLzma="true" LzmaMethod="2" LzmaCompressionLevel="4" PackageType="1" FilesInsideExe="true" ExeIconPath="..\..\..\artwork\ZeroTierIcon.ico" ExtractionFolder="[AppDataFolder][|Manufacturer]\[|ProductName] [|ProductVersion]\install" MsiCmdLine="/qn" UseLargeSchema="true" ExeName="zt1_update_2_1,2_[|ProductVersion]_0"/> @@ -429,10 +432,10 @@ <ROW XmlAttribute="xsischemaLocation" XmlElement="swidsoftware_identification_tag" Name="xsi:schemaLocation" Flags="14" Order="3" Value="http://standards.iso.org/iso/19770/-2/2008/schema.xsd software_identification_tag.xsd"/> </COMPONENT> <COMPONENT cid="caphyon.advinst.msicomp.XmlElementComponent"> - <ROW XmlElement="swidbuild" ParentElement="swidnumeric" Name="swid:build" Condition="1" Order="2" Flags="14" Text="19"/> + <ROW XmlElement="swidbuild" ParentElement="swidnumeric" Name="swid:build" Condition="1" Order="2" Flags="14" Text="0"/> <ROW XmlElement="swidentitlement_required_indicator" ParentElement="swidsoftware_identification_tag" Name="swid:entitlement_required_indicator" Condition="1" Order="0" Flags="14" Text="false"/> <ROW XmlElement="swidmajor" ParentElement="swidnumeric" Name="swid:major" Condition="1" Order="0" Flags="14" Text="1"/> - <ROW XmlElement="swidminor" ParentElement="swidnumeric" Name="swid:minor" Condition="1" Order="1" Flags="14" Text="1"/> + <ROW XmlElement="swidminor" ParentElement="swidnumeric" Name="swid:minor" Condition="1" Order="1" Flags="14" Text="2"/> <ROW XmlElement="swidname" ParentElement="swidproduct_version" Name="swid:name" Condition="1" Order="0" Flags="14" Text="[ProductVersion]"/> <ROW XmlElement="swidname_1" ParentElement="swidsoftware_creator" Name="swid:name" Condition="1" Order="0" Flags="14" Text="ZeroTier, Inc."/> <ROW XmlElement="swidname_2" ParentElement="swidsoftware_licensor" Name="swid:name" Condition="1" Order="0" Flags="14" Text="ZeroTier, Inc."/> @@ -84,7 +84,7 @@ using namespace ZeroTier; static OneService *volatile zt1Service = (OneService *)0; #define PROGRAM_NAME "ZeroTier One" -#define COPYRIGHT_NOTICE "Copyright © 2011–2016 ZeroTier, Inc." +#define COPYRIGHT_NOTICE "Copyright (c) 2011-2017 ZeroTier, Inc." #define LICENSE_GRANT \ "This is free software: you may copy, modify, and/or distribute this" ZT_EOL_S \ "work under the terms of the GNU General Public License, version 3 or" ZT_EOL_S \ @@ -100,9 +100,10 @@ static OneService *volatile zt1Service = (OneService *)0; static void cliPrintHelp(const char *pn,FILE *out) { fprintf(out, - "%s version %d.%d.%d" ZT_EOL_S, + "%s version %d.%d.%d build %d (platform %d arch %d)" ZT_EOL_S, PROGRAM_NAME, - ZEROTIER_ONE_VERSION_MAJOR, ZEROTIER_ONE_VERSION_MINOR, ZEROTIER_ONE_VERSION_REVISION); + ZEROTIER_ONE_VERSION_MAJOR, ZEROTIER_ONE_VERSION_MINOR, ZEROTIER_ONE_VERSION_REVISION, ZEROTIER_ONE_VERSION_BUILD, + ZT_BUILD_PLATFORM, ZT_BUILD_ARCHITECTURE); fprintf(out, COPYRIGHT_NOTICE ZT_EOL_S LICENSE_GRANT ZT_EOL_S); diff --git a/service/SoftwareUpdater.cpp b/service/SoftwareUpdater.cpp index c1d77f98..fa7216ce 100644 --- a/service/SoftwareUpdater.cpp +++ b/service/SoftwareUpdater.cpp @@ -47,13 +47,6 @@ #include "../osdep/OSUtils.hpp" -#ifndef ZT_BUILD_ARCHITECTURE -#define ZT_BUILD_ARCHITECTURE 0 -#endif -#ifndef ZT_BUILD_PLATFORM -#define ZT_BUILD_PLATFORM 0 -#endif - namespace ZeroTier { SoftwareUpdater::SoftwareUpdater(Node &node,const std::string &homePath) : @@ -65,30 +58,7 @@ SoftwareUpdater::SoftwareUpdater(Node &node,const std::string &homePath) : _latestValid(false), _downloadLength(0) { - // Check for a cached newer update. If there's a cached update that is not newer or looks bad, delete. - try { - std::string buf; - if (OSUtils::readFile((_homePath + ZT_PATH_SEPARATOR_S ZT_SOFTWARE_UPDATE_META_FILENAME).c_str(),buf)) { - nlohmann::json meta = OSUtils::jsonParse(buf); - buf = std::string(); - const unsigned int rvMaj = (unsigned int)OSUtils::jsonInt(meta[ZT_SOFTWARE_UPDATE_JSON_VERSION_MAJOR],0); - const unsigned int rvMin = (unsigned int)OSUtils::jsonInt(meta[ZT_SOFTWARE_UPDATE_JSON_VERSION_MINOR],0); - const unsigned int rvRev = (unsigned int)OSUtils::jsonInt(meta[ZT_SOFTWARE_UPDATE_JSON_VERSION_REVISION],0); - const unsigned int rvBld = (unsigned int)OSUtils::jsonInt(meta[ZT_SOFTWARE_UPDATE_JSON_VERSION_BUILD],0); - if ((Utils::compareVersion(rvMaj,rvMin,rvRev,rvBld,ZEROTIER_ONE_VERSION_MAJOR,ZEROTIER_ONE_VERSION_MINOR,ZEROTIER_ONE_VERSION_REVISION,ZEROTIER_ONE_VERSION_BUILD) > 0)&& - (OSUtils::readFile((_homePath + ZT_PATH_SEPARATOR_S ZT_SOFTWARE_UPDATE_BIN_FILENAME).c_str(),buf))) { - if ((uint64_t)buf.length() == OSUtils::jsonInt(meta[ZT_SOFTWARE_UPDATE_JSON_UPDATE_SIZE],0)) { - _latestMeta = meta; - _latestValid = true; - //printf("CACHED UPDATE IS NEWER AND LOOKS GOOD\n"); - } - } - } - } catch ( ... ) {} // exceptions indicate invalid cached update - if (!_latestValid) { - OSUtils::rm((_homePath + ZT_PATH_SEPARATOR_S ZT_SOFTWARE_UPDATE_META_FILENAME).c_str()); - OSUtils::rm((_homePath + ZT_PATH_SEPARATOR_S ZT_SOFTWARE_UPDATE_BIN_FILENAME).c_str()); - } + OSUtils::rm((_homePath + ZT_PATH_SEPARATOR_S ZT_SOFTWARE_UPDATE_BIN_FILENAME).c_str()); } SoftwareUpdater::~SoftwareUpdater() @@ -214,10 +184,7 @@ void SoftwareUpdater::handleSoftwareUpdateUserMessage(uint64_t origin,const void if (_latestMeta != req) { _latestMeta = req; _latestValid = false; - - OSUtils::rm((_homePath + ZT_PATH_SEPARATOR_S ZT_SOFTWARE_UPDATE_META_FILENAME).c_str()); OSUtils::rm((_homePath + ZT_PATH_SEPARATOR_S ZT_SOFTWARE_UPDATE_BIN_FILENAME).c_str()); - _download = std::string(); memcpy(_downloadHashPrefix.data,hash.data(),16); _downloadLength = len; @@ -331,9 +298,7 @@ bool SoftwareUpdater::check(const uint64_t now) // This is the very important security validation part that makes sure // this software update doesn't have cooties. - const std::string metaPath(_homePath + ZT_PATH_SEPARATOR_S ZT_SOFTWARE_UPDATE_META_FILENAME); const std::string binPath(_homePath + ZT_PATH_SEPARATOR_S ZT_SOFTWARE_UPDATE_BIN_FILENAME); - try { // (1) Check the hash itself to make sure the image is basically okay uint8_t sha512[ZT_SHA512_DIGEST_LEN]; @@ -343,8 +308,8 @@ bool SoftwareUpdater::check(const uint64_t now) const std::string sig(OSUtils::jsonBinFromHex(_latestMeta[ZT_SOFTWARE_UPDATE_JSON_UPDATE_SIGNATURE])); if (Identity(ZT_SOFTWARE_UPDATE_SIGNING_AUTHORITY).verify(_download.data(),(unsigned int)_download.length(),sig.data(),(unsigned int)sig.length())) { // (3) Try to save file, and if so we are good. - if (OSUtils::writeFile(metaPath.c_str(),OSUtils::jsonDump(_latestMeta)) && OSUtils::writeFile(binPath.c_str(),_download)) { - OSUtils::lockDownFile(metaPath.c_str(),false); + OSUtils::rm(binPath.c_str()); + if (OSUtils::writeFile(binPath.c_str(),_download)) { OSUtils::lockDownFile(binPath.c_str(),false); _latestValid = true; //printf("VALID UPDATE\n%s\n",OSUtils::jsonDump(_latestMeta).c_str()); @@ -358,7 +323,6 @@ bool SoftwareUpdater::check(const uint64_t now) // If we get here, checks failed. //printf("INVALID UPDATE (!!!)\n%s\n",OSUtils::jsonDump(_latestMeta).c_str()); - OSUtils::rm(metaPath.c_str()); OSUtils::rm(binPath.c_str()); _latestMeta = nlohmann::json(); _latestValid = false; diff --git a/service/SoftwareUpdater.hpp b/service/SoftwareUpdater.hpp index 8950782a..4bb0ef51 100644 --- a/service/SoftwareUpdater.hpp +++ b/service/SoftwareUpdater.hpp @@ -72,11 +72,6 @@ #define ZT_SOFTWARE_UPDATE_DEFAULT_CHANNEL "release" /** - * Filename for latest update's meta JSON - */ -#define ZT_SOFTWARE_UPDATE_META_FILENAME "latest-update.json" - -/** * Filename for latest update's binary image */ #define ZT_SOFTWARE_UPDATE_BIN_FILENAME "latest-update.exe" @@ -43,4 +43,11 @@ */ #define ZEROTIER_ONE_VERSION_BUILD 0 +#ifndef ZT_BUILD_ARCHITECTURE +#define ZT_BUILD_ARCHITECTURE 0 +#endif +#ifndef ZT_BUILD_PLATFORM +#define ZT_BUILD_PLATFORM 0 +#endif + #endif diff --git a/windows/ZeroTierOne/ZeroTierOne.vcxproj b/windows/ZeroTierOne/ZeroTierOne.vcxproj index 5092a655..32d7fa4a 100644 --- a/windows/ZeroTierOne/ZeroTierOne.vcxproj +++ b/windows/ZeroTierOne/ZeroTierOne.vcxproj @@ -271,7 +271,7 @@ <SDLCheck>true</SDLCheck> <AdditionalIncludeDirectories> </AdditionalIncludeDirectories> - <PreprocessorDefinitions>STATICLIB;ZT_SALSA20_SSE;ZT_USE_MINIUPNPC;MINIUPNP_STATICLIB;WIN32;NOMINMAX;ZT_SOFTWARE_UPDATE_DEFAULT="apply";%(PreprocessorDefinitions)</PreprocessorDefinitions> + <PreprocessorDefinitions>STATICLIB;ZT_SALSA20_SSE;ZT_USE_MINIUPNPC;MINIUPNP_STATICLIB;WIN32;NOMINMAX;ZT_SOFTWARE_UPDATE_DEFAULT="apply";ZT_BUILD_PLATFORM=2;ZT_BUILD_ARCHITECTURE=1;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <EnableEnhancedInstructionSet>NoExtensions</EnableEnhancedInstructionSet> <StringPooling>true</StringPooling> @@ -297,7 +297,7 @@ <SDLCheck>true</SDLCheck> <AdditionalIncludeDirectories> </AdditionalIncludeDirectories> - <PreprocessorDefinitions>STATICLIB;ZT_SOFTWARE_UPDATE_DEFAULT="apply";ZT_SALSA20_SSE;ZT_USE_MINIUPNPC;MINIUPNP_STATICLIB;WIN32;NOMINMAX;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <PreprocessorDefinitions>STATICLIB;ZT_SOFTWARE_UPDATE_DEFAULT="apply";ZT_SALSA20_SSE;ZT_USE_MINIUPNPC;MINIUPNP_STATICLIB;WIN32;NOMINMAX;ZT_BUILD_PLATFORM=2;ZT_BUILD_ARCHITECTURE=2;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet> <StringPooling>true</StringPooling> |