Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: remoting/host/pam_authorization_factory_posix.cc

Issue 205583011: [Draft] Fix canceling pin prompt causes host overload (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Unittests and also reject connections upon authenticating Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
11 #include "base/environment.h" 11 #include "base/environment.h"
12 #include "remoting/base/logging.h" 12 #include "remoting/base/logging.h"
13 #include "remoting/host/username.h" 13 #include "remoting/host/username.h"
14 #include "remoting/protocol/channel_authenticator.h" 14 #include "remoting/protocol/channel_authenticator.h"
15 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h" 15 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h"
16 16
17 namespace remoting { 17 namespace remoting {
18 18
19 namespace { 19 namespace {
20 class PamAuthorizer : public protocol::Authenticator { 20 class PamAuthorizer : public protocol::Authenticator {
21 public: 21 public:
22 PamAuthorizer(scoped_ptr<protocol::Authenticator> underlying); 22 PamAuthorizer(scoped_ptr<protocol::Authenticator> underlying);
23 virtual ~PamAuthorizer(); 23 virtual ~PamAuthorizer();
24 24
25 // protocol::Authenticator interface. 25 // protocol::Authenticator interface.
26 virtual State state() const OVERRIDE; 26 virtual State state() const OVERRIDE;
27 virtual bool started() const OVERRIDE;
27 virtual RejectionReason rejection_reason() const OVERRIDE; 28 virtual RejectionReason rejection_reason() const OVERRIDE;
28 virtual void ProcessMessage(const buzz::XmlElement* message, 29 virtual void ProcessMessage(const buzz::XmlElement* message,
29 const base::Closure& resume_callback) OVERRIDE; 30 const base::Closure& resume_callback) OVERRIDE;
30 virtual scoped_ptr<buzz::XmlElement> GetNextMessage() OVERRIDE; 31 virtual scoped_ptr<buzz::XmlElement> GetNextMessage() OVERRIDE;
31 virtual scoped_ptr<protocol::ChannelAuthenticator> 32 virtual scoped_ptr<protocol::ChannelAuthenticator>
32 CreateChannelAuthenticator() const OVERRIDE; 33 CreateChannelAuthenticator() const OVERRIDE;
33 34
34 private: 35 private:
35 void MaybeCheckLocalLogin(); 36 void MaybeCheckLocalLogin();
36 bool IsLocalLoginAllowed(); 37 bool IsLocalLoginAllowed();
(...skipping 18 matching lines...) Expand all
55 } 56 }
56 57
57 protocol::Authenticator::State PamAuthorizer::state() const { 58 protocol::Authenticator::State PamAuthorizer::state() const {
58 if (local_login_status_ == DISALLOWED) { 59 if (local_login_status_ == DISALLOWED) {
59 return REJECTED; 60 return REJECTED;
60 } else { 61 } else {
61 return underlying_->state(); 62 return underlying_->state();
62 } 63 }
63 } 64 }
64 65
66 bool PamAuthorizer::started() const {
67 return underlying_->started();
68 }
69
65 protocol::Authenticator::RejectionReason 70 protocol::Authenticator::RejectionReason
66 PamAuthorizer::rejection_reason() const { 71 PamAuthorizer::rejection_reason() const {
67 if (local_login_status_ == DISALLOWED) { 72 if (local_login_status_ == DISALLOWED) {
68 return INVALID_CREDENTIALS; 73 return INVALID_CREDENTIALS;
69 } else { 74 } else {
70 return underlying_->rejection_reason(); 75 return underlying_->rejection_reason();
71 } 76 }
72 } 77 }
73 78
74 void PamAuthorizer::ProcessMessage(const buzz::XmlElement* message, 79 void PamAuthorizer::ProcessMessage(const buzz::XmlElement* message,
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 const std::string& remote_jid, 170 const std::string& remote_jid,
166 const buzz::XmlElement* first_message) { 171 const buzz::XmlElement* first_message) {
167 scoped_ptr<protocol::Authenticator> authenticator( 172 scoped_ptr<protocol::Authenticator> authenticator(
168 underlying_->CreateAuthenticator(local_jid, remote_jid, first_message)); 173 underlying_->CreateAuthenticator(local_jid, remote_jid, first_message));
169 return scoped_ptr<protocol::Authenticator>( 174 return scoped_ptr<protocol::Authenticator>(
170 new PamAuthorizer(authenticator.Pass())); 175 new PamAuthorizer(authenticator.Pass()));
171 } 176 }
172 177
173 178
174 } // namespace remoting 179 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698