run :: () { hostname_fp :: "/etc/hostname"; content, ok := read_entire_file(hostname_fp); assert(ok); log("Pre Landlock: This is your hostname: »%«", content); log("OK returns: %", ok); log("-------------------------------------------------"); sec_landlock_init(); content, ok = read_entire_file(hostname_fp); log("-------------------------------------------------"); log("Post Landlock: You should NOT see your hostname: »%«", content); log("OK returns: %", ok); /** Note: If a FD is already open pre landlock init, you can still use it here! */ } #scope_file DESIRED_VERSION :: 7; sec_landlock_init :: () { version := landlock_is_version_equal_or_higher(DESIRED_VERSION, true); if !version { log("Warning: Your version of landlock is too old.", flags=.WARNING); } rules := landlock_all_rules(); ok, ll_fd := landlock_create_ruleset(*rules); if !ok exit(1); ok = landlock_lock_privileges(); if !ok exit(1); ok = landlock_restrict_self(ll_fd); if !ok exit(1); log("Landlock is armed."); } #import "Basic"; #import "File"; #import,file "../0x2_Landlock.jai";