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

Unified Diff: remoting/base/util.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, 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/base/util.h ('k') | remoting/host/pam_authorization_factory_posix.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/base/util.cc
diff --git a/remoting/base/util.cc b/remoting/base/util.cc
index 58734229aa733d83c430291913bd389dc9564ddf..53b121352954d103a343ea887626e2abce36d110 100644
--- a/remoting/base/util.cc
+++ b/remoting/base/util.cc
@@ -13,6 +13,12 @@
#include "media/base/yuv_convert.h"
#include "third_party/skia/include/core/SkRegion.h"
+#if defined(OS_POSIX)
+#include <pwd.h>
+#include <sys/types.h>
+#include <unistd.h>
+#endif // defined(OS_POSIX)
+
using media::VideoFrame;
namespace remoting {
@@ -311,4 +317,21 @@ bool StringIsUtf8(const char* data, size_t length) {
return true;
}
+std::string GetUsername() {
+#if defined(OS_POSIX)
+ long buf_size = sysconf(_SC_GETPW_R_SIZE_MAX);
+ if (buf_size <= 0)
+ return std::string();
+ scoped_array<char> buf(new char[buf_size]);
+ struct passwd passwd;
+ struct passwd* passwd_result = NULL;
+ getpwuid_r(getuid(), &passwd, buf.get(), buf_size, &passwd_result);
+ if (!passwd_result)
+ return std::string();
+ return std::string(passwd_result->pw_name);
+#else // !defined(OS_POSIX)
+ return std::string();
+#endif // defined(OS_POSIX)
+}
+
} // namespace remoting
« no previous file with comments | « remoting/base/util.h ('k') | remoting/host/pam_authorization_factory_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698