Debian Codegraph @

src/shared/nsresource.h

raw
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 #pragma once
3
4 #include "shared-forward.h"
5 #include "user-util.h"
6
7 /* Helpful constants for the only numbers of UIDs that can currently be allocated */
8 #define NSRESOURCE_UIDS_64K USERNS_RANGE_SIZE
9 #define NSRESOURCE_UIDS_1 1U
10
11 int nsresource_connect(sd_varlink **ret);
12
13 /* All the calls below take a 'link' parameter, that may be an already established Varlink connection object
14 * towards systemd-nsresourced, previously created via nsresource_connect(). This serves two purposes: first
15 * of all allows more efficient resource usage, as this allows recycling already allocated resources for
16 * multiple calls. Secondly, the user credentials are pinned at time of nsresource_connect(), and the caller
17 * hence can drop privileges afterwards while keeping open the connection and still execute relevant
18 * operations under the original identity, until the connection is closed. The 'link' parameter may be passed
19 * as NULL in which case a short-lived connection is created, just to execute the requested operation. */
20
21 int nsresource_allocate_userns_full(sd_varlink *vl, const char *name, uint64_t size, uint64_t delegate_container_ranges);
22 static inline int nsresource_allocate_userns(sd_varlink *vl, const char *name, uint64_t size) {
23 return nsresource_allocate_userns_full(vl, name, size, /* delegate_container_ranges= */ 0);
24 }
25 int nsresource_register_userns(sd_varlink *vl, const char *name, int userns_fd);
26 int nsresource_add_mount(sd_varlink *vl, int userns_fd, int mount_fd);
27 int nsresource_add_cgroup(sd_varlink *vl, int userns_fd, int cgroup_fd);
28 int nsresource_add_netif_veth(sd_varlink *vl, int userns_fd, int netns_fd, const char *namespace_ifname, char **ret_host_ifname, char **ret_namespace_ifname);
29 int nsresource_add_netif_tap(sd_varlink *vl, int userns_fd, char **ret_host_ifname);