auth: chown & chmod TTY (closes #944)

Signed-off-by: AnErrupTion <anerruption@disroot.org>
This commit is contained in:
AnErrupTion 2026-07-06 11:10:26 +02:00
parent 4513033bcb
commit 9b8046e37c
No known key found for this signature in database
1 changed files with 5 additions and 0 deletions

View File

@ -105,6 +105,11 @@ pub fn authenticate(allocator: std.mem.Allocator, io: std.Io, log_file: *LogFile
try log_file.info(io, "auth/passwd", "setting user shell", .{});
if (user_entry.shell == null) interop.setUserShell(&user_entry);
// chown & chmod stdin (which is the TTY)
// https://github.com/mirror/busybox/blob/371fe9f71d445d18be28c82a2a6d82115c8af19d/loginutils/login.c#L558
if (interop.isError(std.posix.system.fchown(std.posix.STDIN_FILENO, user_entry.uid, user_entry.gid))) return error.TtyChownFailed;
if (interop.isError(std.posix.system.fchmod(std.posix.STDIN_FILENO, 0o600))) return error.TtyChmodFailed;
var shared_err = try SharedError.init(null, null);
defer shared_err.deinit();