| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "remoting/host/pam_authorization_factory_posix.h" | 5 #include "remoting/host/pam_authorization_factory_posix.h" |
| 6 | 6 |
| 7 #include <security/pam_appl.h> | 7 #include <security/pam_appl.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 void OnMessageProcessed(const base::Closure& resume_callback); | 39 void OnMessageProcessed(const base::Closure& resume_callback); |
| 40 | 40 |
| 41 static int PamConversation(int num_messages, | 41 static int PamConversation(int num_messages, |
| 42 const struct pam_message** messages, | 42 const struct pam_message** messages, |
| 43 struct pam_response** responses, | 43 struct pam_response** responses, |
| 44 void* context); | 44 void* context); |
| 45 | 45 |
| 46 scoped_ptr<protocol::Authenticator> underlying_; | 46 scoped_ptr<protocol::Authenticator> underlying_; |
| 47 enum { NOT_CHECKED, ALLOWED, DISALLOWED } local_login_status_; | 47 enum { NOT_CHECKED, ALLOWED, DISALLOWED } local_login_status_; |
| 48 }; | 48 }; |
| 49 |
| 49 } // namespace | 50 } // namespace |
| 50 | 51 |
| 51 PamAuthorizer::PamAuthorizer(scoped_ptr<protocol::Authenticator> underlying) | 52 PamAuthorizer::PamAuthorizer(scoped_ptr<protocol::Authenticator> underlying) |
| 52 : underlying_(underlying.Pass()), | 53 : underlying_(std::move(underlying)), local_login_status_(NOT_CHECKED) {} |
| 53 local_login_status_(NOT_CHECKED) { | |
| 54 } | |
| 55 | 54 |
| 56 PamAuthorizer::~PamAuthorizer() { | 55 PamAuthorizer::~PamAuthorizer() {} |
| 57 } | |
| 58 | 56 |
| 59 protocol::Authenticator::State PamAuthorizer::state() const { | 57 protocol::Authenticator::State PamAuthorizer::state() const { |
| 60 if (local_login_status_ == DISALLOWED) { | 58 if (local_login_status_ == DISALLOWED) { |
| 61 return REJECTED; | 59 return REJECTED; |
| 62 } else { | 60 } else { |
| 63 return underlying_->state(); | 61 return underlying_->state(); |
| 64 } | 62 } |
| 65 } | 63 } |
| 66 | 64 |
| 67 bool PamAuthorizer::started() const { | 65 bool PamAuthorizer::started() const { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 86 } | 84 } |
| 87 | 85 |
| 88 void PamAuthorizer::OnMessageProcessed(const base::Closure& resume_callback) { | 86 void PamAuthorizer::OnMessageProcessed(const base::Closure& resume_callback) { |
| 89 MaybeCheckLocalLogin(); | 87 MaybeCheckLocalLogin(); |
| 90 resume_callback.Run(); | 88 resume_callback.Run(); |
| 91 } | 89 } |
| 92 | 90 |
| 93 scoped_ptr<buzz::XmlElement> PamAuthorizer::GetNextMessage() { | 91 scoped_ptr<buzz::XmlElement> PamAuthorizer::GetNextMessage() { |
| 94 scoped_ptr<buzz::XmlElement> result(underlying_->GetNextMessage()); | 92 scoped_ptr<buzz::XmlElement> result(underlying_->GetNextMessage()); |
| 95 MaybeCheckLocalLogin(); | 93 MaybeCheckLocalLogin(); |
| 96 return result.Pass(); | 94 return result; |
| 97 } | 95 } |
| 98 | 96 |
| 99 const std::string& PamAuthorizer::GetAuthKey() const { | 97 const std::string& PamAuthorizer::GetAuthKey() const { |
| 100 return underlying_->GetAuthKey(); | 98 return underlying_->GetAuthKey(); |
| 101 } | 99 } |
| 102 | 100 |
| 103 scoped_ptr<protocol::ChannelAuthenticator> | 101 scoped_ptr<protocol::ChannelAuthenticator> |
| 104 PamAuthorizer::CreateChannelAuthenticator() const { | 102 PamAuthorizer::CreateChannelAuthenticator() const { |
| 105 return underlying_->CreateChannelAuthenticator(); | 103 return underlying_->CreateChannelAuthenticator(); |
| 106 } | 104 } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 HOST_LOG << "PAM conversation message: " << message->msg; | 151 HOST_LOG << "PAM conversation message: " << message->msg; |
| 154 break; | 152 break; |
| 155 default: | 153 default: |
| 156 LOG(FATAL) << "Unexpected PAM conversation response required: " | 154 LOG(FATAL) << "Unexpected PAM conversation response required: " |
| 157 << message->msg << "; msg_style = " << message->msg_style; | 155 << message->msg << "; msg_style = " << message->msg_style; |
| 158 } | 156 } |
| 159 } | 157 } |
| 160 return PAM_SUCCESS; | 158 return PAM_SUCCESS; |
| 161 } | 159 } |
| 162 | 160 |
| 163 | |
| 164 PamAuthorizationFactory::PamAuthorizationFactory( | 161 PamAuthorizationFactory::PamAuthorizationFactory( |
| 165 scoped_ptr<protocol::AuthenticatorFactory> underlying) | 162 scoped_ptr<protocol::AuthenticatorFactory> underlying) |
| 166 : underlying_(underlying.Pass()) { | 163 : underlying_(std::move(underlying)) {} |
| 167 } | |
| 168 | 164 |
| 169 PamAuthorizationFactory::~PamAuthorizationFactory() { | 165 PamAuthorizationFactory::~PamAuthorizationFactory() {} |
| 170 } | |
| 171 | 166 |
| 172 scoped_ptr<protocol::Authenticator> | 167 scoped_ptr<protocol::Authenticator> |
| 173 PamAuthorizationFactory::CreateAuthenticator( | 168 PamAuthorizationFactory::CreateAuthenticator( |
| 174 const std::string& local_jid, | 169 const std::string& local_jid, |
| 175 const std::string& remote_jid, | 170 const std::string& remote_jid, |
| 176 const buzz::XmlElement* first_message) { | 171 const buzz::XmlElement* first_message) { |
| 177 scoped_ptr<protocol::Authenticator> authenticator( | 172 scoped_ptr<protocol::Authenticator> authenticator( |
| 178 underlying_->CreateAuthenticator(local_jid, remote_jid, first_message)); | 173 underlying_->CreateAuthenticator(local_jid, remote_jid, first_message)); |
| 179 return make_scoped_ptr(new PamAuthorizer(authenticator.Pass())); | 174 return make_scoped_ptr(new PamAuthorizer(std::move(authenticator))); |
| 180 } | 175 } |
| 181 | 176 |
| 182 | |
| 183 } // namespace remoting | 177 } // namespace remoting |
| OLD | NEW |