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: amend empty functions and comments #6305

Merged
merged 1 commit into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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