xref: /aosp_15_r20/external/libbrillo/brillo/userdb_utils.h (revision 1a96fba65179ea7d3f56207137718607415c5953)
1*1a96fba6SXin Li // Copyright 2015 The Chromium OS Authors. All rights reserved.
2*1a96fba6SXin Li // Use of this source code is governed by a BSD-style license that can be
3*1a96fba6SXin Li // found in the LICENSE file.
4*1a96fba6SXin Li 
5*1a96fba6SXin Li #ifndef LIBBRILLO_BRILLO_USERDB_UTILS_H_
6*1a96fba6SXin Li #define LIBBRILLO_BRILLO_USERDB_UTILS_H_
7*1a96fba6SXin Li 
8*1a96fba6SXin Li #include <sys/types.h>
9*1a96fba6SXin Li 
10*1a96fba6SXin Li #include <string>
11*1a96fba6SXin Li 
12*1a96fba6SXin Li #include <base/compiler_specific.h>
13*1a96fba6SXin Li #include <base/macros.h>
14*1a96fba6SXin Li #include <brillo/brillo_export.h>
15*1a96fba6SXin Li 
16*1a96fba6SXin Li namespace brillo {
17*1a96fba6SXin Li namespace userdb {
18*1a96fba6SXin Li 
19*1a96fba6SXin Li // Looks up the UID and GID corresponding to |user|. Returns true on success.
20*1a96fba6SXin Li // Passing nullptr for |uid| or |gid| causes them to be ignored.
21*1a96fba6SXin Li BRILLO_EXPORT bool GetUserInfo(
22*1a96fba6SXin Li     const std::string& user, uid_t* uid, gid_t* gid) WARN_UNUSED_RESULT;
23*1a96fba6SXin Li 
24*1a96fba6SXin Li // Looks up the GID corresponding to |group|. Returns true on success.
25*1a96fba6SXin Li // Passing nullptr for |gid| causes it to be ignored.
26*1a96fba6SXin Li BRILLO_EXPORT bool GetGroupInfo(
27*1a96fba6SXin Li     const std::string& group, gid_t* gid) WARN_UNUSED_RESULT;
28*1a96fba6SXin Li 
29*1a96fba6SXin Li }  // namespace userdb
30*1a96fba6SXin Li }  // namespace brillo
31*1a96fba6SXin Li 
32*1a96fba6SXin Li #endif  // LIBBRILLO_BRILLO_USERDB_UTILS_H_
33