]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/core/dynamic-user.h
66b0cd77273da7a2e25b73075e6f6dec550b9a01
[thirdparty/systemd.git] / src / core / dynamic-user.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 #pragma once
3
4 /***
5 Copyright 2016 Lennart Poettering
6 ***/
7
8 typedef struct DynamicUser DynamicUser;
9
10 typedef struct DynamicCreds {
11 /* A combination of a dynamic user and group */
12 DynamicUser *user;
13 DynamicUser *group;
14 } DynamicCreds;
15
16 #include "manager.h"
17
18 /* Note that this object always allocates a pair of user and group under the same name, even if one of them isn't
19 * used. This means, if you want to allocate a group and user pair, and they might have two different names, then you
20 * need to allocated two of these objects. DynamicCreds below makes that easy. */
21 struct DynamicUser {
22 int n_ref;
23 Manager *manager;
24
25 /* An AF_UNIX socket pair that contains a datagram containing both the numeric ID assigned, as well as a lock
26 * file fd locking the user ID we picked. */
27 int storage_socket[2];
28
29 char name[];
30 };
31
32 int dynamic_user_serialize(Manager *m, FILE *f, FDSet *fds);
33 void dynamic_user_deserialize_one(Manager *m, const char *value, FDSet *fds);
34 void dynamic_user_vacuum(Manager *m, bool close_user);
35
36 int dynamic_user_current(DynamicUser *d, uid_t *ret);
37 int dynamic_user_lookup_uid(Manager *m, uid_t uid, char **ret);
38 int dynamic_user_lookup_name(Manager *m, const char *name, uid_t *ret);
39
40 int dynamic_creds_acquire(DynamicCreds *creds, Manager *m, const char *user, const char *group);
41 int dynamic_creds_realize(DynamicCreds *creds, char **suggested_paths, uid_t *uid, gid_t *gid);
42
43 void dynamic_creds_unref(DynamicCreds *creds);
44 void dynamic_creds_destroy(DynamicCreds *creds);