Merge branch 'master' into docs
11
.SRCINFO
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
pkgbase = lidm
|
||||||
|
pkgdesc = A ✨fully✨ colorful cutomizable TUI display manager made in C for simplicity.
|
||||||
|
pkgver = 0.0.0
|
||||||
|
pkgrel = 1
|
||||||
|
url = https://github.com/javalsai/lidm
|
||||||
|
arch = any
|
||||||
|
license = GPL
|
||||||
|
source = lidm::https://github.com/javalsai/lidm/releases/download/0.0.0/lidm
|
||||||
|
sha256sums = 2771ca603fb02520cb1ea2dac10400fd4f512d7a8883a7ecffefe6595a93dcf5
|
||||||
|
|
||||||
|
pkgname = lidm
|
2
.github/workflows/release.yml
vendored
@ -19,5 +19,5 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
file: lidm
|
file: lidm
|
||||||
asset_name: lidm
|
asset_name: lidm-x86_64 # will compile for more archs other day
|
||||||
tag: ${{ github.ref }}
|
tag: ${{ github.ref }}
|
||||||
|
2
.gitignore
vendored
@ -1,4 +1,4 @@
|
|||||||
lidm
|
/lidm
|
||||||
dist/
|
dist/
|
||||||
|
|
||||||
.cache/
|
.cache/
|
||||||
|
29
Makefile
@ -4,7 +4,9 @@ IDIR=include
|
|||||||
ODIR=dist
|
ODIR=dist
|
||||||
|
|
||||||
CC=gcc
|
CC=gcc
|
||||||
CFLAGS=-O3 -I$(IDIR)
|
CFLAGS?=-O3
|
||||||
|
_CFLAGS=-I$(DIR)
|
||||||
|
ALLFLAGS=$(CFLAGS) -I$(IDIR)
|
||||||
|
|
||||||
LIBS=-lm -lpam -lpam_misc
|
LIBS=-lm -lpam -lpam_misc
|
||||||
|
|
||||||
@ -16,11 +18,32 @@ OBJ = $(patsubst %,$(ODIR)/%,$(_OBJ))
|
|||||||
|
|
||||||
$(ODIR)/%.o: $(CDIR)/%.c $(DEPS)
|
$(ODIR)/%.o: $(CDIR)/%.c $(DEPS)
|
||||||
@mkdir -p $(ODIR)
|
@mkdir -p $(ODIR)
|
||||||
$(CC) -c -o $@ $< $(CFLAGS)
|
$(CC) -c -o $@ $< $(ALLFLAGS)
|
||||||
|
|
||||||
lidm: $(OBJ)
|
lidm: $(OBJ)
|
||||||
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
|
$(CC) -o $@ $^ $(ALLFLAGS) $(LIBS)
|
||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean:
|
clean:
|
||||||
rm -f $(ODIR)/*.o *- li $(INCDIR)/*-
|
rm -f $(ODIR)/*.o *- li $(INCDIR)/*-
|
||||||
|
|
||||||
|
# Copy lidm to /usr/bin
|
||||||
|
install: lidm
|
||||||
|
install -m755 ./lidm /usr/bin
|
||||||
|
install -m755 ./themes/default.ini /etc/lidm.ini
|
||||||
|
|
||||||
|
install-service:
|
||||||
|
@if command -v systemctl &> /dev/null; then \
|
||||||
|
make install-service-systemd; \
|
||||||
|
elif command -v dinitctl &> /dev/null; then \
|
||||||
|
make install-service-dinit; \
|
||||||
|
else \
|
||||||
|
printf '\x1b[1;31m%s\x1b[0m\n' "Unknown init system, skipping install..."; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
install-service-systemd:
|
||||||
|
install -m755 ./assets/services/systemd.service /etc/systemd/system/lidm.service
|
||||||
|
@printf '\x1b[1m%s\x1b[0m\n\n' " don't forget to run 'systemctl enable lidm'"
|
||||||
|
install-service-dinit:
|
||||||
|
install -m755 ./assets/services/dinit /etc/dinit.d/lidm
|
||||||
|
@printf '\x1b[1m%s\x1b[0m\n\n' " don't forget to run 'dinitctl enable lidm'"
|
||||||
|
14
PKGBUILD
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
pkgname=lidm
|
||||||
|
pkgver=0.0.0
|
||||||
|
pkgrel=1
|
||||||
|
pkgdesc="A ✨fully✨ colorful cutomizable TUI display manager made in C for simplicity."
|
||||||
|
arch=('any')
|
||||||
|
url="https://github.com/javalsai/lidm"
|
||||||
|
license=('GPL')
|
||||||
|
source=("lidm::https://github.com/javalsai/lidm/releases/download/v$pkgver.zip")
|
||||||
|
sha256sums=('2771ca603fb02520cb1ea2dac10400fd4f512d7a8883a7ecffefe6595a93dcf5')
|
||||||
|
|
||||||
|
package() {
|
||||||
|
install -d "$pkgdir/usr/bin/lidm"
|
||||||
|
}
|
||||||
|
sha256sums=('5eb72f7d0425e81f9b42f70159ecc44d1b6ca5cfd4fde845d01348964273ab64')
|
@ -34,7 +34,6 @@ We all know that the most important thing in a project is the ideology of the au
|
|||||||
[  ](https://stopchatcontrol.eu)
|
[  ](https://stopchatcontrol.eu)
|
||||||
> *there's also a [change.org post](https://www.change.org/p/stoppt-die-chatkontrolle-grundrechte-gelten-auch-im-netz).*
|
> *there's also a [change.org post](https://www.change.org/p/stoppt-die-chatkontrolle-grundrechte-gelten-auch-im-netz).*
|
||||||
|
|
||||||
|
|
||||||
# Requirements
|
# Requirements
|
||||||
* A computer with unix based system.
|
* A computer with unix based system.
|
||||||
* That system should have the resources neccessary for this program to make sense (Sessions, users...).
|
* That system should have the resources neccessary for this program to make sense (Sessions, users...).
|
||||||
@ -79,6 +78,7 @@ make install-service-dinit # dinit
|
|||||||
|
|
||||||
> [!NOTE]
|
> [!NOTE]
|
||||||
> You can skip **most** of this with the [AUR packages](https://aur.archlinux.org/packages?K=javalsai&SeB=m)
|
> You can skip **most** of this with the [AUR packages](https://aur.archlinux.org/packages?K=javalsai&SeB=m)
|
||||||
|
|
||||||
# Disabling other DM's with systemd
|
# Disabling other DM's with systemd
|
||||||
You may want to disable your current Display Manager for instance:
|
You may want to disable your current Display Manager for instance:
|
||||||
```sh
|
```sh
|
||||||
|
BIN
assets/media/lidm.gif
Normal file
After Width: | Height: | Size: 3.3 MiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
4
assets/pkg/aur/.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
*/*
|
||||||
|
!*/.gitignore
|
||||||
|
!*/PKGBUILD
|
||||||
|
!*/.SRCINFO
|
17
assets/pkg/aur/README.md
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
# AUR Packages
|
||||||
|
These files are just for reference, I'll manually edit and publish them, at least until I automate it with github actions (like updating version automatically on a release).
|
||||||
|
|
||||||
|
There are three packages that follow standard conventions:
|
||||||
|
* [`lidm`](https://aur.archlinux.org/packages/lidm): Builds latest release (manually updated per release basis)
|
||||||
|
* [`lidm-bin`](https://aur.archlinux.org/packages/lidm-bin): Fetches latest release binary (compiled by GitHub Actions, also updated per release)
|
||||||
|
* [`lidm-git`](https://aur.archlinux.org/packages/lidm-git): Fetches latest commit and builds it (should be updated automatically)
|
||||||
|
|
||||||
|
> [!IMPORTANT]
|
||||||
|
> None of those packages include the service files, I'm considering automatically detecting it on the package function or providing it as separate services (standard practice again).
|
||||||
|
>
|
||||||
|
> Depending on how good these packages go (my first packages :P) I'll make service ones too.
|
||||||
|
|
||||||
|
## Services
|
||||||
|
Summary of what to do to install service files anyways:
|
||||||
|
* **systemd:** Copy `assets/services/systemd.service` to `/etc/systemd/system/lidm.service` and enable the service (`systemctl enable lidm`)
|
||||||
|
* **dinit:** Copy `assets/services/dinit` to `/etc/dinit.d/lidm` and enable the service (`dinitctl enable lidm`)
|
18
assets/pkg/aur/lidm-bin/.SRCINFO
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
pkgbase = lidm-bin
|
||||||
|
pkgdesc = A fully colorful cutomizable TUI display manager made in C. (release binary)
|
||||||
|
pkgver = 0.0.1
|
||||||
|
pkgrel = 2
|
||||||
|
url = https://github.com/javalsai/lidm
|
||||||
|
arch = x86_64
|
||||||
|
license = GPL
|
||||||
|
depends = pam
|
||||||
|
provides = lidm
|
||||||
|
conflicts = lidm
|
||||||
|
source = lidm::https://github.com/javalsai/lidm/releases/download/0.0.1/lidm-x86_64
|
||||||
|
source = default-theme.ini::https://raw.githubusercontent.com/javalsai/lidm/0.0.1/themes/default.ini
|
||||||
|
source = LICENSE::https://raw.githubusercontent.com/javalsai/lidm/0.0.1/LICENSE
|
||||||
|
sha256sums = 4969018d527613729336abd51e37283ce77d7c7a2233434642804b88e550e622
|
||||||
|
sha256sums = 27db9b0cd2da80c0c60dcb13dfad0f9d65e7dddbb7b344b859803b9ac3943cd7
|
||||||
|
sha256sums = 3972dc9744f6499f0f9b2dbf76696f2ae7ad8af9b23dde66d6af86c9dfb36986
|
||||||
|
|
||||||
|
pkgname = lidm-bin
|
26
assets/pkg/aur/lidm-bin/PKGBUILD
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
pkgname=lidm-bin
|
||||||
|
pkgver=0.0.1
|
||||||
|
pkgrel=2
|
||||||
|
depends=('pam')
|
||||||
|
pkgdesc="A fully colorful cutomizable TUI display manager made in C. (release binary)"
|
||||||
|
arch=('x86_64')
|
||||||
|
url="https://github.com/javalsai/lidm"
|
||||||
|
license=('GPL')
|
||||||
|
provides=('lidm')
|
||||||
|
conflicts=('lidm')
|
||||||
|
source=(
|
||||||
|
"lidm::$url/releases/download/$pkgver/lidm-$arch"
|
||||||
|
"default-theme.ini::https://raw.githubusercontent.com/javalsai/lidm/$pkgver/themes/default.ini"
|
||||||
|
"LICENSE::https://raw.githubusercontent.com/javalsai/lidm/$pkgver/LICENSE"
|
||||||
|
)
|
||||||
|
sha256sums=(
|
||||||
|
'4969018d527613729336abd51e37283ce77d7c7a2233434642804b88e550e622'
|
||||||
|
'27db9b0cd2da80c0c60dcb13dfad0f9d65e7dddbb7b344b859803b9ac3943cd7'
|
||||||
|
'3972dc9744f6499f0f9b2dbf76696f2ae7ad8af9b23dde66d6af86c9dfb36986'
|
||||||
|
)
|
||||||
|
|
||||||
|
package() {
|
||||||
|
install -Dm755 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
|
||||||
|
install -Dm755 lidm "${pkgdir}/usr/bin/lidm"
|
||||||
|
install -Dm755 default-theme.ini "${pkgdir}/etc/lidm.ini"
|
||||||
|
}
|
16
assets/pkg/aur/lidm-git/.SRCINFO
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
pkgbase = lidm-git
|
||||||
|
pkgdesc = A fully colorful cutomizable TUI display manager made in C. (last git commit)
|
||||||
|
pkgver = 0.0.1.r0.gd6b165b
|
||||||
|
pkgrel = 2
|
||||||
|
url = https://github.com/javalsai/lidm
|
||||||
|
arch = any
|
||||||
|
license = GPL
|
||||||
|
makedepends = git
|
||||||
|
makedepends = make
|
||||||
|
depends = pam
|
||||||
|
provides = lidm
|
||||||
|
conflicts = lidm
|
||||||
|
source = lidm-repo::git+https://github.com/javalsai/lidm
|
||||||
|
sha256sums = SKIP
|
||||||
|
|
||||||
|
pkgname = lidm-git
|
31
assets/pkg/aur/lidm-git/PKGBUILD
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
pkgname=lidm-git
|
||||||
|
pkgver=0.0.1.r0.gd6b165b
|
||||||
|
pkgrel=2
|
||||||
|
depends=('pam')
|
||||||
|
makedepends=('git' 'make')
|
||||||
|
pkgdesc="A fully colorful cutomizable TUI display manager made in C. (last git commit)"
|
||||||
|
arch=('any')
|
||||||
|
url="https://github.com/javalsai/lidm"
|
||||||
|
license=('GPL')
|
||||||
|
provides=('lidm')
|
||||||
|
conflicts=('lidm')
|
||||||
|
source=("lidm-repo::git+https://github.com/javalsai/lidm")
|
||||||
|
sha256sums=('SKIP')
|
||||||
|
|
||||||
|
pkgver() {
|
||||||
|
cd lidm-repo
|
||||||
|
git describe --long --abbrev=7 --tags | \
|
||||||
|
sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g'
|
||||||
|
}
|
||||||
|
|
||||||
|
build() {
|
||||||
|
cd lidm-repo
|
||||||
|
make CFLAGS="-O3"
|
||||||
|
}
|
||||||
|
|
||||||
|
package() {
|
||||||
|
cd lidm-repo
|
||||||
|
install -Dm755 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
|
||||||
|
install -Dm755 lidm "${pkgdir}/usr/bin/lidm"
|
||||||
|
install -Dm755 themes/default.ini "${pkgdir}/etc/lidm.ini"
|
||||||
|
}
|
12
assets/pkg/aur/lidm/.SRCINFO
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
pkgbase = lidm
|
||||||
|
pkgdesc = A fully colorful cutomizable TUI display manager made in C. (build latest tag)
|
||||||
|
pkgver = 0.0.1
|
||||||
|
pkgrel = 2
|
||||||
|
url = https://github.com/javalsai/lidm
|
||||||
|
arch = any
|
||||||
|
license = GPL
|
||||||
|
depends = pam
|
||||||
|
source = lidm-repo::git+https://github.com/javalsai/lidm
|
||||||
|
sha256sums = SKIP
|
||||||
|
|
||||||
|
pkgname = lidm
|
22
assets/pkg/aur/lidm/PKGBUILD
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
pkgname=lidm
|
||||||
|
pkgver=0.0.1
|
||||||
|
pkgrel=2
|
||||||
|
depends=('pam')
|
||||||
|
pkgdesc="A fully colorful cutomizable TUI display manager made in C. (build latest tag)"
|
||||||
|
arch=('any')
|
||||||
|
url="https://github.com/javalsai/lidm"
|
||||||
|
license=('GPL')
|
||||||
|
source=("lidm-repo::git+https://github.com/javalsai/lidm")
|
||||||
|
sha256sums=('SKIP')
|
||||||
|
|
||||||
|
build() {
|
||||||
|
cd lidm-repo
|
||||||
|
make CFLAGS="-O3"
|
||||||
|
}
|
||||||
|
|
||||||
|
package() {
|
||||||
|
cd lidm-repo
|
||||||
|
install -Dm755 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
|
||||||
|
install -Dm755 lidm "${pkgdir}/usr/bin/lidm"
|
||||||
|
install -Dm755 themes/default.ini "${pkgdir}/etc/lidm.ini"
|
||||||
|
}
|
12
assets/pkg/aur/make-srcinfo.sh
Executable file
@ -0,0 +1,12 @@
|
|||||||
|
#/usr/bin/env bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
MYSELF=$(realpath "$0")
|
||||||
|
MYDIR=$(dirname "$MYSELF")
|
||||||
|
|
||||||
|
for pkg in "$MYDIR"/*/; do
|
||||||
|
cd "$pkg"
|
||||||
|
printf "\x1b[1mEntering '%s'\x1b[0m\n" "$pkg"
|
||||||
|
makepkg --printsrcinfo | tee .SRCINFO
|
||||||
|
echo
|
||||||
|
done
|
8
assets/services/dinit
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
type = process
|
||||||
|
command = /sbin/agetty tty7 linux-c -n -l /bin/lidm -o 7
|
||||||
|
restart = true
|
||||||
|
depends-on = login.target
|
||||||
|
termsignal = HUP
|
||||||
|
smooth-recovery = true
|
||||||
|
inittab-id = 7
|
||||||
|
inittab-line = tty7
|
17
assets/services/systemd.service
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=TUI display manager
|
||||||
|
After=systemd-user-sessions.service plymouth-quit-wait.service
|
||||||
|
After=getty@tty3.service
|
||||||
|
Conflicts=getty@tty3.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=idle
|
||||||
|
ExecStart=/usr/bin/lidm
|
||||||
|
StandardError=journal
|
||||||
|
StandardInput=tty
|
||||||
|
TTYPath=/dev/tty3
|
||||||
|
TTYReset=yes
|
||||||
|
TTYVHangup=yes
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
Alias=display-manager.service
|
94
src/auth.c
@ -5,12 +5,14 @@
|
|||||||
#include <security/pam_misc.h>
|
#include <security/pam_misc.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
|
|
||||||
#include <auth.h>
|
#include <auth.h>
|
||||||
#include <sessions.h>
|
#include <sessions.h>
|
||||||
#include <ui.h>
|
#include <ui.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <util.h>
|
||||||
|
|
||||||
int pam_conversation(int num_msg, const struct pam_message **msg,
|
int pam_conversation(int num_msg, const struct pam_message **msg,
|
||||||
struct pam_response **resp, void *appdata_ptr) {
|
struct pam_response **resp, void *appdata_ptr) {
|
||||||
@ -51,6 +53,11 @@ pam_handle_t *get_pamh(char *user, char *passwd) {
|
|||||||
}
|
}
|
||||||
#undef CHECK_PAM_RET
|
#undef CHECK_PAM_RET
|
||||||
|
|
||||||
|
void *shmalloc(size_t size) {
|
||||||
|
return mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS,
|
||||||
|
-1, 0);
|
||||||
|
}
|
||||||
|
|
||||||
void moarEnv(char *user, struct session session, struct passwd *pw) {
|
void moarEnv(char *user, struct session session, struct passwd *pw) {
|
||||||
chdir(pw->pw_dir);
|
chdir(pw->pw_dir);
|
||||||
setenv("HOME", pw->pw_dir, true);
|
setenv("HOME", pw->pw_dir, true);
|
||||||
@ -96,47 +103,68 @@ bool launch(char *user, char *passwd, struct session session,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// point of no return
|
bool *reach_session = shmalloc(sizeof(bool));
|
||||||
// TODO: move this to get_pamh, before first setcred, like login does
|
if (reach_session == NULL) {
|
||||||
if (cb != NULL)
|
perror("error allocating shared memory");
|
||||||
cb();
|
return false;
|
||||||
|
|
||||||
if(setgid(pw->pw_gid) == -1) {
|
|
||||||
perror("setgid");
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
}
|
||||||
if(initgroups(user, pw->pw_gid) == -1) {
|
*reach_session = false;
|
||||||
perror("init groups");
|
|
||||||
exit(EXIT_FAILURE);
|
uint pid = fork();
|
||||||
|
if (pid == 0) { // child
|
||||||
|
char *TERM = NULL;
|
||||||
|
char *_GETTERM = getenv("TERM");
|
||||||
|
if (_GETTERM != NULL)
|
||||||
|
strcln(&TERM, _GETTERM);
|
||||||
|
if (clearenv() != 0) {
|
||||||
|
print_errno("clearenv");
|
||||||
|
_exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
char **envlist = pam_getenvlist(pamh);
|
char **envlist = pam_getenvlist(pamh);
|
||||||
if (envlist == NULL) {
|
if (envlist == NULL) {
|
||||||
perror("pam_getenvlist");
|
print_errno("pam_getenvlist");
|
||||||
exit(EXIT_FAILURE);
|
_exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: chown stdin to user
|
|
||||||
|
|
||||||
if (setuid(pw->pw_uid) == -1) {
|
|
||||||
perror("setuid");
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
system("clear");
|
|
||||||
printf("\x1b[0m\x1b[H");
|
|
||||||
for (uint i = 0; envlist[i] != NULL; i++) {
|
for (uint i = 0; envlist[i] != NULL; i++) {
|
||||||
putenv(envlist[i]);
|
putenv(envlist[i]);
|
||||||
}
|
}
|
||||||
// NOTE: path hotfix
|
// FIXME: path hotfix
|
||||||
putenv("PATH=/bin:/usr/bin");
|
putenv("PATH=/bin:/usr/bin");
|
||||||
|
if (TERM != NULL) {
|
||||||
|
setenv("TERM", TERM, true);
|
||||||
|
free(TERM);
|
||||||
|
}
|
||||||
|
|
||||||
free(envlist);
|
free(envlist);
|
||||||
moarEnv(user, session, pw);
|
moarEnv(user, session, pw);
|
||||||
|
|
||||||
pam_setcred(pamh, PAM_DELETE_CRED);
|
// TODO: chown stdin to user
|
||||||
pam_close_session(pamh, 0);
|
// does it inherit stdin from parent and
|
||||||
pam_end(pamh, PAM_SUCCESS);
|
// does parent need to reclaim it after
|
||||||
|
// this dies?
|
||||||
|
|
||||||
|
if (setgid(pw->pw_gid) == -1) {
|
||||||
|
print_errno("setgid");
|
||||||
|
_exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
if (initgroups(user, pw->pw_gid) == -1) {
|
||||||
|
print_errno("initgroups");
|
||||||
|
_exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (setuid(pw->pw_uid) == -1) {
|
||||||
|
perror("setuid");
|
||||||
|
_exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cb != NULL)
|
||||||
|
cb();
|
||||||
|
|
||||||
|
*reach_session = true;
|
||||||
|
|
||||||
|
// TODO: these will be different due to TryExec
|
||||||
|
// and, Exec/TryExec might contain spaces as args
|
||||||
if (session.type == SHELL) {
|
if (session.type == SHELL) {
|
||||||
system("clear");
|
system("clear");
|
||||||
execlp(session.exec, session.exec, NULL);
|
execlp(session.exec, session.exec, NULL);
|
||||||
@ -146,6 +174,18 @@ bool launch(char *user, char *passwd, struct session session,
|
|||||||
}
|
}
|
||||||
perror("execl error");
|
perror("execl error");
|
||||||
fprintf(stderr, "failure calling session");
|
fprintf(stderr, "failure calling session");
|
||||||
|
} else {
|
||||||
|
waitpid(pid, NULL, 0);
|
||||||
|
|
||||||
|
pam_setcred(pamh, PAM_DELETE_CRED);
|
||||||
|
pam_close_session(pamh, 0);
|
||||||
|
pam_end(pamh, PAM_SUCCESS);
|
||||||
|
|
||||||
|
if (*reach_session == false) {
|
||||||
|
return false;
|
||||||
|
} else
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
11
src/main.c
@ -9,7 +9,18 @@
|
|||||||
#include <ui.h>
|
#include <ui.h>
|
||||||
#include <users.h>
|
#include <users.h>
|
||||||
|
|
||||||
|
void chvt(char *arg) {
|
||||||
|
size_t bsize = snprintf(NULL, 0, "chvt %s", arg) + 1;
|
||||||
|
char *buf = malloc(bsize);
|
||||||
|
snprintf(buf, bsize, "chvt %s", arg);
|
||||||
|
system(buf);
|
||||||
|
free(buf);
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
|
if (argc == 2)
|
||||||
|
chvt(argv[1]);
|
||||||
|
|
||||||
struct config *config = parse_config("/etc/lidm.ini");
|
struct config *config = parse_config("/etc/lidm.ini");
|
||||||
if (config == NULL) {
|
if (config == NULL) {
|
||||||
fprintf(stderr, "error parsing config\n");
|
fprintf(stderr, "error parsing config\n");
|
||||||
|
@ -40,6 +40,7 @@ static u_int16_t used_size = 0;
|
|||||||
static struct session *sessions = NULL;
|
static struct session *sessions = NULL;
|
||||||
static struct sessions_list *__sessions_list = NULL;
|
static struct sessions_list *__sessions_list = NULL;
|
||||||
|
|
||||||
|
// NOTE: commented printf's here would be nice to have debug logs if I ever implement it
|
||||||
static enum session_type session_type;
|
static enum session_type session_type;
|
||||||
static int fn(const char *fpath, const struct stat *sb, int typeflag) {
|
static int fn(const char *fpath, const struct stat *sb, int typeflag) {
|
||||||
// practically impossible to reach this
|
// practically impossible to reach this
|
||||||
@ -47,12 +48,14 @@ static int fn(const char *fpath, const struct stat *sb, int typeflag) {
|
|||||||
if (used_size == 0xffff)
|
if (used_size == 0xffff)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (!S_ISREG(sb->st_mode))
|
if (sb == NULL || !S_ISREG(sb->st_mode))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
/*printf("gonna open %s\n", fpath);*/
|
||||||
FILE *fd = fopen(fpath, "r");
|
FILE *fd = fopen(fpath, "r");
|
||||||
if (fd == NULL) {
|
if (fd == NULL) {
|
||||||
fprintf(stderr, "error opening file (r) %s", fpath);
|
perror("fopen");
|
||||||
|
fprintf(stderr, "error opening file (r) %s\n", fpath);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,6 +66,7 @@ static int fn(const char *fpath, const struct stat *sb, int typeflag) {
|
|||||||
char *exec_buf = NULL;
|
char *exec_buf = NULL;
|
||||||
char *tryexec_buf = NULL;
|
char *tryexec_buf = NULL;
|
||||||
while (true) {
|
while (true) {
|
||||||
|
/*printf(".");*/
|
||||||
char *buf = malloc(sb->st_blksize);
|
char *buf = malloc(sb->st_blksize);
|
||||||
ssize_t read_size = getline(&buf, &alloc_size, fd);
|
ssize_t read_size = getline(&buf, &alloc_size, fd);
|
||||||
if (read_size == -1) {
|
if (read_size == -1) {
|
||||||
@ -91,11 +95,13 @@ static int fn(const char *fpath, const struct stat *sb, int typeflag) {
|
|||||||
if (found == 0b111)
|
if (found == 0b111)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
/*printf("\nend parsing...\n");*/
|
||||||
|
|
||||||
fclose(fd);
|
fclose(fd);
|
||||||
|
|
||||||
// just add this to the list
|
// just add this to the list
|
||||||
if (name_buf != NULL && exec_buf != NULL) {
|
if (name_buf != NULL && exec_buf != NULL) {
|
||||||
|
/*printf("gonna add to session list\n");*/
|
||||||
if (used_size >= alloc_size) {
|
if (used_size >= alloc_size) {
|
||||||
alloc_size += bs;
|
alloc_size += bs;
|
||||||
sessions = realloc(sessions, alloc_size * unit_size);
|
sessions = realloc(sessions, alloc_size * unit_size);
|
||||||
@ -128,6 +134,7 @@ struct sessions_list *get_avaliable_sessions() {
|
|||||||
|
|
||||||
for (uint i = 0; i < sources_size; i++) {
|
for (uint i = 0; i < sources_size; i++) {
|
||||||
session_type = sources[i].type;
|
session_type = sources[i].type;
|
||||||
|
/*printf("recurring into %s\n", sources[i].dir);*/
|
||||||
ftw(sources[i].dir, &fn, 1);
|
ftw(sources[i].dir, &fn, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
src/ui.c
@ -569,7 +569,7 @@ void print_errno(const char *descr) {
|
|||||||
origin.x, theme.colors.err, errno, strerror(errno));
|
origin.x, theme.colors.err, errno, strerror(errno));
|
||||||
else {
|
else {
|
||||||
fprintf(stderr, "\x1b[%d;%dH\x1b[%sm%s(%d): %s", origin.y - 1, origin.x,
|
fprintf(stderr, "\x1b[%d;%dH\x1b[%sm%s(%d): %s", origin.y - 1, origin.x,
|
||||||
descr, theme.colors.err, errno, strerror(errno));
|
theme.colors.err, descr, errno, strerror(errno));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
29
themes/README.md
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
# Themes
|
||||||
|
|
||||||
|
## cherry.ini
|
||||||
|

|
||||||
|
|
||||||
|
## default.ini
|
||||||
|

|
||||||
|
|
||||||
|
## nature.ini
|
||||||
|

|
||||||
|
|
||||||
|
## nord.ini
|
||||||
|

|
||||||
|
|
||||||
|
## old-blue.ini
|
||||||
|

|
||||||
|
|
||||||
|
## old-blue-thick.ini
|
||||||
|

|
||||||
|
|
||||||
|
## pure-tastelessness.ini
|
||||||
|

|
||||||
|
|
||||||
|
## tasteless.ini
|
||||||
|

|
||||||
|
|
||||||
|
## tastelessness.ini
|
||||||
|

|
||||||
|
|
BIN
themes/screenshots/cherry.png
Normal file
After Width: | Height: | Size: 261 KiB |
BIN
themes/screenshots/default.png
Normal file
After Width: | Height: | Size: 267 KiB |
BIN
themes/screenshots/nature.png
Normal file
After Width: | Height: | Size: 262 KiB |
BIN
themes/screenshots/nord.png
Normal file
After Width: | Height: | Size: 262 KiB |
BIN
themes/screenshots/old-blue-thick.png
Normal file
After Width: | Height: | Size: 273 KiB |
BIN
themes/screenshots/old-blue.png
Normal file
After Width: | Height: | Size: 267 KiB |
BIN
themes/screenshots/pure-tastelessness.png
Normal file
After Width: | Height: | Size: 333 KiB |
BIN
themes/screenshots/tasteless.png
Normal file
After Width: | Height: | Size: 344 KiB |
BIN
themes/screenshots/tastelessness.png
Normal file
After Width: | Height: | Size: 347 KiB |