blob: 8d6dc20cab41312a790f551a62dc762485e72206 [file] [log] [blame]
Chris Masone31ca5a32015-04-01 10:27:57 -07001// 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 Vakulenkofed60b02015-10-27 09:53:05 -07005#ifndef LIBBRILLO_BRILLO_USERDB_UTILS_H_
6#define LIBBRILLO_BRILLO_USERDB_UTILS_H_
Chris Masone31ca5a32015-04-01 10:27:57 -07007
8#include <sys/types.h>
9
10#include <string>
11
12#include <base/compiler_specific.h>
13#include <base/macros.h>
Alex Vakulenko9ed0cab2015-10-12 15:21:28 -070014#include <brillo/brillo_export.h>
Chris Masone31ca5a32015-04-01 10:27:57 -070015
Alex Vakulenko9ed0cab2015-10-12 15:21:28 -070016namespace brillo {
Chris Masone31ca5a32015-04-01 10:27:57 -070017namespace 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 Vakulenko9ed0cab2015-10-12 15:21:28 -070021BRILLO_EXPORT bool GetUserInfo(
Chris Masone31ca5a32015-04-01 10:27:57 -070022 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 Vakulenko9ed0cab2015-10-12 15:21:28 -070026BRILLO_EXPORT bool GetGroupInfo(
Chris Masone31ca5a32015-04-01 10:27:57 -070027 const std::string& group, gid_t* gid) WARN_UNUSED_RESULT;
28
29} // namespace userdb
Alex Vakulenko9ed0cab2015-10-12 15:21:28 -070030} // namespace brillo
Chris Masone31ca5a32015-04-01 10:27:57 -070031
Alex Vakulenkofed60b02015-10-27 09:53:05 -070032#endif // LIBBRILLO_BRILLO_USERDB_UTILS_H_