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

WIP: feature: add support for wayland-security-context-v1 #6436

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
6 changes: 6 additions & 0 deletions src/firejail/checkcfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,12 @@ static const char *const compiletime_support =
"enabled"
#else
"disabled"
#endif
"\n\t- wayland security context support is "
#ifdef HAVE_WAYLAND_SECURITY_CONTEXT
"enabled"
#else
"disabled"
Comment on lines +427 to +432
Copy link
Collaborator

@kmk3 kmk3 Aug 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By default put the wayland code right before the x11 code so that it's more or
less sorted.

This applies to all files except wayland.c (and env.c, which is already sorted).

#endif
"\n";

Expand Down
3 changes: 2 additions & 1 deletion src/firejail/env.c
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,8 @@ static const char * const env_whitelist[] = {
"LANGUAGE",
"LC_MESSAGES",
// "PATH",
"DISPLAY" // required by X11
"DISPLAY", // required by X11
"WAYLAND_DISPLAY" // required by wayland
};

static const char * const env_whitelist_sbox[] = {
Expand Down
1 change: 1 addition & 0 deletions src/firejail/firejail.h
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ extern int arg_deterministic_shutdown; // shut down the sandbox if first child d
extern int arg_keep_fd_all; // inherit all file descriptors to sandbox
extern int arg_netlock; // netlocker
extern int arg_restrict_namespaces;
extern int arg_wayland; // filter wayland socket

typedef enum {
DBUS_POLICY_ALLOW, // Allow unrestricted access to the bus
Expand Down
6 changes: 6 additions & 0 deletions src/firejail/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ int login_shell = 0;
int just_run_the_shell = 0;
int arg_netlock = 0;
int arg_restrict_namespaces = 0;
int arg_wayland = 0;

int parent_to_child_fds[2];
int child_to_parent_fds[2];
Expand Down Expand Up @@ -1646,6 +1647,11 @@ int main(int argc, char **argv, char **envp) {
cfg.nice = 0;
arg_nice = 1;
}
#ifdef HAVE_WAYLAND_SECURITY_CONTEXT
else if (strcmp(argv[1], "--wayland") == 0) {
arg_wayland = 1;
}
#endif

//*************************************
// filesystem
Expand Down
22 changes: 22 additions & 0 deletions src/firejail/wayland.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright (C) 2014-2024 Firejail Authors
*
* This file is part of firejail project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "firejail.h"