OLD | NEW |
1 // Copyright (c) 2009-2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2009-2010 The Chromium OS 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 "pam_offline/username_password.h" | 5 #include "pam_offline/username_password.h" |
6 | 6 |
7 #include "openssl/sha.h" | 7 #include "openssl/sha.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 | 9 |
10 #include "chromeos/utility.h" | 10 #include "chromeos/utility.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 const int username_length, | 45 const int username_length, |
46 const char *password, | 46 const char *password, |
47 const int password_length) { | 47 const int password_length) { |
48 username_ = new char[username_length+1]; | 48 username_ = new char[username_length+1]; |
49 password_ = new char[password_length+1]; | 49 password_ = new char[password_length+1]; |
50 strncpy(username_, username, username_length); | 50 strncpy(username_, username, username_length); |
51 strncpy(password_, password, password_length); | 51 strncpy(password_, password, password_length); |
52 username_[username_length] = password_[password_length] = 0; | 52 username_[username_length] = password_[password_length] = 0; |
53 } | 53 } |
54 | 54 |
| 55 #ifdef CHROMEOS_PAM_LOCALACCOUNT |
| 56 bool UsernamePassword::IsLocalAccount() const { |
| 57 return 0 == strncmp(username_, kLocalAccount, strlen(kLocalAccount)); |
| 58 } |
| 59 #endif |
| 60 |
55 void UsernamePassword::GetFullUsername(char *name_buffer, int length) const { | 61 void UsernamePassword::GetFullUsername(char *name_buffer, int length) const { |
56 strncpy(name_buffer, username_, length); | 62 strncpy(name_buffer, username_, length); |
57 } | 63 } |
58 | 64 |
59 void UsernamePassword::GetPartialUsername(char *name_buffer, int length) const { | 65 void UsernamePassword::GetPartialUsername(char *name_buffer, int length) const { |
60 char *at_ptr = strrchr(username_, '@'); | 66 char *at_ptr = strrchr(username_, '@'); |
61 *at_ptr = '\0'; | 67 *at_ptr = '\0'; |
62 strncpy(name_buffer, username_, length); | 68 strncpy(name_buffer, username_, length); |
63 *at_ptr = '@'; | 69 *at_ptr = '@'; |
64 } | 70 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 SHA256_Init(&sha_ctx); | 106 SHA256_Init(&sha_ctx); |
101 SHA256_Update(&sha_ctx, system_salt_ascii.c_str(), | 107 SHA256_Update(&sha_ctx, system_salt_ascii.c_str(), |
102 system_salt_ascii.length()); | 108 system_salt_ascii.length()); |
103 SHA256_Update(&sha_ctx, password_, strlen(password_)); | 109 SHA256_Update(&sha_ctx, password_, strlen(password_)); |
104 SHA256_Final(md_value, &sha_ctx); | 110 SHA256_Final(md_value, &sha_ctx); |
105 | 111 |
106 return AsciiEncode(Blob(md_value, md_value + SHA256_DIGEST_LENGTH / 2)); | 112 return AsciiEncode(Blob(md_value, md_value + SHA256_DIGEST_LENGTH / 2)); |
107 } | 113 } |
108 | 114 |
109 } // namespace pam_offline | 115 } // namespace pam_offline |
OLD | NEW |