Skip to content

Commit 53b9d78

Browse files
mtth-bfftl0kod
authored andcommitted
samples/landlock: Clarify option parsing behaviour
Clarify the distinction between filesystem variables (mandatory) and all others (optional). For optional variables, explain the difference between unset variables (no access check performed) and empty variables (nothing allowed for lists of allowed paths/ports, or no effect for lists of scopes). List the known LL_SCOPED values and their effect. Signed-off-by: Matthieu Buffet <[email protected]> Link: https://lore.kernel.org/r/[email protected] [mic: Add a missing colon] Signed-off-by: Mickaël Salaün <[email protected]>
1 parent f51e55a commit 53b9d78

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

samples/landlock/sandboxer.c

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -296,25 +296,26 @@ static bool check_ruleset_scope(const char *const env_var,
296296
/* clang-format off */
297297

298298
static const char help[] =
299-
"usage: "
300-
ENV_FS_RO_NAME "=\"...\" "
301-
ENV_FS_RW_NAME "=\"...\" "
302-
ENV_TCP_BIND_NAME "=\"...\" "
303-
ENV_TCP_CONNECT_NAME "=\"...\" "
304-
ENV_SCOPED_NAME "=\"...\" %1$s <cmd> [args]...\n"
299+
"usage: " ENV_FS_RO_NAME "=\"...\" " ENV_FS_RW_NAME "=\"...\" "
300+
"[other environment variables] %1$s <cmd> [args]...\n"
305301
"\n"
306-
"Execute a command in a restricted environment.\n"
302+
"Execute the given command in a restricted environment.\n"
303+
"Multi-valued settings (lists of ports, paths, scopes) are colon-delimited.\n"
307304
"\n"
308-
"Environment variables containing paths and ports each separated by a colon:\n"
309-
"* " ENV_FS_RO_NAME ": list of paths allowed to be used in a read-only way.\n"
310-
"* " ENV_FS_RW_NAME ": list of paths allowed to be used in a read-write way.\n"
305+
"Mandatory settings:\n"
306+
"* " ENV_FS_RO_NAME ": paths allowed to be used in a read-only way\n"
307+
"* " ENV_FS_RW_NAME ": paths allowed to be used in a read-write way\n"
311308
"\n"
312-
"Environment variables containing ports are optional and could be skipped.\n"
313-
"* " ENV_TCP_BIND_NAME ": list of ports allowed to bind (server).\n"
314-
"* " ENV_TCP_CONNECT_NAME ": list of ports allowed to connect (client).\n"
315-
"* " ENV_SCOPED_NAME ": list of scoped IPCs.\n"
309+
"Optional settings (when not set, their associated access check "
310+
"is always allowed, which is different from an empty string which "
311+
"means an empty list):\n"
312+
"* " ENV_TCP_BIND_NAME ": ports allowed to bind (server)\n"
313+
"* " ENV_TCP_CONNECT_NAME ": ports allowed to connect (client)\n"
314+
"* " ENV_SCOPED_NAME ": actions denied on the outside of the landlock domain\n"
315+
" - \"a\" to restrict opening abstract unix sockets\n"
316+
" - \"s\" to restrict sending signals\n"
316317
"\n"
317-
"example:\n"
318+
"Example:\n"
318319
ENV_FS_RO_NAME "=\"${PATH}:/lib:/usr:/proc:/etc:/dev/urandom\" "
319320
ENV_FS_RW_NAME "=\"/dev/null:/dev/full:/dev/zero:/dev/pts:/tmp\" "
320321
ENV_TCP_BIND_NAME "=\"9418\" "

0 commit comments

Comments
 (0)