diff --git a/build.zig b/build.zig index fe73229..12ababb 100644 --- a/build.zig +++ b/build.zig @@ -44,8 +44,8 @@ pub fn build(b: *std.Build) !void { const enable_x11_support = b.option(bool, "enable_x11_support", "Enable X11 support (default is on)") orelse true; const default_tty = b.option(u8, "default_tty", "Set the TTY (default is 2)") orelse 2; const fallback_tty = b.option(u8, "fallback_tty", "Set the fallback TTY (default is 2). This value gets embedded into the binary") orelse 2; - const fallback_uid_min = b.option(std.posix.uid_t, "fallback_uid_min", "Set the fallback minimum UID (default is 1000). This value gets embedded into the binary") orelse 2; - const fallback_uid_max = b.option(std.posix.uid_t, "fallback_uid_max", "Set the fallback maximum UID (default is 60000). This value gets embedded into the binary") orelse 2; + const fallback_uid_min = b.option(std.posix.uid_t, "fallback_uid_min", "Set the fallback minimum UID (default is 1000). This value gets embedded into the binary") orelse 1000; + const fallback_uid_max = b.option(std.posix.uid_t, "fallback_uid_max", "Set the fallback maximum UID (default is 60000). This value gets embedded into the binary") orelse 60000; default_tty_str = try std.fmt.allocPrint(b.allocator, "{d}", .{default_tty}); diff --git a/src/interop.zig b/src/interop.zig index 2f8483a..4d52f49 100644 --- a/src/interop.zig +++ b/src/interop.zig @@ -171,17 +171,22 @@ fn PlatformStruct() type { var iterator = std.mem.splitScalar(u8, login_defs_buffer, '\n'); var uid_range = UidRange{}; + var nameFound = false; while (iterator.next()) |line| { const trimmed_line = std.mem.trim(u8, line, " \n\r\t"); if (std.mem.startsWith(u8, trimmed_line, "UID_MIN")) { uid_range.uid_min = try parseValue(std.posix.uid_t, "UID_MIN", trimmed_line); + nameFound = true; } else if (std.mem.startsWith(u8, trimmed_line, "UID_MAX")) { uid_range.uid_max = try parseValue(std.posix.uid_t, "UID_MAX", trimmed_line); + nameFound = true; } } + if (!nameFound) return error.UidNameNotFound; + // This code assumes the OS has a login.defs file with UID_MIN // and UID_MAX values defined in it, which should be the case // for most systemd-based Linux distributions out there.