mirror of
https://github.com/fairyglade/ly.git
synced 2025-12-20 19:24:53 +00:00
Fix fallback UID range + add error if UID range not found
Signed-off-by: AnErrupTion <anerruption@disroot.org>
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user