diff mbox series

[1/3] package/bubblewrap: new package

Message ID 20190920153106.2274596-2-aperez@igalia.com
State Accepted
Headers show
Series Add option to enable WebKitGTK's sandboxing support | expand

Commit Message

Adrian Perez de Castro Sept. 20, 2019, 3:31 p.m. UTC
Bubblewrap is a sandboxing tool based on kernel namespaces, typically
used as lower-level infastructure by other end-user tools e.g. Flatpak.

https://github.com/containers/bubblewrap

Signed-off-by: Adrian Perez de Castro <aperez@igalia.com>
---
 DEVELOPERS                         |  1 +
 package/Config.in                  |  1 +
 package/bubblewrap/Config.in       |  7 ++++++
 package/bubblewrap/bubblewrap.hash |  5 ++++
 package/bubblewrap/bubblewrap.mk   | 40 ++++++++++++++++++++++++++++++
 5 files changed, 54 insertions(+)
 create mode 100644 package/bubblewrap/Config.in
 create mode 100644 package/bubblewrap/bubblewrap.hash
 create mode 100644 package/bubblewrap/bubblewrap.mk

Comments

Peter Korsgaard Dec. 2, 2019, 4:22 p.m. UTC | #1
>>>>> "Adrian" == Adrian Perez de Castro <aperez@igalia.com> writes:

 > Bubblewrap is a sandboxing tool based on kernel namespaces, typically
 > used as lower-level infastructure by other end-user tools e.g. Flatpak.

 > https://github.com/containers/bubblewrap

 > Signed-off-by: Adrian Perez de Castro <aperez@igalia.com>
 > ---
 >  DEVELOPERS                         |  1 +
 >  package/Config.in                  |  1 +
 >  package/bubblewrap/Config.in       |  7 ++++++
 >  package/bubblewrap/bubblewrap.hash |  5 ++++
 >  package/bubblewrap/bubblewrap.mk   | 40 ++++++++++++++++++++++++++++++
 >  5 files changed, 54 insertions(+)
 >  create mode 100644 package/bubblewrap/Config.in
 >  create mode 100644 package/bubblewrap/bubblewrap.hash
 >  create mode 100644 package/bubblewrap/bubblewrap.mk

 > diff --git a/DEVELOPERS b/DEVELOPERS
 > index 67a0fef088..bf23b3e1e7 100644
 > --- a/DEVELOPERS
 > +++ b/DEVELOPERS
 > @@ -73,6 +73,7 @@ F:	package/jack1/
 
 >  N:	Adrian Perez de Castro <aperez@igalia.com>
 >  F:	package/brotli/
 > +F:	package/bubblewrap/
 >  F:	package/cog/
 >  F:	package/libepoxy/
 >  F:	package/libwpe/
 > diff --git a/package/Config.in b/package/Config.in
 > index dbf297f4df..412ea1129f 100644
 > --- a/package/Config.in
 > +++ b/package/Config.in
 > @@ -2193,6 +2193,7 @@ menu "System tools"
 >  	source "package/atop/Config.in"
 >  	source "package/attr/Config.in"
 >  	source "package/audit/Config.in"
 > +	source "package/bubblewrap/Config.in"
 >  	source "package/cgroupfs-mount/Config.in"
 >  	source "package/circus/Config.in"
 >  	source "package/coreutils/Config.in"
 > diff --git a/package/bubblewrap/Config.in b/package/bubblewrap/Config.in
 > new file mode 100644
 > index 0000000000..a5220e3fd5
 > --- /dev/null
 > +++ b/package/bubblewrap/Config.in
 > @@ -0,0 +1,7 @@
 > +config BR2_PACKAGE_BUBBLEWRAP
 > +	bool "bubblewrap"
 > +	select BR2_PACKAGE_LIBCAP

It uses fork(), so it needs to depend on BR2_USE_MMU. It also uses
TEMP_FAILURE_RETRY which isn't available on musl, so it should only be
available for glibc/uclibc - Notice that 0.4.0 was recently released
which according to the changelog fixes builds against musl.

Committed with these fixes, thanks.

I wonder what kernel namespacing options are required and/or
recommended? For required options we should add logic in linux/linux.mk
to enable them, and for optional/recommended options it would be good to
mention them in the help text.
Adrian Perez de Castro Dec. 5, 2019, 11:22 p.m. UTC | #2
Hello,

