Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add brave disable-machine-id and disable-encryption-win switches #795

Merged
merged 1 commit into from
Jan 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions chromium_src/components/metrics/machine_id_provider_win.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include "base/command_line.h"
#include "brave/common/brave_switches.h"

// switches::kDisableMachineId
const char kDisableMachineId[] = "disable-machine-id";
crazy-max marked this conversation as resolved.
Show resolved Hide resolved

namespace {
bool IsMachineIdDisabled() {
return base::CommandLine::ForCurrentProcess()->HasSwitch(kDisableMachineId);
}

} // namespace
#include "../../../../components/metrics/machine_id_provider_win.cc"
17 changes: 17 additions & 0 deletions chromium_src/components/os_crypt/os_crypt_win.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include "base/command_line.h"
#include "brave/common/brave_switches.h"

// switches::kDisableEncryptionWin
const char kDisableEncryptionWin[] = "disable-encryption-win";

namespace {
bool IsEncryptionDisabled(const std::string& input_text, std::string* output_text) {
if (base::CommandLine::ForCurrentProcess()->HasSwitch(kDisableEncryptionWin)) {
*output_text = input_text;
return true;
}
return false;
}

} // namespace
#include "../../../../components/os_crypt/os_crypt_win.cc"
13 changes: 13 additions & 0 deletions chromium_src/services/preferences/tracked/device_id_win.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include "base/command_line.h"
#include "brave/common/brave_switches.h"

// switches::kDisableMachineId
const char kDisableMachineId[] = "disable-machine-id";

namespace {
bool IsMachineIdDisabled() {
return base::CommandLine::ForCurrentProcess()->HasSwitch(kDisableMachineId);
}

} // namespace
#include "../../../../../services/preferences/tracked/device_id_win.cc"
8 changes: 8 additions & 0 deletions common/brave_switches.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,12 @@ const char kUiMode[] = "ui-mode";
// available.
const char kUpgradeFromMuon[] = "upgrade-from-muon";

// Allows disabling the machine ID generation on Windows.
const char kDisableMachineId[] = "disable-machine-id";
crazy-max marked this conversation as resolved.
Show resolved Hide resolved

// Allows disabling encryption on Windows for cookies, passwords, settings...
// WARNING! Use ONLY if your hard drive is encrypted or if you know
// what you are doing.
const char kDisableEncryptionWin[] = "disable-encryption-win";

} // namespace switches
4 changes: 4 additions & 0 deletions common/brave_switches.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ extern const char kUiMode[];

extern const char kUpgradeFromMuon[];

extern const char kDisableMachineId[];

extern const char kDisableEncryptionWin[];

} // namespace switches

#endif // BRAVE_COMMON_BRAVE_SWITCHES_H_
13 changes: 13 additions & 0 deletions patches/components-metrics-machine_id_provider_win.cc.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/components/metrics/machine_id_provider_win.cc b/components/metrics/machine_id_provider_win.cc
index eb7b0d7e8fde..1618ba826821 100644
--- a/components/metrics/machine_id_provider_win.cc
+++ b/components/metrics/machine_id_provider_win.cc
@@ -18,7 +18,7 @@ namespace metrics {

// static
bool MachineIdProvider::HasId() {
- return true;
+ return !IsMachineIdDisabled();
}

// On windows, the machine id is based on the serial number of the drive Chrome
20 changes: 20 additions & 0 deletions patches/components-os_crypt-os_crypt_win.cc.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
diff --git a/components/os_crypt/os_crypt_win.cc b/components/os_crypt/os_crypt_win.cc
index 792233d4405f..1fb45bb390db 100644
--- a/components/os_crypt/os_crypt_win.cc
+++ b/components/os_crypt/os_crypt_win.cc
@@ -26,6 +26,7 @@ bool OSCrypt::DecryptString16(const std::string& ciphertext,

bool OSCrypt::EncryptString(const std::string& plaintext,
std::string* ciphertext) {
+ if (IsEncryptionDisabled(plaintext, ciphertext)) { return true; }
DATA_BLOB input;
input.pbData = const_cast<BYTE*>(
reinterpret_cast<const BYTE*>(plaintext.data()));
@@ -49,6 +50,7 @@ bool OSCrypt::EncryptString(const std::string& plaintext,

bool OSCrypt::DecryptString(const std::string& ciphertext,
std::string* plaintext) {
+ if (IsEncryptionDisabled(ciphertext, plaintext)) { return true; }
DATA_BLOB input;
input.pbData = const_cast<BYTE*>(
reinterpret_cast<const BYTE*>(ciphertext.data()));
12 changes: 12 additions & 0 deletions patches/services-preferences-tracked-device_id_win.cc.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/services/preferences/tracked/device_id_win.cc b/services/preferences/tracked/device_id_win.cc
index 9dbd110674a9..26d8e68ce746 100644
--- a/services/preferences/tracked/device_id_win.cc
+++ b/services/preferences/tracked/device_id_win.cc
@@ -15,6 +15,7 @@

MachineIdStatus GetDeterministicMachineSpecificId(std::string* machine_id) {
DCHECK(machine_id);
+ if (IsMachineIdDisabled()) { return MachineIdStatus::NOT_IMPLEMENTED; }

wchar_t computer_name[MAX_COMPUTERNAME_LENGTH + 1] = {};
DWORD computer_name_size = arraysize(computer_name);