-
Notifications
You must be signed in to change notification settings - Fork 588
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Landlock support to Firejail #5315
Changes from all commits
61b1544
ba828be
877fc99
460fa7a
c6d7474
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,7 +52,7 @@ syn match fjVar /\v\$\{(CFG|DESKTOP|DOCUMENTS|DOWNLOADS|HOME|MUSIC|PATH|PICTURES | |
|
||
" Commands grabbed from: src/firejail/profile.c | ||
" Generate list with: { rg -o 'strn?cmp\(ptr, "([^"]+) "' -r '$1' src/firejail/profile.c; echo private-lib; } | grep -vEx '(include|ignore|caps\.drop|caps\.keep|protocol|restrict-namespaces|seccomp|seccomp\.drop|seccomp\.keep|env|rmenv|net|ip)' | sort -u | tr $'\n' '|' # private-lib is special-cased in the code and doesn't match the regex; grep-ed patterns are handled later with 'syn match nextgroup=' directives (except for include which is special-cased as a fjCommandNoCond keyword) | ||
syn match fjCommand /\v(apparmor|bind|blacklist|blacklist-nolog|cpu|defaultgw|dns|hostname|hosts-file|ip6|iprange|join-or-start|mac|mkdir|mkfile|mtu|name|netfilter|netfilter6|netmask|nice|noblacklist|noexec|nowhitelist|overlay-named|private|private-bin|private-cwd|private-etc|private-home|private-lib|private-opt|private-srv|read-only|read-write|rlimit-as|rlimit-cpu|rlimit-fsize|rlimit-nofile|rlimit-nproc|rlimit-sigpending|timeout|tmpfs|veth-name|whitelist|xephyr-screen) / skipwhite contained | ||
syn match fjCommand /\v(apparmor|bind|blacklist|blacklist-nolog|cpu|defaultgw|dns|hostname|hosts-file|ip6|iprange|join-or-start|landlock|landlock.proc|landlock.read|landlock.write|landlock.special|landlock.execute|mac|mkdir|mkfile|mtu|name|netfilter|netfilter6|netmask|nice|noblacklist|noexec|nowhitelist|overlay-named|private|private-bin|private-cwd|private-etc|private-home|private-lib|private-opt|private-srv|read-only|read-write|rlimit-as|rlimit-cpu|rlimit-fsize|rlimit-nofile|rlimit-nproc|rlimit-sigpending|timeout|tmpfs|veth-name|whitelist|xephyr-screen) / skipwhite contained | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
" Generate list with: rg -o 'strn?cmp\(ptr, "([^ "]*[^ ])"' -r '$1' src/firejail/profile.c | grep -vEx '(include|rlimit|quiet)' | sed -e 's/\./\\./' | sort -u | tr $'\n' '|' # include/rlimit are false positives, quiet is special-cased below | ||
syn match fjCommand /\v(allow-debuggers|allusers|apparmor|caps|deterministic-exit-code|deterministic-shutdown|disable-mnt|ipc-namespace|keep-config-pulse|keep-dev-shm|keep-fd|keep-var-tmp|machine-id|memory-deny-write-execute|netfilter|no3d|noautopulse|nodbus|nodvd|nogroups|noinput|nonewprivs|noprinters|noroot|nosound|notv|nou2f|novideo|overlay|overlay-tmpfs|private|private-cache|private-cwd|private-dev|private-lib|private-tmp|seccomp|seccomp\.32|seccomp\.block-secondary|tracelog|writable-etc|writable-run-user|writable-var|writable-var-log|x11)$/ contained | ||
syn match fjCommand /ignore / nextgroup=fjCommand,fjCommandNoCond skipwhite contained | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,14 +22,35 @@ | |
#include "../include/common.h" | ||
#include "../include/euid_common.h" | ||
#include "../include/rundefs.h" | ||
#ifdef HAVE_LANDLOCK | ||
#include <linux/landlock.h> | ||
#endif | ||
#include <linux/limits.h> // Note: Plain limits.h may break ARG_MAX (see #4583) | ||
#include <stdarg.h> | ||
#include <sys/stat.h> | ||
|
||
// debug restricted shell | ||
//#define DEBUG_RESTRICTED_SHELL | ||
|
||
#ifdef HAVE_LANDLOCK | ||
|
||
extern int landlock_create_ruleset(struct landlock_ruleset_attr *rsattr,size_t size,__u32 flags); | ||
|
||
extern int landlock_add_rule(int fd,enum landlock_rule_type t,void *attr,__u32 flags); | ||
|
||
extern int landlock_restrict_self(int fd,__u32 flags); | ||
|
||
extern int create_full_ruleset(); | ||
|
||
extern int add_read_access_rule_by_path(int rset_fd,char *allowed_path); | ||
|
||
extern int add_write_access_rule_by_path(int rset_fd,char *allowed_path); | ||
|
||
extern int add_create_special_rule_by_path(int rset_fd,char *allowed_path); | ||
|
||
extern int add_execute_rule_by_path(int rset_fd,char *allowed_path); | ||
|
||
#endif | ||
Comment on lines
+35
to
+53
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove the |
||
|
||
// profiles | ||
#define DEFAULT_USER_PROFILE "default" | ||
|
@@ -286,6 +307,11 @@ extern int arg_seccomp32; // enable default seccomp filter for 32 bit arch | |
extern int arg_seccomp_postexec; // need postexec ld.preload library? | ||
extern int arg_seccomp_block_secondary; // block any secondary architectures | ||
|
||
#ifdef HAVE_LANDLOCK | ||
extern int arg_landlock; // Landlock ruleset file descriptor | ||
extern int arg_landlock_proc; // Landlock rule for accessing /proc (0 for no access, 1 for read-only and 2 for read-write) | ||
#endif | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove the extern char *apparmor_profile; // apparmor profile There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was very confusing to see an I thought that it meant the path argument that is eventually passed to a
Suggestion: Avoid being too clever and just use separate variables. Use extern int arg_apparmor; // apparmor
extern char *apparmor_profile; // apparmor profile
+extern int arg_landlock; // Landlock
+extern int arg_landlock_proc; // Landlock rule for accessing /proc (0 for no access, 1 for read-only and 2 for read-write)
+extern int landlock_ruleset_fd; // Landlock ruleset file descriptor Example usage on main.c: else if (strcmp(argv[i], "--landlock") == 0) {
+ arg_landlock = 1;
+
- if (arg_landlock == -1)
- arg_landlock = create_full_ruleset();
+ if (landlock_ruleset_fd < 0) {
+ landlock_ruleset_fd = create_full_ruleset();
+ if (landlock_ruleset_fd < 0)
+ errExit("create_full_ruleset");
+ } The same applies to the other |
||
|
||
extern int arg_caps_default_filter; // enable default capabilities filter | ||
extern int arg_caps_drop; // drop list | ||
extern int arg_caps_drop_all; // drop all capabilities | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,79 @@ | ||||||||||||||||||||||||||||||||
#define _GNU_SOURCE | ||||||||||||||||||||||||||||||||
#include <stdio.h> | ||||||||||||||||||||||||||||||||
#include <stddef.h> | ||||||||||||||||||||||||||||||||
#include <stdlib.h> | ||||||||||||||||||||||||||||||||
#include <unistd.h> | ||||||||||||||||||||||||||||||||
#include <fcntl.h> | ||||||||||||||||||||||||||||||||
#include <sys/syscall.h> | ||||||||||||||||||||||||||||||||
#include <sys/types.h> | ||||||||||||||||||||||||||||||||
#include <sys/prctl.h> | ||||||||||||||||||||||||||||||||
#include <linux/prctl.h> | ||||||||||||||||||||||||||||||||
#include <linux/landlock.h> | ||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is breaking the build on systems that do not support Landlock (such as on Partial error log of the codeql
See
|
||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
int landlock_create_ruleset(struct landlock_ruleset_attr *rsattr,size_t size,__u32 flags) { | ||||||||||||||||||||||||||||||||
return syscall(__NR_landlock_create_ruleset,rsattr,size,flags); | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
int landlock_add_rule(int fd,enum landlock_rule_type t,void *attr,__u32 flags) { | ||||||||||||||||||||||||||||||||
return syscall(__NR_landlock_add_rule,fd,t,attr,flags); | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
int landlock_restrict_self(int fd,__u32 flags) { | ||||||||||||||||||||||||||||||||
prctl(PR_SET_NO_NEW_PRIVS,1,0,0,0); | ||||||||||||||||||||||||||||||||
int result = syscall(__NR_landlock_restrict_self,fd,flags); | ||||||||||||||||||||||||||||||||
if (result!=0) return result; | ||||||||||||||||||||||||||||||||
else { | ||||||||||||||||||||||||||||||||
close(fd); | ||||||||||||||||||||||||||||||||
return 0; | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
Comment on lines
+24
to
+28
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
The same applies to other |
||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
int create_full_ruleset() { | ||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All functions in this file should probably have a |
||||||||||||||||||||||||||||||||
struct landlock_ruleset_attr attr; | ||||||||||||||||||||||||||||||||
attr.handled_access_fs = LANDLOCK_ACCESS_FS_READ_FILE | LANDLOCK_ACCESS_FS_READ_DIR | LANDLOCK_ACCESS_FS_WRITE_FILE | LANDLOCK_ACCESS_FS_REMOVE_FILE | LANDLOCK_ACCESS_FS_REMOVE_DIR | LANDLOCK_ACCESS_FS_MAKE_CHAR | LANDLOCK_ACCESS_FS_MAKE_DIR | LANDLOCK_ACCESS_FS_MAKE_REG | LANDLOCK_ACCESS_FS_MAKE_SOCK | LANDLOCK_ACCESS_FS_MAKE_FIFO | LANDLOCK_ACCESS_FS_MAKE_BLOCK | LANDLOCK_ACCESS_FS_MAKE_SYM | LANDLOCK_ACCESS_FS_EXECUTE; | ||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
To make it readable. The same applies to the other |
||||||||||||||||||||||||||||||||
return landlock_create_ruleset(&attr,sizeof(attr),0); | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
int add_read_access_rule_by_path(int rset_fd,char *allowed_path) { | ||||||||||||||||||||||||||||||||
int result; | ||||||||||||||||||||||||||||||||
int allowed_fd = open(allowed_path,O_PATH | O_CLOEXEC); | ||||||||||||||||||||||||||||||||
struct landlock_path_beneath_attr target; | ||||||||||||||||||||||||||||||||
target.parent_fd = allowed_fd; | ||||||||||||||||||||||||||||||||
target.allowed_access = LANDLOCK_ACCESS_FS_READ_FILE | LANDLOCK_ACCESS_FS_READ_DIR; | ||||||||||||||||||||||||||||||||
result = landlock_add_rule(rset_fd,LANDLOCK_RULE_PATH_BENEATH,&target,0); | ||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are many whitespace issues. See this again: |
||||||||||||||||||||||||||||||||
close(allowed_fd); | ||||||||||||||||||||||||||||||||
return result; | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
int add_write_access_rule_by_path(int rset_fd,char *allowed_path) { | ||||||||||||||||||||||||||||||||
int result; | ||||||||||||||||||||||||||||||||
int allowed_fd = open(allowed_path,O_PATH | O_CLOEXEC); | ||||||||||||||||||||||||||||||||
struct landlock_path_beneath_attr target; | ||||||||||||||||||||||||||||||||
target.parent_fd = allowed_fd; | ||||||||||||||||||||||||||||||||
target.allowed_access = LANDLOCK_ACCESS_FS_WRITE_FILE | LANDLOCK_ACCESS_FS_REMOVE_FILE | LANDLOCK_ACCESS_FS_REMOVE_DIR | LANDLOCK_ACCESS_FS_MAKE_CHAR | LANDLOCK_ACCESS_FS_MAKE_DIR | LANDLOCK_ACCESS_FS_MAKE_REG | LANDLOCK_ACCESS_FS_MAKE_SYM; | ||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did you add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems to be a mistake. I plan to move it to |
||||||||||||||||||||||||||||||||
result = landlock_add_rule(rset_fd,LANDLOCK_RULE_PATH_BENEATH,&target,0); | ||||||||||||||||||||||||||||||||
close(allowed_fd); | ||||||||||||||||||||||||||||||||
return result; | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
int add_create_special_rule_by_path(int rset_fd,char *allowed_path) { | ||||||||||||||||||||||||||||||||
int result; | ||||||||||||||||||||||||||||||||
int allowed_fd = open(allowed_path,O_PATH | O_CLOEXEC); | ||||||||||||||||||||||||||||||||
struct landlock_path_beneath_attr target; | ||||||||||||||||||||||||||||||||
target.parent_fd = allowed_fd; | ||||||||||||||||||||||||||||||||
target.allowed_access = LANDLOCK_ACCESS_FS_MAKE_SOCK | LANDLOCK_ACCESS_FS_MAKE_FIFO | LANDLOCK_ACCESS_FS_MAKE_BLOCK; | ||||||||||||||||||||||||||||||||
result = landlock_add_rule(rset_fd,LANDLOCK_RULE_PATH_BENEATH,&target,0); | ||||||||||||||||||||||||||||||||
close(allowed_fd); | ||||||||||||||||||||||||||||||||
return result; | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
int add_execute_rule_by_path(int rset_fd,char *allowed_path) { | ||||||||||||||||||||||||||||||||
int result; | ||||||||||||||||||||||||||||||||
int allowed_fd = open(allowed_path,O_PATH | O_CLOEXEC); | ||||||||||||||||||||||||||||||||
struct landlock_path_beneath_attr target; | ||||||||||||||||||||||||||||||||
target.parent_fd = allowed_fd; | ||||||||||||||||||||||||||||||||
target.allowed_access = LANDLOCK_ACCESS_FS_EXECUTE; | ||||||||||||||||||||||||||||||||
result = landlock_add_rule(rset_fd,LANDLOCK_RULE_PATH_BENEATH,&target,0); | ||||||||||||||||||||||||||||||||
close(allowed_fd); | ||||||||||||||||||||||||||||||||
return result; | ||||||||||||||||||||||||||||||||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -81,6 +81,11 @@ int arg_seccomp_postexec = 0; // need postexec ld.preload library? | |||||||||||||||||||||||||||||||
int arg_seccomp_block_secondary = 0; // block any secondary architectures | ||||||||||||||||||||||||||||||||
int arg_seccomp_error_action = 0; | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
#ifdef HAVE_LANDLOCK | ||||||||||||||||||||||||||||||||
int arg_landlock = -1; // Landlock ruleset file descriptor (-1 if it doesn't exist) | ||||||||||||||||||||||||||||||||
int arg_landlock_proc = 0; // Landlock rule for accessing /proc (0 for no access, 1 for read-only and 2 for read-write) | ||||||||||||||||||||||||||||||||
#endif | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
int arg_caps_default_filter = 0; // enable default capabilities filter | ||||||||||||||||||||||||||||||||
int arg_caps_drop = 0; // drop list | ||||||||||||||||||||||||||||||||
int arg_caps_drop_all = 0; // drop all capabilities | ||||||||||||||||||||||||||||||||
|
@@ -1401,6 +1406,82 @@ int main(int argc, char **argv, char **envp) { | |||||||||||||||||||||||||||||||
else | ||||||||||||||||||||||||||||||||
exit_err_feature("seccomp"); | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
#ifdef HAVE_LANDLOCK | ||||||||||||||||||||||||||||||||
else if (strcmp(argv[i], "--landlock") == 0) { | ||||||||||||||||||||||||||||||||
if (arg_landlock == -1) arg_landlock = create_full_ruleset(); | ||||||||||||||||||||||||||||||||
const char *home_dir = env_get("HOME"); | ||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use The same applies to the other |
||||||||||||||||||||||||||||||||
int home_fd = open(home_dir,O_PATH | O_CLOEXEC); | ||||||||||||||||||||||||||||||||
struct landlock_path_beneath_attr target; | ||||||||||||||||||||||||||||||||
target.parent_fd = home_fd; | ||||||||||||||||||||||||||||||||
target.allowed_access = LANDLOCK_ACCESS_FS_READ_FILE | LANDLOCK_ACCESS_FS_READ_DIR | LANDLOCK_ACCESS_FS_WRITE_FILE | LANDLOCK_ACCESS_FS_REMOVE_FILE | LANDLOCK_ACCESS_FS_REMOVE_DIR | LANDLOCK_ACCESS_FS_MAKE_CHAR | LANDLOCK_ACCESS_FS_MAKE_DIR | LANDLOCK_ACCESS_FS_MAKE_REG | LANDLOCK_ACCESS_FS_MAKE_SYM; | ||||||||||||||||||||||||||||||||
if (landlock_add_rule(arg_landlock,LANDLOCK_RULE_PATH_BENEATH,&target,0)) { | ||||||||||||||||||||||||||||||||
fprintf(stderr,"An error has occured while adding a rule to the Landlock ruleset.\n"); | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
close(home_fd); | ||||||||||||||||||||||||||||||||
if (add_read_access_rule_by_path(arg_landlock, "/bin/")) { | ||||||||||||||||||||||||||||||||
fprintf(stderr,"An error has occured while adding a rule to the Landlock ruleset.\n"); | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
Comment on lines
+1417
to
+1423
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Make the error messages match the rest of the code and make them more The same applies to the other |
||||||||||||||||||||||||||||||||
if (add_execute_rule_by_path(arg_landlock, "/bin/")) { | ||||||||||||||||||||||||||||||||
fprintf(stderr,"An error has occured while adding a rule to the Landlock ruleset.\n"); | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
if (add_read_access_rule_by_path(arg_landlock, "/dev/")) { | ||||||||||||||||||||||||||||||||
fprintf(stderr,"An error has occured while adding a rule to the Landlock ruleset.\n"); | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
if (add_read_access_rule_by_path(arg_landlock, "/etc/")) { | ||||||||||||||||||||||||||||||||
fprintf(stderr,"An error has occured while adding a rule to the Landlock ruleset.\n"); | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
if (add_read_access_rule_by_path(arg_landlock, "/lib/")) { | ||||||||||||||||||||||||||||||||
fprintf(stderr,"An error has occured while adding a rule to the Landlock ruleset.\n"); | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
if (add_execute_rule_by_path(arg_landlock, "/lib/")) { | ||||||||||||||||||||||||||||||||
fprintf(stderr,"An error has occured while adding a rule to the Landlock ruleset.\n"); | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
if (add_read_access_rule_by_path(arg_landlock, "/opt/")) { | ||||||||||||||||||||||||||||||||
fprintf(stderr,"An error has occured while adding a rule to the Landlock ruleset.\n"); | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
if (add_execute_rule_by_path(arg_landlock, "/opt/")) { | ||||||||||||||||||||||||||||||||
fprintf(stderr,"An error has occured while adding a rule to the Landlock ruleset.\n"); | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
if (add_read_access_rule_by_path(arg_landlock, "/usr/")) { | ||||||||||||||||||||||||||||||||
fprintf(stderr,"An error has occured while adding a rule to the Landlock ruleset.\n"); | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
if (add_execute_rule_by_path(arg_landlock, "/usr/")) { | ||||||||||||||||||||||||||||||||
fprintf(stderr,"An error has occured while adding a rule to the Landlock ruleset.\n"); | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
if (add_read_access_rule_by_path(arg_landlock, "/var/")) { | ||||||||||||||||||||||||||||||||
fprintf(stderr,"An error has occured while adding a rule to the Landlock ruleset.\n"); | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
else if (strncmp(argv[i], "--landlock.proc=", 16) == 0) { | ||||||||||||||||||||||||||||||||
if (strncmp(argv[i]+16, "no", 2) == 0) arg_landlock_proc = 0; | ||||||||||||||||||||||||||||||||
else if (strncmp(argv[i]+16, "ro", 2) == 0) arg_landlock_proc = 1; | ||||||||||||||||||||||||||||||||
else if (strncmp(argv[i]+16, "rw", 2) == 0) arg_landlock_proc = 2; | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
else if (strncmp(argv[i], "--landlock.read=", 16) == 0) { | ||||||||||||||||||||||||||||||||
if (arg_landlock == -1) arg_landlock = create_full_ruleset(); | ||||||||||||||||||||||||||||||||
if (add_read_access_rule_by_path(arg_landlock, argv[i]+16)) { | ||||||||||||||||||||||||||||||||
fprintf(stderr,"An error has occured while adding a rule to the Landlock ruleset.\n"); | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
else if (strncmp(argv[i], "--landlock.write=", 17) == 0) { | ||||||||||||||||||||||||||||||||
if (arg_landlock == -1) arg_landlock = create_full_ruleset(); | ||||||||||||||||||||||||||||||||
if (add_write_access_rule_by_path(arg_landlock, argv[i]+17)) { | ||||||||||||||||||||||||||||||||
fprintf(stderr,"An error has occured while adding a rule to the Landlock ruleset.\n"); | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
else if (strncmp(argv[i], "--landlock.special=", 17) == 0) { | ||||||||||||||||||||||||||||||||
if (arg_landlock == -1) arg_landlock = create_full_ruleset(); | ||||||||||||||||||||||||||||||||
if (add_create_special_rule_by_path(arg_landlock, argv[i]+17)) { | ||||||||||||||||||||||||||||||||
fprintf(stderr,"An error has occured while adding a rule to the Landlock ruleset.\n"); | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
else if (strncmp(argv[i], "--landlock.execute=", 19) == 0) { | ||||||||||||||||||||||||||||||||
if (arg_landlock == -1) arg_landlock = create_full_ruleset(); | ||||||||||||||||||||||||||||||||
if (add_execute_rule_by_path(arg_landlock, argv[i]+19)) { | ||||||||||||||||||||||||||||||||
fprintf(stderr,"An error has occured while adding a rule to the Landlock ruleset.\n"); | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
#endif | ||||||||||||||||||||||||||||||||
else if (strcmp(argv[i], "--memory-deny-write-execute") == 0) { | ||||||||||||||||||||||||||||||||
if (checkcfg(CFG_SECCOMP)) | ||||||||||||||||||||||||||||||||
arg_memory_deny_write_execute = 1; | ||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be sorted by name.