• 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 // Returns the path at which the daemon |daemon| should store per-user data
46 // when the user's home was mounted with mount_hidden.
47 BRILLO_EXPORT base::FilePath GetDaemonPathForHiddenUserHome(
48     const std::string& username,
49     const std::string& daemon);
50 
51 // Checks whether |sanitized| has the format of a sanitized username.
52 BRILLO_EXPORT bool IsSanitizedUserName(const std::string& sanitized);
53 
54 // Returns a sanitized form of |username|. For x != y, SanitizeUserName(x) !=
55 // SanitizeUserName(y).
56 BRILLO_EXPORT std::string SanitizeUserName(const std::string& username);
57 
58 // Overrides the common prefix under which the mount points for user homes are
59 // created. This is used for testing only.
60 BRILLO_EXPORT void SetUserHomePrefix(const std::string& prefix);
61 
62 // Overrides the common prefix under which the mount points for root homes are
63 // created. This is used for testing only.
64 BRILLO_EXPORT void SetRootHomePrefix(const std::string& prefix);
65 
66 // Overrides the contents of the system salt.
67 // salt should be non-NULL and non-empty when attempting to avoid filesystem
68 // usage in tests.
69 // Note:
70 // (1) Never mix usage with SetSystemSaltPath().
71 // (2) Ownership of the pointer stays with the caller.
72 BRILLO_EXPORT void SetSystemSalt(std::string* salt);
73 
74 // Returns the system salt.
75 BRILLO_EXPORT std::string* GetSystemSalt();
76 
77 // Ensures the system salt is loaded in the memory.
78 BRILLO_EXPORT bool EnsureSystemSaltIsLoaded();
79 
80 }  // namespace home
81 }  // namespace cryptohome
82 }  // namespace brillo
83 
84 #endif  // LIBBRILLO_BRILLO_CRYPTOHOME_H_
85