Compare commits

..

3 commits

Author SHA1 Message Date
AnErrupTion
a6e5f87e24
auth: Check faillock for locked account (closes #898)
Signed-off-by: AnErrupTion <anerruption@disroot.org>
2026-08-26 15:24:14 +02:00
AnErrupTion
c90aec373e
auth: Implement password reset after expiration (closes #992)
Signed-off-by: AnErrupTion <anerruption@disroot.org>
2026-08-26 09:36:02 +02:00
AnErrupTion
35fa91058b
migrator: One TODO is gone! Yippee!
Signed-off-by: AnErrupTion <anerruption@disroot.org>
2026-08-26 09:13:39 +02:00
42 changed files with 258 additions and 136 deletions

View file

@ -123,7 +123,7 @@ pub fn build(b: *std.Build) !void {
const run_cmd = b.addRunArtifact(exe);
run_cmd.step.dependOn(b.getInstallStep());
run_cmd.addPassthruArgs();
if (b.args) |args| run_cmd.addArgs(args);
const run_step = b.step("run", "Run the app");
run_step.dependOn(&run_cmd.step);
@ -188,7 +188,7 @@ fn getVersionStr(b: *std.Build, name: []const u8, version: std.SemanticVersion)
const git_describe_raw = b.runAllowFail(&[_][]const u8{
"git",
"-C",
try b.root.toString(b.allocator),
b.build_root.path orelse ".",
"describe",
"--match",
"*.*.*",

View file

@ -2,14 +2,14 @@
.name = .ly,
.version = "1.6.0",
.fingerprint = 0xa148ffcc5dc2cb59,
.minimum_zig_version = "0.17.0",
.minimum_zig_version = "0.16.0",
.dependencies = .{
.ly_ui = .{
.path = "ly-ui",
},
.clap = .{
.url = "git+https://github.com/Hejsil/zig-clap?ref=master#e91d66b1abba2024cd2e816426f14d233d3dad9a",
.hash = "clap-0.12.0-oBajB2LpAQD1BQpAukHcuwhIUoHWYNy2DzU6lDW2v2N8",
.url = "git+https://github.com/Hejsil/zig-clap#fc1e5cc3f6d9d3001112385ee6256d694e959d2f",
.hash = "clap-0.11.0-oBajB7foAQC3Iyn4IVCkUdYaOVVng5IZkSncySTjNig1",
},
},
.paths = .{

View file

@ -381,7 +381,7 @@ fn installText(
destination_directory: std.Io.Dir,
destination_directory_path: []const u8,
destination_file: []const u8,
options: std.Io.Dir.CreateFileOptions,
options: std.Io.File.CreateFlags,
) !void {
var file = try destination_directory.createFile(io, destination_file, options);
defer file.close(io);

View file

@ -28,7 +28,9 @@ pub fn build(b: *std.Build) void {
});
mod.addImport("zlua", zlua.module("zlua"));
const translate_c = b.dependency("translate_c", .{});
const translate_c = b.dependency("translate_c", .{
.target = target,
});
addCImport(b, mod, translate_c, target, optimize, "pam", "#include <security/pam_appl.h>");
addCImport(b, mod, translate_c, target, optimize, "utmp", "#include <utmpx.h>");

View file

@ -2,19 +2,19 @@
.name = .ly_core,
.version = "1.2.0",
.fingerprint = 0xddda7afda795472,
.minimum_zig_version = "0.17.0",
.minimum_zig_version = "0.16.0",
.dependencies = .{
.zigini = .{
.url = "git+https://github.com/AshAmetrine/zigini?ref=main#085badbf90e25016f4609b5bde334689cdb41c5c",
.hash = "zigini-0.6.0-BSkB7UtYAAB6b6HEm3Pjj5WIy-uiuBYsNTNCUENVwL1t",
.url = "git+https://github.com/AshAmetrine/zigini?ref=master#a665d081dda42664a96da2840ea09c5ccf9d0692",
.hash = "zigini-0.5.0-BSkB7e9WAACfyCBABNZiWL3gFMw18GKn3qBcPs8L1Ec1",
},
.translate_c = .{
.url = "git+https://codeberg.org/ziglang/translate-c?ref=master#3da873cacdd7e9190fe1cf40372ddf5387c970ea",
.hash = "translate_c-0.0.0-Q_BUWktLBwBO7VLbmrOKUcAMRtE5fmOxI35189X5XbJs",
.url = "git+https://codeberg.org/ziglang/translate-c?ref=zig-0.16.x#6fe0ffc4549f15c5f2d9432c2b4460ba90ff85ac",
.hash = "translate_c-1.0.0-Q_BUWo_5BgD4flHdUhA31zOz0XvZk9k7lQv1ouzyNXj2",
},
.zlua = .{
.url = "git+https://github.com/AnErrupTion/ziglua?ref=zig-0.17#4159a5592a8de728022e0c491a3bdde7decbdc16",
.hash = "zlua-0.1.0-hGRpCw6VBQDaOiIiYsLOcQTlcJCpqDqIrhyDVqkanTSB",
.url = "git+https://github.com/natecraddock/ziglua?ref=zig-0.16#8f271c82baa5fc43aa02a72f6da020c2025d9436",
.hash = "zlua-0.1.0-hGRpC2aABQD4D9PBVH3wAW8k32-I4969MRQ0CpOwoley",
},
},
.paths = .{

View file

@ -54,7 +54,7 @@ pub fn info(self: *LogFile, io: std.Io, category: []const u8, comptime message:
} else {
var buffer: [1024]u8 = undefined;
const slice = try std.fmt.bufPrint(&buffer, message, args);
const msg = try std.fmt.bufPrintSentinel(buffer[slice.len..], "[info/{s}] {s}", .{ category, slice }, 0);
const msg = try std.fmt.bufPrintZ(buffer[slice.len..], "[info/{s}] {s}", .{ category, slice });
std.posix.system.syslog(std.posix.LOG.INFO, msg.ptr);
}
@ -72,7 +72,7 @@ pub fn err(self: *LogFile, io: std.Io, category: []const u8, comptime message: [
} else {
var buffer: [1024]u8 = undefined;
const slice = try std.fmt.bufPrint(&buffer, message, args);
const msg = try std.fmt.bufPrintSentinel(buffer[slice.len..], "[info/{s}] {s}", .{ category, slice }, 0);
const msg = try std.fmt.bufPrintZ(buffer[slice.len..], "[info/{s}] {s}", .{ category, slice });
std.posix.system.syslog(std.posix.LOG.ERR, msg.ptr);
}

View file

@ -1,7 +1,7 @@
const std = @import("std");
const ErrInt = @Int(.unsigned, @bitSizeOf(anyerror));
const PaddingInt = @Int(.unsigned, 8 - (@bitSizeOf(ErrInt) + @bitSizeOf(bool)) % 8);
const ErrInt = std.meta.Int(.unsigned, @bitSizeOf(anyerror));
const PaddingInt = std.meta.Int(.unsigned, 8 - (@bitSizeOf(ErrInt) + @bitSizeOf(bool)) % 8);
const ErrorHandler = packed struct {
has_error: bool = false,

View file

@ -376,7 +376,7 @@ pub fn setNumlock(val: bool) !void {
}
pub fn setUserContext(allocator: std.mem.Allocator, entry: UsernameEntry) !void {
const username_z = try allocator.dupeSentinel(u8, entry.username.?, 0);
const username_z = try allocator.dupeZ(u8, entry.username.?);
defer allocator.free(username_z);
return platform_struct.setUserContextImpl(username_z.ptr, entry);
@ -392,10 +392,10 @@ pub fn setUserShell(entry: *UsernameEntry) void {
}
pub fn setEnvironmentVariable(allocator: std.mem.Allocator, name: []const u8, value: []const u8, replace: bool) !void {
const name_z = try allocator.dupeSentinel(u8, name, 0);
const name_z = try allocator.dupeZ(u8, name);
defer allocator.free(name_z);
const value_z = try allocator.dupeSentinel(u8, value, 0);
const value_z = try allocator.dupeZ(u8, value);
defer allocator.free(value_z);
const status = stdlib.setenv(name_z.ptr, value_z.ptr, @intFromBool(replace));
@ -422,7 +422,7 @@ pub fn getNextUsernameEntry() ?UsernameEntry {
}
pub fn getUsernameEntry(allocator: std.mem.Allocator, username: []const u8) ?UsernameEntry {
const username_z = allocator.dupeSentinel(u8, username, 0) catch return null;
const username_z = allocator.dupeZ(u8, username) catch return null;
defer allocator.free(username_z);
const entry = pwd.getpwnam(username_z);

View file

@ -131,11 +131,13 @@ pub fn LuaParser(comptime Struct: type) type {
var arena = std.heap.ArenaAllocator.init(allocator);
const arena_alloc = arena.allocator();
var maybe_load_error: ?anyerror = null;
errdefer |err| maybe_load_error = err;
const data = parseLua(arena_alloc, path) catch load_error: {
break :load_error Struct{};
};
var maybe_load_error: ?anyerror = null;
if (global_errors.items.len != 0) {
maybe_load_error = error.InvalidConfig;
}
@ -174,8 +176,8 @@ pub fn LuaParser(comptime Struct: type) type {
defer lua.pop(1); // pop ly table
if (ly_type == .nil) return error.MissingLyTable;
inline for (struc.field_names, struc.field_types) |name, ftype| {
try setField(allocator, lua, name, ftype, &data);
inline for (struc.fields) |field| {
try setField(allocator, lua, field, &data);
}
},
else => @compileError("Expected a struct."),
@ -186,47 +188,21 @@ pub fn LuaParser(comptime Struct: type) type {
return data;
}
pub fn setField(
allocator: std.mem.Allocator,
lua: *Lua,
comptime field_name: [:0]const u8,
field_type: type,
data: *Struct,
) !void {
return setFieldInner(
allocator,
lua,
field_name,
field_type,
data,
) catch |err| {
const value = lua.toString(-1) catch "";
const duped = allocator.dupe(u8, value) catch "";
errorHandler(@typeName(field_type), field_name, duped, err);
};
}
fn setFieldInner(
allocator: std.mem.Allocator,
lua: *Lua,
comptime field_name: [:0]const u8,
field_type: type,
data: *Struct,
) !void {
const type_info = @typeInfo(field_type);
pub fn setField(allocator: std.mem.Allocator, lua: *Lua, comptime field: std.builtin.Type.StructField, data: *Struct) !void {
const type_info = @typeInfo(field.type);
const actual_type, const is_optional = blk: {
if (type_info == .optional) {
break :blk .{ type_info.optional.child, true };
}
break :blk .{ field_type, false };
break :blk .{ field.type, false };
};
// push value to top of stack
_ = lua.getField(-1, field_name);
_ = lua.getField(-1, field.name);
defer lua.pop(1);
// handle null, i.e. undefined fields
if (is_optional and lua.isNil(-1)) {
@field(data, field_name) = null;
@field(data, field.name) = null;
return;
}
@ -236,11 +212,17 @@ pub fn LuaParser(comptime Struct: type) type {
}
const actual_type_info = @typeInfo(actual_type);
errdefer |err| {
const value = lua.toString(-1) catch "";
const duped = allocator.dupe(u8, value) catch "";
errorHandler(@typeName(field.type), field.name, duped, err);
}
// dispatch depending on type
if (actual_type_info == .int and is_optional) {
if (lua.isNumber(-1)) {
const value = try lua.toNumber(-1);
@field(data, field_name) = @trunc(value);
@field(data, field.name) = @trunc(value);
} else {
const str = try lua.toString(-1);
@ -251,13 +233,13 @@ pub fn LuaParser(comptime Struct: type) type {
if (iter.nextCodepoint() != null) return error.ExpectedSingleCharacter;
@field(data, field_name) = if (codepoint) |cp| @intCast(cp) else null;
@field(data, field.name) = if (codepoint) |cp| @intCast(cp) else null;
}
// non null integer
} else if (actual_type_info == .int) {
if (lua.isNumber(-1)) {
const value = try lua.toNumber(-1);
@field(data, field_name) = @trunc(value);
@field(data, field.name) = @trunc(value);
} else {
const str = try lua.toString(-1);
@ -268,27 +250,27 @@ pub fn LuaParser(comptime Struct: type) type {
if (iter.nextCodepoint() != null) return error.ExpectedSingleCharacter;
@field(data, field_name) = @intCast(codepoint);
@field(data, field.name) = @intCast(codepoint);
}
} else if (actual_type_info == .float) { // all floats
const value = try lua.toNumber(-1);
@field(data, field_name) = @floatCast(value);
@field(data, field.name) = @floatCast(value);
} else if (actual_type_info == .bool) {
if (!lua.isBoolean(-1)) return error.ExpectedBoolean;
const value = lua.toBoolean(-1);
@field(data, field_name) = value;
@field(data, field.name) = value;
} else if (actual_type == []const u8) {
const value = try lua.toString(-1);
const duped = try allocator.dupe(u8, value);
@field(data, field_name) = duped;
@field(data, field.name) = duped;
} else if (actual_type == [:0]const u8) {
const value = try lua.toString(-1);
const duped = try allocator.dupeSentinel(u8, value, 0);
@field(data, field_name) = duped;
@field(data, field.name) = duped;
} else if (actual_type_info == .@"enum") {
const value = try lua.toString(-1);
const variant = std.meta.stringToEnum(actual_type, value) orelse return error.InvalidVariant;
@field(data, field_name) = variant;
@field(data, field.name) = variant;
} else unreachable;
}

View file

@ -28,7 +28,9 @@ pub fn build(b: *std.Build) void {
.optimize = optimize,
});
const translate_c_dep = b.dependency("translate_c", .{});
const translate_c_dep = b.dependency("translate_c", .{
.target = target,
});
const termbox2: Translator = .init(translate_c_dep, .{
.c_source_file = termbox_dep.path("termbox2.h"),
@ -36,7 +38,18 @@ pub fn build(b: *std.Build) void {
.optimize = optimize,
});
termbox2.defineCMacro("TB_IMPL", null);
// TODO 0.16.0: Workaround until Aro gets better...
// https://codeberg.org/ziglang/translate-c/issues/319
termbox2.defineCMacro("_XOPEN_SOURCE", "700");
termbox2.defineCMacro("TB_OPT_ATTR_W", "32"); // Enable 24-bit color support + styling (32-bit)
// TODO 0.16.0: Including <fcntl.h> with -OReleaseSafe causes
// __attribute__(__error__()) to be called. Below
// is the workaround.
termbox2.defineCMacro("_FORTIFY_SOURCE", "0");
// TODO 0.16.0: Needed for now
if (target.result.os.tag == .freebsd) {
termbox2.defineCMacro("__BSD_VISIBLE", "1");
}
mod.addImport("termbox2", termbox2.mod);
const mod_tests = b.addTest(.{

View file

@ -2,18 +2,18 @@
.name = .ly_ui,
.version = "1.2.0",
.fingerprint = 0x8d11bf85a74ec803,
.minimum_zig_version = "0.17.0",
.minimum_zig_version = "0.16.0",
.dependencies = .{
.ly_core = .{
.path = "../ly-core",
},
.termbox2 = .{
.url = "git+https://github.com/AnErrupTion/termbox2?ref=master#496730697c662893eec43192f48ff616c2539da6",
.hash = "N-V-__8AAOEWBQDt5tNdIzIFY6n8DdZsCP-6MyLoNS20wgpA",
.url = "git+https://github.com/AnErrupTion/termbox2?ref=master#c7f241e8888ce243e1748b05c26a42fcfaaad936",
.hash = "N-V-__8AAAUXBQD6Fwpi9m0MBqWXFFaqW5l1lVrJC2Ynj7a-",
},
.translate_c = .{
.url = "git+https://codeberg.org/ziglang/translate-c?ref=master#3da873cacdd7e9190fe1cf40372ddf5387c970ea",
.hash = "translate_c-0.0.0-Q_BUWktLBwBO7VLbmrOKUcAMRtE5fmOxI35189X5XbJs",
.url = "git+https://codeberg.org/ziglang/translate-c?ref=zig-0.16.x#6fe0ffc4549f15c5f2d9432c2b4460ba90ff85ac",
.hash = "translate_c-1.0.0-Q_BUWo_5BgD4flHdUhA31zOz0XvZk9k7lQv1ouzyNXj2",
},
},
.paths = .{

View file

@ -262,6 +262,13 @@ ly = {
-- Default is red and bold
error_fg = 0x01FF0000,
-- Tally directory for the pam_faillock module (if present)
-- Used for getting if an account is locked or not after too many failed
-- login attempts
-- If directory doesn't exist, lock status won't be checked when
-- authenticating
faillock_tally_dir = "/var/run/faillock",
-- Foreground color id
fg = 0x00FFFFFF,

View file

@ -6,6 +6,7 @@ custom = مخصص
custom_info_err_output_long = الإخراج طويل جداً
custom_info_err_no_output = لا يوجد إخراج
custom_info_err_no_output_error = ، خطأ محتمل
err_alloc = فشل في تخصيص الذاكرة
err_args = تعذر تحليل وسيطات سطر الأوامر
err_autologin_session = لم يتم العثور على جلسة تسجيل الدخول التلقائي
@ -33,7 +34,6 @@ err_pam_abort = تم إلغاء معاملة PAM
err_pam_acct_expired = الحساب منتهي الصلاحية
err_pam_auth = خطأ في المصادقة (Authentication error)
err_pam_authinfo_unavail = فشل في الحصول على معلومات المستخدم
err_pam_authok_reqd = انتهت صلاحية رمز المصادقة (Token)
err_pam_buf = خطأ في ذاكرة التخزين المؤقت (Buffer)
err_pam_cred_err = فشل في تعيين بيانات الاعتماد (Credentials)
err_pam_cred_expired = بيانات الاعتماد منتهية الصلاحية
@ -77,6 +77,7 @@ shell = shell
shutdown = ايقاف التشغيل
sleep = وضع السكون
toggle_password = إظهار/إخفاء كلمة المرور
wayland = wayland
x11 = x11
xinitrc = xinitrc

View file

@ -6,6 +6,7 @@ custom = персонализирано
custom_info_err_output_long = резултатът е твърде дълъг
custom_info_err_no_output = няма резултат
custom_info_err_no_output_error = , възможна грешка
err_alloc = неуспешно заделяне на памет
err_args = неуспешен анализ на аргументите от командния ред
err_autologin_session = сесията за автоматично влизане не е намерена
@ -33,7 +34,6 @@ err_pam_abort = прекратена транзакция
err_pam_acct_expired = изтекъл профил
err_pam_auth = грешка при удостоверяването
err_pam_authinfo_unavail = неуспешно получаване на информация за потребителя
err_pam_authok_reqd = изтекъл жетон
err_pam_buf = грешка в буфера на паметта
err_pam_cred_err = неуспешно задаване на удостоверения
err_pam_cred_expired = изтекли удостоверения
@ -77,6 +77,7 @@ shell = обвивка
shutdown = изключване
sleep = заспиване
toggle_password = превключване на паролата
wayland = wayland
x11 = x11
xinitrc = xinitrc

View file

@ -6,6 +6,7 @@ custom = personalitzat
custom_info_err_output_long = sortida massa llarga
custom_info_err_no_output = sense sortida
custom_info_err_no_output_error = , possible error
err_alloc = assignació de memòria fallida
err_args = no s'han pogut analitzar els arguments de la línia d'ordres
err_autologin_session = no s'ha trobat la sessió d'inici de sessió automàtic
@ -33,7 +34,6 @@ err_pam_abort = transacció pam avortada
err_pam_acct_expired = compte expirat
err_pam_auth = error d'autenticació
err_pam_authinfo_unavail = error en obtenir la informació de l'usuari
err_pam_authok_reqd = token expirat
err_pam_buf = error en la memòria intermèdia
err_pam_cred_err = error en establir les credencials
err_pam_cred_expired = credencials expirades
@ -77,6 +77,7 @@ shell = shell
shutdown = aturar
sleep = suspendre
toggle_password = mostrar/amagar contrasenya
wayland = wayland
x11 = x11
xinitrc = xinitrc

View file

@ -6,6 +6,7 @@ custom = vlastní
custom_info_err_output_long = výstup je příliš dlouhý
custom_info_err_no_output = žádný výstup
custom_info_err_no_output_error = , možná chyba
err_alloc = alokace paměti selhala
err_args = nelze analyzovat argumenty příkazového řádku
err_autologin_session = relace automatického přihlášení nebyla nalezena
@ -33,7 +34,6 @@ err_pam_abort = pam transakce přerušena
err_pam_acct_expired = platnost účtu vypršela
err_pam_auth = chyba autentizace
err_pam_authinfo_unavail = nelze získat informace o uživateli
err_pam_authok_reqd = platnost tokenu vypršela
err_pam_buf = chyba vyrovnávací paměti
err_pam_cred_err = nelze nastavit pověření
err_pam_cred_expired = platnost pověření vypršela
@ -77,6 +77,7 @@ shell = příkazový řádek
shutdown = vypnout
sleep = uspat
toggle_password = zobrazit/skrýt heslo
wayland = wayland
x11 = x11
xinitrc = xinitrc

View file

@ -6,6 +6,7 @@ custom = benutzerdefiniert
custom_info_err_output_long = Ausgabe zu lang
custom_info_err_no_output = keine Ausgabe
custom_info_err_no_output_error = , möglicher Fehler
err_alloc = Speicherzuweisung fehlgeschlagen
err_args = Kommandozeilenargumente konnten nicht verarbeitet werden
err_autologin_session = Autologin-Sitzung nicht gefunden
@ -33,7 +34,6 @@ err_pam_abort = PAM-Transaktion abgebrochen
err_pam_acct_expired = Benutzerkonto abgelaufen
err_pam_auth = Authentifizierungsfehler
err_pam_authinfo_unavail = Abrufen der Benutzerinformationen fehlgeschlagen
err_pam_authok_reqd = Passwort abgelaufen
err_pam_buf = Speicherpufferfehler
err_pam_cred_err = Fehler beim Setzen der Anmeldedaten
err_pam_cred_expired = Anmeldedaten abgelaufen
@ -77,6 +77,7 @@ shell = Shell
shutdown = Herunterfahren
sleep = Sleep
toggle_password = Passwort anzeigen/verbergen
wayland = wayland
x11 = x11
xinitrc = xinitrc

View file

@ -6,6 +6,7 @@ custom = custom
custom_info_err_output_long = output too long
custom_info_err_no_output = no output
custom_info_err_no_output_error = , possible error
err_acc_locked = account locked, too many attempts
err_alloc = failed memory allocation
err_args = unable to parse command line arguments
err_autologin_session = autologin session not found
@ -33,7 +34,6 @@ err_pam_abort = pam transaction aborted
err_pam_acct_expired = account expired
err_pam_auth = authentication error
err_pam_authinfo_unavail = failed to get user info
err_pam_authok_reqd = token expired
err_pam_buf = memory buffer error
err_pam_cred_err = failed to set credentials
err_pam_cred_expired = credentials expired
@ -77,6 +77,7 @@ shell = shell
shutdown = shutdown
sleep = sleep
toggle_password = toggle password
token_expired = password expired, please reset
wayland = wayland
x11 = x11
xinitrc = xinitrc

View file

@ -6,6 +6,7 @@ custom = propra
custom_info_err_output_long = eligo tro longa
custom_info_err_no_output = neniu eligo
custom_info_err_no_output_error = , ebla eraro
err_alloc = malsukcesis memorasignon
err_args = ne povas analizi argumentojn de komanda linio
err_autologin_session = aŭtomatan ensalutan seancon ne trovis
@ -33,7 +34,6 @@ err_pam_abort = PAM-a transakcio malsukcesis
err_pam_acct_expired = konto eksvalidiĝis
err_pam_auth = aŭtentiga eraro
err_pam_authinfo_unavail = malsukcesis preni uzantajn informojn
err_pam_authok_reqd = memorsigno eksvalidiĝis
err_pam_buf = bufra eraro
err_pam_cred_err = malsukcesis agordi akreditaĵon
err_pam_cred_expired = akreditaĵo eksvalidiĝis
@ -77,6 +77,7 @@ shell = ŝelo
shutdown = malŝalti
sleep = memordormi
toggle_password = montri/kaŝi pasvorton
wayland = wayland
x11 = x11
xinitrc = xinitrc

View file

@ -6,6 +6,7 @@ custom = personalizado
custom_info_err_output_long = salida demasiado larga
custom_info_err_no_output = sin salida
custom_info_err_no_output_error = , posible error
err_alloc = asignación de memoria fallida
err_args = no se pudieron analizar los argumentos de la línea de comandos
err_autologin_session = no se encontró la sesión de inicio de sesión automático
@ -33,7 +34,6 @@ err_pam_abort = transacción pam abortada
err_pam_acct_expired = cuenta expirada
err_pam_auth = error de autenticación
err_pam_authinfo_unavail = error al obtener información del usuario
err_pam_authok_reqd = token expirado
err_pam_buf = error de la memoria intermedia
err_pam_cred_err = error al establecer las credenciales
err_pam_cred_expired = credenciales expiradas
@ -77,6 +77,7 @@ shell = shell
shutdown = apagar
sleep = suspender
toggle_password = mostrar/ocultar contraseña
wayland = wayland
x11 = x11
xinitrc = xinitrc

View file

@ -6,6 +6,7 @@ custom = customisé
custom_info_err_output_long = sortie trop longue
custom_info_err_no_output = pas de sortie
custom_info_err_no_output_error = , erreur possible
err_acc_locked = compte bloqué, trop de tentatives
err_alloc = échec d'allocation mémoire
err_args = échec de l'analyse des arguments en lignes de commande
err_autologin_session = session de connexion automatique introuvable
@ -33,7 +34,6 @@ err_pam_abort = transaction pam avortée
err_pam_acct_expired = compte expiré
err_pam_auth = erreur d'authentification
err_pam_authinfo_unavail = échec de l'obtention des infos utilisateur
err_pam_authok_reqd = tiquet expiré
err_pam_buf = erreur de mémoire tampon
err_pam_cred_err = échec de la modification des identifiants
err_pam_cred_expired = identifiants expirés
@ -77,6 +77,7 @@ shell = shell
shutdown = éteindre
sleep = veille
toggle_password = afficher le mot de passe
token_expired = mot de passe expiré, veuillez le changer
wayland = wayland
x11 = x11
xinitrc = xinitrc

View file

@ -6,6 +6,7 @@ custom = personalizzato
custom_info_err_output_long = output troppo lungo
custom_info_err_no_output = nessun output
custom_info_err_no_output_error = , possibile errore
err_alloc = impossibile allocare memoria
err_args = impossibile analizzare gli argomenti della riga di comando
err_autologin_session = sessione di accesso automatico non trovata
@ -33,7 +34,6 @@ err_pam_abort = transazione PAM interrotta
err_pam_acct_expired = account scaduto
err_pam_auth = errore di autenticazione
err_pam_authinfo_unavail = impossibile ottenere informazioni utente
err_pam_authok_reqd = token scaduto
err_pam_buf = errore buffer memoria
err_pam_cred_err = impossibile impostare credenziali
err_pam_cred_expired = credenziali scadute
@ -77,6 +77,7 @@ shell = shell
shutdown = arresto
sleep = sospendi
toggle_password = mostra/nascondi password
wayland = wayland
x11 = x11
xinitrc = xinitrc

View file

@ -6,6 +6,7 @@ custom = カスタム
custom_info_err_output_long = 出力が長すぎます
custom_info_err_no_output = 出力なし
custom_info_err_no_output_error = 、エラーの可能性あり
err_alloc = メモリ割り当て失敗
err_args = コマンドライン引数を解析できません
err_autologin_session = 自動ログインセッションが見つかりません
@ -33,7 +34,6 @@ err_pam_abort = PAMトランザクションが中断されました
err_pam_acct_expired = アカウントの有効期限が切れています
err_pam_auth = 認証エラー
err_pam_authinfo_unavail = ユーザー情報の取得に失敗しました
err_pam_authok_reqd = トークンの有効期限が切れています
err_pam_buf = メモリバッファエラー
err_pam_cred_err = 認証情報の設定に失敗しました
err_pam_cred_expired = 認証情報の有効期限が切れています
@ -77,6 +77,7 @@ shell = シェル
shutdown = シャットダウン
sleep = スリープ
toggle_password = パスワードの表示/非表示
wayland = Wayland
x11 = x11
xinitrc = xinitrc

View file

@ -6,6 +6,7 @@ custom = kesane
custom_info_err_output_long = encam pir dirêj e
custom_info_err_no_output = encam tune
custom_info_err_no_output_error = , xeletiya mimkun
err_alloc = veqetandina bîrê têk çû
err_args = argumanên rêzika fermanê nehatin analîzkirin
err_autologin_session = danişîna têketina xweber nehate dîtin
@ -33,7 +34,6 @@ err_pam_abort = danûstendina pam hate têkbirin
err_pam_acct_expired = dema jimarê derbas bûye
err_pam_auth = şaşetiya piştrastkirinê
err_pam_authinfo_unavail = zanyariyên bikarhêner nehatin girtin
err_pam_authok_reqd = dema nîşandanê derbas bûye
err_pam_buf = şaşetiya bîra demkî
err_pam_cred_err = sazkirina rastkitinê têk çû
err_pam_cred_expired = dema rastkitinê derbas bûye
@ -77,6 +77,7 @@ shell = shell
shutdown = vemirîne
sleep = têxîne xewê
toggle_password = şîfre nîşan bide/veşêre
wayland = wayland
x11 = x11
xinitrc = xinitrc

View file

@ -6,6 +6,7 @@ custom = pielāgots
custom_info_err_output_long = izvade pārāk gara
custom_info_err_no_output = nav izvades
custom_info_err_no_output_error = , iespējama kļūda
err_alloc = neizdevās atmiņas piešķiršana
err_args = nevar parsēt komandrindas argumentus
err_autologin_session = automātiskās pieteikšanās sesija nav atrasta
@ -33,7 +34,6 @@ err_pam_abort = pam transakcija pārtraukta
err_pam_acct_expired = konts novecojis
err_pam_auth = autentifikācijas kļūda
err_pam_authinfo_unavail = neizdevās iegūt lietotāja informāciju
err_pam_authok_reqd = žetons beidzies
err_pam_buf = atmiņas bufera kļūda
err_pam_cred_err = neizdevās iestatīt akreditācijas datus
err_pam_cred_expired = akreditācijas dati novecojuši
@ -77,6 +77,7 @@ shell = terminālis
shutdown = izslēgt
sleep = snauda
toggle_password = rādīt/slēpt paroli
wayland = wayland
x11 = x11
xinitrc = xinitrc

View file

@ -6,6 +6,7 @@ custom = własny
custom_info_err_output_long = wyjście zbyt długie
custom_info_err_no_output = brak wyjścia
custom_info_err_no_output_error = , możliwy błąd
err_alloc = nieudana alokacja pamięci
err_args = nie można przetworzyć argumentów wiersza poleceń
err_autologin_session = nie znaleziono sesji autologowania
@ -33,7 +34,6 @@ err_pam_abort = transakcja pam przerwana
err_pam_acct_expired = konto wygasło
err_pam_auth = błąd uwierzytelniania
err_pam_authinfo_unavail = nie udało się zdobyć informacji o użytkowniku
err_pam_authok_reqd = token wygasł
err_pam_buf = błąd bufora pamięci
err_pam_cred_err = nie udało się ustawić uwierzytelnienia
err_pam_cred_expired = uwierzytelnienie wygasło
@ -77,6 +77,7 @@ shell = powłoka
shutdown = wyłącz
sleep = uśpij
toggle_password = Pokaż/ukryj hasło
wayland = wayland
x11 = x11
xinitrc = xinitrc

View file

@ -6,6 +6,7 @@ custom = personalizado
custom_info_err_output_long = saída demasiado longa
custom_info_err_no_output = sem saída
custom_info_err_no_output_error = , possível erro
err_alloc = erro na atribuição de memória
err_args = não foi possível analisar os argumentos da linha de comandos
err_autologin_session = sessão de início de sessão automático não encontrada
@ -33,7 +34,6 @@ err_pam_abort = transação pam abortada
err_pam_acct_expired = conta expirada
err_pam_auth = erro de autenticação
err_pam_authinfo_unavail = erro ao obter informação do utilizador
err_pam_authok_reqd = token expirado
err_pam_buf = erro de buffer de memória
err_pam_cred_err = erro ao definir credenciais
err_pam_cred_expired = credenciais expiradas
@ -77,6 +77,7 @@ shell = shell
shutdown = encerrar
sleep = suspender
toggle_password = mostrar/ocultar palavra-passe
wayland = wayland
x11 = x11
xinitrc = xinitrc

View file

@ -6,6 +6,7 @@ custom = personalizado
custom_info_err_output_long = saída muito longa
custom_info_err_no_output = sem saída
custom_info_err_no_output_error = , possível erro
err_alloc = alocação de memória malsucedida
err_args = não foi possível analisar os argumentos da linha de comando
err_autologin_session = sessão de login automático não encontrada
@ -33,7 +34,6 @@ err_pam_abort = transação pam abortada
err_pam_acct_expired = conta expirada
err_pam_auth = erro de autenticação
err_pam_authinfo_unavail = não foi possível obter informações do usuário
err_pam_authok_reqd = token expirado
err_pam_buf = erro de buffer de memória
err_pam_cred_err = erro para definir credenciais
err_pam_cred_expired = credenciais expiradas
@ -77,6 +77,7 @@ shell = shell
shutdown = desligar
sleep = suspender
toggle_password = mostrar/ocultar senha
wayland = wayland
x11 = x11
xinitrc = xinitrc

View file

@ -6,6 +6,7 @@ custom = personalizat
custom_info_err_output_long = ieșire prea lungă
custom_info_err_no_output = fără ieșire
custom_info_err_no_output_error = , posibil eroare
err_alloc = alocare de memorie eșuată
err_args = imposibil de analizat argumentele liniei de comandă
err_autologin_session = sesiunea de autentificare automată nu a fost găsită
@ -33,7 +34,6 @@ err_pam_abort = tranzacţie pam anulată
err_pam_acct_expired = cont expirat
err_pam_auth = eroare de autentificare
err_pam_authinfo_unavail = nu s-au putut obţine informaţii despre utilizator
err_pam_authok_reqd = token expirat
err_pam_buf = eroare de memorie (buffer)
err_pam_cred_err = nu s-au putut seta date de identificare (credentials)
err_pam_cred_expired = datele de identificare (credentials) au expirat
@ -77,6 +77,7 @@ shell = shell
shutdown = opreşte sistemul
sleep = repaus
toggle_password = afișare/ascundere parolă
wayland = wayland
x11 = x11
xinitrc = xinitrc

View file

@ -6,6 +6,7 @@ custom = пользовательский
custom_info_err_output_long = вывод слишком длинный
custom_info_err_no_output = нет вывода
custom_info_err_no_output_error = , возможная ошибка
err_alloc = не удалось выделить память
err_args = не удалось разобрать аргументы командной строки
err_autologin_session = не найдена сессия с автологином
@ -33,7 +34,6 @@ err_pam_abort = pam транзакция прервана
err_pam_acct_expired = срок действия аккаунта истёк
err_pam_auth = ошибка аутентификации
err_pam_authinfo_unavail = не удалось получить информацию о пользователе
err_pam_authok_reqd = токен истёк
err_pam_buf = ошибка буфера памяти
err_pam_cred_err = не удалось установить полномочия
err_pam_cred_expired = полномочия истекли
@ -77,6 +77,7 @@ shell = оболочка
shutdown = выключить
sleep = сон
toggle_password = показать/скрыть пароль
wayland = wayland
x11 = x11
xinitrc = xinitrc

View file

@ -6,6 +6,7 @@ custom = prilagođeno
custom_info_err_output_long = izlaz predugačak
custom_info_err_no_output = nema izlaza
custom_info_err_no_output_error = , moguća greška
err_alloc = neuspješna alokacija memorije
err_args = nije moguće raščlaniti argumente komandne linije
err_autologin_session = sesija automatske prijave nije pronađena
@ -33,7 +34,6 @@ err_pam_abort = pam transakcija prekinuta
err_pam_acct_expired = nalog istekao
err_pam_auth = greška pri autentikaciji
err_pam_authinfo_unavail = neuspješno uzimanje informacija o korisniku
err_pam_authok_reqd = token istekao
err_pam_buf = greška bafera memorije
err_pam_cred_err = neuspješno postavljanje kredencijala
err_pam_cred_expired = kredencijali istekli
@ -77,6 +77,7 @@ shell = shell
shutdown = ugasi
sleep = uspavaj
toggle_password = prikaži/sakrij lozinku
wayland = wayland
x11 = x11
xinitrc = xinitrc

View file

@ -6,6 +6,7 @@ custom = прилагођено
custom_info_err_output_long = излаз предугачак
custom_info_err_no_output = нема излаза
custom_info_err_no_output_error = , могућа грешка
err_alloc = неуспешна алокација меморије
err_args = није могуће рашчланити аргументе командне линије
err_autologin_session = сесија аутоматске пријаве није пронађена
@ -33,7 +34,6 @@ err_pam_abort = pam трансакција прекинута
err_pam_acct_expired = налог истекао
err_pam_auth = грешка при аутентикацији
err_pam_authinfo_unavail = неуспешно узимање информација о кориснику
err_pam_authok_reqd = токен истекао
err_pam_buf = грешка бафера меморије
err_pam_cred_err = неуспешно постављање акредитива
err_pam_cred_expired = акредитиви истекли
@ -77,6 +77,7 @@ shell = shell
shutdown = угаси
sleep = успавај
toggle_password = прикажи/сакриј лозинку
wayland = wayland
x11 = x11
xinitrc = xinitrc

View file

@ -6,6 +6,7 @@ custom = anpassad
custom_info_err_output_long = utdata för lång
custom_info_err_no_output = ingen utdata
custom_info_err_no_output_error = , möjligt fel
err_alloc = minnesallokering misslyckades
err_args = tolkning av kommandoargument misslyckades
err_autologin_session = autologin-session hittades inte
@ -33,7 +34,6 @@ err_pam_abort = pam-transaktion avbröts
err_pam_acct_expired = kontot har löpt ut
err_pam_auth = autentisering misslyckades
err_pam_authinfo_unavail = hämtning av användarinformation misslyckades
err_pam_authok_reqd = token har löpt ut
err_pam_buf = minnesbufferfel
err_pam_cred_err = inställning av inloggningsuppgifter misslyckades
err_pam_cred_expired = inloggningsuppgifterna har löpt ut
@ -77,6 +77,7 @@ shell = shell
shutdown = stäng av
sleep = viloläge
toggle_password = visa/dölj lösenord
wayland = wayland
x11 = x11
xinitrc = xinitrc

View file

@ -6,6 +6,7 @@ custom = özel
custom_info_err_output_long = çıktı çok uzun
custom_info_err_no_output = çıktı yok
custom_info_err_no_output_error = , olası hata
err_alloc = basarisiz bellek ayirma
err_args = komut satırı argümanları ayrıştırılamıyor
err_autologin_session = otomatik oturum açma oturumu bulunamadı
@ -33,7 +34,6 @@ err_pam_abort = pam islemi durduruldu
err_pam_acct_expired = hesabin suresi dolmus
err_pam_auth = kimlik dogrulama hatasi
err_pam_authinfo_unavail = kullanici bilgileri getirilirken hata olustu
err_pam_authok_reqd = suresi dolmus token
err_pam_buf = bellek arabellegi hatasi
err_pam_cred_err = kimlik bilgileri ayarlanamadi
err_pam_cred_expired = kimlik bilgilerinin suresi dolmus
@ -77,6 +77,7 @@ shell = shell
shutdown = makineyi kapat
sleep = uykuya al
toggle_password = parolayı göster/gizle
wayland = wayland
x11 = x11
xinitrc = xinitrc

View file

@ -6,6 +6,7 @@ custom = власний
custom_info_err_output_long = вивід занадто довгий
custom_info_err_no_output = немає виводу
custom_info_err_no_output_error = , можлива помилка
err_alloc = невдале виділення пам'яті
err_args = не вдалося розібрати аргументи командного рядка
err_autologin_session = сеанс автоматичного входу не знайдено
@ -33,7 +34,6 @@ err_pam_abort = pam транзакція перервана
err_pam_acct_expired = термін дії акаунту вичерпано
err_pam_auth = помилка автентифікації
err_pam_authinfo_unavail = не вдалося отримати дані користувача
err_pam_authok_reqd = термін дії токена вичерпано
err_pam_buf = помилка буферу пам'яті
err_pam_cred_err = не вдалося змінити облікові дані
err_pam_cred_expired = термін дії повноважень вичерпано
@ -77,6 +77,7 @@ shell = оболонка
shutdown = вимкнути
sleep = сплячий режим
toggle_password = показати/приховати пароль
wayland = wayland
x11 = x11
xinitrc = xinitrc

View file

@ -6,6 +6,7 @@ custom = 自定义
custom_info_err_output_long = 输出过长
custom_info_err_no_output = 无输出
custom_info_err_no_output_error = ,可能有错误
err_alloc = 内存分配失败
err_args = 无法解析命令行参数
err_autologin_session = 未找到自动登录会话
@ -33,7 +34,6 @@ err_pam_abort = PAM事务已中止
err_pam_acct_expired = 帐户已过期
err_pam_auth = 身份验证错误
err_pam_authinfo_unavail = 获取用户信息失败
err_pam_authok_reqd = 口令已过期
err_pam_buf = 内存缓冲区错误
err_pam_cred_err = 设置凭据失败
err_pam_cred_expired = 凭据已过期
@ -77,6 +77,7 @@ shell = shell
shutdown = 关机
sleep = 睡眠
toggle_password = 显示/隐藏密码
wayland = wayland
x11 = x11
xinitrc = xinitrc

View file

@ -6,6 +6,7 @@ custom = 自訂
custom_info_err_output_long = 輸出過長
custom_info_err_no_output = 無輸出
custom_info_err_no_output_error = ,可能有錯誤
err_alloc = 記憶體配置失敗
err_args = 無法解析命令列參數
err_autologin_session = 找不到自動登入工作階段
@ -33,7 +34,6 @@ err_pam_abort = PAM 交易已中止
err_pam_acct_expired = 帳號已過期
err_pam_auth = 驗證錯誤
err_pam_authinfo_unavail = 取得使用者資訊失敗
err_pam_authok_reqd = 金鑰已過期
err_pam_buf = 記憶體緩衝區錯誤
err_pam_cred_err = 設定憑證失敗
err_pam_cred_expired = 憑證已過期
@ -77,6 +77,7 @@ shell = shell
shutdown = 關機
sleep = 睡眠
toggle_password = 顯示/隱藏密碼
wayland = wayland
x11 = x11
xinitrc = xinitrc

View file

@ -20,6 +20,7 @@ pub const AuthOptions = struct {
xauth_cmd: []const u8,
setup_cmd: []const u8,
login_cmd: ?[]const u8,
faillock_tally_dir: []const u8,
x_cmd: []const u8,
x_vt: ?u8,
session_pid: std.posix.pid_t,
@ -29,11 +30,23 @@ pub const AuthOptions = struct {
const PamAppdata = struct {
username: []const u8,
password: []const u8,
authreq_requested: bool,
new_authtok_requested: bool,
authreq_responded: bool,
new_password: []const u8,
};
//https://github.com/linux-pam/linux-pam/blob/master/modules/pam_faillock/faillock.h#L55
const PamFaillockEntry = extern struct {
pub const STATUS_VALID: usize = 0x1;
pub const STATUS_RHOST: usize = 0x2;
pub const STATUS_TTY: usize = 0x4;
source: [52]u8,
reserved: u16,
status: u16,
time: u64,
};
var xorg_pid: std.posix.pid_t = 0;
pub fn xorgSignalHandler(sig: std.posix.SIG) callconv(.c) void {
if (xorg_pid > 0) _ = std.c.kill(xorg_pid, sig);
@ -52,12 +65,18 @@ pub fn authenticate(
current_environment: Environment,
login: []const u8,
password: []const u8,
maybe_new_password: ?[]const u8,
) !void {
var faillock_entries: usize = 0;
if (try dirExists(io, options.faillock_tally_dir)) {
faillock_entries = try getFaillockEntries(allocator, io, login, options.faillock_tally_dir);
}
var tty_buffer: [3]u8 = undefined;
const tty_str = try std.fmt.bufPrint(&tty_buffer, "{d}", .{options.tty});
var pam_tty_buffer: [6]u8 = undefined;
const pam_tty_str = try std.fmt.bufPrintSentinel(&pam_tty_buffer, "tty{d}", .{options.tty}, 0);
const pam_tty_str = try std.fmt.bufPrintZ(&pam_tty_buffer, "tty{d}", .{options.tty});
// Set the XDG environment variables
try log_file.info(io, "auth/env", "setting xdg environment variables", .{});
@ -69,7 +88,7 @@ pub fn authenticate(
var credentials: PamAppdata = .{
.username = login,
.password = password,
.authreq_requested = false,
.new_authtok_requested = false,
.authreq_responded = false,
.new_password = "",
};
@ -93,14 +112,23 @@ pub fn authenticate(
// Do the PAM routine
try log_file.info(io, "auth/pam", "authenticating", .{});
status = interop.pam.pam_authenticate(handle, 0);
if (status == interop.pam.PAM_AUTH_ERR and try dirExists(io, options.faillock_tally_dir)) {
const new_faillock_entries = try getFaillockEntries(allocator, io, login, options.faillock_tally_dir);
if (faillock_entries == new_faillock_entries) {
return error.AccountLocked;
}
}
if (status != interop.pam.PAM_SUCCESS) return pamDiagnose(status);
try log_file.info(io, "auth/pam", "validating account", .{});
status = interop.pam.pam_acct_mgmt(handle, 0);
if (status == interop.pam.PAM_NEW_AUTHTOK_REQD) {
// credentials.authreq_requested = true;
// credentials.new_password = "";
// status = interop.pam.pam_chauthtok(handle, interop.pam.PAM_CHANGE_EXPIRED_AUTHTOK);
if (maybe_new_password) |new_passwsord| {
credentials.new_authtok_requested = true;
credentials.new_password = new_passwsord;
status = interop.pam.pam_chauthtok(handle, interop.pam.PAM_CHANGE_EXPIRED_AUTHTOK);
}
}
if (status != interop.pam.PAM_SUCCESS) return pamDiagnose(status);
@ -185,6 +213,46 @@ pub fn authenticate(
if (shared_err.readError()) |err| return err;
}
fn dirExists(io: std.Io, path: []const u8) !bool {
var dir = std.Io.Dir.openDirAbsolute(io, path, .{}) catch |err| {
if (err == error.FileNotFound) return false;
return err;
};
defer dir.close(io);
return true;
}
fn getFaillockEntries(
allocator: std.mem.Allocator,
io: std.Io,
username: []const u8,
tally_dir: []const u8,
) !usize {
const path = try std.fs.path.join(allocator, &.{ tally_dir, username });
defer allocator.free(path);
var file = try std.Io.Dir.openFileAbsolute(io, path, .{});
defer file.close(io);
var buffer: [1024]u8 = undefined;
var reader = file.reader(io, &buffer);
var count: usize = 0;
while (!reader.atEnd()) {
const entry = reader.interface.takeStruct(PamFaillockEntry, .little) catch |err| {
if (err == error.EndOfStream) break;
return err;
};
if (entry.status & PamFaillockEntry.STATUS_VALID != 0) {
count += 1;
}
}
return count;
}
fn startSession(
log_file: *LogFile,
allocator: std.mem.Allocator,
@ -221,7 +289,7 @@ fn startSession(
}
}
const home_z = try allocator.dupeSentinel(u8, user_entry.home.?, 0);
const home_z = try allocator.dupeZ(u8, user_entry.home.?);
defer allocator.free(home_z);
// Change to the user's home directory
@ -326,7 +394,7 @@ fn loginConv(
for (0..message_count) |i| set_credentials: {
switch (messages[i].?.msg_style) {
interop.pam.PAM_PROMPT_ECHO_ON => {
username = allocator.dupeSentinel(u8, data.username, 0) catch {
username = allocator.dupeZ(u8, data.username) catch {
status = interop.pam.PAM_BUF_ERR;
break :set_credentials;
};
@ -334,14 +402,14 @@ fn loginConv(
},
interop.pam.PAM_PROMPT_ECHO_OFF => {
var pass = data.password;
if (data.authreq_requested) {
if (data.new_authtok_requested) {
if (data.authreq_responded) {
pass = data.new_password;
}
data.authreq_responded = true;
}
password = allocator.dupeSentinel(u8, pass, 0) catch {
password = allocator.dupeZ(u8, pass) catch {
status = interop.pam.PAM_BUF_ERR;
break :set_credentials;
};
@ -362,7 +430,7 @@ fn getFreeDisplay() !u8 {
var buf: [15]u8 = undefined;
var i: u8 = 0;
while (i < 200) : (i += 1) {
const xlock = try std.fmt.bufPrintSentinel(&buf, "/tmp/.X{d}-lock", .{i}, 0);
const xlock = try std.fmt.bufPrintZ(&buf, "/tmp/.X{d}-lock", .{i});
if (interop.isError(std.posix.system.access(xlock.ptr, std.posix.F_OK))) break;
}
return i;
@ -463,7 +531,7 @@ fn xauth(log_file: *LogFile, allocator: std.mem.Allocator, io: std.Io, display_n
try log_file.reinit(io);
var cmd_buffer: [1024]u8 = undefined;
const cmd_str = std.fmt.bufPrintSentinel(&cmd_buffer, "{s} add {s} . {s}", .{ options.xauth_cmd, display_name, magic_cookie }, 0) catch std.process.exit(1);
const cmd_str = std.fmt.bufPrintZ(&cmd_buffer, "{s} add {s} . {s}", .{ options.xauth_cmd, display_name, magic_cookie }) catch std.process.exit(1);
try log_file.info(io, "auth/x11", "executing: {s} -c {s}", .{ shell, cmd_str });
const args = [_:null]?[*:0]const u8{ shell, "-c", cmd_str };
@ -499,7 +567,7 @@ fn executeX11Cmd(log_file: *LogFile, allocator: std.mem.Allocator, io: std.Io, s
const display_name = try std.fmt.bufPrint(&buf, ":{d}", .{display_num});
try log_file.info(io, "auth/x11", "got free display: {d}", .{display_num});
const shell_z = try allocator.dupeSentinel(u8, shell, 0);
const shell_z = try allocator.dupeZ(u8, shell);
defer allocator.free(shell_z);
try log_file.info(io, "auth/x11", "creating xauth file", .{});
@ -509,7 +577,7 @@ fn executeX11Cmd(log_file: *LogFile, allocator: std.mem.Allocator, io: std.Io, s
const pid = std.posix.system.fork();
if (pid == 0) {
var cmd_buffer: [1024]u8 = undefined;
const cmd_str = std.fmt.bufPrintSentinel(&cmd_buffer, "{s} {s} {s} -auth {s}", .{ options.x_cmd, display_name, vt, xauthority }, 0) catch std.process.exit(1);
const cmd_str = std.fmt.bufPrintZ(&cmd_buffer, "{s} {s} {s} -auth {s}", .{ options.x_cmd, display_name, vt, xauthority }) catch std.process.exit(1);
try log_file.info(io, "auth/x11", "executing: {s} -c {s} -auth {s}", .{ shell, cmd_str, xauthority });
const args = [_:null]?[*:0]const u8{ shell_z, "-c", cmd_str };
@ -538,7 +606,7 @@ fn executeX11Cmd(log_file: *LogFile, allocator: std.mem.Allocator, io: std.Io, s
xorg_pid = std.posix.system.fork();
if (xorg_pid == 0) {
var cmd_buffer: [1024]u8 = undefined;
const cmd_str = std.fmt.bufPrintSentinel(&cmd_buffer, "{s} {s} {s} {s}", .{ if (options.use_kmscon_vt) "kmscon-launch-gui" else "", options.setup_cmd, options.login_cmd orelse "", desktop_cmd }, 0) catch std.process.exit(1);
const cmd_str = std.fmt.bufPrintZ(&cmd_buffer, "{s} {s} {s} {s}", .{ if (options.use_kmscon_vt) "kmscon-launch-gui" else "", options.setup_cmd, options.login_cmd orelse "", desktop_cmd }) catch std.process.exit(1);
try log_file.info(io, "auth/x11", "executing: {s} -c {s}", .{ shell, cmd_str });
const args = [_:null]?[*:0]const u8{ shell_z, "-c", cmd_str };
@ -589,11 +657,11 @@ fn executeCmd(global_log_file: *LogFile, allocator: std.mem.Allocator, io: std.I
}
defer if (maybe_log_file) |log_file| log_file.close(io);
const shell_z = try allocator.dupeSentinel(u8, shell, 0);
const shell_z = try allocator.dupeZ(u8, shell);
defer allocator.free(shell_z);
var cmd_buffer: [1024]u8 = undefined;
const cmd_str = try std.fmt.bufPrintSentinel(&cmd_buffer, "{s} {s} {s} {s}", .{ if (!is_terminal and options.use_kmscon_vt) "kmscon-launch-gui" else "", options.setup_cmd, options.login_cmd orelse "", exec_cmd orelse shell }, 0);
const cmd_str = try std.fmt.bufPrintZ(&cmd_buffer, "{s} {s} {s} {s}", .{ if (!is_terminal and options.use_kmscon_vt) "kmscon-launch-gui" else "", options.setup_cmd, options.login_cmd orelse "", exec_cmd orelse shell });
try global_log_file.info(io, "auth/sys", "executing: {s} -c {s}", .{ shell, cmd_str });
const args = [_:null]?[*:0]const u8{ shell_z, "-c", cmd_str };
@ -642,7 +710,7 @@ fn addUtmpEntry(io: std.Io, entry: *Utmp, username: []const u8, pid: c_int) !voi
// Get the TTY name (i.e. without the /dev/ prefix)
var ttyname_buf: [@sizeOf(@TypeOf(entry.ut_line))]u8 = undefined;
_ = try std.fmt.bufPrintSentinel(&ttyname_buf, "{s}", .{tty_path["/dev/".len..]}, 0);
_ = try std.fmt.bufPrintZ(&ttyname_buf, "{s}", .{tty_path["/dev/".len..]});
entry.ut_line = ttyname_buf;
// Get the TTY ID (i.e. without the tty prefix) and truncate it to the size
@ -650,7 +718,7 @@ fn addUtmpEntry(io: std.Io, entry: *Utmp, username: []const u8, pid: c_int) !voi
entry.ut_id = ttyname_buf["tty".len..(@sizeOf(@TypeOf(entry.ut_id)) + "tty".len)].*;
var username_buf: [@sizeOf(@TypeOf(entry.ut_user))]u8 = undefined;
_ = try std.fmt.bufPrintSentinel(&username_buf, "{s}", .{username}, 0);
_ = try std.fmt.bufPrintZ(&username_buf, "{s}", .{username});
entry.ut_user = username_buf;

View file

@ -59,6 +59,7 @@ dur_y_offset: i32 = 0,
edge_margin: u8 = 0,
error_bg: u32 = 0x00000000,
error_fg: u32 = 0x01FF0000,
faillock_tally_dir: []const u8 = "/var/run/faillock",
fg: u32 = 0x00FFFFFF,
full_color: bool = true,
gameoflife_fg: u32 = 0x0000FF00,

View file

@ -1,5 +1,5 @@
//
// NOTE: After editing this file, please run `/res/lang/normalize_lang_files.py`
// NOTE: After editing this file, please run `res/lang/normalize_lang_files.py`
// to update all the language files accordingly.
//
@ -11,6 +11,7 @@ custom: []const u8 = "custom",
custom_info_err_output_long: []const u8 = "output too long",
custom_info_err_no_output: []const u8 = "no output",
custom_info_err_no_output_error: []const u8 = ", possible error",
err_acc_locked: []const u8 = "account locked, too many attempts",
err_alloc: []const u8 = "failed memory allocation",
err_args: []const u8 = "unable to parse command line arguments",
err_autologin_session: []const u8 = "autologin session not found",
@ -38,7 +39,6 @@ err_pam_abort: []const u8 = "pam transaction aborted",
err_pam_acct_expired: []const u8 = "account expired",
err_pam_auth: []const u8 = "authentication error",
err_pam_authinfo_unavail: []const u8 = "failed to get user info",
err_pam_authok_reqd: []const u8 = "token expired",
err_pam_buf: []const u8 = "memory buffer error",
err_pam_cred_err: []const u8 = "failed to set credentials",
err_pam_cred_expired: []const u8 = "credentials expired",
@ -82,6 +82,7 @@ shell: [:0]const u8 = "shell",
shutdown: []const u8 = "shutdown",
sleep: []const u8 = "sleep",
toggle_password: []const u8 = "toggle password",
token_expired: []const u8 = "password expired, please reset",
wayland: []const u8 = "wayland",
x11: []const u8 = "x11",
xinitrc: [:0]const u8 = "xinitrc",

View file

@ -232,9 +232,7 @@ pub fn configFieldHandler(_: std.mem.Allocator, field: ini.IniField) ?ini.IniFie
// on the progress of said interface, only to find out afterwards
// that you have PROCRASTINATED on the efforts meant to enhance
// configuration. Thus the requirement for this reminder larger
// compared to the two reminders regarding better methods of
// X termination detection and new usernames with existing
// save files.
// compared to the one regarding better methods of X termination.
//
// Thus is my que to leave this TODO at thy request,
//

View file

@ -113,6 +113,7 @@ const UiState = struct {
login_text: ?*Text,
password: *Text,
password_widget: *Widget,
maybe_old_password: ?[]const u8,
insert_mode: bool,
edge_margin: Position,
config: Config,
@ -154,8 +155,8 @@ pub fn main(init: std.process.Init) !void {
}
var gpa: std.heap.DebugAllocator(.{
.never_unmap = builtin.mode == .debug,
.retain_metadata = builtin.mode == .debug,
.never_unmap = builtin.mode == .Debug,
.retain_metadata = builtin.mode == .Debug,
}) = .init;
defer if (gpa.deinit() == .leak) std.log.err("attention please, memory has been leaked!", .{});
@ -333,7 +334,7 @@ pub fn main(init: std.process.Init) !void {
const username_line = reader.takeDelimiterInclusive('\n') catch break :read_save_file;
if (std.mem.containsAtLeastScalar(u8, username_line, '-', 1)) read_username: {
if (std.mem.containsAtLeastScalar2(u8, username_line, '-', 1)) read_username: {
var iterator = std.mem.splitScalar(u8, username_line[0..(username_line.len - 1)], '-');
if (iterator.next() == null) break :read_username; // Would be index
@ -889,6 +890,9 @@ pub fn main(init: std.process.Init) !void {
);
defer state.password_label.deinit();
state.maybe_old_password = null;
defer if (state.maybe_old_password) |pass| state.allocator.free(pass);
state.insert_mode = !state.config.vi_mode or state.config.vi_default_mode == .insert;
state.password = try Text.init(
@ -1237,8 +1241,8 @@ pub fn main(init: std.process.Init) !void {
var iter = custom.binds.iterator();
while (iter.next()) |i| {
var concat = try std.mem.concat(state.allocator, u8, &[_][]const u8{ i.key_ptr.*, " ", i.value_ptr.name });
inline for (@typeInfo(Lang).@"struct".field_names) |lang_key| {
const new = try std.mem.replaceOwned(u8, state.allocator, concat, "$" ++ lang_key, @field(state.lang, lang_key));
inline for (@typeInfo(Lang).@"struct".fields) |lang_key| {
const new = try std.mem.replaceOwned(u8, state.allocator, concat, "$" ++ lang_key.name, @field(state.lang, lang_key.name));
state.allocator.free(concat);
concat = new;
}
@ -1610,6 +1614,7 @@ fn authenticate(ptr: *anyopaque) !bool {
.xauth_cmd = state.config.xauth_cmd,
.setup_cmd = state.config.setup_cmd,
.login_cmd = state.config.login_cmd,
.faillock_tally_dir = state.config.faillock_tally_dir,
.x_cmd = state.config.x_cmd,
.x_vt = state.config.x_vt,
.session_pid = session_pid,
@ -1633,7 +1638,8 @@ fn authenticate(ptr: *anyopaque) !bool {
auth_options,
current_environment,
if (state.login_text) |box| box.text.items else state.login.?.getCurrentUsername(),
password_text,
if (state.maybe_old_password) |pass| pass else password_text,
if (state.maybe_old_password != null) password_text else null,
) catch |err| {
shared_err.writeError(err);
@ -1645,12 +1651,19 @@ fn authenticate(ptr: *anyopaque) !bool {
std.process.exit(0);
}
var session_status: c_int = undefined;
_ = std.posix.system.waitpid(session_pid, &session_status, 0);
// HACK: It seems like the session process is not exiting immediately after the waitpid call.
// This is a workaround to ensure the session process has exited before re-initializing the TTY.
state.io.sleep(.fromSeconds(1), .real) catch {};
session_pid = -1;
if (state.maybe_old_password) |pass| {
state.allocator.free(pass);
state.maybe_old_password = null;
}
if (session_pid != -1) {
var session_status: c_int = undefined;
_ = std.posix.system.waitpid(session_pid, &session_status, 0);
// HACK: It seems like the session process is not exiting immediately after the waitpid call.
// This is a workaround to ensure the session process has exited before re-initializing the TTY.
state.io.sleep(.fromSeconds(1), .real) catch {};
session_pid = -1;
}
try state.log_file.reinit(state.io);
}
@ -1658,7 +1671,20 @@ fn authenticate(ptr: *anyopaque) !bool {
try state.buffer.reclaim();
const auth_err = shared_err.readError();
if (auth_err) |err| {
if (auth_err) |err| handle_error: {
if (err == error.PamNewAuthTokenRequired) {
try state.info_line.addMessage(
state.lang.token_expired,
state.config.bg,
state.config.fg,
);
state.maybe_old_password = try state.allocator.dupe(u8, state.password.text.items);
state.password.clear();
state.is_autologin = false;
break :handle_error;
}
state.auth_fails += 1;
state.buffer.setActiveWidget(state.password_widget);
@ -1926,7 +1952,7 @@ fn updateBigClock(self: *BigLabel, ptr: *anyopaque) !void {
const time = try interop.getTimeOfDay();
const animate_time = @divTrunc(time.microseconds, 500_000);
const separator = if (state.animate and animate_time != 0) " " else ":";
const format = try std.fmt.bufPrintSentinel(
const format = try std.fmt.bufPrintZ(
&state.bigclock_format_buf,
"{s}{s}{s}{s}{s}{s}",
.{
@ -1937,7 +1963,6 @@ fn updateBigClock(self: *BigLabel, ptr: *anyopaque) !void {
if (state.config.bigclock_seconds) "%S" else "",
if (state.config.bigclock_12hr) "%P" else "",
},
0,
);
const clock_str = interop.timeAsString(state.io, &state.bigclock_buf, format);
@ -2612,12 +2637,12 @@ fn getAuthErrorMsg(err: anyerror, lang: Lang) []const u8 {
error.PamCredentialsInsufficient => lang.err_pam_cred_insufficient,
error.PamCredentialsUnavailable => lang.err_pam_cred_unavail,
error.PamMaximumTries => lang.err_pam_maxtries,
error.PamNewAuthTokenRequired => lang.err_pam_authok_reqd,
error.PamPermissionDenied => lang.err_pam_perm_denied,
error.PamSessionError => lang.err_pam_session,
error.PamSystemError => lang.err_pam_sys,
error.PamUserUnknown => lang.err_pam_user_unknown,
error.PamAbort => lang.err_pam_abort,
error.AccountLocked => lang.err_acc_locked,
else => @errorName(err),
};
}