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

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

Issue 6484002: Authenticate user/password with PAM in BeginSessionRequest() (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Fixes for review comments Created 9 years, 10 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "base/task.h" 5 #include "base/task.h"
6 #include "remoting/host/chromoting_host.h" 6 #include "remoting/host/chromoting_host.h"
7 #include "remoting/host/host_stub_fake.h" 7 #include "remoting/host/host_stub_fake.h"
8 #include "remoting/proto/auth.pb.h" 8 #include "remoting/proto/auth.pb.h"
9 #include "remoting/protocol/client_stub.h" 9 #include "remoting/protocol/client_stub.h"
10 #include "remoting/protocol/connection_to_client.h" 10 #include "remoting/protocol/connection_to_client.h"
11 11
12 #if defined(OS_LINUX)
13 #include "remoting/host/user_auth_pam.h"
14 #endif
15
12 namespace remoting { 16 namespace remoting {
13 17
14 HostStubFake::HostStubFake(ChromotingHost* host) 18 HostStubFake::HostStubFake(ChromotingHost* host)
15 : host_(host) { 19 : host_(host) {
16 } 20 }
17 21
18 void HostStubFake::SuggestResolution( 22 void HostStubFake::SuggestResolution(
19 const protocol::SuggestResolutionRequest* msg, Task* done) { 23 const protocol::SuggestResolutionRequest* msg, Task* done) {
20 done->Run(); 24 done->Run();
21 delete done; 25 delete done;
22 } 26 }
23 27
24 void HostStubFake::BeginSessionRequest( 28 void HostStubFake::BeginSessionRequest(
25 const protocol::LocalLoginCredentials* credentials, Task* done) { 29 const protocol::LocalLoginCredentials* credentials, Task* done) {
30 protocol::LocalLoginStatus* status = new protocol::LocalLoginStatus();
31 bool success = false;
32 switch (credentials->type()) {
33 case protocol::PASSWORD:
34 #if defined(OS_LINUX)
35 success = UserAuthPam().Authenticate(credentials->username(),
36 credentials->credential());
37 #else
38 // TODO(lambroslambrou): Implement on other platforms.
39 success = true;
40 #endif // defined(OS_LINUX)
41 break;
42 default:
43 break;
44 }
45 status->set_success(success);
46 host_->connection_to_client()->client_stub()->BeginSessionResponse(
47 status, new DeleteTask<protocol::LocalLoginStatus>(status));
48 if (success) {
49 host_->LocalLoginSucceeded();
50 } else {
51 LOG(ERROR) << "Login failed for user " << credentials->username();
52 }
26 done->Run(); 53 done->Run();
27 delete done; 54 delete done;
28
29 protocol::LocalLoginStatus* status = new protocol::LocalLoginStatus();
30 status->set_success(true);
31 host_->connection_to_client()->client_stub()->BeginSessionResponse(
32 status, new DeleteTask<protocol::LocalLoginStatus>(status));
33 host_->LocalLoginSucceeded();
34 } 55 }
35 56
36 } // namespace remoting 57 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698