On Mon, 02 Dec 2019 17:22:52 +0100, Peter Korsgaard <peter@korsgaard.com> wrote:
> >>>>> "Adrian" == Adrian Perez de Castro <aperez@igalia.com> writes:
> 
>  > Bubblewrap is a sandboxing tool based on kernel namespaces, typically
>  > used as lower-level infastructure by other end-user tools e.g. Flatpak.
> 
>  > https://github.com/containers/bubblewrap
> 
>  > Signed-off-by: Adrian Perez de Castro <aperez@igalia.com>
>  > ---
>  >  DEVELOPERS                         |  1 +
>  >  package/Config.in                  |  1 +
>  >  package/bubblewrap/Config.in       |  7 ++++++
>  >  package/bubblewrap/bubblewrap.hash |  5 ++++
>  >  package/bubblewrap/bubblewrap.mk   | 40 ++++++++++++++++++++++++++++++
>  >  5 files changed, 54 insertions(+)
>  >  create mode 100644 package/bubblewrap/Config.in
>  >  create mode 100644 package/bubblewrap/bubblewrap.hash
>  >  create mode 100644 package/bubblewrap/bubblewrap.mk
> 
>  > diff --git a/DEVELOPERS b/DEVELOPERS
>  > index 67a0fef088..bf23b3e1e7 100644
>  > --- a/DEVELOPERS
>  > +++ b/DEVELOPERS
>  > @@ -73,6 +73,7 @@ F:	package/jack1/
>  
>  >  N:	Adrian Perez de Castro <aperez@igalia.com>
>  >  F:	package/brotli/
>  > +F:	package/bubblewrap/
>  >  F:	package/cog/
>  >  F:	package/libepoxy/
>  >  F:	package/libwpe/
>  > diff --git a/package/Config.in b/package/Config.in
>  > index dbf297f4df..412ea1129f 100644
>  > --- a/package/Config.in
>  > +++ b/package/Config.in
>  > @@ -2193,6 +2193,7 @@ menu "System tools"
>  >  	source "package/atop/Config.in"
>  >  	source "package/attr/Config.in"
>  >  	source "package/audit/Config.in"
>  > +	source "package/bubblewrap/Config.in"
>  >  	source "package/cgroupfs-mount/Config.in"
>  >  	source "package/circus/Config.in"
>  >  	source "package/coreutils/Config.in"
>  > diff --git a/package/bubblewrap/Config.in b/package/bubblewrap/Config.in
>  > new file mode 100644
>  > index 0000000000..a5220e3fd5
>  > --- /dev/null
>  > +++ b/package/bubblewrap/Config.in
>  > @@ -0,0 +1,7 @@
>  > +config BR2_PACKAGE_BUBBLEWRAP
>  > +	bool "bubblewrap"
>  > +	select BR2_PACKAGE_LIBCAP
> 
> It uses fork(), so it needs to depend on BR2_USE_MMU. It also uses
> TEMP_FAILURE_RETRY which isn't available on musl, so it should only be
> available for glibc/uclibc - Notice that 0.4.0 was recently released
> which according to the changelog fixes builds against musl.
> 
> Committed with these fixes, thanks.

\o/

I will post a follow patch updating to version 0.4.0 when I manage to get a
little bit of spare time, so we can support the package on Musl as well.

> I wonder what kernel namespacing options are required and/or
> recommended? For required options we should add logic in linux/linux.mk
> to enable them, and for optional/recommended options it would be good to
> mention them in the help text.

Mount namespaces are mandatory (I think those cannot be disabled in the kernel
config, I'll have to check to be sure), while User, IPC, PID, Network, and UTS
namespaces are optional. Side note: If User namespaces are enabled in the
kernel, we could avoid installing the “bwrap” binary setuid root, is this
something desirable?

Cheers,
—Adrián
Peter Korsgaard Dec. 7, 2019, 1:12 p.m. UTC | #3
>>>>> "Adrian" == Adrian Perez de Castro <aperez@igalia.com> writes:

Hi,

 >> Committed with these fixes, thanks.

 > \o/

;)

 > I will post a follow patch updating to version 0.4.0 when I manage to get a
 > little bit of spare time, so we can support the package on Musl as well.

