Skip to content

Commit 2135b29

Browse files
Added selinux support to sysfs mount
1 parent ffda8f8 commit 2135b29

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

bubblewrap.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,6 +1199,7 @@ setup_newroot (bool unshare_pid,
11991199
{
12001200
SetupOp *op;
12011201
int tmp_overlay_idx = 0;
1202+
struct stat sbuf;
12021203

12031204
for (op = ops; op != NULL; op = op->next)
12041205
{
@@ -1461,6 +1462,16 @@ setup_newroot (bool unshare_pid,
14611462
privileged_op (privileged_op_socket,
14621463
PRIV_SEP_OP_SYS_MOUNT, 0, 0, 0,
14631464
dest, NULL);
1465+
1466+
/* In case the host utilizes SELinux, /sys/fs/selinux should be shared with the sandbox */
1467+
char *selinux_src_dir = "oldroot/sys/fs/selinux";
1468+
cleanup_free char *selinux_dest_dir = strconcat (dest, "/fs/selinux");
1469+
if (stat (selinux_src_dir, &sbuf) == 0 && stat (selinux_dest_dir, &sbuf) == 0)
1470+
{
1471+
privileged_op (privileged_op_socket,
1472+
PRIV_SEP_OP_BIND_MOUNT, 0, 0, 0,
1473+
selinux_src_dir, selinux_dest_dir);
1474+
}
14641475
}
14651476
else
14661477
{

0 commit comments

Comments
 (0)