Skip to content
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

Landlock test code #2

Open
l0kod opened this issue Sep 26, 2024 · 0 comments
Open

Landlock test code #2

l0kod opened this issue Sep 26, 2024 · 0 comments

Comments

@l0kod
Copy link

l0kod commented Sep 26, 2024

The landlock-c.md example doesn't build. The syscall declarations are missing and an error case is not defined:

landlock-test.c: In function ‘main’:
landlock-test.c:66:13: error: implicit declaration of function ‘landlock_create_ruleset’; did you mean ‘SYS_landlock_create_ruleset’? [-Wimplicit-function-declaration]
   66 |         if (landlock_create_ruleset(NULL, 0, LANDLOCK_CREATE_RULESET_VERSION) < 0)
      |             ^~~~~~~~~~~~~~~~~~~~~~~
      |             SYS_landlock_create_ruleset
landlock-test.c:73:13: error: implicit declaration of function ‘landlock_restrict_self’; did you mean ‘SYS_landlock_restrict_self’? [-Wimplicit-function-declaration]
   73 |         if (landlock_restrict_self(ruleset_fd, 0)) {
      |             ^~~~~~~~~~~~~~~~~~~~~~
      |             SYS_landlock_restrict_self
landlock-test.c:75:17: error: label ‘err_close_ruleset’ used but not defined
   75 |                 goto err_close_ruleset;
      |                 ^~~~

You need to define the syscalls as in the sample code:

#ifndef landlock_create_ruleset
static inline int
landlock_create_ruleset(...

You should be able to trim most included headers too.

There is currently no C library as explained in #1, which is why this file has so much lines. A minimal C library is planned though (landlock-lsm/linux#38), but we encourage the use of Rust or Go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant