Skip to content

Commit

Permalink
landlock: fix building without landlock.h
Browse files Browse the repository at this point in the history
landlock.h may not be available on the system (such as with older
versions of Linux API headers), so only try to include it if
`HAVE_LANDLOCK` is defined.

This fixes the following error from `build_debian_package` (which uses
`debian:buster`) on GitLab CI[1]:

    $ ./mkdeb.sh --enable-fatal-warnings
    [...]
    gcc [...] -c ../../src/firejail/landlock.c -o ../../src/firejail/landlock.o
    ../../src/firejail/landlock.c:22:10: fatal error: linux/landlock.h: No such file or directory
     #include <linux/landlock.h>
              ^~~~~~~~~~~~~~~~~~
    compilation terminated.

This amends commit a05ae97 ("landlock: amend empty functions and
comments", 2024-04-08) / PR netblue30#6305.

Relates to netblue30#6078.

[1] https://gitlab.com/Firejail/firejail_ci/-/jobs/6743161059
  • Loading branch information
kmk3 committed Apr 29, 2024
1 parent 6ff97d0 commit 62ac93a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/firejail/landlock.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
*/

#include "firejail.h"
#include <linux/landlock.h>
#include <sys/prctl.h>
#include <sys/syscall.h>
#include <sys/types.h>
Expand All @@ -28,6 +27,8 @@

#ifdef HAVE_LANDLOCK

#include <linux/landlock.h>

static int ll_ruleset_fd = -1;
static int ll_abi = -1;

Expand Down

0 comments on commit 62ac93a

Please sign in to comment.