Chris Masone | 31ca5a3 | 2015-04-01 10:27:57 -0700 | [diff] [blame] | 1 | // Copyright 2015 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 | |
Alex Vakulenko | fed60b0 | 2015-10-27 09:53:05 -0700 | [diff] [blame] | 5 | #ifndef LIBBRILLO_BRILLO_USERDB_UTILS_H_ |
| 6 | #define LIBBRILLO_BRILLO_USERDB_UTILS_H_ |
Chris Masone | 31ca5a3 | 2015-04-01 10:27:57 -0700 | [diff] [blame] | 7 | |
| 8 | #include <sys/types.h> |
| 9 | |
| 10 | #include <string> |
| 11 | |
| 12 | #include <base/compiler_specific.h> |
| 13 | #include <base/macros.h> |
Alex Vakulenko | 9ed0cab | 2015-10-12 15:21:28 -0700 | [diff] [blame] | 14 | #include <brillo/brillo_export.h> |
Chris Masone | 31ca5a3 | 2015-04-01 10:27:57 -0700 | [diff] [blame] | 15 | |
Alex Vakulenko | 9ed0cab | 2015-10-12 15:21:28 -0700 | [diff] [blame] | 16 | namespace brillo { |
Chris Masone | 31ca5a3 | 2015-04-01 10:27:57 -0700 | [diff] [blame] | 17 | namespace userdb { |
| 18 | |
| 19 | // Looks up the UID and GID corresponding to |user|. Returns true on success. |
| 20 | // Passing nullptr for |uid| or |gid| causes them to be ignored. |
Alex Vakulenko | 9ed0cab | 2015-10-12 15:21:28 -0700 | [diff] [blame] | 21 | BRILLO_EXPORT bool GetUserInfo( |
Chris Masone | 31ca5a3 | 2015-04-01 10:27:57 -0700 | [diff] [blame] | 22 | const std::string& user, uid_t* uid, gid_t* gid) WARN_UNUSED_RESULT; |
| 23 | |
| 24 | // Looks up the GID corresponding to |group|. Returns true on success. |
| 25 | // Passing nullptr for |gid| causes it to be ignored. |
Alex Vakulenko | 9ed0cab | 2015-10-12 15:21:28 -0700 | [diff] [blame] | 26 | BRILLO_EXPORT bool GetGroupInfo( |
Chris Masone | 31ca5a3 | 2015-04-01 10:27:57 -0700 | [diff] [blame] | 27 | const std::string& group, gid_t* gid) WARN_UNUSED_RESULT; |
| 28 | |
| 29 | } // namespace userdb |
Alex Vakulenko | 9ed0cab | 2015-10-12 15:21:28 -0700 | [diff] [blame] | 30 | } // namespace brillo |
Chris Masone | 31ca5a3 | 2015-04-01 10:27:57 -0700 | [diff] [blame] | 31 | |
Alex Vakulenko | fed60b0 | 2015-10-27 09:53:05 -0700 | [diff] [blame] | 32 | #endif // LIBBRILLO_BRILLO_USERDB_UTILS_H_ |