Skip to content

Commit

Permalink
uid mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
NilsIrl committed Aug 15, 2024
1 parent 598df9f commit 8462f5c
Show file tree
Hide file tree
Showing 4 changed files with 298 additions and 60 deletions.
29 changes: 29 additions & 0 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,35 @@ pub fn build(b: *std.Build) void {
},
});

runtime.addIncludePath(b.dependency("shadow", .{}).path("libsubid"));
runtime.addIncludePath(b.dependency("shadow", .{}).path("lib"));
runtime.addIncludePath(b.dependency("shadow", .{}).path(""));

runtime.addCSourceFiles(.{
.root = b.dependency("shadow", .{}).path(""),
.files = &[_][]const u8{
"libsubid/api.c",
"lib/shadowlog.c",
"lib/subordinateio.c",
"lib/commonio.c",
"lib/write_full.c",
"lib/nss.c",
"lib/get_pid.c",
"lib/memzero.c",
"lib/alloc.c",
"lib/atoi/str2i.c",
"lib/atoi/a2i.c",
"lib/atoi/strtou_noneg.c",
"lib/atoi/strtoi.c",
"lib/string/sprintf.c",
},
.flags = &[_][]const u8{
"-DENABLE_SUBIDS",
// duplicate symbol with crun
"-Dxasprintf=shadow_xasprintf",
},
});

const aarch64_target = b.resolveTargetQuery(.{
.cpu_arch = .aarch64,
.abi = .musl,
Expand Down
4 changes: 4 additions & 0 deletions build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
.url = "https://github.com/Hejsil/zig-clap/archive/60cd46aacff4960104703da9ba683077b1e3c76c.tar.gz",
.hash = "12205eb22c644df2469045083efe9c92189d56494ebe8901b36ef1218c3717e6eb78",
},
.shadow = .{
.url = "https://github.com/shadow-maint/shadow/releases/download/4.15.3/shadow-4.15.3.tar.gz",
.hash = "12202972bc830245199eb4c5b10f853f1be094eb8c86d431299a69b1c01fa5781a7e",
},
},
.paths = .{
// This makes *all* files, recursively, included in this package. It is generally
Expand Down
11 changes: 5 additions & 6 deletions src/dockerc.zig
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,12 @@ pub fn main() !void {
"0",
};

// in rootfull, do not force uid/gid to 0,0
if (res.args.rootfull != 0) {
mksquashfs_args[mksquashfs_args.len - 4] = null;
}

mksquashfs_main(
mksquashfs_args.len,
// in rootfull, do not force uid/gid to 0,0
if (res.args.rootfull != 0)
mksquashfs_args.len - 4
else
mksquashfs_args.len,
&mksquashfs_args,
);

Expand Down
Loading

0 comments on commit 8462f5c

Please sign in to comment.