Skip to content

Commit

Permalink
Merge pull request #6305 from kmk3/landlock-amend-empty
Browse files Browse the repository at this point in the history
landlock: amend empty functions and comments
  • Loading branch information
netblue30 authored Apr 11, 2024
2 parents 403d9ae + a05ae97 commit 442a2f8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
2 changes: 0 additions & 2 deletions src/firejail/firejail.h
Original file line number Diff line number Diff line change
Expand Up @@ -966,10 +966,8 @@ void run_ids(int argc, char **argv);
void oom_set(const char *oom_string);

// landlock.c
#ifdef HAVE_LANDLOCK
int ll_get_fd(void);
int ll_restrict(uint32_t flags);
void ll_add_profile(int type, const char *data);
#endif /* HAVE_LANDLOCK */

#endif
14 changes: 13 additions & 1 deletion src/firejail/landlock.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#ifdef HAVE_LANDLOCK
#include "firejail.h"
#include <linux/landlock.h>
#include <sys/prctl.h>
Expand All @@ -27,6 +26,8 @@
#include <errno.h>
#include <fcntl.h>

#ifdef HAVE_LANDLOCK

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

Expand Down Expand Up @@ -295,6 +296,17 @@ void ll_add_profile(int type, const char *data) {
}

#else

int ll_get_fd(void) {
return -1;
}

int ll_restrict(uint32_t flags) {
(void) flags;

return 0;
}

void ll_add_profile(int type, const char *data) {
(void) type;
(void) data;
Expand Down
6 changes: 4 additions & 2 deletions src/firejail/profile.c
Original file line number Diff line number Diff line change
Expand Up @@ -1074,8 +1074,10 @@ int profile_check_line(char *ptr, int lineno, const char *fname) {
}

//#ifdef HAVE_LANDLOCK
// landlock_connon.inc included by derfault in landlock.profile
// all landlcok functions are empty in case landlock is not available in the kernel
// landlock-common.inc is included by default.profile, so the entries of the
// former should be processed or ignored instead of aborting.
// Note that all landlock functions are empty when building without landlock
// support.
if (strncmp(ptr, "landlock.enforce", 16) == 0) {
arg_landlock_enforce = 1;
return 0;
Expand Down

0 comments on commit 442a2f8

Please sign in to comment.