mirror of https://github.com/fairyglade/ly.git
tiny changes
This commit is contained in:
parent
54d488ea58
commit
cc1bb0def9
|
@ -18,7 +18,7 @@ pub fn init() !SharedError {
|
|||
}
|
||||
|
||||
pub fn deinit(self: *SharedError) void {
|
||||
defer std.posix.munmap(self.data);
|
||||
std.posix.munmap(self.data);
|
||||
}
|
||||
|
||||
pub fn writeError(self: SharedError, err: anyerror) void {
|
||||
|
|
14
src/auth.zig
14
src/auth.zig
|
@ -30,7 +30,7 @@ pub fn authenticate(config: Config, desktop: Desktop, login: [:0]const u8, passw
|
|||
try setXdgEnv(tty_str, current_environment.name, current_environment.xdg_name);
|
||||
|
||||
// Open the PAM session
|
||||
var credentials = [2:null]?[*:0]const u8{ login, password };
|
||||
var credentials = [_:null]?[*:0]const u8{ login, password };
|
||||
|
||||
const conv = interop.pam.pam_conv{
|
||||
.conv = loginConv,
|
||||
|
@ -244,7 +244,7 @@ fn loginConv(
|
|||
fn resetTerminal(shell: [*:0]const u8, term_reset_cmd: [:0]const u8) !void {
|
||||
const pid = try std.posix.fork();
|
||||
if (pid == 0) {
|
||||
const args = [3:null]?[*:0]const u8{ shell, "-c", term_reset_cmd };
|
||||
const args = [_:null]?[*:0]const u8{ shell, "-c", term_reset_cmd };
|
||||
std.posix.execveZ(shell, &args, std.c.environ) catch {};
|
||||
std.process.exit(1);
|
||||
}
|
||||
|
@ -337,7 +337,7 @@ fn xauth(display_name: [:0]u8, shell: [*:0]const u8, pw_dir: [*:0]const u8, xaut
|
|||
if (pid == 0) {
|
||||
var cmd_buffer: [1024]u8 = undefined;
|
||||
const cmd_str = std.fmt.bufPrintZ(&cmd_buffer, "{s} add {s} . $({s})", .{ xauth_cmd, display_name, mcookie_cmd }) catch std.process.exit(1);
|
||||
const args = [3:null]?[*:0]const u8{ shell, "-c", cmd_str.ptr };
|
||||
const args = [_:null]?[*:0]const u8{ shell, "-c", cmd_str };
|
||||
std.posix.execveZ(shell, &args, std.c.environ) catch {};
|
||||
std.process.exit(1);
|
||||
}
|
||||
|
@ -346,14 +346,14 @@ fn xauth(display_name: [:0]u8, shell: [*:0]const u8, pw_dir: [*:0]const u8, xaut
|
|||
}
|
||||
|
||||
fn executeShellCmd(shell: [*:0]const u8) !void {
|
||||
const args = [1:null]?[*:0]const u8{shell};
|
||||
const args = [_:null]?[*:0]const u8{shell};
|
||||
return std.posix.execveZ(shell, &args, std.c.environ);
|
||||
}
|
||||
|
||||
fn executeWaylandCmd(shell: [*:0]const u8, wayland_cmd: []const u8, desktop_cmd: []const u8) !void {
|
||||
var cmd_buffer: [1024]u8 = undefined;
|
||||
const cmd_str = try std.fmt.bufPrintZ(&cmd_buffer, "{s} {s}", .{ wayland_cmd, desktop_cmd });
|
||||
const args = [3:null]?[*:0]const u8{ shell, "-c", cmd_str };
|
||||
const args = [_:null]?[*:0]const u8{ shell, "-c", cmd_str };
|
||||
return std.posix.execveZ(shell, &args, std.c.environ);
|
||||
}
|
||||
|
||||
|
@ -367,7 +367,7 @@ fn executeX11Cmd(shell: [*:0]const u8, pw_dir: [*:0]const u8, config: Config, de
|
|||
if (pid == 0) {
|
||||
var cmd_buffer: [1024]u8 = undefined;
|
||||
const cmd_str = std.fmt.bufPrintZ(&cmd_buffer, "{s} {s} {s}", .{ config.x_cmd, display_name, vt }) catch std.process.exit(1);
|
||||
const args = [3:null]?[*:0]const u8{ shell, "-c", cmd_str };
|
||||
const args = [_:null]?[*:0]const u8{ shell, "-c", cmd_str };
|
||||
std.posix.execveZ(shell, &args, std.c.environ) catch {};
|
||||
std.process.exit(1);
|
||||
}
|
||||
|
@ -390,7 +390,7 @@ fn executeX11Cmd(shell: [*:0]const u8, pw_dir: [*:0]const u8, config: Config, de
|
|||
if (xorg_pid == 0) {
|
||||
var cmd_buffer: [1024]u8 = undefined;
|
||||
const cmd_str = std.fmt.bufPrintZ(&cmd_buffer, "{s} {s}", .{ config.x_cmd_setup, desktop_cmd }) catch std.process.exit(1);
|
||||
const args = [3:null]?[*:0]const u8{ shell, "-c", cmd_str };
|
||||
const args = [_:null]?[*:0]const u8{ shell, "-c", cmd_str };
|
||||
std.posix.execveZ(shell, &args, std.c.environ) catch {};
|
||||
std.process.exit(1);
|
||||
}
|
||||
|
|
|
@ -56,7 +56,6 @@ pub const LED_CAP: c_int = 0x04;
|
|||
pub const K_NUMLOCK: c_int = 0x02;
|
||||
pub const K_CAPSLOCK: c_int = 0x04;
|
||||
|
||||
pub extern "c" fn time(second: ?*c_time) c_time;
|
||||
pub extern "c" fn localtime(timer: *const c_time) *tm;
|
||||
pub extern "c" fn strftime(str: [*:0]u8, maxsize: c_size, format: [*:0]const u8, timeptr: *const tm) c_size;
|
||||
pub extern "c" fn setenv(name: [*:0]const u8, value: [*:0]const u8, overwrite: c_int) c_int;
|
||||
|
@ -70,7 +69,7 @@ pub extern "c" fn endusershell() void;
|
|||
pub extern "c" fn initgroups(user: [*:0]const u8, group: c_gid) c_int;
|
||||
|
||||
pub fn timeAsString(buf: [:0]u8, format: [:0]const u8) ![]u8 {
|
||||
const timer = time(null);
|
||||
const timer = std.time.timestamp();
|
||||
const tm_info = localtime(&timer);
|
||||
|
||||
const len = strftime(buf, buf.len, format, tm_info);
|
||||
|
@ -85,6 +84,7 @@ pub fn getLockState(console_dev: [:0]const u8) !struct {
|
|||
} {
|
||||
const fd = std.c.open(console_dev, .{ .ACCMODE = .RDONLY });
|
||||
if (fd < 0) return error.CannotOpenConsoleDev;
|
||||
defer _ = std.c.close(fd);
|
||||
|
||||
var numlock = false;
|
||||
var capslock = false;
|
||||
|
@ -101,8 +101,6 @@ pub fn getLockState(console_dev: [:0]const u8) !struct {
|
|||
capslock = (led & K_CAPSLOCK) != 0;
|
||||
}
|
||||
|
||||
_ = std.c.close(fd);
|
||||
|
||||
return .{
|
||||
.numlock = numlock,
|
||||
.capslock = capslock,
|
||||
|
|
Loading…
Reference in New Issue