• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef LIBBRILLO_BRILLO_CRYPTOHOME_H_
6 #define LIBBRILLO_BRILLO_CRYPTOHOME_H_
7 
8 #include <string>
9 
10 #include <base/files/file_path.h>
11 #include <brillo/brillo_export.h>
12 
13 namespace brillo {
14 namespace cryptohome {
15 namespace home {
16 
17 BRILLO_EXPORT extern const char kGuestUserName[];
18 
19 // Returns the common prefix under which the mount points for user homes are
20 // created.
21 BRILLO_EXPORT base::FilePath GetUserPathPrefix();
22 
23 // Returns the common prefix under which the mount points for root homes are
24 // created.
25 BRILLO_EXPORT base::FilePath GetRootPathPrefix();
26 
27 // Returns the path at which the user home for |username| will be mounted.
28 // Returns "" for failures.
29 BRILLO_EXPORT base::FilePath GetUserPath(const std::string& username);
30 
31 // Returns the path at which the user home for |hashed_username| will be
32 // mounted. Useful when you already have the username hashed.
33 // Returns "" for failures.
34 BRILLO_EXPORT base::FilePath GetHashedUserPath(
35     const std::string& hashed_username);
36 
37 // Returns the path at which the root home for |username| will be mounted.
38 // Returns "" for failures.
39 BRILLO_EXPORT base::FilePath GetRootPath(const std::string& username);
40 
41 // Returns the path at which the daemon |daemon| should store per-user data.
42 BRILLO_EXPORT base::FilePath GetDaemonPath(const std::string& username,
43                                            const std::string& daemon);
44 
45 // Checks whether |sanitized| has the format of a sanitized username.
46 BRILLO_EXPORT bool IsSanitizedUserName(const std::string& sanitized);
47 
48 // Returns a sanitized form of |username|. For x != y, SanitizeUserName(x) !=
49 // SanitizeUserName(y).
50 BRILLO_EXPORT std::string SanitizeUserName(const std::string& username);
51 
52 // Overrides the common prefix under which the mount points for user homes are
53 // created. This is used for testing only.
54 BRILLO_EXPORT void SetUserHomePrefix(const std::string& prefix);
55 
56 // Overrides the common prefix under which the mount points for root homes are
57 // created. This is used for testing only.
58 BRILLO_EXPORT void SetRootHomePrefix(const std::string& prefix);
59 
60 // Overrides the contents of the system salt.
61 // salt should be non-NULL and non-empty when attempting to avoid filesystem
62 // usage in tests.
63 // Note:
64 // (1) Never mix usage with SetSystemSaltPath().
65 // (2) Ownership of the pointer stays with the caller.
66 BRILLO_EXPORT void SetSystemSalt(std::string* salt);
67 
68 // Returns the system salt.
69 BRILLO_EXPORT std::string* GetSystemSalt();
70 
71 }  // namespace home
72 }  // namespace cryptohome
73 }  // namespace brillo
74 
75 #endif  // LIBBRILLO_BRILLO_CRYPTOHOME_H_
76