Commit 1c0816a5 authored by Steven Bennetts's avatar Steven Bennetts Committed by Commit Bot

CrOS: Do not set an empty policy hostname

This is in preparation for adding UI to allow users
to set a custom DHCP hostname. Currently the policy
code is always setting the hostname, even if
kDeviceHostnameTemplate is not set by policy,
which overrides any other custom set hostname.

Bug: 1103272
Change-Id: Ia99ee58c59ae1f38e8fe10ed693997dead861c4b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2320991
Commit-Queue: Steven Bennetts <stevenjb@chromium.org>
Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Reviewed-by: default avatarOmar Morsi <omorsi@google.com>
Reviewed-by: default avatarDenis Kuznetsov [CET] <antrim@chromium.org>
Reviewed-by: default avatarRoman Sorokin [CET] <rsorokin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#799393}
parent 64f8e172
......@@ -119,8 +119,12 @@ void HostnameHandler::OnDeviceHostnamePropertyChanged() {
void HostnameHandler::
OnDeviceHostnamePropertyChangedAndMachineStatisticsLoaded() {
std::string hostname_template;
cros_settings_->GetString(chromeos::kDeviceHostnameTemplate,
&hostname_template);
if (!cros_settings_->GetString(chromeos::kDeviceHostnameTemplate,
&hostname_template)) {
// Do not set an empty hostname (which would overwrite any custom hostname
// set) if DeviceHostnameTemplate is not specified by policy.
return;
}
const std::string serial = chromeos::system::StatisticsProvider::GetInstance()
->GetEnterpriseMachineID();
......
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