authenticate and run on current virtual terminal

This commit is contained in:
Muki Kiboigo 2024-06-19 16:19:35 -07:00
parent 6d3808553e
commit ab462e91c2
No known key found for this signature in database
GPG Key ID: 933D01D1D80F8991
2 changed files with 10 additions and 0 deletions

View File

@ -6,6 +6,10 @@ pub const termbox = @cImport({
@cInclude("termbox.h");
});
pub const vt = @cImport({
@cInclude("linux/vt.h");
});
pub const pam = @cImport({
@cInclude("security/pam_appl.h");
});
@ -44,6 +48,7 @@ pub const passwd = extern struct {
pw_shell: [*:0]u8,
};
pub const VT_GETSTATE: c_int = 0x5603;
pub const VT_ACTIVATE: c_int = 0x5606;
pub const VT_WAITACTIVE: c_int = 0x5607;

View File

@ -526,6 +526,11 @@ pub fn main() !void {
defer shared_err.deinit();
{
// This will set the current active VT as our TTY.
var vtstat: interop.vt.vt_stat = undefined;
_ = std.c.ioctl(std.c.STDIN_FILENO, interop.VT_GETSTATE, &vtstat);
config.tty = @intCast(vtstat.v_active);
const login_text = try allocator.dupeZ(u8, login.text.items);
defer allocator.free(login_text);
const password_text = try allocator.dupeZ(u8, password.text.items);