Skip to content

Commit

Permalink
Add --require-userns build option for setuid mode
Browse files Browse the repository at this point in the history
Some distributions may want to enforce this in the privileged case;
it enforces stronger isolation rather than allowing users to
cherry-pick namespaces.

Closes: #141

Closes: #159
Approved by: valoq
  • Loading branch information
valoq authored and rh-atomic-bot committed Jan 20, 2017
1 parent 3032e8c commit c3a8858
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
6 changes: 6 additions & 0 deletions bubblewrap.c
Expand Up @@ -1718,6 +1718,12 @@ main (int argc,
if (!is_privileged && getuid () != 0)
opt_unshare_user = TRUE;

#ifdef ENABLE_REQUIRE_USERNS
/* In this build option, we require userns. */
if (is_privileged && getuid () != 0)
opt_unshare_user = TRUE;
#endif

if (opt_unshare_user_try &&
stat ("/proc/self/ns/user", &sbuf) == 0)
{
Expand Down
11 changes: 11 additions & 0 deletions configure.ac
Expand Up @@ -100,6 +100,16 @@ AC_ARG_ENABLE(sudo,
[SUDO_BIN="sudo"], [SUDO_BIN=""])
AC_SUBST([SUDO_BIN])

AC_ARG_ENABLE(require-userns,
AS_HELP_STRING([--enable-require-userns=yes/no (default no)],
[Require user namespaces by default when installed suid]),
[],
[enable_require_userns="no"])

AS_IF([ test "x$enable_require_userns" = "xyes" ], [
AC_DEFINE(ENABLE_REQUIRE_USERNS, 1, [Define if userns should be used by default in suid mode])
])

AC_CONFIG_FILES([
Makefile
])
Expand All @@ -112,5 +122,6 @@ echo "
man pages (xsltproc): $enable_man
SELinux: $have_selinux
setuid mode on make install: $with_priv_mode
require default userns: $enable_require_userns
mysteriously satisfying to pop: yes"
echo ""

0 comments on commit c3a8858

Please sign in to comment.