Logo

index : 0x2lib

Library extension for Jai

  • summary
  • about
  • tree
  • log
  • branches
<< path: root/public/0x2lib.git/html/tests/landlock.jai blob: 69647c4b3b9f9ff92a806367b0c0885c0bc126d3 [raw] [clear marker]

        
0
1
2
3run :: () {
4 hostname_fp :: "/etc/hostname";
5 content, ok := read_entire_file(hostname_fp);
6 assert(ok);
7
8 log("Pre Landlock: This is your hostname: »%«", content);
9 log("OK returns: %", ok);
10 log("-------------------------------------------------");
11
12 sec_landlock_init();
13 content, ok = read_entire_file(hostname_fp);
14
15 log("-------------------------------------------------");
16 log("Post Landlock: You should NOT see your hostname: »%«", content);
17 log("OK returns: %", ok);
18
19 /** Note: If a FD is already open pre landlock init, you can still use it here! */
20}
21
22
23#scope_file
24
25
26DESIRED_VERSION :: 7;
27
28
29sec_landlock_init :: () {
30 version := landlock_is_version_equal_or_higher(DESIRED_VERSION, true);
31 if !version {
32 log("Warning: Your version of landlock is too old.", flags=.WARNING);
33 }
34
35 rules := landlock_all_rules();
36 ok, ll_fd := landlock_create_ruleset(*rules);
37 if !ok exit(1);
38
39 ok = landlock_lock_privileges();
40 if !ok exit(1);
41
42 ok = landlock_restrict_self(ll_fd);
43 if !ok exit(1);
44
45 log("Landlock is armed.");
46}
47
48
49#import "Basic";
50#import "File";
51
52#import,file "../0x2_Landlock.jai";
53
54
Copyright 2026  E766CB298A6D1E64 | Git-Thing heavily inspired by cgit