_(landlock_access_fs[i].help));
}
}
+
+void list_landlock_support(void)
+{
+ size_t i;
+
+ printf("ABI: %d\n", supported_landlock_abi());
+
+ printf("access: fs\n");
+
+ printf("rights:");
+ for (i = 0; i < ARRAY_SIZE(landlock_access_fs); i++)
+ printf(" %s", landlock_access_fs[i].type);
+ printf("\n");
+
+ printf("rules: path-beneath\n");
+}
+
+void list_landlock_access(void)
+{
+ printf("fs\n");
+}
+
+void list_landlock_rights(const char *access)
+{
+ uint64_t mask;
+ size_t i;
+
+ if (strcmp(access, "fs") != 0)
+ errx(EXIT_FAILURE, _("unknown landlock access: %s"), access);
+
+ mask = landlock_abi_fs_mask();
+ for (i = 0; i < ARRAY_SIZE(landlock_access_fs); i++)
+ if (landlock_access_fs[i].value & mask)
+ printf("%s\n", landlock_access_fs[i].type);
+}
void parse_landlock_rule(struct setpriv_landlock_opts *opts, const char *str);
void init_landlock_opts(struct setpriv_landlock_opts *opts);
void usage_landlock(FILE *out);
+void list_landlock_support(void);
+void list_landlock_access(void);
+void list_landlock_rights(const char *access);
#else
#define parse_landlock_rule parse_landlock_access
static inline void init_landlock_opts(void *opts __attribute__((unused))) {}
static inline void usage_landlock(FILE *out __attribute__((unused))) {}
+static inline void list_landlock_support(void)
+{
+ errx(EXIT_FAILURE, _("no support for landlock"));
+}
+#define list_landlock_access list_landlock_support
+static inline void list_landlock_rights(const char *access __attribute__((unused)))
+{
+ errx(EXIT_FAILURE, _("no support for landlock"));
+}
#endif /* HAVE_LANDLOCK */
fputs(_(" --apparmor-profile <pr> set AppArmor profile\n"), out);
fputs(_(" --landlock-access <access> add Landlock access\n"), out);
fputs(_(" --landlock-rule <rule> add Landlock rule\n"), out);
+ fputs(_(" --landlock-support list supported Landlock ABI, access, rights, and rules\n"), out);
+ fputs(_(" --list-landlock-access list Landlock access categories\n"), out);
+ fputs(_(" --list-landlock-rights <access>\n"
+ " list an access category's rights\n"), out);
fputs(_(" --seccomp-filter <file> load seccomp filter from file\n"), out);
fputs(_(" --reset-env clear all environment and initialize\n"
" HOME, SHELL, USER, LOGNAME and PATH\n"), out);
APPARMOR_PROFILE,
LANDLOCK_ACCESS,
LANDLOCK_RULE,
+ LANDLOCK_SUPPORT,
+ LIST_LANDLOCK_ACCESS,
+ LIST_LANDLOCK_RIGHTS,
SECCOMP_FILTER,
RESET_ENV
};
{ "apparmor-profile", required_argument, NULL, APPARMOR_PROFILE },
{ "landlock-access", required_argument, NULL, LANDLOCK_ACCESS },
{ "landlock-rule", required_argument, NULL, LANDLOCK_RULE },
+ { "landlock-support", no_argument, NULL, LANDLOCK_SUPPORT },
+ { "list-landlock-access", no_argument, NULL, LIST_LANDLOCK_ACCESS },
+ { "list-landlock-rights", required_argument, NULL, LIST_LANDLOCK_RIGHTS },
{ "seccomp-filter", required_argument, NULL, SECCOMP_FILTER },
{ "help", no_argument, NULL, 'h' },
{ "reset-env", no_argument, NULL, RESET_ENV, },
int dumplevel = 0;
int total_opts = 0;
int list_caps = 0;
+ int landlock_support = 0;
+ int landlock_list_access = 0;
+ const char *landlock_list_rights_access = NULL;
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
case LANDLOCK_RULE:
parse_landlock_rule(&opts.landlock, optarg);
break;
+ case LANDLOCK_SUPPORT:
+ landlock_support = 1;
+ break;
+ case LIST_LANDLOCK_ACCESS:
+ landlock_list_access = 1;
+ break;
+ case LIST_LANDLOCK_RIGHTS:
+ landlock_list_rights_access = optarg;
+ break;
case SECCOMP_FILTER:
if (opts.seccomp_filter)
errx(EXIT_FAILURE,
return EXIT_SUCCESS;
}
+ if (landlock_support) {
+ if (total_opts != 1 || optind < argc)
+ errx(EXIT_FAILURE,
+ _("--landlock-support must be specified alone"));
+ list_landlock_support();
+ return EXIT_SUCCESS;
+ }
+
+ if (landlock_list_access) {
+ if (total_opts != 1 || optind < argc)
+ errx(EXIT_FAILURE,
+ _("--list-landlock-access must be specified alone"));
+ list_landlock_access();
+ return EXIT_SUCCESS;
+ }
+
+ if (landlock_list_rights_access) {
+ if (total_opts != 1 || optind < argc)
+ errx(EXIT_FAILURE,
+ _("--list-landlock-rights must be specified alone"));
+ list_landlock_rights(landlock_list_rights_access);
+ return EXIT_SUCCESS;
+ }
+
if (argc <= optind)
errx(EXIT_FAILURE, _("No program specified"));