Skip to content

Commit

Permalink
Workaround for permission issues on bwrap overlays with dwarfs
Browse files Browse the repository at this point in the history
  • Loading branch information
ruanformigoni committed Nov 16, 2024
1 parent 3936ed6 commit ffba751
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions deploy/flatimage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ function _create_subsystem_blueprint()

# Set permissions
chown -R 1000:1000 "/tmp/$dist"
chmod -R 777 "/tmp/$dist"

# MIME
mkdir -p "/tmp/$dist/fim/desktop"
Expand Down Expand Up @@ -272,6 +273,7 @@ function _create_subsystem_alpine()

# Create layer 0 compressed filesystem
chown -R 1000:1000 /tmp/"$dist"
chmod -R 777 /tmp/"$dist"
# mksquashfs /tmp/"$dist" "$dist".layer -comp zstd -Xcompression-level 15
./bin/mkdwarfs -i /tmp/"$dist" -o "$dist".layer

Expand Down Expand Up @@ -496,6 +498,7 @@ function _create_subsystem_arch()

# Create layer 0 compressed filesystem
chown -R 1000:1000 ./arch
chmod -R 777 ./arch
# chmod 777 -R ./arch
# mksquashfs ./arch ./arch.layer -comp zstd -Xcompression-level 15
./bin/mkdwarfs -i ./arch -o ./arch.layer
Expand Down
10 changes: 10 additions & 0 deletions src/boot/cmd/layers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ inline void create(fs::path const& path_dir_src, fs::path const& path_file_dst,
// Compression level must be at least 1 and less or equal to 10
compression_level = std::clamp(compression_level, uint64_t{0}, uint64_t{9});

// Change permissions on source directory files if possible
// Required for bwrap, since --uid and --gid do not affect the overlay permissions
// which leads to permission issues, since the layer user does not match the sandbox user
// A solution would be to use -o uid=xxxx,gid=xxxx in dwarfs' mount options, but these
// seem to currently be unavailable
for(auto entry : fs::directory_iterator(path_dir_src))
{
lec(fs::permissions,entry.path(), fs::perms::all, fs::perm_options::replace);
} // for

// // Convert to non-percentual compression level
// compression_level = std::ceil(22 * (static_cast<double>(compression_level) / 10));

Expand Down

0 comments on commit ffba751

Please sign in to comment.