Commit 5eecb7ac authored by Yusuf Sengul's avatar Yusuf Sengul Committed by Commit Bot

Move saving OS user - gaia user association outside of forked process

Bug: 999020
Change-Id: If681cf59fba880b50a7f0c9e20603ad5704edc88
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1775232
Commit-Queue: Yusuf Sengul <yusufsn@google.com>
Reviewed-by: default avatarRoger Tawa <rogerta@chromium.org>
Cr-Commit-Position: refs/heads/master@{#691849}
parent d9620cbf
...@@ -1831,6 +1831,35 @@ HRESULT CGaiaCredentialBase::SaveAccountInfo(const base::Value& properties) { ...@@ -1831,6 +1831,35 @@ HRESULT CGaiaCredentialBase::SaveAccountInfo(const base::Value& properties) {
return hr; return hr;
} }
// Registers OS user - gaia user association in HKEY_LOCAL_MACHINE registry
// hive.
HRESULT RegisterAssociation(const base::string16& sid,
const base::string16& id,
const base::string16& email,
const base::string16& token_handle) {
// Save token handle. This handle will be used later to determine if the
// the user has changed their password since the account was created.
HRESULT hr = SetUserProperty(sid, kUserTokenHandle, token_handle);
if (FAILED(hr)) {
LOGFN(ERROR) << "SetUserProperty(th) hr=" << putHR(hr);
return hr;
}
hr = SetUserProperty(sid, kUserId, id);
if (FAILED(hr)) {
LOGFN(ERROR) << "SetUserProperty(id) hr=" << putHR(hr);
return hr;
}
hr = SetUserProperty(sid, kUserEmail, email);
if (FAILED(hr)) {
LOGFN(ERROR) << "SetUserProperty(email) hr=" << putHR(hr);
return hr;
}
return S_OK;
}
HRESULT CGaiaCredentialBase::ReportResult( HRESULT CGaiaCredentialBase::ReportResult(
NTSTATUS status, NTSTATUS status,
NTSTATUS substatus, NTSTATUS substatus,
...@@ -1853,12 +1882,33 @@ HRESULT CGaiaCredentialBase::ReportResult( ...@@ -1853,12 +1882,33 @@ HRESULT CGaiaCredentialBase::ReportResult(
authentication_results_->SetKey( authentication_results_->SetKey(
kKeyPassword, base::Value(base::UTF16ToUTF8((BSTR)password_))); kKeyPassword, base::Value(base::UTF16ToUTF8((BSTR)password_)));
base::string16 gaia_id = GetDictString(*authentication_results_, kKeyId);
if (gaia_id.empty()) {
LOGFN(ERROR) << "Id is empty";
return E_INVALIDARG;
}
base::string16 email = GetDictString(*authentication_results_, kKeyEmail);
if (email.empty()) {
LOGFN(ERROR) << "Email is empty";
return E_INVALIDARG;
}
// Os user - gaia user association is saved in HKEY_LOCAL_MACHINE. So, we
// can attempt saving association even before calling forked process. Forked
// process will also re-write everything saved here as well as valid token
// handle. Token handle is saved as empty here, so that if for any reason
// forked process fails to save association, it will enforce re-auth due to
// invalid token handle.
HRESULT hr = RegisterAssociation(OLE2CW(user_sid_), gaia_id, email, L"");
if (FAILED(hr))
return hr;
// At this point the user and password stored in authentication_results_ // At this point the user and password stored in authentication_results_
// should match what is stored in username_ and password_ so the // should match what is stored in username_ and password_ so the
// SaveAccountInfo process can be forked. // SaveAccountInfo process can be forked.
CComBSTR status_text; CComBSTR status_text;
HRESULT hr = hr = ForkSaveAccountInfoStub(*authentication_results_, &status_text);
ForkSaveAccountInfoStub(*authentication_results_, &status_text);
if (FAILED(hr)) if (FAILED(hr))
LOGFN(ERROR) << "ForkSaveAccountInfoStub hr=" << putHR(hr); LOGFN(ERROR) << "ForkSaveAccountInfoStub hr=" << putHR(hr);
} }
......
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