Commit 705f4e98 authored by Vladislav Kuzkokov's avatar Vladislav Kuzkokov Committed by Commit Bot

[CUPS Printing] Only allow sending username and filename to secure printers

Bug: 660612
Change-Id: Iff14d75ee912e38c10334fed5b5337de9606610a
Reviewed-on: https://chromium-review.googlesource.com/c/1446216Reviewed-by: default avatarSean Kau <skau@chromium.org>
Reviewed-by: default avatarSergey Poromov <poromov@chromium.org>
Reviewed-by: default avatarRebekah Potter <rbpotter@chromium.org>
Commit-Queue: Vladislav Kuzkokov <vkuzkokov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#629117}
parent 88733290
...@@ -128,6 +128,8 @@ class CupsPrintersManagerImpl : public CupsPrintersManager, ...@@ -128,6 +128,8 @@ class CupsPrintersManagerImpl : public CupsPrintersManager,
native_printers_allowed_.Init(prefs::kUserNativePrintersAllowed, native_printers_allowed_.Init(prefs::kUserNativePrintersAllowed,
pref_service); pref_service);
send_username_and_filename_.Init(
prefs::kPrintingSendUsernameAndFilenameEnabled, pref_service);
} }
~CupsPrintersManagerImpl() override = default; ~CupsPrintersManagerImpl() override = default;
...@@ -141,6 +143,17 @@ class CupsPrintersManagerImpl : public CupsPrintersManager, ...@@ -141,6 +143,17 @@ class CupsPrintersManagerImpl : public CupsPrintersManager,
"UserNativePrintersAllowed is set to false"; "UserNativePrintersAllowed is set to false";
return {}; return {};
} }
if (send_username_and_filename_.GetValue()) {
std::vector<Printer> result(printers_[printer_class].size());
auto it_end = std::copy_if(
printers_[printer_class].begin(), printers_[printer_class].end(),
result.begin(), [](const Printer& printer) {
return !printer.HasNetworkProtocol() ||
printer.GetProtocol() == Printer::kIpps;
});
result.resize(it_end - result.begin());
return result;
}
return printers_.at(printer_class); return printers_.at(printer_class);
} }
...@@ -556,6 +569,10 @@ class CupsPrintersManagerImpl : public CupsPrintersManager, ...@@ -556,6 +569,10 @@ class CupsPrintersManagerImpl : public CupsPrintersManager,
// Holds the current value of the pref |UserNativePrintersAllowed|. // Holds the current value of the pref |UserNativePrintersAllowed|.
BooleanPrefMember native_printers_allowed_; BooleanPrefMember native_printers_allowed_;
// Holds the current value of the pref
// |PrintingSendUsernameAndFilenameEnabled|.
BooleanPrefMember send_username_and_filename_;
base::WeakPtrFactory<CupsPrintersManagerImpl> weak_ptr_factory_; base::WeakPtrFactory<CupsPrintersManagerImpl> weak_ptr_factory_;
}; };
...@@ -599,6 +616,8 @@ void CupsPrintersManager::RegisterProfilePrefs( ...@@ -599,6 +616,8 @@ void CupsPrintersManager::RegisterProfilePrefs(
registry->RegisterBooleanPref( registry->RegisterBooleanPref(
prefs::kUserNativePrintersAllowed, true, prefs::kUserNativePrintersAllowed, true,
user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
registry->RegisterBooleanPref(prefs::kPrintingSendUsernameAndFilenameEnabled,
false);
} }
} // namespace chromeos } // namespace chromeos
...@@ -20,8 +20,6 @@ void PolicySettings::RegisterProfilePrefs( ...@@ -20,8 +20,6 @@ void PolicySettings::RegisterProfilePrefs(
registry->RegisterIntegerPref(prefs::kPrintingColorDefault, 0); registry->RegisterIntegerPref(prefs::kPrintingColorDefault, 0);
registry->RegisterIntegerPref(prefs::kPrintingDuplexDefault, 0); registry->RegisterIntegerPref(prefs::kPrintingDuplexDefault, 0);
registry->RegisterDictionaryPref(prefs::kPrintingSizeDefault); registry->RegisterDictionaryPref(prefs::kPrintingSizeDefault);
registry->RegisterBooleanPref(prefs::kPrintingSendUsernameAndFilenameEnabled,
false);
#endif #endif
} }
......
...@@ -2071,7 +2071,9 @@ ...@@ -2071,7 +2071,9 @@
'id': 506, 'id': 506,
'caption': '''Send username and filename to native printers''', 'caption': '''Send username and filename to native printers''',
'tags': [], 'tags': [],
'desc': '''Send username and filename to native printers server with every print job. The default is not to send.''', 'desc': '''Send username and filename to native printers server with every print job. The default is not to send.
Setting this policy to true also disables printers that use protocols other than IPPS, USB, or IPP-over-USB since username and filename shouldn't be sent over the network openly.''',
}, },
{ {
'name': 'ForceSafeSearch', 'name': 'ForceSafeSearch',
......
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