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

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

Issue 13312005: Don't use $USER for Local Login check (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix comment Created 7 years, 8 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
« no previous file with comments | « remoting/host/pam_authorization_factory_posix.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // This file implements a standalone host process for Me2Me. 5 // This file implements a standalone host process for Me2Me.
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/at_exit.h" 9 #include "base/at_exit.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 16 matching lines...) Expand all
27 #include "crypto/nss_util.h" 27 #include "crypto/nss_util.h"
28 #include "ipc/ipc_channel.h" 28 #include "ipc/ipc_channel.h"
29 #include "ipc/ipc_channel_proxy.h" 29 #include "ipc/ipc_channel_proxy.h"
30 #include "ipc/ipc_listener.h" 30 #include "ipc/ipc_listener.h"
31 #include "net/base/network_change_notifier.h" 31 #include "net/base/network_change_notifier.h"
32 #include "net/socket/ssl_server_socket.h" 32 #include "net/socket/ssl_server_socket.h"
33 #include "net/url_request/url_fetcher.h" 33 #include "net/url_request/url_fetcher.h"
34 #include "remoting/base/auto_thread_task_runner.h" 34 #include "remoting/base/auto_thread_task_runner.h"
35 #include "remoting/base/breakpad.h" 35 #include "remoting/base/breakpad.h"
36 #include "remoting/base/constants.h" 36 #include "remoting/base/constants.h"
37 #include "remoting/base/util.h"
37 #include "remoting/host/branding.h" 38 #include "remoting/host/branding.h"
38 #include "remoting/host/chromoting_host.h" 39 #include "remoting/host/chromoting_host.h"
39 #include "remoting/host/chromoting_host_context.h" 40 #include "remoting/host/chromoting_host_context.h"
40 #include "remoting/host/chromoting_messages.h" 41 #include "remoting/host/chromoting_messages.h"
41 #include "remoting/host/config_file_watcher.h" 42 #include "remoting/host/config_file_watcher.h"
42 #include "remoting/host/curtain_mode.h" 43 #include "remoting/host/curtain_mode.h"
43 #include "remoting/host/curtaining_host_observer.h" 44 #include "remoting/host/curtaining_host_observer.h"
44 #include "remoting/host/desktop_environment.h" 45 #include "remoting/host/desktop_environment.h"
45 #include "remoting/host/desktop_session_connector.h" 46 #include "remoting/host/desktop_session_connector.h"
46 #include "remoting/host/dns_blackhole_checker.h" 47 #include "remoting/host/dns_blackhole_checker.h"
(...skipping 15 matching lines...) Expand all
62 #include "remoting/host/policy_hack/policy_watcher.h" 63 #include "remoting/host/policy_hack/policy_watcher.h"
63 #include "remoting/host/service_urls.h" 64 #include "remoting/host/service_urls.h"
64 #include "remoting/host/session_manager_factory.h" 65 #include "remoting/host/session_manager_factory.h"
65 #include "remoting/host/signaling_connector.h" 66 #include "remoting/host/signaling_connector.h"
66 #include "remoting/host/ui_strings.h" 67 #include "remoting/host/ui_strings.h"
67 #include "remoting/host/usage_stats_consent.h" 68 #include "remoting/host/usage_stats_consent.h"
68 #include "remoting/jingle_glue/xmpp_signal_strategy.h" 69 #include "remoting/jingle_glue/xmpp_signal_strategy.h"
69 #include "remoting/protocol/me2me_host_authenticator_factory.h" 70 #include "remoting/protocol/me2me_host_authenticator_factory.h"
70 71
71 #if defined(OS_POSIX) 72 #if defined(OS_POSIX)
72 #include <pwd.h>
73 #include <signal.h> 73 #include <signal.h>
74 #include "base/file_descriptor_posix.h" 74 #include "base/file_descriptor_posix.h"
75 #include "remoting/host/pam_authorization_factory_posix.h" 75 #include "remoting/host/pam_authorization_factory_posix.h"
76 #include "remoting/host/posix/signal_handler.h" 76 #include "remoting/host/posix/signal_handler.h"
77 #endif // defined(OS_POSIX) 77 #endif // defined(OS_POSIX)
78 78
79 #if defined(OS_MACOSX) 79 #if defined(OS_MACOSX)
80 #include "base/mac/scoped_cftyperef.h" 80 #include "base/mac/scoped_cftyperef.h"
81 #endif // defined(OS_MACOSX) 81 #endif // defined(OS_MACOSX)
82 82
(...skipping 17 matching lines...) Expand all
100 const char kApplicationName[] = "chromoting"; 100 const char kApplicationName[] = "chromoting";
101 101
102 // The command line switch used to pass name of the pipe to capture audio on 102 // The command line switch used to pass name of the pipe to capture audio on
103 // linux. 103 // linux.
104 const char kAudioPipeSwitchName[] = "audio-pipe-name"; 104 const char kAudioPipeSwitchName[] = "audio-pipe-name";
105 105
106 void QuitMessageLoop(MessageLoop* message_loop) { 106 void QuitMessageLoop(MessageLoop* message_loop) {
107 message_loop->PostTask(FROM_HERE, MessageLoop::QuitClosure()); 107 message_loop->PostTask(FROM_HERE, MessageLoop::QuitClosure());
108 } 108 }
109 109
110 // Returns true if GetUsername() is implemented on this platform.
111 bool CanGetUsername() {
112 #if defined(OS_POSIX)
113 return true;
114 #else // !defined(OS_POSIX)
115 return false;
116 #endif // defined(OS_POSIX)
117 } // namespace
118
119 // Returns the username associated with this process, or the empty string on
120 // error.
121 std::string GetUsername() {
122 #if defined(OS_POSIX)
123 long buf_size = sysconf(_SC_GETPW_R_SIZE_MAX);
124 if (buf_size <= 0)
125 return "";
126 scoped_array<char> buf(new char[buf_size]);
127 struct passwd passwd;
128 struct passwd* passwd_result = NULL;
129 getpwuid_r(getuid(), &passwd, buf.get(), buf_size, &passwd_result);
130 if (!passwd_result)
131 return "";
132 return std::string(passwd_result->pw_name);
133 #else // !defined(OS_POSIX)
134 NOTREACHED();
135 return "";
136 #endif // defined(OS_POSIX)
137 }
138
139 } // namespace 110 } // namespace
140 111
141 namespace remoting { 112 namespace remoting {
142 113
143 class HostProcess 114 class HostProcess
144 : public ConfigFileWatcher::Delegate, 115 : public ConfigFileWatcher::Delegate,
145 public HeartbeatSender::Listener, 116 public HeartbeatSender::Listener,
146 public HostChangeNotificationListener::Listener, 117 public HostChangeNotificationListener::Listener,
147 public IPC::Listener, 118 public IPC::Listener,
148 public base::RefCountedThreadSafe<HostProcess> { 119 public base::RefCountedThreadSafe<HostProcess> {
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 } 762 }
792 return false; 763 return false;
793 } 764 }
794 765
795 bool HostProcess::OnUsernamePolicyUpdate(bool host_username_match_required) { 766 bool HostProcess::OnUsernamePolicyUpdate(bool host_username_match_required) {
796 // Returns false: never restart the host after this policy update. 767 // Returns false: never restart the host after this policy update.
797 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); 768 DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
798 769
799 if (host_username_match_required) { 770 if (host_username_match_required) {
800 LOG(INFO) << "Policy requires host username match."; 771 LOG(INFO) << "Policy requires host username match.";
801 bool shutdown = !CanGetUsername() || 772 std::string username = GetUsername();
802 !StartsWithASCII(xmpp_login_, GetUsername() + std::string("@"), 773 bool shutdown = username.empty() ||
774 !StartsWithASCII(xmpp_login_, username + std::string("@"),
803 false); 775 false);
804 776
805 #if defined(OS_MACOSX) 777 #if defined(OS_MACOSX)
806 // On Mac, we run as root at the login screen, so the username won't match. 778 // On Mac, we run as root at the login screen, so the username won't match.
807 // However, there's no need to enforce the policy at the login screen, as 779 // However, there's no need to enforce the policy at the login screen, as
808 // the client will have to reconnect if a login occurs. 780 // the client will have to reconnect if a login occurs.
809 if (shutdown && getuid() == 0) { 781 if (shutdown && getuid() == 0) {
810 shutdown = false; 782 shutdown = false;
811 } 783 }
812 #endif 784 #endif
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
1145 return exit_code; 1117 return exit_code;
1146 } 1118 }
1147 1119
1148 } // namespace remoting 1120 } // namespace remoting
1149 1121
1150 #if !defined(OS_WIN) 1122 #if !defined(OS_WIN)
1151 int main(int argc, char** argv) { 1123 int main(int argc, char** argv) {
1152 return remoting::HostMain(argc, argv); 1124 return remoting::HostMain(argc, argv);
1153 } 1125 }
1154 #endif // !defined(OS_WIN) 1126 #endif // !defined(OS_WIN)
OLDNEW
« no previous file with comments | « remoting/host/pam_authorization_factory_posix.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698