]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/basic/user-util.h
util-lib: split out user/group/uid/gid calls into user-util.[ch]
[thirdparty/systemd.git] / src / basic / user-util.h
CommitLineData
b1d4f8e1
LP
1/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2
3#pragma once
4
5/***
6 This file is part of systemd.
7
8 Copyright 2010 Lennart Poettering
9
10 systemd is free software; you can redistribute it and/or modify it
11 under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
14
15 systemd is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
19
20 You should have received a copy of the GNU Lesser General Public License
21 along with systemd; If not, see <http://www.gnu.org/licenses/>.
22***/
23
24#include <sys/types.h>
25#include <stdbool.h>
26
27bool uid_is_valid(uid_t uid);
28
29static inline bool gid_is_valid(gid_t gid) {
30 return uid_is_valid((uid_t) gid);
31}
32
33int parse_uid(const char *s, uid_t* ret_uid);
34
35static inline int parse_gid(const char *s, gid_t *ret_gid) {
36 return parse_uid(s, (uid_t*) ret_gid);
37}
38
39char* lookup_uid(uid_t uid);
40char* getlogname_malloc(void);
41char* getusername_malloc(void);
42
43int get_user_creds(const char **username, uid_t *uid, gid_t *gid, const char **home, const char **shell);
44int get_group_creds(const char **groupname, gid_t *gid);
45
46char* uid_to_name(uid_t uid);
47char* gid_to_name(gid_t gid);
48
49int in_gid(gid_t gid);
50int in_group(const char *name);
51
52int get_home_dir(char **ret);
53int get_shell(char **_ret);
54
55int reset_uid_gid(void);