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