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