Debian Codegraph @

upstream/opensuse-leap-16-1/man1/mkosi-sandbox.1.md

raw
1 % mkosi-sandbox(1)
2 %
3 %
4
5 # NAME
6
7 mkosi-sandbox — Run commands in a custom sandbox
8
9 # SYNOPSIS
10
11 `mkosi-sandbox [options…] command [arguments]`
12
13 # DESCRIPTION
14
15 `mkosi-sandbox` runs the given command in a custom sandbox. The sandbox is configured
16 by specifying command line options that configure individual parts of the sandbox.
17
18 If no command is specified, `mkosi-sandbox` will start `bash` in the sandbox.
19
20 Note that this sandbox is not designed to be a security boundary. Its intended purpose
21 is to allow running commands in an isolated environment so they are not affected by the
22 host system.
23
24 # OPTIONS
25
26 `--tmpfs DST`
27 : Mounts a new tmpfs at `DST` in the sandbox.
28
29 `--dev DST`
30 : Sets up a private `/dev` at `DST` in the sandbox. This private `/dev` will only
31 contain the basic device nodes required for a functioning sandbox (e.g. `/dev/null`)
32 and no actual devices.
33
34 `--proc DST`
35 : Mounts `/proc` from the host at `DST` in the sandbox.
36
37 `--dir DST`
38 : Creates a directory and all missing parent directories at `DST` in the sandbox.
39 All directories are created with mode 755 unless the path ends with `/tmp` or
40 `/var/tmp` in which case it is created with mode 1777.
41
42 `--bind SRC DST`
43 : The source path `SRC` is recursively bind mounted to `DST` in the sandbox. The
44 mountpoint is created in the sandbox if it does not yet exist. Any missing parent
45 directories in the sandbox are created as well.
46
47 `--bind-try SRC DST`
48 : Like `--bind`, but doesn't fail if the source path doesn't exist.
49
50 `--ro-bind SRC DST`
51 : Like `--bind`, but does a recursive readonly bind mount.
52
53 `--ro-bind-try SRC DST`
54 : Like `--bind-try`, but does a recursive readonly bind mount.
55
56 `--symlink SRC DST`
57 : Creates a symlink at `DST` in the sandbox pointing to `SRC`. If `DST` already
58 exists and is a file or symlink, a temporary symlink is created and mounted on
59 top of `DST`.
60
61 `--write DATA DST`
62 : Writes the string from `DATA` to `DST` in the sandbox.
63
64 `--overlay-lowerdir DIR`
65 : Adds `DIR` from the host as a new lower directory for the next overlayfs mount.
66
67 `--overlay-upperdir DIR`
68 : Sets the upper directory for the next overlayfs mount to `DIR` from the host. If
69 set to `tmpfs`, the upperdir and workdir will be subdirectories of a fresh tmpfs
70 mount.
71
72 `--overlay-workdir DIR`
73 : Sets the working directory for the next overlayfs mount to `DIR` from the host.
74
75 `--overlay DST`
76 : Mounts a new overlay filesystem at `DST` in the sandbox. The lower directories, upper
77 directory and working directory are specified using the `--overlay-lowerdir`,
78 `--overlay-upperdir` and `--overlay-workdir` options respectively. After each
79 `--overlay` option is parsed, the other overlay options are reset.
80
81 `--unsetenv NAME`
82 : Unsets the `NAME` environment variable in the sandbox.
83
84 `--setenv NAME VALUE`
85 : Sets the `NAME` environment variable to `VALUE` in the sandbox
86
87 `--chdir DIR`
88 : Changes the working directory to `DIR` in the sandbox.
89
90 `--same-dir`
91 : Changes to the working directory in the sandbox to the current working directory that
92 `mkosi-sandbox` is invoked in on the host.
93
94 `--become-root`
95 : Maps the current user to the root user in the sandbox. If this option is not specified,
96 the current user is mapped to itself in the sandbox. Regardless of whether this option
97 is specified or not, the current user will have a full set of ambient capabilities in
98 the sandbox. This includes `CAP_SYS_ADMIN` which means that the invoked process in the
99 sandbox will be able to do bind mounts and other operations.
100
101 If `mkosi-sandbox` is invoked as the root user, this option won't do anything.
102
103 `--suppress-chown`
104 : Specifying this option causes all calls to `chown()` or similar system calls to become a
105 noop in the sandbox. This is primarily useful when invoking package managers in the
106 sandbox which might try to `chown()` files to different users or groups which would fail
107 unless `mkosi-sandbox` is invoked by a privileged user.
108
109 `--unshare-net`
110 : Specifying this option makes `mkosi-sandbox` unshare a network namespace if possible.
111
112 `--unshare-ipc`
113 : Specifying this option makes `mkosi-sandbox` unshare an IPC namespace if possible.
114
115 `--exec-fd FD`
116 : The specified `FD` will be closed when `mkosi-sandbox` calls `execvp()`. This is useful
117 to wait until all setup logic has completed before continuing execution in the parent
118 process invoking `mkosi-sandbox`.
119
120 `--version`
121 : Show package version.
122
123 `--help`, `-h`
124 : Show brief usage information.
125
126 # EXAMPLES
127
128 Start `bash` in the current working directory in its own network namespace as the current user.
129
130 ```sh
131 mkosi-sandbox --bind / / --same-dir --unshare-net
132 ```
133
134 Run `id` as the root user in a sandbox with only `/usr` from the host plus the necessary symlinks
135 to be able to run commands.
136
137 ```sh
138 mkosi-sandbox \
139 --ro-bind /usr /usr \
140 --symlink usr/bin /bin \
141 --symlink usr/bin /bin \
142 --symlink usr/lib /lib \
143 --symlink usr/lib64 /lib64 \
144 --symlink usr/sbin /sbin \
145 --dev /dev \
146 --proc /proc \
147 --tmpfs /tmp \
148 --become-root \
149 id
150 ```
151
152 # SEE ALSO
153 `mkosi(1)`