{
unsigned long r = 0;
- /* without argument, match all supported by the current kernel */
- if (list[0] == '\0')
- return landlock_abi_fs_mask();
-
if (string_to_bitmask(list, &r, landlock_access_to_mask))
errx(EXIT_FAILURE,
_("could not parse landlock fs access: %s"), list);
{
const char *type;
+ type = ul_startswith(str, "fs:");
+
/* without argument, match all supported by the current kernel */
- if (strcmp(str, "fs") == 0) {
+ if (strcmp(str, "fs") == 0 || (type && type[0] == '\0')) {
opts->access_fs |= landlock_abi_fs_mask();
return;
}
- type = ul_startswith(str, "fs:");
if (type)
opts->access_fs |= parse_landlock_fs_access(type);
}
rule->rule_type = LANDLOCK_RULE_PATH_BENEATH;
accesses_part = xstrndup(accesses, path - accesses);
- rule->path_beneath_attr.allowed_access = parse_landlock_fs_access(accesses_part);
+ if (accesses_part[0] != '\0')
+ rule->path_beneath_attr.allowed_access = parse_landlock_fs_access(accesses_part);
+ else
+ rule->path_beneath_attr.allowed_access = 0;
free(accesses_part);
path++;
struct landlock_rule_entry *rule;
struct list_head *entry;
int fd, ret;
+ struct landlock_path_beneath_attr path_beneath_attr;
list_for_each(entry, &opts->rules) {
rule = list_entry(entry, struct landlock_rule_entry, head);
assert(rule->rule_type == LANDLOCK_RULE_PATH_BENEATH);
- ret = landlock_add_rule(fd, rule->rule_type, &rule->path_beneath_attr, 0);
+ path_beneath_attr = rule->path_beneath_attr;
+ if (!path_beneath_attr.allowed_access)
+ path_beneath_attr.allowed_access = opts->access_fs;
+
+ ret = landlock_add_rule(fd, rule->rule_type, &path_beneath_attr, 0);
if (ret == -1)
err(SETPRIV_EXIT_PRIVERR, _("adding landlock rule failed"));
}