Great, thanks.


 >> I wonder what kernel namespacing options are required and/or
 >> recommended? For required options we should add logic in linux/linux.mk
 >> to enable them, and for optional/recommended options it would be good to
 >> mention them in the help text.

 > Mount namespaces are mandatory (I think those cannot be disabled in the kernel
 > config, I'll have to check to be sure), while User, IPC, PID, Network, and UTS
 > namespaces are optional.

Ok. Perhaps we should mention something about that in the help text?


 > Side note: If User namespaces are enabled in the kernel, we could
 > avoid installing the “bwrap” binary setuid root, is this something
 > desirable?

I believe so, but there is no simple way to detect that at build time,
so the only thing we can do is to add a sub option to install the bwrap
binary suid or not (default to y) with a help text describing the user
namespace dependency.
diff mbox series

Patch

diff --git a/DEVELOPERS b/DEVELOPERS
index 67a0fef088..bf23b3e1e7 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -73,6 +73,7 @@  F:	package/jack1/
 
 N:	Adrian Perez de Castro <aperez@igalia.com>
 F:	package/brotli/
+F:	package/bubblewrap/
 F:	package/cog/
 F:	package/libepoxy/
 F:	package/libwpe/
diff --git a/package/Config.in b/package/Config.in
index dbf297f4df..412ea1129f 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -2193,6 +2193,7 @@  menu "System tools"
 	source "package/atop/Config.in"
 	source "package/attr/Config.in"
 	source "package/audit/Config.in"
+	source "package/bubblewrap/Config.in"
 	source "package/cgroupfs-mount/Config.in"
 	source "package/circus/Config.in"
 	source "package/coreutils/Config.in"
diff --git a/package/bubblewrap/Config.in b/package/bubblewrap/Config.in
new file mode 100644
index 0000000000..a5220e3fd5
--- /dev/null
+++ b/package/bubblewrap/Config.in
@@ -0,0 +1,7 @@ 
+config BR2_PACKAGE_BUBBLEWRAP
+	bool "bubblewrap"
+	select BR2_PACKAGE_LIBCAP
+	help
+	  Unprivileged sandbox tool based on Linux namespaces.
+
+	  https://github.com/projectatomic/bubblewrap
diff --git a/package/bubblewrap/bubblewrap.hash b/package/bubblewrap/bubblewrap.hash
new file mode 100644
index 0000000000..c8177d00f5
--- /dev/null
+++ b/package/bubblewrap/bubblewrap.hash
@@ -0,0 +1,5 @@ 
+# Locally computed:
+sha256 c6a45f51794a908b76833b132471397a7413f07620af08e76c273d9f7b364dff bubblewrap-0.3.3.tar.xz
+
+# Hash for license files:
+sha256 b7993225104d90ddd8024fd838faf300bea5e83d91203eab98e29512acebd69c COPYING
diff --git a/package/bubblewrap/bubblewrap.mk b/package/bubblewrap/bubblewrap.mk
new file mode 100644
index 0000000000..cb02594373
--- /dev/null
+++ b/package/bubblewrap/bubblewrap.mk
@@ -0,0 +1,40 @@ 
+################################################################################
+#
+# bubblewrap
+#
+################################################################################
+
+BUBBLEWRAP_VERSION = 0.3.3
+BUBBLEWRAP_SITE = https://github.com/containers/bubblewrap/releases/download/v$(BUBBLEWRAP_VERSION)
+BUBBLEWRAP_SOURCE = bubblewrap-$(BUBBLEWRAP_VERSION).tar.xz
+BUBBLEWRAP_DEPENDENCIES = host-pkgconf libcap
+
+BUBBLEWRAP_LICENSE = LGPL-2.0-or-later
+BUBBLEWRAP_LICENSE_FILES = COPYING
+
+BUBBLEWRAP_CONF_OPTS = \
+	--enable-require-userns=no \
+	--disable-man \
+	--disable-sudo \
+	--with-priv-mode=none
+
+ifeq ($(BR2_PACKAGE_BASH_COMPLETION),y)
+BUBBLEWRAP_CONF_OPTS += --with-bash-completion-dir=/usr/share/bash-completion/completions
+else
+BUBBLEWRAP_CONF_OPTS += --without-bash-completion-dir
+endif
+
+ifeq ($(BR2_PACKAGE_LIBSELINUX),y)
+BUBBLEWRAP_CONF_OPTS += --enable-selinux
+BUBBLEWRAP_DEPENDENCIES += libselinux
+else
+BUBBLEWRAP_CONF_OPTS += --disable-selinux
+endif
+
+# We need to mark bwrap as setuid, in case the kernel
+# has user namespaces disabled for non-root users.
+define BUBBLEWRAP_PERMISSIONS
+	/usr/bin/bwrap f 1755 0 0 - - - - -
+endef
+
+$(eval $(autotools-package))