mirror of
https://github.com/javalsai/lidm.git
synced 2025-09-01 02:47:59 +02:00
Compare commits
6 Commits
master
...
93af32d386
Author | SHA1 | Date | |
---|---|---|---|
93af32d386
|
|||
6f5413903a
|
|||
d52de80107
|
|||
dad5296839
|
|||
947c92ce3f
|
|||
e529483c28
|
3
.github/workflows/build.yml
vendored
3
.github/workflows/build.yml
vendored
@@ -132,7 +132,6 @@ jobs:
|
|||||||
path: lidm-riscv64
|
path: lidm-riscv64
|
||||||
retention-days: 1
|
retention-days: 1
|
||||||
|
|
||||||
# This build job is only symbolic, the behavior of the packaged Void Linux version may differ.
|
|
||||||
build-linux-amd64-musl:
|
build-linux-amd64-musl:
|
||||||
name: amd64-musl
|
name: amd64-musl
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
@@ -148,7 +147,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
cd /workspace
|
cd /workspace
|
||||||
|
|
||||||
xbps-install -Syu xbps && xbps-install -yu
|
xbps-install -Sy
|
||||||
xbps-install -y git pam-devel make gcc bash git
|
xbps-install -y git pam-devel make gcc bash git
|
||||||
|
|
||||||
ARCH=amd64-musl GITHUB_STEP_SUMMARY=gss.out GITHUB_OUTPUT=go.out assets/github_scripts/build.sh
|
ARCH=amd64-musl GITHUB_STEP_SUMMARY=gss.out GITHUB_OUTPUT=go.out assets/github_scripts/build.sh
|
||||||
|
4
Makefile
4
Makefile
@@ -16,10 +16,10 @@ ALLFLAGS=$(CFLAGS) $(CPPFLAGS) -I$(IDIR)
|
|||||||
|
|
||||||
LIBS=-lpam
|
LIBS=-lpam
|
||||||
|
|
||||||
_DEPS = version.h log.h util.h ui.h ui_state.h config.h desktop.h desktop_exec.h auth.h ofield.h efield.h keys.h users.h sessions.h chvt.h macros.h launch_state.h
|
_DEPS = version.h log.h util.h ui.h ui_state.h config.h desktop.h auth.h ofield.h efield.h keys.h users.h sessions.h chvt.h macros.h launch_state.h
|
||||||
DEPS = $(patsubst %,$(IDIR)/%,$(_DEPS))
|
DEPS = $(patsubst %,$(IDIR)/%,$(_DEPS))
|
||||||
|
|
||||||
_OBJ = main.o log.o util.o ui.o ui_state.o config.o desktop.o desktop_exec.o auth.o ofield.o efield.o users.o sessions.o chvt.o launch_state.o
|
_OBJ = main.o log.o util.o ui.o ui_state.o config.o desktop.o auth.o ofield.o efield.o users.o sessions.o chvt.o launch_state.o
|
||||||
OBJ = $(patsubst %,$(ODIR)/%,$(_OBJ))
|
OBJ = $(patsubst %,$(ODIR)/%,$(_OBJ))
|
||||||
|
|
||||||
INFO_GIT_REV?=$$(git describe --long --tags --always || echo '?')
|
INFO_GIT_REV?=$$(git describe --long --tags --always || echo '?')
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
pkgbase = lidm-bin
|
pkgbase = lidm-bin
|
||||||
pkgdesc = A fully colorful customizable TUI display manager made in C. (release binary)
|
pkgdesc = A fully colorful customizable TUI display manager made in C. (release binary)
|
||||||
pkgver = 1.2.3
|
pkgver = 1.2.3
|
||||||
pkgrel = 3
|
pkgrel = 1
|
||||||
url = https://github.com/javalsai/lidm
|
url = https://github.com/javalsai/lidm
|
||||||
arch = x86_64
|
arch = x86_64
|
||||||
arch = i686
|
arch = i686
|
||||||
@@ -9,7 +9,7 @@ pkgbase = lidm-bin
|
|||||||
arch = armv7h
|
arch = armv7h
|
||||||
arch = riscv64
|
arch = riscv64
|
||||||
license = GPL
|
license = GPL
|
||||||
depends = libpam.so
|
depends = libpam.so=0
|
||||||
provides = lidm
|
provides = lidm
|
||||||
conflicts = lidm
|
conflicts = lidm
|
||||||
source = lidm-default-theme-1.2.3.ini::https://raw.githubusercontent.com/javalsai/lidm/v1.2.3/themes/default.ini
|
source = lidm-default-theme-1.2.3.ini::https://raw.githubusercontent.com/javalsai/lidm/v1.2.3/themes/default.ini
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
# Maintainer: javalsai <javalsai@proton.me>
|
# Maintainer: javalsai <javalsai@proton.me>
|
||||||
pkgname=lidm-bin
|
pkgname=lidm-bin
|
||||||
pkgver=1.2.3
|
pkgver=1.2.3
|
||||||
pkgrel=3
|
pkgrel=1
|
||||||
depends=('libpam.so')
|
depends=('libpam.so')
|
||||||
pkgdesc="A fully colorful customizable TUI display manager made in C. (release binary)"
|
pkgdesc="A fully colorful customizable TUI display manager made in C. (release binary)"
|
||||||
arch=('x86_64' 'i686' 'aarch64' 'armv7h' 'riscv64')
|
arch=('x86_64' 'i686' 'aarch64' 'armv7h' 'riscv64')
|
||||||
|
@@ -1,11 +1,13 @@
|
|||||||
pkgbase = lidm-git
|
pkgbase = lidm-git
|
||||||
pkgdesc = A fully colorful customizable TUI display manager made in C. (last git commit)
|
pkgdesc = A fully colorful customizable TUI display manager made in C. (last git commit)
|
||||||
pkgver = 1.2.3.r3.g363deea
|
pkgver = 1.2.3.r3.g363deea
|
||||||
pkgrel = 3
|
pkgrel = 1
|
||||||
url = https://github.com/javalsai/lidm
|
url = https://github.com/javalsai/lidm
|
||||||
arch = any
|
arch = any
|
||||||
license = GPL
|
license = GPL
|
||||||
makedepends = git
|
makedepends = git
|
||||||
|
makedepends = make
|
||||||
|
makedepends = gcc
|
||||||
depends = pam
|
depends = pam
|
||||||
provides = lidm
|
provides = lidm
|
||||||
conflicts = lidm
|
conflicts = lidm
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
# Maintainer: javalsai <javalsai@proton.me>
|
# Maintainer: javalsai <javalsai@proton.me>
|
||||||
pkgname=lidm-git
|
pkgname=lidm-git
|
||||||
pkgver=1.2.3.r3.g363deea
|
pkgver=1.2.3.r3.g363deea
|
||||||
pkgrel=3
|
pkgrel=1
|
||||||
depends=('pam')
|
depends=('pam')
|
||||||
makedepends=('git')
|
makedepends=('git')
|
||||||
pkgdesc="A fully colorful customizable TUI display manager made in C. (last git commit)"
|
pkgdesc="A fully colorful customizable TUI display manager made in C. (last git commit)"
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
pkgbase = lidm
|
pkgbase = lidm
|
||||||
pkgdesc = A fully colorful customizable TUI display manager made in C. (build latest tag)
|
pkgdesc = A fully colorful customizable TUI display manager made in C. (build latest tag)
|
||||||
pkgver = 1.2.3
|
pkgver = 1.2.3
|
||||||
pkgrel = 3
|
pkgrel = 1
|
||||||
url = https://github.com/javalsai/lidm
|
url = https://github.com/javalsai/lidm
|
||||||
arch = any
|
arch = any
|
||||||
license = GPL
|
license = GPL
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
# Maintainer: javalsai <javalsai@proton.me>
|
# Maintainer: javalsai <javalsai@proton.me>
|
||||||
pkgname=lidm
|
pkgname=lidm
|
||||||
pkgver=1.2.3
|
pkgver=1.2.3
|
||||||
pkgrel=3
|
pkgrel=1
|
||||||
depends=('pam')
|
depends=('pam')
|
||||||
makedepends=()
|
makedepends=()
|
||||||
pkgdesc="A fully colorful customizable TUI display manager made in C. (build latest tag)"
|
pkgdesc="A fully colorful customizable TUI display manager made in C. (build latest tag)"
|
||||||
|
@@ -1,7 +0,0 @@
|
|||||||
#ifndef DESKTOP_EXEC_H_
|
|
||||||
#define DESKTOP_EXEC_H_
|
|
||||||
|
|
||||||
int parse_exec_string(const char* exec_s, int* arg_count, char*** args);
|
|
||||||
void free_parsed_args(int arg_count, char** args);
|
|
||||||
|
|
||||||
#endif
|
|
28
src/auth.c
28
src/auth.c
@@ -10,8 +10,6 @@
|
|||||||
|
|
||||||
#include "auth.h"
|
#include "auth.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "desktop_exec.h"
|
|
||||||
#include "log.h"
|
|
||||||
#include "sessions.h"
|
#include "sessions.h"
|
||||||
#include "ui.h"
|
#include "ui.h"
|
||||||
#include "unistd.h"
|
#include "unistd.h"
|
||||||
@@ -168,22 +166,6 @@ void moarEnv(char* user, struct session session, struct passwd* pw,
|
|||||||
// NOLINTBEGIN(readability-function-cognitive-complexity)
|
// NOLINTBEGIN(readability-function-cognitive-complexity)
|
||||||
bool launch(char* user, char* passwd, struct session session, void (*cb)(void),
|
bool launch(char* user, char* passwd, struct session session, void (*cb)(void),
|
||||||
struct config* config) {
|
struct config* config) {
|
||||||
char** desktop_exec;
|
|
||||||
int desktop_count;
|
|
||||||
|
|
||||||
if (session.type != SHELL) {
|
|
||||||
desktop_exec = NULL;
|
|
||||||
int parse_status =
|
|
||||||
parse_exec_string(session.exec, &desktop_count, &desktop_exec);
|
|
||||||
if (parse_status != 0 || desktop_count == 0 || !desktop_exec[0]) {
|
|
||||||
print_err("failure parsing exec string");
|
|
||||||
log_printf("failure parsing exec string '%s': %d\n",
|
|
||||||
session.exec ? session.exec : "NULL", parse_status);
|
|
||||||
free_parsed_args(desktop_count, desktop_exec);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct passwd* pw = getpwnam(user);
|
struct passwd* pw = getpwnam(user);
|
||||||
if (pw == NULL) {
|
if (pw == NULL) {
|
||||||
print_err("could not get user info");
|
print_err("could not get user info");
|
||||||
@@ -255,7 +237,8 @@ bool launch(char* user, char* passwd, struct session session, void (*cb)(void),
|
|||||||
|
|
||||||
*reach_session = true;
|
*reach_session = true;
|
||||||
|
|
||||||
// TODO: test existence of executable with TryExec
|
// TODO: these will be different due to TryExec
|
||||||
|
// and, Exec/TryExec might contain spaces as args
|
||||||
printf("\x1b[0m");
|
printf("\x1b[0m");
|
||||||
// NOLINTNEXTLINE(bugprone-branch-clone)
|
// NOLINTNEXTLINE(bugprone-branch-clone)
|
||||||
if (session.type == SHELL) {
|
if (session.type == SHELL) {
|
||||||
@@ -265,12 +248,9 @@ bool launch(char* user, char* passwd, struct session session, void (*cb)(void),
|
|||||||
} else if (session.type == XORG || session.type == WAYLAND) {
|
} else if (session.type == XORG || session.type == WAYLAND) {
|
||||||
clear_screen();
|
clear_screen();
|
||||||
(void)fflush(stdout);
|
(void)fflush(stdout);
|
||||||
// NOLINTNEXTLINE
|
execlp(session.exec, session.exec, NULL);
|
||||||
execvp(desktop_exec[0], desktop_exec);
|
|
||||||
// NOLINTNEXTLINE
|
|
||||||
free_parsed_args(desktop_count, desktop_exec);
|
|
||||||
}
|
}
|
||||||
perror("exec error");
|
perror("execl error");
|
||||||
(void)fputs("failure calling session\n", stderr);
|
(void)fputs("failure calling session\n", stderr);
|
||||||
} else {
|
} else {
|
||||||
pid_t child_pid = (pid_t)pid;
|
pid_t child_pid = (pid_t)pid;
|
||||||
|
@@ -1,183 +0,0 @@
|
|||||||
#include <stddef.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "desktop_exec.h"
|
|
||||||
|
|
||||||
// constants for exec string parsing
|
|
||||||
#define MAX_ARGS 100
|
|
||||||
// ARG_LENGTH is the initial length of a parsed argument
|
|
||||||
#define ARG_LENGTH 64
|
|
||||||
|
|
||||||
// parse Exec=/bin/prog arg1 arg2\ with\ spaces
|
|
||||||
void free_parsed_args(int arg_count, char** args) {
|
|
||||||
if (!args) return;
|
|
||||||
for (int i = 0; i < arg_count; i++) {
|
|
||||||
free(args[i]);
|
|
||||||
}
|
|
||||||
free((void*)args);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* small closure-like struct to pass state to helper functions */
|
|
||||||
struct ctx {
|
|
||||||
char** pcur;
|
|
||||||
size_t* pcur_len;
|
|
||||||
size_t* pcur_cap;
|
|
||||||
char*** pargv;
|
|
||||||
int* pargc;
|
|
||||||
};
|
|
||||||
/* append_char(state, ch) -> 0 on error, 1 on success */
|
|
||||||
int append_char(struct ctx* st, char ch) {
|
|
||||||
char** pcur = st->pcur;
|
|
||||||
size_t* plen = st->pcur_len;
|
|
||||||
size_t* pcap = st->pcur_cap;
|
|
||||||
if (*plen + 1 >= *pcap) {
|
|
||||||
size_t newcap = *pcap ? (*pcap) * 2 : ARG_LENGTH;
|
|
||||||
char* cur = (char*)realloc(*pcur, newcap);
|
|
||||||
if (!cur) return 0;
|
|
||||||
*pcur = cur;
|
|
||||||
*pcap = newcap;
|
|
||||||
}
|
|
||||||
(*pcur)[(*plen)++] = ch;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* push_arg(state) -> 0 on error, 1 on success */
|
|
||||||
int push_arg(struct ctx* st) {
|
|
||||||
char** pcur = st->pcur;
|
|
||||||
size_t* plen = st->pcur_len;
|
|
||||||
size_t* pcap = st->pcur_cap;
|
|
||||||
char*** pargv = st->pargv;
|
|
||||||
int* pargc = st->pargc;
|
|
||||||
|
|
||||||
if (*pargc > MAX_ARGS) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if (!*pcur) {
|
|
||||||
char* empty = strdup("");
|
|
||||||
if (!empty) return 0;
|
|
||||||
char** na = (char**)realloc((void*)*pargv, sizeof(char*) * ((*pargc) + 1));
|
|
||||||
if (!na) {
|
|
||||||
free(empty);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
*pargv = na;
|
|
||||||
(*pargv)[(*pargc)++] = empty;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if (!append_char(st, '\0')) return 0;
|
|
||||||
char* final = (char*)realloc(*pcur, *plen);
|
|
||||||
if (!final) final = *pcur;
|
|
||||||
*pcur = NULL;
|
|
||||||
*plen = 0;
|
|
||||||
*pcap = 0;
|
|
||||||
char** na = (char**)realloc((void*)*pargv, sizeof(char*) * ((*pargc) + 1));
|
|
||||||
if (!na) {
|
|
||||||
free(final);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
*pargv = na;
|
|
||||||
(*pargv)[(*pargc)++] = final;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Return codes:
|
|
||||||
0 = success
|
|
||||||
1 = bad args
|
|
||||||
2 = memory
|
|
||||||
3 = syntax
|
|
||||||
Important: call free_parsed_args afterwards to free the passed ***args
|
|
||||||
*/
|
|
||||||
// NOLINTBEGIN(readability-function-cognitive-complexity)
|
|
||||||
int parse_exec_string(const char* exec_s, int* arg_count, char*** args) {
|
|
||||||
if (!exec_s || !args || !arg_count) return 1;
|
|
||||||
*args = NULL;
|
|
||||||
*arg_count = 0;
|
|
||||||
|
|
||||||
size_t len = strlen(exec_s);
|
|
||||||
size_t idx = 0;
|
|
||||||
char* cur = NULL;
|
|
||||||
size_t cur_len = 0;
|
|
||||||
size_t cur_cap = 0;
|
|
||||||
char** argv = NULL;
|
|
||||||
int argc = 0;
|
|
||||||
int in_quote = 0;
|
|
||||||
|
|
||||||
struct ctx ctx;
|
|
||||||
ctx.pcur = &cur;
|
|
||||||
ctx.pcur_len = &cur_len;
|
|
||||||
ctx.pcur_cap = &cur_cap;
|
|
||||||
ctx.pargv = &argv;
|
|
||||||
ctx.pargc = &argc;
|
|
||||||
|
|
||||||
while (idx < len) {
|
|
||||||
char cur_c = exec_s[idx];
|
|
||||||
if (!in_quote && (cur_c == ' ' || cur_c == '\t' || cur_c == '\n')) {
|
|
||||||
if (cur_cap) {
|
|
||||||
if (!push_arg(&ctx)) goto nomem;
|
|
||||||
}
|
|
||||||
idx++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (!in_quote && cur_c == '"') {
|
|
||||||
in_quote = 1;
|
|
||||||
idx++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (in_quote && cur_c == '"') {
|
|
||||||
in_quote = 0;
|
|
||||||
idx++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cur_c == '\\') {
|
|
||||||
if (idx + 1 >= len) goto syntax_err;
|
|
||||||
if (!append_char(&ctx, exec_s[idx + 1])) goto nomem;
|
|
||||||
idx += 2;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cur_c == '%') {
|
|
||||||
if (idx + 1 >= len) goto syntax_err;
|
|
||||||
if (exec_s[idx + 1] == '%') {
|
|
||||||
if (!append_char(&ctx, '%')) goto nomem;
|
|
||||||
idx += 2;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
/* drop any %X */
|
|
||||||
idx += 2;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!append_char(&ctx, cur_c)) goto nomem;
|
|
||||||
idx++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_quote) goto syntax_err;
|
|
||||||
if (cur_cap) {
|
|
||||||
if (!push_arg(&ctx)) goto nomem;
|
|
||||||
}
|
|
||||||
char** na = (char**)realloc((void*)argv, sizeof(char*) * (argc + 1));
|
|
||||||
if (!na) goto nomem;
|
|
||||||
argv = na;
|
|
||||||
argv[argc] = NULL;
|
|
||||||
|
|
||||||
*args = argv;
|
|
||||||
*arg_count = argc;
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
nomem:
|
|
||||||
if (cur) free(cur);
|
|
||||||
free_parsed_args(argc, argv);
|
|
||||||
*args = NULL;
|
|
||||||
*arg_count = 0;
|
|
||||||
return 2;
|
|
||||||
|
|
||||||
syntax_err:
|
|
||||||
if (cur) free(cur);
|
|
||||||
free_parsed_args(argc, argv);
|
|
||||||
*args = NULL;
|
|
||||||
*arg_count = 0;
|
|
||||||
return 3;
|
|
||||||
}
|
|
||||||
// NOLINTEND(readability-function-cognitive-complexity)
|
|
Reference in New Issue
Block a user