Commit 89581bf3 authored by Yusuf Sengul's avatar Yusuf Sengul Committed by Commit Bot

Add packaging and installation of gcpw extension

Adding an empty process that is built and installed along with GCPW.
gcpw_extension.exe process is meant to be a service process that is
installed by gcp_setup.exe.

In this change;

An empty process with basic initialization is created
Self extracting module script is modified to include gcpw_extension.exe
Adds another event category called "GCPW Extension Events"

Bug: 1101590
Change-Id: I39f0e73d266c5328b4c18d348003a9109a55fe78
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2278588Reviewed-by: default avatarRakesh Soma <rakeshsoma@google.com>
Reviewed-by: default avatarNico Weber <thakis@chromium.org>
Commit-Queue: Yusuf Sengul <yusufsn@google.com>
Cr-Commit-Position: refs/heads/master@{#789533}
parent 1cff1c20
......@@ -15,8 +15,15 @@ action("gcp_installer") {
rebase_path(target_gen_dir, root_build_dir),
]
if (is_debug) {
args += [ "debug" ]
} else {
args += [ "release" ]
}
deps = [
"//chrome/credential_provider/eventlog:gcp_eventlog_provider",
"//chrome/credential_provider/extension:gcpw_extension",
"//chrome/credential_provider/gaiacp:gaia1_0",
"//chrome/credential_provider/setup:gcp_setup",
"//chrome/credential_provider/setup:gcp_sfx",
......
......@@ -61,6 +61,38 @@ def GetLZMAExec(src_path):
return (os.path.join(src_path, r'third_party\lzma_sdk\7zr.exe')
if sys.platform == 'win32' else '7zr')
def GetCmdLine(command, sz_fn, gcp_7z_fn):
"""Builds the command line for the given archive.
Args:
command: 7Zip command such as 'u', 'rn'..
sz_fn: The executable command to run 7zip.
gcp_7z_fn: 7zip file for the archive.
Returns:
Returns the command line for the provided command and 7zip archive. Command
needs to be one of the supported 7zip commands.
"""
return [
sz_fn, # Path to 7z executable.
command,
# The follow options are equivalent to -mx9 with bcj2 turned on.
# Because //third_party/lzma_sdk is only partial copy of the ful sdk
# it does not support all forms of compression. Make sure to use
# compression that is compatible. These same options are used when
# building the chrome install compressed files.
'-m0=BCJ2',
'-m1=LZMA:d27:fb128',
'-m2=LZMA:d22:fb128:mf=bt2',
'-m3=LZMA:d22:fb128:mf=bt2',
'-mb0:1',
'-mb0s1:2',
'-mb0s2:3',
# Full path to archive.
gcp_7z_fn,
]
def main():
parser = argparse.ArgumentParser(
......@@ -70,6 +102,8 @@ def main():
help='Path to the credential provider directory')
parser.add_argument('root_build_path', help='$root_build_dir GN variable')
parser.add_argument('target_gen_path', help='$target_gen_dir GN variable')
parser.add_argument('is_debug', help='$target_gen_dir GN variable')
args = parser.parse_args()
# Make sure all arguments are converted to absolute paths for use below.
......@@ -92,43 +126,51 @@ def main():
sfx_fn = os.path.join(args.root_build_path, 'gcp_sfx.exe')
# Build the command line for updating files in the GCP 7z archive.
cmd = [
sz_fn, # Path to 7z executable.
'u', # Update file in archive.
u_cmd = GetCmdLine('u', sz_fn, gcp_7z_fn)
# The follow options are equivalent to -mx9 with bcj2 turned on.
# Because //third_party/lzma_sdk is only partial copy of the ful sdk
# it does not support all forms of compression. Make sure to use
# compression that is compatible. These same options are used when
# building the chrome install compressed files.
'-m0=BCJ2',
'-m1=LZMA:d27:fb128',
'-m2=LZMA:d22:fb128:mf=bt2',
'-m3=LZMA:d22:fb128:mf=bt2',
'-mb0:1',
'-mb0s1:2',
'-mb0s2:3',
# 7Zip CLI doesn't provide a direct way of adding files into a custom
# folder. As suggested by the developer of 7Zip the method is to rename
# a file with a specific subfolder to achieve the same.
# https://sourceforge.net/p/sevenzip/discussion/45798/thread/5856d980/
# For instance, if there is a file called "a.txt" in the parent folder of
# archive, when it is renamed with "f\a.txt", the "a.txt" file is actually
# placed in a folder called "f".
rn_cmd = GetCmdLine('rn', sz_fn, gcp_7z_fn)
# Full path to archive.
gcp_7z_fn,
]
# Builds the command line for deleting files in the archive.
d_cmd = GetCmdLine('d', sz_fn, gcp_7z_fn)
# Because of the way that 7zS2.sfx determine what program to run after
# extraction, only gcp_setup.exe should be placed in the root of the archive.
# Other "executable" type files (bat, cmd, exe, inf, msi, html, htm) should
# be located only in subfolders.
# be located only in subfolders. That's why all the files initially added in
# the top folder. Then the ones need to move to subfolders are renamed. 7z
# doesn't have a method to achieve the same directly.
# Add the credential provider dll and setup programs to the archive.
# If the files added to the archive are changed, make sure to update the
# kFilenames array in setup_lib.cc.
# Add the credential provider dll, credential provider extension and setup
# programs to the archive. If the files added to the archive are changed,
# make sure to update the kFilenames array in setup_lib.cc.
# 7zip and copy commands don't have a "silent" mode, so redirecting stdout
# and stderr to nul.
with open(os.devnull) as nul_file:
os.chdir(args.root_build_path)
subprocess.check_call(cmd + ['gaia1_0.dll'], stdout=nul_file)
subprocess.check_call(cmd + ['gcp_setup.exe'], stdout=nul_file)
subprocess.check_call(cmd + ['gcp_eventlog_provider.dll'], stdout=nul_file)
subprocess.check_call(d_cmd + ['*'], stdout=nul_file)
subprocess.check_call(u_cmd + ['gaia1_0.dll'], stdout=nul_file)
subprocess.check_call(u_cmd + ['gcp_setup.exe'], stdout=nul_file)
subprocess.check_call(u_cmd + ['gcp_eventlog_provider.dll'],
stdout=nul_file)
# GCPW extension is added into gcp_installer.exe only in debug builds to
# avoid increasing binary size until the feature is shipped.
if args.is_debug == 'debug':
with open(os.devnull) as nul_file:
subprocess.check_call(u_cmd + ['gcpw_extension.exe'], stdout=nul_file)
# Move the executable into a subfolder as there needs to be only one
# executable in the parent folder.
subprocess.check_call(rn_cmd +
['gcpw_extension.exe', 'extension\gcpw_extension.exe'],
stdout=nul_file)
# Combine the SFX module with the archive to make a self extracting
# executable.
......
B;// Copyright 2020 The Chromium Authors. All rights reserved.
......
# Copyright 2020 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/config/allocator.gni")
import("//build/config/clang/clang.gni")
import("//build/config/compiler/compiler.gni")
import("//build/config/dcheck_always_on.gni")
import("//build/nocompile.gni")
import("//chrome/process_version_rc_template.gni")
import("//testing/libfuzzer/fuzzer_test.gni")
import("//testing/test.gni")
import("//tools/grit/grit_rule.gni")
process_version_rc_template("version") {
template_file = "extension.rc.version"
output = "$root_out_dir/extension_version.rc"
}
grit("extension_resources") {
source = "extension_resources.grd"
inputs = [ "extension_icon.ico" ]
outputs = [
"grit/extension_resources.h",
"grit/extension_resources.rc",
]
resource_ids = ""
grit_flags = [
"-E",
"root_gen_dir=" + rebase_path(root_gen_dir, root_build_dir),
]
}
executable("gcpw_extension") {
sources = [ "extension_main.cc" ]
deps = [
":extension_resources",
":version",
"../eventlog:gcp_eventlog_messages",
"../gaiacp:common",
"//base",
"//components/crash/core/app:crash_export_thunks",
"//components/crash/core/app:run_as_crashpad_handler",
]
configs += [ "//build/config/win:windowed" ]
}
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Use the ordinal 1 here, to avoid needing to #include a header file
// to use the VS_VERSION_INFO macro. This header file changes with different
// SDK versions which causes headaches building in some environments. The
// VERSIONINFO resource will always be at index 1.
1 VERSIONINFO
FILEVERSION @MAJOR@,@MINOR@,@BUILD@,@PATCH@
PRODUCTVERSION @MAJOR@,@MINOR@,@BUILD@,@PATCH@
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "CompanyName", "@COMPANY_FULLNAME@"
VALUE "FileDescription", "Google Credential Provider for Windows Extension"
VALUE "FileVersion", "@MAJOR@.@MINOR@.@BUILD@.@PATCH@"
VALUE "InternalName", "gcpw_extension"
VALUE "LegalCopyright", "@COPYRIGHT@"
VALUE "ProductName", "Google Credential Provider for Windows Extension"
VALUE "ProductVersion", "@MAJOR@.@MINOR@.@BUILD@.@PATCH@"
VALUE "CompanyShortName", "@COMPANY_SHORTNAME@"
VALUE "ProductShortName", "GCPW Extension"
VALUE "LastChange", "@LASTCHANGE@"
VALUE "Official Build", "@OFFICIAL_BUILD@"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
\ No newline at end of file
// Copyright (c) 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "windows.h"
#include "base/at_exit.h"
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/logging.h"
#include "base/process/memory.h"
#include "base/win/process_startup_helper.h"
#include "chrome/credential_provider/eventlog/gcp_eventlog_messages.h"
#include "chrome/credential_provider/gaiacp/logging.h"
int APIENTRY wWinMain(HINSTANCE hInstance,
HINSTANCE /*hPrevInstance*/,
wchar_t* lpCmdLine,
int /*nCmdShow*/) {
base::AtExitManager exit_manager;
base::CommandLine::Init(0, nullptr);
base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess();
// Initialize logging.
logging::LoggingSettings settings;
settings.logging_dest = logging::LOG_NONE;
// See if the log file path was specified on the command line.
base::FilePath log_file_path = cmdline->GetSwitchValuePath("log-file");
if (!log_file_path.empty()) {
settings.logging_dest = logging::LOG_TO_FILE;
settings.log_file_path = log_file_path.value().c_str();
}
logging::InitLogging(settings);
logging::SetLogItems(true, // Enable process id.
true, // Enable thread id.
true, // Enable timestamp.
false); // Enable tickcount.
// Make sure the process exits cleanly on unexpected errors.
base::EnableTerminationOnHeapCorruption();
base::EnableTerminationOnOutOfMemory();
base::win::RegisterInvalidParamHandler();
base::win::SetupCRT(*base::CommandLine::ForCurrentProcess());
// Set the event logging source and category for GCPW Extension.
logging::SetEventSource("GCPW", GCPW_EXTENSION_CATEGORY, MSG_LOG_MESSAGE);
LOGFN(VERBOSE) << "GCPW Extension started running.";
return 0;
}
<?xml version="1.0" encoding="UTF-8"?>
<grit current_release="1" latest_public_release="0">
<outputs>
<output filename="grit/extension_resources.h" type="rc_header">
<emit emit_type='prepend'></emit>
</output>
<output filename="grit/extension_resources.rc" type="rc_all" />
</outputs>
<translations/>
<release seq="1">
<includes>
<include name="IDI_GCP_ICON"
file="extension_icon.ico"
type="ICON" />
</includes>
</release>
</grit>
\ No newline at end of file
// Copyright 2018 The Chromium Authors. All rights reserved.
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
......@@ -55,6 +55,15 @@
//
#define GCPW_CATEGORY ((WORD)0x00000001L)
//
// MessageId: GCPW_EXTENSION_CATEGORY
//
// MessageText:
//
// GCPW Extension Events
//
#define GCPW_EXTENSION_CATEGORY ((WORD)0x00000002L)
//
// MessageId: MSG_LOG_MESSAGE
//
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment