diff --git a/doc/ClientUpdateProtocolEcdsa.md b/doc/ClientUpdateProtocolEcdsa.md index 7d9588be1..c4b29d809 100644 --- a/doc/ClientUpdateProtocolEcdsa.md +++ b/doc/ClientUpdateProtocolEcdsa.md @@ -50,9 +50,13 @@ The server receives an update request XML, public key id, and nonce; it performs The server attempts to find a matching ECDSA private key for the specified public key id, returning an HTTP error if no such private key exists. Finally, it assembles the update response. -Before sending, the server stores the update response XML (also in UTF-8) in a buffer. It appends the computed SHA-256 hash of the request body+keyid+nonce to the buffer. It then calculates an ECDSA signature over that combined buffer, using the server’s private key. It sends the ECDSA signature and the response body + client hash back to the user. +Before sending, the server stores the SHA-256 hash of the request body in a buffer. It appends the SHA-256 hash of the response body, then the cup2key query value (%d:%u, where the first parameter is the keypair id, and the second is the client freshness nonce). It then calculates an ECDSA signature over the SHA-256 hash of that buffer, using the server's private key. It sends the ECDSA signature and the client hash (i.e. hash of the request body) back to the user. -The client receives the response XML, observed client hash, and ECDSA signature. It concatenates its copy of the request hash to the response XML, and attempts to verify the ECDSA signature using its public key. If the signature does not match, the client recognizes that the server response has been tampered in transit, and rejects the exchange. + + +The client receives the response XML, observed client hash, and ECDSA signature. It creates a buffer containing the SHA-256 hash of the request body. It then appends the SHA-256 hash of the response body, then the cup2key query value (see above). It then tests whether the received ECDSA signature can be verified to match the SHA-256 hash of this buffer using the public key. If the signature does not match, the client recognizes that the server response has been tampered in transit, and rejects the exchange. + + The client then compares the SHA-256 hash in the response to the original hash of the request. If the hashes do not match, the client recognizes that the request has been tampered in transit, and rejects the exchange. diff --git a/doc/DeveloperSetupGuide.md b/doc/DeveloperSetupGuide.md index 7da433c56..9e33bb355 100644 --- a/doc/DeveloperSetupGuide.md +++ b/doc/DeveloperSetupGuide.md @@ -4,7 +4,7 @@ These instructions are intended to assist the would-be Omaha developer with sett We are striving to make the code build with the latest Windows toolchain from Microsoft. Since there is no continuous integration for this project, the code may not build using previous versions of the toolchain. -#### Currently, the supported toolchain is Visual Studio 2019 Update 16.10.4 and Windows SDK 10.0.18362.0. #### +#### Currently, the supported toolchain is Visual Studio 2019 Update 16.11.10 and Windows SDK 10.0.22000.0. #### The updater runs on Windows 7, 8, and 10. Windows XP is not supported in the current build configuration due to a number of issues, such as thread-safe initializing of static local variables, etc. diff --git a/omaha/base/build.scons b/omaha/base/build.scons index 7d44b8973..266fc1b9c 100644 --- a/omaha/base/build.scons +++ b/omaha/base/build.scons @@ -15,6 +15,7 @@ Import('env') +import fnmatch import glob import operator import os @@ -97,107 +98,43 @@ local_env.Append(ASFLAGS = ['/safeseh']) # Build these into a library. local_env.ComponentStaticLibraryMultiarch('base', inputs) -if 'OMAHA_PROTOBUF_BIN_DIR' not in os.environ: - """ Build the Protocol Buffer Compiler executable protoc.exe.""" - - def GenerateGYPRunAction(source, target, env, for_signature): - """This Generator creates a command line that when executed runs gyp on the - specified source file to generate the specified target file. - - * We explicitly change to the directory of the - source file before running gyp. Not doing this confuses some of the gyp - generators, especially the msvs generator. - * The |--generator-output| option is needed to generate the target in the - target directory. Without |--generator-output|, the target is generated - in the source directory, which is not desirable especially if the source - directory is read-only. Explicitly generating the target in a different - output directory also avoids other warnings. - * |--generator-output| needs to be specified as a - path relative to the source file path to be compatible with the gyp - generators. - - Args: - source: A List containing a single .gyp file path. - target: A List containing a single target file path. - env: The Environment in which to build. - for_signature: We ignore this parameter. It indicates to the generator to - just generate the command and not actually run it. - - Returns: - A valid command line that when executed runs gyp on the specified source - file to generate the specified target file. - """ - - # We use the googleclient gyp since the google3 gyp does not work well with - # python 2.7. - gyp_bat_file = '$GOOGLECLIENT\\third_party\\gyp\\files\\gyp.bat' - - # Explicitly using 'cd', since using the chdir option to env.Command() is - # not compatible with parallel builds using the -j option. - gyprun_action = 'cd %s' % source[0].dir.abspath - gyprun_action += ' && ' # Chaining the gyp generation to the 'cd' command. - gyprun_action += '%s %s --generator-output=%s -G msvs_version=2005' % ( - env.File(gyp_bat_file).abspath, - source[0].name, - os.path.relpath(target[0].dir.abspath, source[0].dir.abspath)) - - return gyprun_action - - Import('env') - local_env = env.Clone() - - # Use gyp to generate protoc.sln, which in turn is fed to VCBuild to generate - # protoc.exe. - # gyp. - gyprun = Builder(generator = GenerateGYPRunAction) - local_env.Append( BUILDERS = {'GYPRun' : gyprun}) - protoc_sln = local_env.GYPRun( - target='protoc.sln', - source='$GOOGLE3/net/proto2/contrib/portable/gyp/protoc.gyp') - - # VCBuild. - vcbld = Builder(action = - '$GOOGLECLIENT\\third_party\\vc_80\\files\\vc\\vcpackages\\vcbuild.exe' + - ' /useenv $SOURCE "Default|Win32"') - local_env.Append( BUILDERS = {'VCBuild' : vcbld}) - local_env.VCBuild(target='Default/protoc.exe', source=protoc_sln) +def MultiGlobFilter(env, include, exclude=None): + """Glob for each pattern in `includes`, filter out patterns in `excludes`.""" + files = set() + for pat in include: + files.update(env.Glob(pat, strings=True)) + for exclude_pat in (exclude or []): + files.difference_update(fnmatch.filter(files, exclude_pat)) + return sorted(files) """ Build libprotobuf. """ +proto_env = env.Clone() + default_protobuf_src_dir = '$GOOGLE3/third_party/protobuf/src' protobuf_src_dir = os.getenv('OMAHA_PROTOBUF_SRC_DIR', default_protobuf_src_dir) - -proto_env = env.Clone() protobuf_src_path = os.path.join(protobuf_src_dir, 'google/protobuf/') +protobuf_src_path_dir = proto_env.Dir(protobuf_src_path) +proto_env.Dir('protobuf').addRepository(protobuf_src_path_dir) + +proto_env.FilterOut(CCFLAGS=['/W4', '/Wall']) + +proto_env.Prepend(CCFLAGS=['/W2']) + proto_env.Append( - CPPDEFINES=['LIBPROTOBUF_EXPORTS'], CCFLAGS=[ - '/wd4005', - '/wd4018', - '/wd4065', - '/wd4100', - '/wd4125', - '/wd4146', - '/wd4242', - '/wd4244', - '/wd4267', - '/wd4305', - '/wd4309', - '/wd4310', - '/wd4355', - '/wd4388', - '/wd4389', - '/wd4456', - '/wd4506', - '/wd4548', - '/wd4647', - '/wd4701', - '/wd4702', - '/wd4703', - '/wd4715', - '/wd4798', - '/wd4800', - '/wd4946', + '/wd4309', # truncation of constant value + '/wd4244', # conversion from 'T1' to 'T2', possible loss of data + '/wd4506', # no definition for inline function + ], + CPPDEFINES=[ + 'LIBPROTOBUF_EXPORTS', + # Force the compiler to output public accessors for Google-specific + # ctypes. + 'PUBLIC_UNKNOWN_CTYPES', + # Let the compiler silently ignore unknown options in the proto files. + 'ALLOW_UNKNOWN_OPTIONS', + 'PROTOBUF_INTERNAL_IGNORE_FIELD_NAME_ERRORS_=1', ], CPPPATH=[ protobuf_src_dir, @@ -205,55 +142,48 @@ proto_env.Append( ], ) -protobuf_src_path_dir = proto_env.Dir(protobuf_src_path) -proto_env.Dir('protobuf').addRepository(protobuf_src_path_dir) -cc_files = [ - 'protobuf/compiler/importer.cc', - 'protobuf/compiler/parser.cc', - 'protobuf/any.cc', - 'protobuf/arena.cc', - 'protobuf/arenastring.cc', - 'protobuf/descriptor.cc', - 'protobuf/descriptor.pb.cc', - 'protobuf/descriptor_database.cc', - 'protobuf/dynamic_message.cc', - 'protobuf/extension_set.cc', - 'protobuf/extension_set_heavy.cc', - 'protobuf/generated_message_reflection.cc', - 'protobuf/generated_message_util.cc', - 'protobuf/implicit_weak_message.cc', - 'protobuf/io/coded_stream.cc', - 'protobuf/io/io_win32.cc', - 'protobuf/io/printer.cc', - 'protobuf/io/strtod.cc', - 'protobuf/io/tokenizer.cc', - 'protobuf/io/zero_copy_stream.cc', - 'protobuf/io/zero_copy_stream_impl.cc', - 'protobuf/io/zero_copy_stream_impl_lite.cc', - 'protobuf/map_field.cc', - 'protobuf/message.cc', - 'protobuf/message_lite.cc', - 'protobuf/parse_context.cc', - 'protobuf/reflection_ops.cc', - 'protobuf/repeated_field.cc', - 'protobuf/service.cc', - 'protobuf/stubs/common.cc', - 'protobuf/stubs/int128.cc', - 'protobuf/stubs/status.cc', - 'protobuf/stubs/stringprintf.cc', - 'protobuf/stubs/stringpiece.cc', - 'protobuf/stubs/structurally_valid.cc', - 'protobuf/stubs/strutil.cc', - 'protobuf/stubs/substitute.cc', - 'protobuf/text_format.cc', - 'protobuf/unknown_field_set.cc', - 'protobuf/wire_format.cc', - 'protobuf/wire_format_lite.cc', -] +cc_files = MultiGlobFilter( + proto_env, + [ + 'protobuf/*.cc', + 'protobuf/io/*.cc', + 'protobuf/stubs/*.cc', + ], + exclude=['protobuf/*test*.cc'], +) proto_env.ComponentStaticLibraryMultiarch( 'libprotobuf', cc_files, COMPONENT_STATIC=True) +if 'OMAHA_PROTOBUF_BIN_DIR' not in os.environ: + """ Build the Protocol Buffer Compiler executable protoc.exe.""" + + protoc_env = proto_env.Clone() + + protoc_env.FilterOut(LINKFLAGS=['/SUBSYSTEM:WINDOWS,5.01']) + + protoc_env.Append( + LIBS=[ + protoc_env['crt_libs'][protoc_env.Bit('debug')], + 'libprotobuf', + ], + LINKFLAGS=['/SUBSYSTEM:CONSOLE,5.01'], + ) + + cc_files = MultiGlobFilter( + protoc_env, + [ + 'protobuf/compiler/*.cc', + 'protobuf/compiler/*/*.cc', + ], + exclude = [ + 'protobuf/compiler/mock_code_generator.cc', + 'protobuf/compiler/*test*.cc', + 'protobuf/compiler/*/*test*.cc', + ], + ) + protoc_env.ComponentProgram('Default/protoc.exe', cc_files) + """ Build the CRX Verifier libraries.""" Import('env') @@ -290,7 +220,6 @@ cc_files += ['zlib/' + glob.glob(zlib_src_path_dir.path + os.sep + '*.c')] """ Add libzip library files.""" - libzip_src_path = '$GOOGLE3/third_party/libzip/lib/' libzip_src_path_dir = local_env.Dir(libzip_src_path) local_env.Dir('libzip').addRepository(libzip_src_path_dir) diff --git a/omaha/base/constants.h b/omaha/base/constants.h index 5e9f757cd..355965d3a 100644 --- a/omaha/base/constants.h +++ b/omaha/base/constants.h @@ -184,6 +184,7 @@ const TCHAR* const kChromeAppId = CHROME_APP_ID; #define OMAHA_REL_COMPANY_DIR PATH_COMPANY_NAME #define OMAHA_REL_CRASH_DIR OMAHA_REL_COMPANY_DIR _T("\\CrashReports") #define OMAHA_REL_POLICY_RESPONSES_DIR OMAHA_REL_COMPANY_DIR _T("\\Policies") +#define OMAHA_REL_TEMP_DIR OMAHA_REL_COMPANY_DIR _T("\\Temp") // Directories relative to \Google\Update #define OMAHA_REL_GOOPDATE_INSTALL_DIR \ diff --git a/omaha/base/path.cc b/omaha/base/path.cc index 5d14caf26..43a90e920 100644 --- a/omaha/base/path.cc +++ b/omaha/base/path.cc @@ -29,16 +29,6 @@ #include "omaha/base/utils.h" namespace omaha { - -const TCHAR* const kRegSvr32Cmd1 = _T("regsvr32 "); -const TCHAR* const kRegSvr32Cmd2 = _T("regsvr32.exe "); -const TCHAR* const kRunDll32Cmd1 = _T("rundll32 "); -const TCHAR* const kRunDll32Cmd2 = _T("rundll32.exe "); -const TCHAR* const kMsiExecCmd1 = _T("msiexec "); -const TCHAR* const kMsiExecCmd2 = _T("msiexec.exe "); -const TCHAR* const kDotExe = _T(".exe"); - - namespace detail { typedef bool (*Filter)(const WIN32_FIND_DATA&); diff --git a/omaha/common/config_manager.cc b/omaha/common/config_manager.cc index 9f55bbbd5..1d0d139a6 100644 --- a/omaha/common/config_manager.cc +++ b/omaha/common/config_manager.cc @@ -854,6 +854,19 @@ CString ConfigManager::GetMachineGoopdateInstallDir() const { return path; } +CString ConfigManager::GetTempDir() const { + if (::IsUserAnAdmin()) { + CString path; + VERIFY_SUCCEEDED(GetDir32(CSIDL_PROGRAM_FILES, + CString(OMAHA_REL_TEMP_DIR), + true, + &path)); + return path; + } + + return app_util::GetTempDirForImpersonatedOrCurrentUser(); +} + bool ConfigManager::IsRunningFromMachineGoopdateInstallDir() const { return is_running_from_official_machine_dir_; } diff --git a/omaha/common/config_manager.h b/omaha/common/config_manager.h index ffd23864b..b4e1dd780 100644 --- a/omaha/common/config_manager.h +++ b/omaha/common/config_manager.h @@ -251,6 +251,11 @@ class ConfigManager { // %ProgramFiles%/Google/Update CString GetMachineGoopdateInstallDir() const; + // Creates and returns a secure directory, %ProgramFiles%/Google/Temp, if + // running as Admin. Otherwise, returns the %TMP% for the impersonated or + // current user. + CString GetTempDir() const; + // Checks if the running program is executing from the User Goopdate dir. bool IsRunningFromMachineGoopdateInstallDir() const; diff --git a/omaha/common/config_manager_unittest.cc b/omaha/common/config_manager_unittest.cc index 73b3d2c3c..c8a1d7fdc 100644 --- a/omaha/common/config_manager_unittest.cc +++ b/omaha/common/config_manager_unittest.cc @@ -497,6 +497,23 @@ TEST_F(ConfigManagerNoOverrideTest, GetMachineSecureOfflineStorageDir) { EXPECT_TRUE(File::Exists(expected_path) || !vista_util::IsUserAdmin()); } +TEST_F(ConfigManagerNoOverrideTest, GetTempDir) { + CString expected_path; + + if (::IsUserAnAdmin()) { + CString program_files; + EXPECT_SUCCEEDED(GetFolderPath(CSIDL_PROGRAM_FILES, &program_files)); + expected_path = program_files + _T("\\") + PATH_COMPANY_NAME + _T("\\Temp"); + EXPECT_SUCCEEDED(DeleteTestDirectory(expected_path)); + } else { + expected_path = app_util::GetTempDirForImpersonatedOrCurrentUser(); + } + + ASSERT_FALSE(expected_path.IsEmpty()); + EXPECT_STREQ(expected_path, cm_->GetTempDir()); + EXPECT_TRUE(File::Exists(expected_path)); +} + TEST_F(ConfigManagerNoOverrideTest, IsRunningFromMachineGoopdateInstallDir) { EXPECT_FALSE(cm_->IsRunningFromMachineGoopdateInstallDir()); } diff --git a/omaha/common/goopdate_utils.cc b/omaha/common/goopdate_utils.cc index 2d516937d..5f07e48b6 100644 --- a/omaha/common/goopdate_utils.cc +++ b/omaha/common/goopdate_utils.cc @@ -17,7 +17,9 @@ #include #include +#include #include +#include #include "omaha/base/app_util.h" #include "omaha/base/const_addresses.h" @@ -1393,18 +1395,21 @@ bool IsAppInstallWorkerRunning(bool is_machine) { return !processes.empty(); } -HRESULT WriteInstallerDataToTempFile(const CString& installer_data, +HRESULT WriteInstallerDataToTempFile(const CPath& directory, + const CString& installer_data, CString* installer_data_file_path) { ASSERT1(installer_data_file_path); + CORE_LOG(L2, (_T("[WriteInstallerDataToTempFile][directory=%s][data=%s]"), + directory.m_strPath, installer_data)); + // TODO(omaha): consider eliminating the special case and simply create an // empty file. - CORE_LOG(L2, (_T("[WriteInstallerDataToTempFile][data=%s]"), installer_data)); - if (installer_data.IsEmpty()) { + if (!directory.IsDirectory() || installer_data.IsEmpty()) { return S_FALSE; } - CString temp_file = GetTempFilename(_T("gui")); + CString temp_file = GetTempFilenameAt(directory, _T("gui")); if (temp_file.IsEmpty()) { HRESULT hr = HRESULTFromLastError(); CORE_LOG(LE, (_T("[::GetTempFilename failed][0x08%x]"), hr)); diff --git a/omaha/common/goopdate_utils.h b/omaha/common/goopdate_utils.h index 9c950ab50..0e1d032ca 100644 --- a/omaha/common/goopdate_utils.h +++ b/omaha/common/goopdate_utils.h @@ -247,10 +247,11 @@ HRESULT WriteNameValuePairsToHandle(const HANDLE file_handle, bool IsAppInstallWorkerRunning(bool is_machine); // Converts the installer_data value to UTF8. Then writes this UTF8 data -// prefixed with the UTF8 BOM of EF BB BF to a temp file. Returns the path to -// temp file that was created. The returned path will be quote-enclosed by -// EnclosePath(). -HRESULT WriteInstallerDataToTempFile(const CString& installer_data, +// prefixed with the UTF8 BOM of EF BB BF to a temp file in `directory`. Returns +// the path to temp file that was created. The returned path will be +// quote-enclosed by EnclosePath(). +HRESULT WriteInstallerDataToTempFile(const CPath& directory, + const CString& installer_data, CString* installer_data_file_path); // Updates LastChecked to now. Call after successful update check for all apps. diff --git a/omaha/common/goopdate_utils_unittest.cc b/omaha/common/goopdate_utils_unittest.cc index 6c06fa919..6a122c78d 100644 --- a/omaha/common/goopdate_utils_unittest.cc +++ b/omaha/common/goopdate_utils_unittest.cc @@ -1474,6 +1474,12 @@ TEST(GoopdateUtilsTest, ReadNameValuePairsFromFileTest_ReadManyPairs) { } TEST(GoopdateUtilsTest, WriteInstallerDataToTempFile) { + CString file_path; + EXPECT_EQ(S_FALSE, WriteInstallerDataToTempFile( + CPath(_T("NonExistentDirectory")), + CString(_T("hello\n")), + &file_path)); + CStringA utf8_bom; utf8_bom.Format("%c%c%c", 0xEF, 0xBB, 0xBF); @@ -1499,12 +1505,14 @@ TEST(GoopdateUtilsTest, WriteInstallerDataToTempFile) { ASSERT_EQ(expected_installer_data.size(), list_installer_data.size()); + const CPath directory(app_util::GetCurrentModuleDirectory()); for (size_t i = 0; i < list_installer_data.size(); ++i) { CString installer_data = list_installer_data[i]; SCOPED_TRACE(installer_data.GetString()); - CString file_path; - HRESULT hr = WriteInstallerDataToTempFile(installer_data, &file_path); + HRESULT hr = WriteInstallerDataToTempFile(directory, + installer_data, + &file_path); ON_SCOPE_EXIT(::DeleteFile, file_path.GetString()); EXPECT_SUCCEEDED(hr); diff --git a/omaha/goopdate/download_manager_unittest.cc b/omaha/goopdate/download_manager_unittest.cc index f9aa39fa3..e95795e0e 100644 --- a/omaha/goopdate/download_manager_unittest.cc +++ b/omaha/goopdate/download_manager_unittest.cc @@ -1316,7 +1316,7 @@ TEST(DownloadManagerTest, GetMessageForError) { EXPECT_STREQ( _T("Unable to connect to the Internet. If you use a firewall, please ") - _T("whitelist ") MAIN_EXE_BASE_NAME _T(".exe."), + _T("allowlist ") MAIN_EXE_BASE_NAME _T(".exe."), DownloadManager::GetMessageForError( ErrorContext(GOOPDATE_E_NO_NETWORK), kEnglish)); diff --git a/omaha/goopdate/install_manager_unittest.cc b/omaha/goopdate/install_manager_unittest.cc index 2a03da608..9c662894c 100644 --- a/omaha/goopdate/install_manager_unittest.cc +++ b/omaha/goopdate/install_manager_unittest.cc @@ -440,7 +440,7 @@ TEST_F(InstallManagerInstallAppUserTest, EXPECT_EQ(POST_INSTALL_ACTION_DEFAULT, GetPostInstallAction(app_)); } -TEST_F(InstallManagerInstallAppUserTest, InstallApp_InstallerEmtpyFilename) { +TEST_F(InstallManagerInstallAppUserTest, InstallApp_InstallerEmptyFilename) { // Package asserts that the filename and file path are not NULL. ExpectAsserts expect_asserts; diff --git a/omaha/goopdate/installer_wrapper.cc b/omaha/goopdate/installer_wrapper.cc index 6356808a7..d65cb3c9c 100644 --- a/omaha/goopdate/installer_wrapper.cc +++ b/omaha/goopdate/installer_wrapper.cc @@ -13,7 +13,10 @@ // limitations under the License. // ======================================================================== +#include + #include + #include "goopdate/omaha3_idl.h" #include "omaha/goopdate/installer_wrapper.h" #include "omaha/base/const_object_names.h" @@ -272,7 +275,15 @@ HRESULT InstallerWrapper::BuildCommandLineFromFilename( // created, so Omaha does not delete it. CString enclosed_installer_data_file_path; + // We use the App Installer's directory for the InstallerData file. + CPath app_installer_directory(file_path); + if (!app_installer_directory.RemoveFileSpec()) { + OPT_LOG(LE, (_T("[Does not appear to be a filename '%s']"), file_path)); + return GOOPDATEINSTALL_E_FILENAME_INVALID; + } + VERIFY_SUCCEEDED(goopdate_utils::WriteInstallerDataToTempFile( + app_installer_directory, installer_data, &enclosed_installer_data_file_path)); if (!enclosed_installer_data_file_path.IsEmpty()) { diff --git a/omaha/goopdate/installer_wrapper_unittest.cc b/omaha/goopdate/installer_wrapper_unittest.cc index a9a619a42..dd2e3ea90 100644 --- a/omaha/goopdate/installer_wrapper_unittest.cc +++ b/omaha/goopdate/installer_wrapper_unittest.cc @@ -711,7 +711,7 @@ TEST_F(InstallerWrapperUserTest, EXPECT_EQ(POST_INSTALL_ACTION_DEFAULT, result_info_.post_install_action); } -TEST_F(InstallerWrapperUserTest, InstallApp_InstallerEmtpyFilename) { +TEST_F(InstallerWrapperUserTest, InstallApp_InstallerEmptyFilename) { EXPECT_EQ(GOOPDATEINSTALL_E_FILENAME_INVALID, iw_->InstallApp(NULL, kAppGuid, diff --git a/omaha/goopdate/resources/goopdateres/generated_resources_en.rc b/omaha/goopdate/resources/goopdateres/generated_resources_en.rc index 593db628a..e5dbbbc65 100644 Binary files a/omaha/goopdate/resources/goopdateres/generated_resources_en.rc and b/omaha/goopdate/resources/goopdateres/generated_resources_en.rc differ diff --git a/omaha/goopdate/resources/goopdateres/goopdate.grh b/omaha/goopdate/resources/goopdateres/goopdate.grh index 0fa27cd55..2fac62b93 100644 --- a/omaha/goopdate/resources/goopdateres/goopdate.grh +++ b/omaha/goopdate/resources/goopdateres/goopdate.grh @@ -1,4 +1,4 @@ -// Copyright 2007-2016 Google Inc. +// Copyright 2007-2022 Google LLC. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -13,12 +13,29 @@ // limitations under the License. // ======================================================================== // This file is automatically generated by GRIT. Do not edit. -// Built on Fri Apr 08 17:01:06 2016 -#ifndef RESOURCE_421947754731__ -#define RESOURCE_421947754731__ +#pragma once +#define IDB_ERROR_ILLUSTRATION 1000 +#define IDD_PROGRESS 2000 +#define IDC_TITLE_BAR_SPACER 2001 +#define IDC_GET_HELP 2002 +#define IDC_CLOSE 2003 +#define IDC_BUTTON1 2004 +#define IDC_BUTTON2 2005 +#define IDC_PROGRESS 2006 +#define IDC_INSTALLER_STATE_TEXT 2007 +#define IDC_INFO_TEXT 2008 +#define IDC_PAUSE_RESUME_TEXT 2009 +#define IDC_COMPLETE_TEXT 2010 +#define IDC_ERROR_TEXT 2011 +#define IDC_ERROR_ILLUSTRATION 2012 +#define IDC_APP_BITMAP 2013 +#define IDD_INSTALL_STOPPED 2014 +#define IDC_INSTALL_STOPPED_TEXT 2015 +#define IDD_YES_NO 2016 +#define IDC_YES_NO_TEXT 2017 #define IDS_FRIENDLY_COMPANY_NAME 3000 #define IDS_PRODUCT_DISPLAY_NAME 3001 #define IDS_DEFAULT_APP_DISPLAY_NAME 3002 @@ -101,24 +118,3 @@ #define IDS_BUNDLE_MIXED_RESULTS_CANCELED_APPS 3082 #define IDS_APPLICATION_NAME_CONCATENATION 3083 #define IDS_PROXY_PROMPT_MESSAGE 3084 -#define IDB_ERROR_ILLUSTRATION 1000 -#define IDD_PROGRESS 2000 -#define IDC_TITLE_BAR_SPACER 2001 -#define IDC_GET_HELP 2002 -#define IDC_CLOSE 2003 -#define IDC_BUTTON1 2004 -#define IDC_BUTTON2 2005 -#define IDC_PROGRESS 2006 -#define IDC_INSTALLER_STATE_TEXT 2008 -#define IDC_INFO_TEXT 2009 -#define IDC_PAUSE_RESUME_TEXT 2010 -#define IDC_COMPLETE_TEXT 2011 -#define IDC_ERROR_TEXT 2012 -#define IDC_ERROR_ILLUSTRATION 2013 -#define IDC_APP_BITMAP 2014 -#define IDD_INSTALL_STOPPED 2015 -#define IDC_INSTALL_STOPPED_TEXT 2017 -#define IDD_YES_NO 2018 -#define IDC_YES_NO_TEXT 2020 - -#endif // RESOURCE_421947754731__ diff --git a/omaha/goopdate/worker_utils_unittest.cc b/omaha/goopdate/worker_utils_unittest.cc index 1a280af92..37e9cb7a1 100644 --- a/omaha/goopdate/worker_utils_unittest.cc +++ b/omaha/goopdate/worker_utils_unittest.cc @@ -37,7 +37,7 @@ TEST(WorkerUtilsTest, FormatMessageForNetworkError) { &message)); EXPECT_STREQ( _T("Unable to connect to the Internet. If you use a firewall, please ") - _T("whitelist ") MAIN_EXE_BASE_NAME _T(".exe."), + _T("allowlist ") MAIN_EXE_BASE_NAME _T(".exe."), message); EXPECT_EQ(true, FormatMessageForNetworkError(GOOPDATE_E_NETWORK_UNAUTHORIZED, @@ -68,7 +68,7 @@ TEST(WorkerUtilsTest, FormatMessageForNetworkError) { EXPECT_EQ(false, FormatMessageForNetworkError(E_FAIL, kEnglish, &message)); EXPECT_STREQ( _T("Unable to connect to the Internet. If you use a firewall, please ") - _T("whitelist ") MAIN_EXE_BASE_NAME _T(".exe."), + _T("allowlist ") MAIN_EXE_BASE_NAME _T(".exe."), message); ResourceManager::Delete(); diff --git a/omaha/internal/grit/goopdateres.grd b/omaha/internal/grit/goopdateres.grd index a59bda3a1..f2855625a 100644 --- a/omaha/internal/grit/goopdateres.grd +++ b/omaha/internal/grit/goopdateres.grd @@ -189,7 +189,7 @@ - Unable to connect to the Internet. If you use a firewall, please whitelist %1!s!GoogleUpdate.exe. + Unable to connect to the Internet. If you use a firewall, please allowlist %1!s!GoogleUpdate.exe. diff --git a/omaha/main.scons b/omaha/main.scons index e34624f3d..8d06c7406 100644 --- a/omaha/main.scons +++ b/omaha/main.scons @@ -578,6 +578,8 @@ win_env.AppendUnique( '_SECURE_ATL=1', '_WTL_NO_CSTRING', # WTL uses ATL CString instead. + 'GUNIT_NO_GOOGLE3', + 'ARCH_CPU_X86_FAMILY', # For Chromium code. 'LOGGING', # Logging is enabled in all modes for diagnostics purposes. diff --git a/omaha/mi_exe_stub/mi.cc b/omaha/mi_exe_stub/mi.cc index 1c0d47334..2513581e1 100644 --- a/omaha/mi_exe_stub/mi.cc +++ b/omaha/mi_exe_stub/mi.cc @@ -335,10 +335,6 @@ class MetaInstaller { // issues with anti-malware heuristics, this function returns early and does // not try to create a directory if the user is not an admin. bool CreateProgramFilesTempDir() { - if (!::IsUserAnAdmin()) { - return false; - } - CString program_files_dir; HRESULT hr = ::SHGetFolderPath(NULL, CSIDL_PROGRAM_FILES | CSIDL_FLAG_CREATE, @@ -387,7 +383,10 @@ class MetaInstaller { // creating the directory under %ProgramFiles%, and if that fails, creates // under the user's %TMP% directory. int CreateUniqueTempDirectory() { - return CreateProgramFilesTempDir() || CreateUserTempDir() ? 0 : -1; + return (::IsUserAnAdmin() ? CreateProgramFilesTempDir() + : CreateUserTempDir()) + ? 0 + : -1; } HANDLE ExtractTarballToTempLocation() { diff --git a/omaha/net/cup_ecdsa_pubkey.12.h b/omaha/net/cup_ecdsa_pubkey.12.h new file mode 100644 index 000000000..c9a3683a1 --- /dev/null +++ b/omaha/net/cup_ecdsa_pubkey.12.h @@ -0,0 +1,31 @@ +// Copyright 2022 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ======================================================================== +// +// CUP-ECDSA public keys consist of a byte array, 66 bytes long, containing: +// * The key ID (one byte) +// * The public key in X9.62 uncompressed encoding (65 bytes): +// * Uncompressed header byte (0x04) +// * Gx coordinate (256-bit integer, big-endian) +// * Gy coordinate (256-bit integer, big-endian) +{0x0c, +0x04, +0x4c, 0x68, 0x73, 0xb8, 0x32, 0x47, 0x44, 0x5c, +0x7b, 0xff, 0xf6, 0x2a, 0xa9, 0xd6, 0x8d, 0x4d, +0x8d, 0xdd, 0x67, 0xc5, 0xfd, 0x5e, 0x15, 0x02, +0xd2, 0x8e, 0xdf, 0x99, 0x9b, 0x4e, 0x15, 0xef, +0x5c, 0x8c, 0xf3, 0x0b, 0xf4, 0xa5, 0x47, 0x3d, +0xad, 0x8c, 0xe6, 0x1c, 0x61, 0x25, 0x38, 0x48, +0x6d, 0x14, 0x0c, 0x12, 0x59, 0x2c, 0x1f, 0x2e, +0x25, 0x95, 0x9a, 0x16, 0x83, 0xa2, 0x93, 0x67}; diff --git a/omaha/net/cup_ecdsa_request.cc b/omaha/net/cup_ecdsa_request.cc index a0252e233..8f0fdab7c 100644 --- a/omaha/net/cup_ecdsa_request.cc +++ b/omaha/net/cup_ecdsa_request.cc @@ -43,7 +43,7 @@ namespace omaha { namespace internal { const uint8 CupEcdsaRequestImpl::kCupProductionPublicKey[] = -#include "omaha/net/cup_ecdsa_pubkey.11.h" +#include "omaha/net/cup_ecdsa_pubkey.12.h" ; // NOLINT const uint8 CupEcdsaRequestImpl::kCupTestPublicKey[] = diff --git a/omaha/net/cup_ecdsa_utils_unittest.cc b/omaha/net/cup_ecdsa_utils_unittest.cc index fefe5f328..16546ddbd 100644 --- a/omaha/net/cup_ecdsa_utils_unittest.cc +++ b/omaha/net/cup_ecdsa_utils_unittest.cc @@ -491,7 +491,7 @@ TEST(EcdsaPublicKey, DecodeFromBuffer_ProdKey) { EcdsaPublicKey key; uint8 kProdKey[] = -#include "omaha/net/cup_ecdsa_pubkey.11.h" +#include "omaha/net/cup_ecdsa_pubkey.12.h" ; // NOLINT key.DecodeFromBuffer(kProdKey); diff --git a/omaha/setup/setup_files.cc b/omaha/setup/setup_files.cc index ade36bac6..91653296e 100644 --- a/omaha/setup/setup_files.cc +++ b/omaha/setup/setup_files.cc @@ -271,8 +271,13 @@ HRESULT SetupFiles::ShouldCopyShell(const CString& shell_install_path, } HRESULT SetupFiles::SaveShellForRollback(const CString& shell_install_path) { + const CString temp_dir = ConfigManager::Instance()->GetTempDir(); + if (temp_dir.IsEmpty()) { + return E_UNEXPECTED; + } + // Copy existing file to a temporary file in case we need to roll back. - CString temp_file = GetTempFilename(_T("gsh")); + CString temp_file = GetTempFilenameAt(temp_dir, _T("gsh")); if (temp_file.IsEmpty()) { const DWORD error = ::GetLastError(); SETUP_LOG(LEVEL_WARNING, (_T("[::GetTempFilename failed][%d]"), error)); diff --git a/omaha/site_scons/site_tools/code_signing.py b/omaha/site_scons/site_tools/code_signing.py index 7bbf2e3be..8465c892e 100644 --- a/omaha/site_scons/site_tools/code_signing.py +++ b/omaha/site_scons/site_tools/code_signing.py @@ -109,7 +109,7 @@ def SignedBinaryGenerator(source, target, env, for_signature): # Only do signing if there is a certificate file or certificate name. if env.subst('$CERTIFICATE_PATH') or env.subst('$CERTIFICATE_NAME'): # The command used to do signing (target added on below). - signing_cmd = '$SIGNTOOL sign ' + signing_cmd = '$SIGNTOOL sign /fd sha1' # Add in certificate file if any. if env.subst('$CERTIFICATE_PATH'): signing_cmd += ' /f "$CERTIFICATE_PATH"' @@ -161,6 +161,7 @@ def DualSignedBinaryGenerator(source, target, env, for_signature): # /t http://timestamp.globalsign.com/scripts/timstamp.dll # /i "Verisign" someFile.exe sha1_signing_cmd = base_signing_cmd + sha1_signing_cmd += ' /fd sha1' # Add in certificate file if any. if env.subst('$SHA1_CERTIFICATE_PATH'): sha1_signing_cmd += ' /f "$SHA1_CERTIFICATE_PATH"' diff --git a/omaha/testing/unittest_support/SaveArguments.exe b/omaha/testing/unittest_support/SaveArguments.exe index 8f1c6b568..e4ea34fd2 100644 Binary files a/omaha/testing/unittest_support/SaveArguments.exe and b/omaha/testing/unittest_support/SaveArguments.exe differ