]>
Commit | Line | Data |
---|---|---|
1 | /* SPDX-License-Identifier: LGPL-2.1-or-later */ | |
2 | #pragma once | |
3 | ||
4 | #include "forward.h" | |
5 | #include "volatile-util.h" | |
6 | ||
7 | typedef enum MountSettingsMask { | |
8 | MOUNT_FATAL = 1 << 0, /* if set, a mount error is considered fatal */ | |
9 | MOUNT_USE_USERNS = 1 << 1, /* if set, mounts are patched considering uid/gid shifts in a user namespace */ | |
10 | MOUNT_IN_USERNS = 1 << 2, /* if set, the mount is executed in the inner child, otherwise in the outer child */ | |
11 | MOUNT_APPLY_APIVFS_RO = 1 << 3, /* if set, /proc/sys, and /sys will be mounted read-only, otherwise read-write. */ | |
12 | MOUNT_APPLY_APIVFS_NETNS = 1 << 4, /* if set, /proc/sys/net will be mounted read-write. | |
13 | Works only if MOUNT_APPLY_APIVFS_RO is also set. */ | |
14 | MOUNT_APPLY_TMPFS_TMP = 1 << 5, /* if set, /tmp will be mounted as tmpfs */ | |
15 | MOUNT_ROOT_ONLY = 1 << 6, /* if set, only root mounts are mounted */ | |
16 | MOUNT_NON_ROOT_ONLY = 1 << 7, /* if set, only non-root mounts are mounted */ | |
17 | MOUNT_MKDIR = 1 << 8, /* if set, make directory to mount over first */ | |
18 | MOUNT_TOUCH = 1 << 9, /* if set, touch file to mount over first */ | |
19 | MOUNT_PREFIX_ROOT = 1 << 10,/* if set, prefix the source path with the container's root directory */ | |
20 | MOUNT_FOLLOW_SYMLINKS = 1 << 11,/* if set, we'll follow symlinks for the mount target */ | |
21 | MOUNT_UNMANAGED = 1 << 12,/* if set, we'll only mount this in the outer child if we are running in privileged mode */ | |
22 | MOUNT_PRIVILEGED = 1 << 13,/* if set, we'll only mount this if we have full privileges */ | |
23 | MOUNT_USRQUOTA_GRACEFUL = 1 << 14,/* if set, append "usrquota" to mount options if kernel tmpfs supports that */ | |
24 | } MountSettingsMask; | |
25 | ||
26 | typedef enum CustomMountType { | |
27 | CUSTOM_MOUNT_BIND, | |
28 | CUSTOM_MOUNT_TMPFS, | |
29 | CUSTOM_MOUNT_OVERLAY, | |
30 | CUSTOM_MOUNT_INACCESSIBLE, | |
31 | CUSTOM_MOUNT_ARBITRARY, | |
32 | _CUSTOM_MOUNT_TYPE_MAX, | |
33 | _CUSTOM_MOUNT_TYPE_INVALID = -EINVAL, | |
34 | } CustomMountType; | |
35 | ||
36 | typedef struct CustomMount { | |
37 | CustomMountType type; | |
38 | bool read_only; | |
39 | char *source; /* for overlayfs this is the upper directory */ | |
40 | char *destination; | |
41 | uid_t destination_uid; | |
42 | char *options; | |
43 | char *work_dir; | |
44 | char **lower; | |
45 | char *rm_rf_tmpdir; | |
46 | char *type_argument; /* only for CUSTOM_MOUNT_ARBITRARY */ | |
47 | bool graceful; | |
48 | bool in_userns; | |
49 | } CustomMount; | |
50 | ||
51 | CustomMount* custom_mount_add(CustomMount **l, size_t *n, CustomMountType t); | |
52 | void custom_mount_free_all(CustomMount *l, size_t n); | |
53 | int custom_mount_prepare_all(const char *dest, CustomMount *l, size_t n); | |
54 | ||
55 | int bind_mount_parse(CustomMount **l, size_t *n, const char *s, bool read_only); | |
56 | int tmpfs_mount_parse(CustomMount **l, size_t *n, const char *s); | |
57 | int overlay_mount_parse(CustomMount **l, size_t *n, const char *s, bool read_only); | |
58 | int inaccessible_mount_parse(CustomMount **l, size_t *n, const char *s); | |
59 | ||
60 | int mount_all(const char *dest, MountSettingsMask mount_settings, uid_t uid_shift, const char *selinux_apifs_context); | |
61 | int mount_sysfs(const char *dest, MountSettingsMask mount_settings); | |
62 | ||
63 | int mount_custom(const char *dest, CustomMount *mounts, size_t n, uid_t uid_shift, uid_t uid_range, const char *selinux_apifs_context, MountSettingsMask mount_settings); | |
64 | bool has_custom_root_mount(const CustomMount *mounts, size_t n); | |
65 | ||
66 | int setup_volatile_mode(const char *directory, VolatileMode mode, uid_t uid_shift, const char *selinux_apifs_context); | |
67 | int setup_volatile_mode_after_remount_idmap( | |
68 | const char *directory, | |
69 | VolatileMode mode, | |
70 | uid_t uid_shift, | |
71 | const char *selinux_apifs_context); | |
72 | ||
73 | int pivot_root_parse(char **pivot_root_new, char **pivot_root_old, const char *s); | |
74 | int setup_pivot_root(const char *directory, const char *pivot_root_new, const char *pivot_root_old); | |
75 | ||
76 | int tmpfs_patch_options(const char *options,uid_t uid_shift, const char *selinux_apifs_context, char **ret); | |
77 | ||
78 | int pin_fully_visible_api_fs(void); | |
79 | int wipe_fully_visible_api_fs(int mntns_fd); |