]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
setpriv: error when a landlock rule has no access
authorSkye Soss <skye@soss.website>
Sat, 18 Jul 2026 18:26:53 +0000 (13:26 -0500)
committerSkye Soss <skye@soss.website>
Sun, 2 Aug 2026 02:16:40 +0000 (21:16 -0500)
The --landlock-rule option is used to allow operations through the
restriction introduced by a --landlock-access option. Specifying
--landlock-rule without specifying the corresponding --landlock-access
is always a user error, so produce an error message when that happens.

Signed-off-by: Skye Soss <skye@soss.website>
sys-utils/setpriv-landlock.c

index e95fedd0f76906353d09f4d89305f8f028441de9..aeaf1b12f4a4997f27697153312a22747cad80d7 100644 (file)
@@ -224,6 +224,14 @@ void do_landlock(const struct setpriv_landlock_opts *opts)
        struct list_head *entry;
        int fd, ret;
 
+       list_for_each(entry, &opts->rules) {
+               rule = list_entry(entry, struct landlock_rule_entry, head);
+               if (rule->rule_type == LANDLOCK_RULE_PATH_BENEATH && !opts->access_fs) {
+                       errx(EXIT_FAILURE,
+                               _("landlock path-beneath rule requires a filesystem access restriction (--landlock-access fs)"));
+               }
+       }
+
        if (!opts->access_fs)
                return;