Commit 6a70a9de authored by Bailey Berro's avatar Bailey Berro Committed by Commit Bot

Setup Kerberos in SmbService

This change updates the SmbService setup flow so that setup is not run
when SmbService is created on the LockScreen and adds a call to
SetupKerberos for ChromAD users.

Bug: chromium:757625
Test: verified on local ActivceDirectory test network
Change-Id: I36ca8f48368be33e740ee1128e8cc5cc23ca8e5d
Reviewed-on: https://chromium-review.googlesource.com/1045130Reviewed-by: default avatarZentaro Kavanagh <zentaro@chromium.org>
Commit-Queue: Bailey Berro <baileyberro@chromium.org>
Cr-Commit-Position: refs/heads/master@{#557193}
parent c3deb300
......@@ -8,11 +8,11 @@
#include "base/files/file_path.h"
#include "base/task_scheduler/post_task.h"
#include "chrome/browser/chromeos/file_system_provider/provided_file_system_info.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/chromeos/smb_client/smb_file_system.h"
#include "chrome/browser/chromeos/smb_client/smb_file_system_id.h"
#include "chrome/browser/chromeos/smb_client/smb_provider.h"
#include "chrome/browser/chromeos/smb_client/smb_service_factory.h"
#include "chrome/browser/chromeos/smb_client/temp_file_manager.h"
#include "chrome/common/chrome_features.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/smb_provider_client.h"
......@@ -25,9 +25,7 @@ namespace smb_client {
SmbService::SmbService(Profile* profile)
: provider_id_(ProviderId::CreateFromNativeId("smb")), profile_(profile) {
if (base::FeatureList::IsEnabled(features::kNativeSmb)) {
GetProviderService()->RegisterProvider(std::make_unique<SmbProvider>(
base::BindRepeating(&SmbService::Unmount, base::Unretained(this))));
RestoreMounts();
StartSetup();
}
}
......@@ -150,5 +148,42 @@ void SmbService::InitTempFileManager() {
temp_file_manager_ = std::make_unique<TempFileManager>();
}
void SmbService::StartSetup() {
user_manager::User* user =
chromeos::ProfileHelper::Get()->GetUserByProfile(profile_);
if (!user) {
// An instance of SmbService is created on the lockscreen. When this
// instance is created, no setup will run.
return;
}
if (user->IsActiveDirectoryUser()) {
auto account_id = user->GetAccountId();
const std::string account_id_guid = account_id.GetObjGuid();
GetSmbProviderClient()->SetupKerberos(
account_id_guid,
base::BindOnce(&SmbService::OnSetupKerberosResponse, AsWeakPtr()));
return;
}
CompleteSetup();
}
void SmbService::OnSetupKerberosResponse(bool success) {
if (!success) {
LOG(ERROR) << "SmbService: Kerberos setup failed.";
}
CompleteSetup();
}
void SmbService::CompleteSetup() {
GetProviderService()->RegisterProvider(std::make_unique<SmbProvider>(
base::BindRepeating(&SmbService::Unmount, base::Unretained(this))));
RestoreMounts();
}
} // namespace smb_client
} // namespace chromeos
......@@ -98,6 +98,15 @@ class SmbService : public KeyedService,
void OnRemountResponse(const std::string& file_system_id,
smbprovider::ErrorType error);
// Sets up SmbService, including setting up Keberos if the user is ChromAD.
void StartSetup();
// Completes SmbService setup. Called by StartSetup().
void CompleteSetup();
// Handles the response from attempting to setup Kerberos.
void OnSetupKerberosResponse(bool success);
const ProviderId provider_id_;
Profile* profile_;
std::unique_ptr<TempFileManager> temp_file_manager_;
......
......@@ -4,6 +4,7 @@
#include "chrome/browser/chromeos/smb_client/smb_service_factory.h"
#include "chrome/browser/chromeos/authpolicy/auth_policy_credentials_manager.h"
#include "chrome/browser/chromeos/file_system_provider/service_factory.h"
#include "chrome/browser/chromeos/smb_client/smb_service.h"
#include "chrome/browser/profiles/incognito_helpers.h"
......@@ -31,6 +32,7 @@ SmbServiceFactory::SmbServiceFactory()
"SmbService",
BrowserContextDependencyManager::GetInstance()) {
DependsOn(file_system_provider::ServiceFactory::GetInstance());
DependsOn(AuthPolicyCredentialsManagerFactory::GetInstance());
}
SmbServiceFactory::~SmbServiceFactory() {}
......
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