Skip to content

Commit 598df9f

Browse files
committed
Fix rootless file ownership
1 parent 8558480 commit 598df9f

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/dockerc.zig

+10-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ pub fn main() !void {
163163
const offset_arg = try std.fmt.allocPrintZ(allocator, "{}", .{runtime_content.len});
164164
defer allocator.free(offset_arg);
165165

166-
const mksquashfs_args = [_:null]?[*:0]const u8{
166+
var mksquashfs_args = [_:null]?[*:0]const u8{
167167
"mksquashfs",
168168
bundle_destination,
169169
output_path,
@@ -172,8 +172,17 @@ pub fn main() !void {
172172
"-offset",
173173
offset_arg,
174174
"-noappend",
175+
"-force-uid",
176+
"0",
177+
"-force-gid",
178+
"0",
175179
};
176180

181+
// in rootfull, do not force uid/gid to 0,0
182+
if (res.args.rootfull != 0) {
183+
mksquashfs_args[mksquashfs_args.len - 4] = null;
184+
}
185+
177186
mksquashfs_main(
178187
mksquashfs_args.len,
179188
&mksquashfs_args,

0 commit comments

Comments
 (0)