Commit 5c603095 authored by Bailey Berro's avatar Bailey Berro Committed by Commit Bot

Encode kerberos status in FileSystemId

- SmbService encodes whether a share was mounted with ChromAD Kerberos or
not when creating the FileSystemId string.
- Removes old ctor from FileSystemId

Bug: chromium:757625
Change-Id: I735dbc15cd4ea1eef45e81f09244dc2b91863014
Reviewed-on: https://chromium-review.googlesource.com/1093963
Commit-Queue: Bailey Berro <baileyberro@chromium.org>
Reviewed-by: default avatarZentaro Kavanagh <zentaro@chromium.org>
Cr-Commit-Position: refs/heads/master@{#569658}
parent 4a7940ba
......@@ -31,11 +31,6 @@ std::vector<std::string> GetComponents(const std::string& file_system_id) {
} // namespace.
std::string CreateFileSystemId(int32_t mount_id,
const base::FilePath& share_path) {
return CreateFileSystemId(mount_id, share_path, false /* is_kerberos */);
}
std::string CreateFileSystemId(int32_t mount_id,
const base::FilePath& share_path,
bool is_kerberos_chromad) {
......
......@@ -17,8 +17,6 @@ namespace smb_client {
std::string CreateFileSystemId(int32_t mount_id,
const base::FilePath& share_path,
bool is_kerberos_chromad);
std::string CreateFileSystemId(int32_t mount_id,
const base::FilePath& share_path);
// Returns the MountId component of a |file_system_id|. |file_system_id| must be
// well-formed (e.g. 2@@smb://192.168.1.1/testShare).
......
......@@ -106,6 +106,8 @@ void SmbService::CallMount(const file_system_provider::MountOptions& options,
std::string password;
std::string workgroup;
bool is_kerberos_chromad = false;
if (username_input.empty()) {
// If no credentials were provided and the user is ChromAD, pass the users
// username and workgroup for their email address to be used for Kerberos
......@@ -114,6 +116,7 @@ void SmbService::CallMount(const file_system_provider::MountOptions& options,
chromeos::ProfileHelper::Get()->GetUserByProfile(profile_);
if (user && user->IsActiveDirectoryUser()) {
ParseUserPrincipalName(user->GetDisplayEmail(), &username, &workgroup);
is_kerberos_chromad = true;
}
} else {
// Credentials were provided so use them and parse the username into
......@@ -137,13 +140,15 @@ void SmbService::CallMount(const file_system_provider::MountOptions& options,
mount_path, workgroup, username,
temp_file_manager_->WritePasswordToFile(password),
base::BindOnce(&SmbService::OnMountResponse, AsWeakPtr(),
base::Passed(&callback), options, share_path));
base::Passed(&callback), options, share_path,
is_kerberos_chromad));
}
void SmbService::OnMountResponse(
MountResponse callback,
const file_system_provider::MountOptions& options,
const base::FilePath& share_path,
bool is_kerberos_chromad,
smbprovider::ErrorType error,
int32_t mount_id) {
if (error != smbprovider::ERROR_OK) {
......@@ -154,7 +159,8 @@ void SmbService::OnMountResponse(
DCHECK_GE(mount_id, 0);
file_system_provider::MountOptions mount_options(options);
mount_options.file_system_id = CreateFileSystemId(mount_id, share_path);
mount_options.file_system_id =
CreateFileSystemId(mount_id, share_path, is_kerberos_chromad);
base::File::Error result =
GetProviderService()->MountFileSystem(provider_id_, mount_options);
......
......@@ -61,6 +61,7 @@ class SmbService : public KeyedService,
void OnMountResponse(MountResponse callback,
const file_system_provider::MountOptions& options,
const base::FilePath& share_path,
bool is_kerberos_chromad,
smbprovider::ErrorType error,
int32_t mount_id);
......
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