]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/core/dynamic-user.h
Add SPDX license identifiers to source files under the LGPL
[thirdparty/systemd.git] / src / core / dynamic-user.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 #pragma once
3
4 /***
5 This file is part of systemd.
6
7 Copyright 2016 Lennart Poettering
8
9 systemd is free software; you can redistribute it and/or modify it
10 under the terms of the GNU Lesser General Public License as published by
11 the Free Software Foundation; either version 2.1 of the License, or
12 (at your option) any later version.
13
14 systemd is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Lesser General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public License
20 along with systemd; If not, see <http://www.gnu.org/licenses/>.
21 ***/
22
23 typedef struct DynamicUser DynamicUser;
24
25 typedef struct DynamicCreds {
26 /* A combination of a dynamic user and group */
27 DynamicUser *user;
28 DynamicUser *group;
29 } DynamicCreds;
30
31 #include "manager.h"
32
33 /* Note that this object always allocates a pair of user and group under the same name, even if one of them isn't
34 * used. This means, if you want to allocate a group and user pair, and they might have two different names, then you
35 * need to allocated two of these objects. DynamicCreds below makes that easy. */
36 struct DynamicUser {
37 int n_ref;
38 Manager *manager;
39
40 /* An AF_UNIX socket pair that contains a datagram containing both the numeric ID assigned, as well as a lock
41 * file fd locking the user ID we picked. */
42 int storage_socket[2];
43
44 char name[];
45 };
46
47 int dynamic_user_serialize(Manager *m, FILE *f, FDSet *fds);
48 void dynamic_user_deserialize_one(Manager *m, const char *value, FDSet *fds);
49 void dynamic_user_vacuum(Manager *m, bool close_user);
50
51 int dynamic_user_lookup_uid(Manager *m, uid_t uid, char **ret);
52 int dynamic_user_lookup_name(Manager *m, const char *name, uid_t *ret);
53
54 int dynamic_creds_acquire(DynamicCreds *creds, Manager *m, const char *user, const char *group);
55 int dynamic_creds_realize(DynamicCreds *creds, char **suggested_paths, uid_t *uid, gid_t *gid);
56
57 void dynamic_creds_unref(DynamicCreds *creds);
58 void dynamic_creds_destroy(DynamicCreds *creds);