support using different login shell

This commit is contained in:
Fahmi Akbar Wildana 2025-12-19 09:41:29 +07:00
commit 50529e4547
4 changed files with 10 additions and 2 deletions

View file

@ -267,6 +267,11 @@ lang = en
# You can also set environment variables in there, they'll persist until logout
login_cmd = null
# SHELL to use when logging in
# If null, it will use the default login shell
# Important: it must be an absolute path!
login_shell = null
# Path for login.defs file (used for listing all local users on the system on
# Linux)
login_defs_path = /etc/login.defs

View file

@ -19,6 +19,7 @@ pub const AuthOptions = struct {
xauth_cmd: []const u8,
setup_cmd: []const u8,
login_cmd: ?[]const u8,
login_shell: ?[]const u8,
x_cmd: []const u8,
session_pid: std.posix.pid_t,
};
@ -417,7 +418,7 @@ fn executeX11Cmd(log_file: *LogFile, allocator: std.mem.Allocator, shell: []cons
var buf: [4]u8 = undefined;
const display_name = try std.fmt.bufPrint(&buf, ":{d}", .{display_num});
const shell_z = try allocator.dupeZ(u8, shell);
const shell_z = try allocator.dupeZ(u8, options.login_shell orelse shell);
defer allocator.free(shell_z);
try log_writer.writeAll("[x11] creating xauth file\n");
@ -491,7 +492,7 @@ fn executeCmd(global_log_file: *LogFile, allocator: std.mem.Allocator, shell: []
}
defer if (maybe_log_file) |log_file| log_file.close();
const shell_z = try allocator.dupeZ(u8, shell);
const shell_z = try allocator.dupeZ(u8, options.login_shell orelse shell);
defer allocator.free(shell_z);
var cmd_buffer: [1024]u8 = undefined;

View file

@ -66,6 +66,7 @@ initial_info_text: ?[]const u8 = null,
input_len: u8 = 34,
lang: []const u8 = "en",
login_cmd: ?[]const u8 = null,
login_shell: ?[]const u8 = null,
login_defs_path: []const u8 = "/etc/login.defs",
logout_cmd: ?[]const u8 = null,
ly_log: []const u8 = "/var/log/ly.log",

View file

@ -1084,6 +1084,7 @@ pub fn main() !void {
.xauth_cmd = config.xauth_cmd,
.setup_cmd = config.setup_cmd,
.login_cmd = config.login_cmd,
.login_shell = config.login_shell,
.x_cmd = config.x_cmd,
.session_pid = session_pid,
};