Skip to content

Commit

Permalink
Explicit uid and gid for bwrap
Browse files Browse the repository at this point in the history
  • Loading branch information
ruanformigoni committed Nov 16, 2024
1 parent 23260f5 commit 3936ed6
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/cpp/lib/bwrap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,14 @@ inline Bwrap::Bwrap(
of.close();

// Check if should be root in the container
if ( m_is_root ) { ns_vector::push_back(m_args, "--uid", "0", "--gid", "0"); }
if ( m_is_root )
{
ns_vector::push_back(m_args, "--uid", "0", "--gid", "0");
}
else
{
ns_vector::push_back(m_args, "--uid", std::to_string(getuid()), "--gid", std::to_string(getgid()));
}

// Use native bwrap --overlay options or overlayfs
if ( opt_overlay )
Expand Down

0 comments on commit 3936ed6

Please sign in to comment.