mirror of
https://github.com/javalsai/lidm.git
synced 2025-09-01 02:47:59 +02:00
Compare commits
30 Commits
Author | SHA1 | Date | |
---|---|---|---|
e2014f46a9 | |||
|
5d298ea6d8 | ||
b003909c3e
|
|||
47b212019a
|
|||
255256bb27
|
|||
874f6f98f1
|
|||
4fb2bb2d62 | |||
2c283a14fe
|
|||
f34a71195e
|
|||
e13a8ff79c
|
|||
4c7d221a17
|
|||
6d9b02e6de
|
|||
f03656f509
|
|||
9495bd5afe
|
|||
0ba5519937
|
|||
1e0ffcdf2f | |||
b8caf5b7d7
|
|||
06fa419a6c
|
|||
49e3ad528f
|
|||
d7bfa79284
|
|||
6489df2e41
|
|||
ab6703416f
|
|||
43447ca415
|
|||
2c606cda2c
|
|||
d30d5a8884
|
|||
a0b68491ba
|
|||
01ddd62852
|
|||
c586a48320
|
|||
c4a996c1e8
|
|||
9f32ce274b
|
@@ -1,2 +1,2 @@
|
|||||||
[codespell]
|
[codespell]
|
||||||
skip = ./assets/pkg/aur/*/src
|
skip = ./assets/pkg/aur/*/src,./assets/pkg/aur/*/*/objects
|
||||||
|
15
.github/workflows/check-and-build.yml
vendored
15
.github/workflows/check-and-build.yml
vendored
@@ -136,8 +136,9 @@ jobs:
|
|||||||
|
|
||||||
- uses: uraimo/run-on-arch-action@v2
|
- uses: uraimo/run-on-arch-action@v2
|
||||||
with:
|
with:
|
||||||
arch: aarch64
|
arch: none
|
||||||
distro: ubuntu22.04
|
distro: none
|
||||||
|
base_image: '--platform=linux/aarch64 ubuntu:22.04'
|
||||||
githubToken: ${{ github.token }}
|
githubToken: ${{ github.token }}
|
||||||
install: |
|
install: |
|
||||||
apt-get update && \
|
apt-get update && \
|
||||||
@@ -180,8 +181,9 @@ jobs:
|
|||||||
|
|
||||||
- uses: uraimo/run-on-arch-action@v2
|
- uses: uraimo/run-on-arch-action@v2
|
||||||
with:
|
with:
|
||||||
arch: armv7
|
arch: none
|
||||||
distro: ubuntu22.04
|
distro: none
|
||||||
|
base_image: '--platform=linux/arm/v7 ubuntu:22.04'
|
||||||
githubToken: ${{ github.token }}
|
githubToken: ${{ github.token }}
|
||||||
install: |
|
install: |
|
||||||
apt-get update && \
|
apt-get update && \
|
||||||
@@ -224,8 +226,9 @@ jobs:
|
|||||||
|
|
||||||
- uses: uraimo/run-on-arch-action@v2
|
- uses: uraimo/run-on-arch-action@v2
|
||||||
with:
|
with:
|
||||||
arch: riscv64
|
arch: none
|
||||||
distro: ubuntu22.04
|
distro: none
|
||||||
|
base_image: '--platform=linux/riscv64 riscv64/ubuntu:22.04'
|
||||||
githubToken: ${{ github.token }}
|
githubToken: ${{ github.token }}
|
||||||
install: |
|
install: |
|
||||||
apt-get update && \
|
apt-get update && \
|
||||||
|
37
.github/workflows/make-release.yml
vendored
37
.github/workflows/make-release.yml
vendored
@@ -33,7 +33,40 @@ jobs:
|
|||||||
tag: v${{ inputs.version }}
|
tag: v${{ inputs.version }}
|
||||||
commit: ${{ github.sha }}
|
commit: ${{ github.sha }}
|
||||||
artifacts: builds/lidm-*
|
artifacts: builds/lidm-*
|
||||||
artifactsErrorsFailBuild: true
|
artifactErrorsFailBuild: true
|
||||||
body: Release notes not generated yet.
|
body: Release notes not generated yet.
|
||||||
|
|
||||||
# TODO: get checksums and commit new AUR pkgbuilds
|
aur-update:
|
||||||
|
name: Update AUR pkgs
|
||||||
|
runs-on: ubuntu-24.04
|
||||||
|
container: archlinux:latest
|
||||||
|
permissions: write-all
|
||||||
|
needs: release
|
||||||
|
steps:
|
||||||
|
- run: pacman -Sy --noconfirm git github-cli base-devel pacman-contrib
|
||||||
|
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- run: |
|
||||||
|
chage -E -1 nobody
|
||||||
|
passwd -u nobody
|
||||||
|
|
||||||
|
cd "assets/pkg/aur"
|
||||||
|
chown nobody:nobody . -R
|
||||||
|
su - -s /bin/bash nobody -c "$PWD/update-pkgs.sh ${{ inputs.version }}"
|
||||||
|
su - -s /bin/bash nobody -c "$PWD/test-makepkg.sh" # This will also update -git pkgver
|
||||||
|
chown $UID:$(id -g) . -R
|
||||||
|
|
||||||
|
- run: |
|
||||||
|
BRANCH=actions/update-aur-${{ inputs.version }}
|
||||||
|
git config --global --add safe.directory $GITHUB_WORKSPACE
|
||||||
|
git config user.name "GitHub Actions"
|
||||||
|
git config user.email "actions@github.com"
|
||||||
|
git checkout -b $BRANCH
|
||||||
|
git commit -am "Update AUR pkgs to v${{ inputs.version }}"
|
||||||
|
git push -u origin $BRANCH
|
||||||
|
gh pr create --head $BRANCH \
|
||||||
|
--title "[AUR update]: Bump to ${{ inputs.version }}" \
|
||||||
|
--body "*This PR was created automatically*"
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ github.token }}
|
||||||
|
1
Makefile
1
Makefile
@@ -36,7 +36,6 @@ install: lidm
|
|||||||
install -Dm644 ./themes/default.ini ${DESTDIR}/etc/lidm.ini
|
install -Dm644 ./themes/default.ini ${DESTDIR}/etc/lidm.ini
|
||||||
install -Dm644 ./assets/man/lidm.1 ${DESTDIR}${PREFIX}/share/man/man1/
|
install -Dm644 ./assets/man/lidm.1 ${DESTDIR}${PREFIX}/share/man/man1/
|
||||||
install -Dm644 ./assets/man/lidm-config.5 ${DESTDIR}${PREFIX}/share/man/man5/
|
install -Dm644 ./assets/man/lidm-config.5 ${DESTDIR}${PREFIX}/share/man/man5/
|
||||||
gzip -f ${DESTDIR}${PREFIX}/share/man/man{1/lidm.1,5/lidm-config.5}
|
|
||||||
|
|
||||||
uninstall:
|
uninstall:
|
||||||
rm -rf ${DESTDIR}${PREFIX}/bin/lidm ${DESTDIR}/etc/lidm.ini
|
rm -rf ${DESTDIR}${PREFIX}/bin/lidm ${DESTDIR}/etc/lidm.ini
|
||||||
|
@@ -123,3 +123,9 @@ The name is just ly but changing "y" with "i", that had a reason but forgot it,
|
|||||||
* cerealexperiments\_, found a missing newline (had the guts to read the source code, crazy ik)
|
* cerealexperiments\_, found a missing newline (had the guts to read the source code, crazy ik)
|
||||||
* ChatGPT, in times of slow laptops where pages take ages to load, a single tab connected to a bunch of burning cloud GPUs feeding corporate hype is all you need to get quick answers for your questions, as long as you know how to filter AI crap ofc.
|
* ChatGPT, in times of slow laptops where pages take ages to load, a single tab connected to a bunch of burning cloud GPUs feeding corporate hype is all you need to get quick answers for your questions, as long as you know how to filter AI crap ofc.
|
||||||
* [My lack of gf](https://www.instagram.com/reel/C8sa3Gltmtq), can't imagine this project being possible if somebody actually cared about me daily.
|
* [My lack of gf](https://www.instagram.com/reel/C8sa3Gltmtq), can't imagine this project being possible if somebody actually cared about me daily.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
🌟 Finally, consider starring this repo or... 🔪
|
||||||
|
|
||||||
|

|
||||||
|
@@ -73,6 +73,12 @@ Text to display as the header for such sessions.
|
|||||||
.TP
|
.TP
|
||||||
\fBbehavior.include_defshell\fP
|
\fBbehavior.include_defshell\fP
|
||||||
"true"/"false" (invalid input defaults to false), if true, includes the user default shell as a session to launch
|
"true"/"false" (invalid input defaults to false), if true, includes the user default shell as a session to launch
|
||||||
|
.TP
|
||||||
|
\fBbehavior.source\fP
|
||||||
|
Specify paths to source on login, simple KEY=VALUE format with comments (#) or empty'ish lines, quoting or escape sequences not supported yet. It is NOT an array, but you rather assign to it multiple times.
|
||||||
|
.TP
|
||||||
|
\fBbehavior.user_source\fP
|
||||||
|
Same as \fIbehavior.source\fP but relative to user home (if present).
|
||||||
|
|
||||||
|
|
||||||
.SH "SEE ALSO"
|
.SH "SEE ALSO"
|
||||||
|
@@ -1,21 +1,20 @@
|
|||||||
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 = 0.0.2
|
pkgver = 0.2.0
|
||||||
pkgrel = 1
|
pkgrel = 1
|
||||||
url = https://github.com/javalsai/lidm
|
url = https://github.com/javalsai/lidm
|
||||||
arch = x86_64
|
arch = x86_64
|
||||||
license = GPL
|
license = GPL
|
||||||
makedepends = gzip
|
|
||||||
depends = pam
|
depends = pam
|
||||||
provides = lidm
|
provides = lidm
|
||||||
conflicts = lidm
|
conflicts = lidm
|
||||||
source = lidm::https://github.com/javalsai/lidm/releases/download/0.0.2/lidm-x86_64
|
source = lidm::https://github.com/javalsai/lidm/releases/download/v0.2.0/lidm-amd64
|
||||||
source = default-theme.ini::https://raw.githubusercontent.com/javalsai/lidm/0.0.2/themes/default.ini
|
source = default-theme.ini::https://raw.githubusercontent.com/javalsai/lidm/v0.2.0/themes/default.ini
|
||||||
source = lidm.1::https://raw.githubusercontent.com/javalsai/lidm/0.0.2/assets/man/lidm.1
|
source = lidm.1::https://raw.githubusercontent.com/javalsai/lidm/v0.2.0/assets/man/lidm.1
|
||||||
source = lidm-config.5::https://raw.githubusercontent.com/javalsai/lidm/0.0.2/assets/man/lidm-config.5
|
source = lidm-config.5::https://raw.githubusercontent.com/javalsai/lidm/v0.2.0/assets/man/lidm-config.5
|
||||||
sha256sums = b5d1dbdaa6b78da57be69ce5e2cc3366717a045de3cb316e66c1c3f36b796ee0
|
sha256sums = 65b42f4f7acd970b167fe84d1fa75450b54e01a6f0edddb9d8dd487058a20850
|
||||||
sha256sums = 27db9b0cd2da80c0c60dcb13dfad0f9d65e7dddbb7b344b859803b9ac3943cd7
|
sha256sums = 68662430a6d262b35cc54d9f0e164ed935b7f7f4497a87cc94946c558bbe8a91
|
||||||
sha256sums = SKIP
|
sha256sums = a6807a55ff72ec5a5678583156b3efd0d367f0bcb79854094132771f0cb86bce
|
||||||
sha256sums = SKIP
|
sha256sums = 3adaae60f79dff1cef2b2aba7dcea04196cd49816759ad36afb9f7331ac9c3e4
|
||||||
|
|
||||||
pkgname = lidm-bin
|
pkgname = lidm-bin
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
|
# shellcheck disable=SC2034,SC2148,SC2128,SC2154,SC2164
|
||||||
# Maintainer: javalsai <javalsai@proton.me>
|
# Maintainer: javalsai <javalsai@proton.me>
|
||||||
pkgname=lidm-bin
|
pkgname=lidm-bin
|
||||||
pkgver=0.0.2
|
pkgver=0.2.0
|
||||||
pkgrel=1
|
pkgrel=1
|
||||||
depends=('pam')
|
depends=('pam')
|
||||||
makedepends=('gzip')
|
|
||||||
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')
|
arch=('x86_64')
|
||||||
url="https://github.com/javalsai/lidm"
|
url="https://github.com/javalsai/lidm"
|
||||||
@@ -11,22 +11,19 @@ license=('GPL')
|
|||||||
provides=('lidm')
|
provides=('lidm')
|
||||||
conflicts=('lidm')
|
conflicts=('lidm')
|
||||||
source=(
|
source=(
|
||||||
"lidm::$url/releases/download/$pkgver/lidm-$arch"
|
"lidm::$url/releases/download/v$pkgver/lidm-amd64"
|
||||||
"default-theme.ini::https://raw.githubusercontent.com/javalsai/lidm/$pkgver/themes/default.ini"
|
"default-theme.ini::https://raw.githubusercontent.com/javalsai/lidm/v$pkgver/themes/default.ini"
|
||||||
"lidm.1::https://raw.githubusercontent.com/javalsai/lidm/$pkgver/assets/man/lidm.1"
|
"lidm.1::https://raw.githubusercontent.com/javalsai/lidm/v$pkgver/assets/man/lidm.1"
|
||||||
"lidm-config.5::https://raw.githubusercontent.com/javalsai/lidm/$pkgver/assets/man/lidm-config.5"
|
"lidm-config.5::https://raw.githubusercontent.com/javalsai/lidm/v$pkgver/assets/man/lidm-config.5"
|
||||||
)
|
|
||||||
sha256sums=(
|
|
||||||
'b5d1dbdaa6b78da57be69ce5e2cc3366717a045de3cb316e66c1c3f36b796ee0'
|
|
||||||
'27db9b0cd2da80c0c60dcb13dfad0f9d65e7dddbb7b344b859803b9ac3943cd7'
|
|
||||||
'SKIP'
|
|
||||||
'SKIP'
|
|
||||||
)
|
)
|
||||||
|
sha256sums=('65b42f4f7acd970b167fe84d1fa75450b54e01a6f0edddb9d8dd487058a20850'
|
||||||
|
'68662430a6d262b35cc54d9f0e164ed935b7f7f4497a87cc94946c558bbe8a91'
|
||||||
|
'a6807a55ff72ec5a5678583156b3efd0d367f0bcb79854094132771f0cb86bce'
|
||||||
|
'3adaae60f79dff1cef2b2aba7dcea04196cd49816759ad36afb9f7331ac9c3e4')
|
||||||
|
|
||||||
package() {
|
package() {
|
||||||
install -Dm755 lidm "${pkgdir}/usr/bin/lidm"
|
install -Dm755 lidm "${pkgdir}/usr/bin/lidm"
|
||||||
install -Dm644 default-theme.ini "${pkgdir}/etc/lidm.ini"
|
install -Dm644 default-theme.ini "${pkgdir}/etc/lidm.ini"
|
||||||
install -Dm644 lidm.1 "${pkgdir}/usr/share/man/man1/"
|
install -Dm644 lidm.1 "${pkgdir}/usr/share/man/man1/lidm.1"
|
||||||
install -Dm644 lidm-config.5 "${pkgdir}/usr/share/man/man5/"
|
install -Dm644 lidm-config.5 "${pkgdir}/usr/share/man/man5/lidm-config.5"
|
||||||
gzip -f "${pkgdir}"/share/man/man{1/lidm.1,5/lidm-config.5}
|
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
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 = 0.0.2.r37.gf1f9d6b
|
pkgver = 0.1.0.r0.g8071694
|
||||||
pkgrel = 1
|
pkgrel = 1
|
||||||
url = https://github.com/javalsai/lidm
|
url = https://github.com/javalsai/lidm
|
||||||
arch = any
|
arch = any
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
|
# shellcheck disable=SC2034,SC2148,SC2128,SC2154,SC2164
|
||||||
# Maintainer: javalsai <javalsai@proton.me>
|
# Maintainer: javalsai <javalsai@proton.me>
|
||||||
pkgname=lidm-git
|
pkgname=lidm-git
|
||||||
pkgver=0.0.2.r37.gf1f9d6b
|
pkgver=0.2.0.r2.g255256b
|
||||||
pkgrel=1
|
pkgrel=1
|
||||||
depends=('pam')
|
depends=('pam')
|
||||||
makedepends=('git' 'make' 'gcc')
|
makedepends=('git' 'make' 'gcc')
|
||||||
|
@@ -1,16 +1,14 @@
|
|||||||
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 = 0.0.2
|
pkgver = 0.2.0
|
||||||
pkgrel = 1
|
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
|
makedepends = gcc
|
||||||
makedepends = gzip
|
|
||||||
depends = pam
|
depends = pam
|
||||||
source = tarball.tar.gz::https://github.com/javalsai/lidm/archive/refs/tags/0.0.2.tar.gz
|
source = tarball.tar.gz::https://github.com/javalsai/lidm/archive/refs/tags/v0.2.0.tar.gz
|
||||||
sha256sums = adf2d196969f6a2df8ceeb3564e1d51cc377f0deaeca31fee0bace58a3d2df2d
|
sha256sums = 6d397cf75cafdcb95e5a2623d70f2e07bbb085a07b7c3b743caac06454ed7b16
|
||||||
|
|
||||||
pkgname = lidm
|
pkgname = lidm
|
||||||
|
@@ -1,15 +1,16 @@
|
|||||||
|
# shellcheck disable=SC2034,SC2148,SC2128,SC2154,SC2164
|
||||||
# Maintainer: javalsai <javalsai@proton.me>
|
# Maintainer: javalsai <javalsai@proton.me>
|
||||||
pkgname=lidm
|
pkgname=lidm
|
||||||
pkgver=0.0.2
|
pkgver=0.2.0
|
||||||
pkgrel=1
|
pkgrel=1
|
||||||
depends=('pam')
|
depends=('pam')
|
||||||
makedepends=('git' 'make' 'gcc' 'gzip')
|
makedepends=('git' 'gcc')
|
||||||
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)"
|
||||||
arch=('any')
|
arch=('any')
|
||||||
url="https://github.com/javalsai/lidm"
|
url="https://github.com/javalsai/lidm"
|
||||||
license=('GPL')
|
license=('GPL')
|
||||||
source=("tarball.tar.gz::https://github.com/javalsai/lidm/archive/refs/tags/$pkgver.tar.gz")
|
source=("tarball.tar.gz::https://github.com/javalsai/lidm/archive/refs/tags/v$pkgver.tar.gz")
|
||||||
sha256sums=('adf2d196969f6a2df8ceeb3564e1d51cc377f0deaeca31fee0bace58a3d2df2d')
|
sha256sums=('6d397cf75cafdcb95e5a2623d70f2e07bbb085a07b7c3b743caac06454ed7b16')
|
||||||
|
|
||||||
build() {
|
build() {
|
||||||
tar -xzf "tarball.tar.gz"
|
tar -xzf "tarball.tar.gz"
|
||||||
|
29
assets/pkg/aur/update-pkgs.sh
Executable file
29
assets/pkg/aur/update-pkgs.sh
Executable file
@@ -0,0 +1,29 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
MYSELF=$(realpath "$0")
|
||||||
|
MYDIR=$(dirname "$MYSELF")
|
||||||
|
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
printf "\x1b[1;31mERR: No version to update provided\x1b[0m\n" >&2
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
version="$1"
|
||||||
|
printf "\x1b[34mINF: Using '%s' version\x1b[0m\n" "$version"
|
||||||
|
|
||||||
|
for pkg in "$MYDIR"/lidm{,-bin}/; do
|
||||||
|
cd "$pkg"
|
||||||
|
printf "\x1b[1mEntering '%s'\x1b[0m\n" "$pkg"
|
||||||
|
sed -i "s/pkgver=.*/pkgver=$1/" PKGBUILD
|
||||||
|
sed -i "s/pkgrel=.*/pkgrel=1/" PKGBUILD
|
||||||
|
|
||||||
|
grep 'source = ' <.SRCINFO | awk -F'= |::' '{print $2}' | \
|
||||||
|
while read -r srcfile; do
|
||||||
|
printf "\x1b[31mDeleting '%s'\x1b[0m\n" "$srcfile"
|
||||||
|
rm -f "$srcfile"
|
||||||
|
done
|
||||||
|
|
||||||
|
updpkgsums
|
||||||
|
makepkg --printsrcinfo | tee .SRCINFO
|
||||||
|
echo
|
||||||
|
done
|
@@ -3,8 +3,9 @@
|
|||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
#include <sessions.h>
|
#include "config.h"
|
||||||
|
#include "sessions.h"
|
||||||
|
|
||||||
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 behavior* behavior);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -4,9 +4,8 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <keys.h>
|
#include "keys.h"
|
||||||
#include <sessions.h>
|
#include "util.h"
|
||||||
#include <users.h>
|
|
||||||
|
|
||||||
// should be ansi escape codes under \x1b[...m
|
// should be ansi escape codes under \x1b[...m
|
||||||
// if not prepared accordingly, it might break
|
// if not prepared accordingly, it might break
|
||||||
@@ -63,6 +62,8 @@ struct strings {
|
|||||||
|
|
||||||
struct behavior {
|
struct behavior {
|
||||||
bool include_defshell;
|
bool include_defshell;
|
||||||
|
struct Vector source;
|
||||||
|
struct Vector user_source;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct config {
|
struct config {
|
||||||
|
@@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
enum session_type {
|
enum session_type {
|
||||||
XORG,
|
XORG,
|
||||||
WAYLAND,
|
WAYLAND,
|
||||||
@@ -16,11 +18,6 @@ struct session {
|
|||||||
enum session_type type;
|
enum session_type type;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct sessions_list {
|
struct Vector get_avaliable_sessions();
|
||||||
u_int16_t length;
|
|
||||||
struct session *sessions;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct sessions_list *get_avaliable_sessions();
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -1,10 +1,11 @@
|
|||||||
#ifndef _UIH_
|
#ifndef _UIH_
|
||||||
#define _UIH_
|
#define _UIH_
|
||||||
|
|
||||||
#include <config.h>
|
#include "config.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
void setup(struct config);
|
void setup(struct config);
|
||||||
int load(struct users_list *, struct sessions_list *);
|
int load(struct Vector * users, struct Vector * sessions);
|
||||||
void print_err(const char *);
|
void print_err(const char *);
|
||||||
void print_errno(const char *);
|
void print_errno(const char *);
|
||||||
|
|
||||||
|
@@ -3,17 +3,14 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
struct user {
|
struct user {
|
||||||
char *shell;
|
char *shell;
|
||||||
char *username;
|
char *username;
|
||||||
char *display_name;
|
char *display_name;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct users_list {
|
struct Vector get_human_users();
|
||||||
u_int16_t length;
|
|
||||||
struct user *users;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct users_list *get_human_users();
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -1,13 +1,31 @@
|
|||||||
#ifndef _UTILH_
|
#ifndef _UTILH_
|
||||||
#define _UTILH_
|
#define _UTILH_
|
||||||
|
|
||||||
#include <keys.h>
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include "keys.h"
|
||||||
|
|
||||||
enum keys find_keyname(char *);
|
enum keys find_keyname(char *);
|
||||||
enum keys find_ansi(char *);
|
enum keys find_ansi(char *);
|
||||||
void read_press(u_char *, char *);
|
void read_press(u_char *, char *);
|
||||||
void strcln(char **dest, const char *source);
|
void strcln(char **dest, const char *source);
|
||||||
|
|
||||||
|
struct Vector {
|
||||||
|
uint32_t length;
|
||||||
|
uint32_t alloc_len;
|
||||||
|
uint16_t alloc_size;
|
||||||
|
void** pages;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Vector vec_new();
|
||||||
|
int vec_push(struct Vector*, void* item);
|
||||||
|
void vec_free(struct Vector*);
|
||||||
|
void vec_clear(struct Vector*);
|
||||||
|
void vec_reset(struct Vector*);
|
||||||
|
void* vec_pop(struct Vector*); // won't free it, nor shrink vec list space
|
||||||
|
void* vec_get(struct Vector*, size_t index);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
86
src/auth.c
86
src/auth.c
@@ -1,22 +1,25 @@
|
|||||||
#include <grp.h>
|
#include <grp.h>
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#include <security/pam_misc.h>
|
#include <security/pam_misc.h>
|
||||||
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
|
|
||||||
#include <auth.h>
|
#include "auth.h"
|
||||||
#include <sessions.h>
|
#include "config.h"
|
||||||
#include <ui.h>
|
#include "sessions.h"
|
||||||
#include <unistd.h>
|
#include "ui.h"
|
||||||
#include <util.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) {
|
||||||
struct pam_response *reply =
|
struct pam_response *reply =
|
||||||
(struct pam_response *)malloc(sizeof(struct pam_response) * num_msg);
|
(struct pam_response *)malloc(sizeof(struct pam_response) * num_msg);
|
||||||
for (int i = 0; i < num_msg; i++) {
|
for (size_t i = 0; i < num_msg; i++) {
|
||||||
reply[i].resp = NULL;
|
reply[i].resp = NULL;
|
||||||
reply[i].resp_retcode = 0;
|
reply[i].resp_retcode = 0;
|
||||||
if (msg[i]->msg_style == PAM_PROMPT_ECHO_OFF ||
|
if (msg[i]->msg_style == PAM_PROMPT_ECHO_OFF ||
|
||||||
@@ -59,7 +62,40 @@ void *shmalloc(size_t size) {
|
|||||||
-1, 0);
|
-1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void moarEnv(char *user, struct session session, struct passwd *pw) {
|
void sourceFileTry(char *file) {
|
||||||
|
FILE *file2source = fopen(file, "r");
|
||||||
|
if (file2source == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
char *line = NULL;
|
||||||
|
size_t len = 0;
|
||||||
|
ssize_t read;
|
||||||
|
|
||||||
|
while ((read = getline(&line, &len, file2source)) != -1) {
|
||||||
|
if (read == 0 || (read > 0 && *line == '#'))
|
||||||
|
continue;
|
||||||
|
if (line[read - 1] == '\n')
|
||||||
|
line[read - 1] = '\0';
|
||||||
|
|
||||||
|
/* printf("Retrieved line of length %zu:\n", read); */
|
||||||
|
/* printf("%s\n", line); */
|
||||||
|
for (size_t i = 1; i < read; i++) {
|
||||||
|
if (line[i] == '=') {
|
||||||
|
/* printf("FOUND '='!\n"); */
|
||||||
|
line[i] = '\0';
|
||||||
|
setenv(line, &line[i + 1], 1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (line)
|
||||||
|
free(line);
|
||||||
|
fclose(file2source);
|
||||||
|
}
|
||||||
|
|
||||||
|
void moarEnv(char *user, struct session session, struct passwd *pw,
|
||||||
|
struct behavior *behavior) {
|
||||||
if (chdir(pw->pw_dir) == -1)
|
if (chdir(pw->pw_dir) == -1)
|
||||||
print_errno("can't chdir to user home");
|
print_errno("can't chdir to user home");
|
||||||
|
|
||||||
@@ -81,6 +117,31 @@ void moarEnv(char *user, struct session session, struct passwd *pw) {
|
|||||||
xdg_session_type = "wayland";
|
xdg_session_type = "wayland";
|
||||||
setenv("XDG_SESSION_TYPE", xdg_session_type, true);
|
setenv("XDG_SESSION_TYPE", xdg_session_type, true);
|
||||||
|
|
||||||
|
printf("\n\n\n\n\x1b[1m");
|
||||||
|
for (size_t i = 0; i < behavior->source.length; i++) {
|
||||||
|
/* printf("DEBUG(source)!!!! %d %s\n", i, (char*)vec_get(&behavior->source,
|
||||||
|
* i)); */
|
||||||
|
sourceFileTry((char *)vec_get(&behavior->source, i));
|
||||||
|
}
|
||||||
|
/* printf("\n"); */
|
||||||
|
if (pw->pw_dir) {
|
||||||
|
uint home_len = strlen(pw->pw_dir);
|
||||||
|
for (size_t i = 0; i < behavior->user_source.length; i++) {
|
||||||
|
char *file2sourcepath = (char *)vec_get(&behavior->user_source, i);
|
||||||
|
char *newbuf =
|
||||||
|
malloc(home_len + strlen(file2sourcepath) + 2); // nullbyte and slash
|
||||||
|
if (newbuf == NULL)
|
||||||
|
continue; // can't bother
|
||||||
|
strcpy(newbuf, pw->pw_dir);
|
||||||
|
newbuf[home_len] = '/'; // assume pw_dir doesn't start with '/' :P
|
||||||
|
strcpy(&newbuf[home_len + 1], file2sourcepath);
|
||||||
|
|
||||||
|
/* printf("DEBUG(user_source)!!!! %d %s\n", i, newbuf); */
|
||||||
|
sourceFileTry(newbuf);
|
||||||
|
free(newbuf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*char *buf;*/
|
/*char *buf;*/
|
||||||
/*size_t bsize = snprintf(NULL, 0, "/run/user/%d", pw->pw_uid) + 1;*/
|
/*size_t bsize = snprintf(NULL, 0, "/run/user/%d", pw->pw_uid) + 1;*/
|
||||||
/*buf = malloc(bsize);*/
|
/*buf = malloc(bsize);*/
|
||||||
@@ -92,8 +153,8 @@ void moarEnv(char *user, struct session session, struct passwd *pw) {
|
|||||||
/*setenv("XDG_SEAT", "seat0", true);*/
|
/*setenv("XDG_SEAT", "seat0", true);*/
|
||||||
}
|
}
|
||||||
|
|
||||||
bool launch(char *user, char *passwd, struct session session,
|
bool launch(char *user, char *passwd, struct session session, void (*cb)(void),
|
||||||
void (*cb)(void)) {
|
struct behavior *behavior) {
|
||||||
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");
|
||||||
@@ -129,7 +190,7 @@ bool launch(char *user, char *passwd, struct session session,
|
|||||||
print_errno("pam_getenvlist");
|
print_errno("pam_getenvlist");
|
||||||
_exit(EXIT_FAILURE);
|
_exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
for (uint i = 0; envlist[i] != NULL; i++) {
|
for (size_t i = 0; envlist[i] != NULL; i++) {
|
||||||
putenv(envlist[i]);
|
putenv(envlist[i]);
|
||||||
}
|
}
|
||||||
// FIXME: path hotfix
|
// FIXME: path hotfix
|
||||||
@@ -140,7 +201,7 @@ bool launch(char *user, char *passwd, struct session session,
|
|||||||
}
|
}
|
||||||
|
|
||||||
free(envlist);
|
free(envlist);
|
||||||
moarEnv(user, session, pw);
|
moarEnv(user, session, pw, behavior);
|
||||||
|
|
||||||
// TODO: chown stdin to user
|
// TODO: chown stdin to user
|
||||||
// does it inherit stdin from parent and
|
// does it inherit stdin from parent and
|
||||||
@@ -168,11 +229,14 @@ bool launch(char *user, char *passwd, struct session session,
|
|||||||
|
|
||||||
// TODO: these will be different due to TryExec
|
// TODO: these will be different due to TryExec
|
||||||
// and, Exec/TryExec might contain spaces as args
|
// and, Exec/TryExec might contain spaces as args
|
||||||
|
printf("\x1b[0m");
|
||||||
if (session.type == SHELL) {
|
if (session.type == SHELL) {
|
||||||
clear_screen();
|
clear_screen();
|
||||||
|
fflush(stdout);
|
||||||
execlp(session.exec, session.exec, NULL);
|
execlp(session.exec, session.exec, NULL);
|
||||||
} else if (session.type == XORG || session.type == WAYLAND) {
|
} else if (session.type == XORG || session.type == WAYLAND) {
|
||||||
clear_screen();
|
clear_screen();
|
||||||
|
fflush(stdout);
|
||||||
execlp(session.exec, session.exec, NULL);
|
execlp(session.exec, session.exec, NULL);
|
||||||
}
|
}
|
||||||
perror("execl error");
|
perror("execl error");
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <chvt.h>
|
#include "chvt.h"
|
||||||
|
|
||||||
static char *vterms[] = {"/dev/tty", "/dev/tty0", "/dev/vc/0", "/dev/systty",
|
static char *vterms[] = {"/dev/tty", "/dev/tty0", "/dev/vc/0", "/dev/systty",
|
||||||
"/dev/console"};
|
"/dev/console"};
|
||||||
@@ -26,7 +26,7 @@ int chvt_str(char *str) {
|
|||||||
int chvt(int n) {
|
int chvt(int n) {
|
||||||
fprintf(stderr, "activating vt %d\n", n);
|
fprintf(stderr, "activating vt %d\n", n);
|
||||||
char c = 0;
|
char c = 0;
|
||||||
for (int i = 0; i < sizeof(vterms) / sizeof(vterms[0]); i++) {
|
for (size_t i = 0; i < sizeof(vterms) / sizeof(vterms[0]); i++) {
|
||||||
int fd = open(vterms[i], O_RDWR);
|
int fd = open(vterms[i], O_RDWR);
|
||||||
if (fd >= 0 && isatty(fd) && ioctl(fd, KDGKBTYPE, &c) == 0 && c < 3) {
|
if (fd >= 0 && isatty(fd) && ioctl(fd, KDGKBTYPE, &c) == 0 && c < 3) {
|
||||||
if (ioctl(fd, VT_ACTIVATE, n) < 0 || ioctl(fd, VT_WAITACTIVE, n) < 0) {
|
if (ioctl(fd, VT_ACTIVATE, n) < 0 || ioctl(fd, VT_WAITACTIVE, n) < 0) {
|
||||||
|
11
src/config.c
11
src/config.c
@@ -1,8 +1,8 @@
|
|||||||
#include "util.h"
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#include <config.h>
|
#include "config.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
bool line_parser(FILE *fd, ssize_t *blksize,
|
bool line_parser(FILE *fd, ssize_t *blksize,
|
||||||
u_char (*cb)(char *key, char *value)) {
|
u_char (*cb)(char *key, char *value)) {
|
||||||
@@ -109,6 +109,10 @@ u_char config_line_handler(char *k, char *v) {
|
|||||||
__config->strings.s_shell = v;
|
__config->strings.s_shell = v;
|
||||||
else if (strcmp(k, "behavior.include_defshell") == 0)
|
else if (strcmp(k, "behavior.include_defshell") == 0)
|
||||||
__config->behavior.include_defshell = strcmp(v, "true") == 0;
|
__config->behavior.include_defshell = strcmp(v, "true") == 0;
|
||||||
|
else if (strcmp(k, "behavior.source") == 0)
|
||||||
|
vec_push(&__config->behavior.source, v);
|
||||||
|
else if (strcmp(k, "behavior.user_source") == 0)
|
||||||
|
vec_push(&__config->behavior.user_source, v);
|
||||||
else
|
else
|
||||||
return 0b1111;
|
return 0b1111;
|
||||||
|
|
||||||
@@ -124,6 +128,9 @@ struct config *parse_config(char *path) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
__config = malloc(sizeof(struct config));
|
__config = malloc(sizeof(struct config));
|
||||||
|
__config->behavior.source = vec_new();
|
||||||
|
__config->behavior.user_source = vec_new();
|
||||||
|
|
||||||
if (__config == NULL)
|
if (__config == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
bool ret = line_parser(fd, (ssize_t *)&sb.st_blksize, config_line_handler);
|
bool ret = line_parser(fd, (ssize_t *)&sb.st_blksize, config_line_handler);
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <efield.h>
|
#include "efield.h"
|
||||||
#include <ui.h>
|
#include "ui.h"
|
||||||
|
|
||||||
struct editable_field field_new(char *content) {
|
struct editable_field field_new(char *content) {
|
||||||
struct editable_field __efield;
|
struct editable_field __efield;
|
||||||
|
17
src/main.c
17
src/main.c
@@ -4,11 +4,12 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <chvt.h>
|
#include "chvt.h"
|
||||||
#include <config.h>
|
#include "config.h"
|
||||||
#include <sessions.h>
|
#include "sessions.h"
|
||||||
#include <ui.h>
|
#include "ui.h"
|
||||||
#include <users.h>
|
#include "users.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
if (argc == 2)
|
if (argc == 2)
|
||||||
@@ -23,10 +24,10 @@ int main(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
setup(*config);
|
setup(*config);
|
||||||
|
|
||||||
struct users_list *users = get_human_users();
|
struct Vector users = get_human_users();
|
||||||
struct sessions_list *sessions = get_avaliable_sessions();
|
struct Vector sessions = get_avaliable_sessions();
|
||||||
|
|
||||||
int ret = load(users, sessions);
|
int ret = load(&users, &sessions);
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
execl(argv[0], argv[0], NULL);
|
execl(argv[0], argv[0], NULL);
|
||||||
}
|
}
|
||||||
|
@@ -7,8 +7,8 @@
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include <sessions.h>
|
#include "sessions.h"
|
||||||
#include <util.h>
|
#include "util.h"
|
||||||
|
|
||||||
struct source_dir {
|
struct source_dir {
|
||||||
enum session_type type;
|
enum session_type type;
|
||||||
@@ -18,7 +18,6 @@ static const struct source_dir sources[] = {
|
|||||||
{XORG, "/usr/share/xsessions"},
|
{XORG, "/usr/share/xsessions"},
|
||||||
{WAYLAND, "/usr/share/wayland-sessions"},
|
{WAYLAND, "/usr/share/wayland-sessions"},
|
||||||
};
|
};
|
||||||
static const size_t sources_size = sizeof(sources) / sizeof(sources[0]);
|
|
||||||
|
|
||||||
static struct session __new_session(enum session_type type, char *name,
|
static struct session __new_session(enum session_type type, char *name,
|
||||||
const char *exec, const char *tryexec) {
|
const char *exec, const char *tryexec) {
|
||||||
@@ -31,24 +30,12 @@ static struct session __new_session(enum session_type type, char *name,
|
|||||||
return __session;
|
return __session;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const u_int8_t bs = 16;
|
static struct Vector *cb_sessions = NULL;
|
||||||
static const u_int8_t unit_size = sizeof(struct session);
|
|
||||||
|
|
||||||
static u_int16_t alloc_size = bs;
|
|
||||||
static u_int16_t used_size = 0;
|
|
||||||
|
|
||||||
static struct session *sessions = NULL;
|
|
||||||
static struct sessions_list *__sessions_list = NULL;
|
|
||||||
|
|
||||||
// NOTE: commented printf's here would be nice to have debug logs if I ever
|
// NOTE: commented printf's here would be nice to have debug logs if I ever
|
||||||
// implement it
|
// 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
|
|
||||||
// but will prevent break
|
|
||||||
if (used_size == 0xffff)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (sb == NULL || !S_ISREG(sb->st_mode))
|
if (sb == NULL || !S_ISREG(sb->st_mode))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@@ -56,7 +43,7 @@ static int fn(const char *fpath, const struct stat *sb, int typeflag) {
|
|||||||
FILE *fd = fopen(fpath, "r");
|
FILE *fd = fopen(fpath, "r");
|
||||||
if (fd == NULL) {
|
if (fd == NULL) {
|
||||||
perror("fopen");
|
perror("fopen");
|
||||||
fprintf(stderr, "error opening file (r) %s\n", fpath);
|
fprintf(stderr, "error opening file (r) '%s'\n", fpath);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,8 +53,8 @@ static int fn(const char *fpath, const struct stat *sb, int typeflag) {
|
|||||||
char *name_buf = NULL;
|
char *name_buf = NULL;
|
||||||
char *exec_buf = NULL;
|
char *exec_buf = NULL;
|
||||||
char *tryexec_buf = NULL;
|
char *tryexec_buf = NULL;
|
||||||
|
// This should be made a specific function
|
||||||
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) {
|
||||||
@@ -102,17 +89,10 @@ static int fn(const char *fpath, const struct stat *sb, int typeflag) {
|
|||||||
|
|
||||||
// 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");*/
|
struct session *session_i = malloc(sizeof (struct session));
|
||||||
if (used_size >= alloc_size) {
|
*session_i = __new_session(session_type, name_buf, exec_buf,
|
||||||
alloc_size += bs;
|
tryexec_buf == NULL ? "" : tryexec_buf);
|
||||||
sessions = realloc(sessions, alloc_size * unit_size);
|
vec_push(cb_sessions, session_i);
|
||||||
}
|
|
||||||
|
|
||||||
/*printf("n %s\ne %s\nte %s\n", name_buf, exec_buf, tryexec_buf);*/
|
|
||||||
sessions[used_size] = __new_session(session_type, name_buf, exec_buf,
|
|
||||||
tryexec_buf == NULL ? "" : tryexec_buf);
|
|
||||||
|
|
||||||
used_size++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (name_buf != NULL)
|
if (name_buf != NULL)
|
||||||
@@ -125,23 +105,17 @@ static int fn(const char *fpath, const struct stat *sb, int typeflag) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct sessions_list __list;
|
|
||||||
// This code is designed to be run purely single threaded
|
// This code is designed to be run purely single threaded
|
||||||
struct sessions_list *get_avaliable_sessions() {
|
struct Vector get_avaliable_sessions() {
|
||||||
if (sessions != NULL)
|
struct Vector sessions = vec_new();
|
||||||
return __sessions_list;
|
|
||||||
else
|
|
||||||
sessions = malloc(alloc_size * unit_size);
|
|
||||||
|
|
||||||
for (uint i = 0; i < sources_size; i++) {
|
cb_sessions = &sessions;
|
||||||
session_type = sources[i].type;
|
for (size_t i = 0; i < (sizeof(sources) / sizeof(sources[0])); i++) {
|
||||||
/*printf("recurring into %s\n", sources[i].dir);*/
|
/*printf("recurring into %s\n", sources[i].dir);*/
|
||||||
|
session_type = sources[i].type;
|
||||||
ftw(sources[i].dir, &fn, 1);
|
ftw(sources[i].dir, &fn, 1);
|
||||||
}
|
}
|
||||||
|
cb_sessions = NULL;
|
||||||
|
|
||||||
sessions = realloc(sessions, used_size * unit_size);
|
return sessions;
|
||||||
|
|
||||||
__list.length = used_size;
|
|
||||||
__list.sessions = sessions;
|
|
||||||
return __sessions_list = &__list;
|
|
||||||
}
|
}
|
||||||
|
32
src/ui.c
32
src/ui.c
@@ -10,17 +10,19 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <sys/reboot.h>
|
#include <sys/reboot.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <auth.h>
|
#include "auth.h"
|
||||||
#include <efield.h>
|
#include "efield.h"
|
||||||
#include <keys.h>
|
#include "keys.h"
|
||||||
#include <sessions.h>
|
#include "sessions.h"
|
||||||
#include <ui.h>
|
#include "ui.h"
|
||||||
#include <util.h>
|
#include "users.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
static void print_box();
|
static void print_box();
|
||||||
static void print_footer();
|
static void print_footer();
|
||||||
@@ -179,8 +181,8 @@ struct opt_field of_session;
|
|||||||
struct opt_field of_user;
|
struct opt_field of_user;
|
||||||
struct opt_field of_passwd;
|
struct opt_field of_passwd;
|
||||||
|
|
||||||
struct users_list *gusers;
|
struct Vector *gusers;
|
||||||
struct sessions_list *gsessions;
|
struct Vector *gsessions;
|
||||||
|
|
||||||
// not *that* OF tho
|
// not *that* OF tho
|
||||||
struct opt_field *get_of(enum input from) {
|
struct opt_field *get_of(enum input from) {
|
||||||
@@ -217,7 +219,7 @@ void ffield_cursor_focus() {
|
|||||||
|
|
||||||
struct user get_current_user() {
|
struct user get_current_user() {
|
||||||
if (of_user.current_opt != 0)
|
if (of_user.current_opt != 0)
|
||||||
return gusers->users[of_user.current_opt - 1];
|
return *(struct user*)vec_get(gusers, of_user.current_opt - 1);
|
||||||
else {
|
else {
|
||||||
struct user custom_user;
|
struct user custom_user;
|
||||||
custom_user.shell = "/usr/bin/bash";
|
custom_user.shell = "/usr/bin/bash";
|
||||||
@@ -237,7 +239,7 @@ struct session get_current_session() {
|
|||||||
shell_session.exec = shell_session.name = get_current_user().shell;
|
shell_session.exec = shell_session.name = get_current_user().shell;
|
||||||
return shell_session;
|
return shell_session;
|
||||||
} else
|
} else
|
||||||
return gsessions->sessions[of_session.current_opt - 1];
|
return *(struct session*)vec_get(gsessions, of_session.current_opt - 1);
|
||||||
} else {
|
} else {
|
||||||
struct session custom_session;
|
struct session custom_session;
|
||||||
custom_session.type = SHELL;
|
custom_session.type = SHELL;
|
||||||
@@ -320,7 +322,7 @@ void ffield_type(char *text) {
|
|||||||
print_ffield();
|
print_ffield();
|
||||||
}
|
}
|
||||||
|
|
||||||
int load(struct users_list *users, struct sessions_list *sessions) {
|
int load(struct Vector *users, struct Vector *sessions) {
|
||||||
/// SETUP
|
/// SETUP
|
||||||
gusers = users;
|
gusers = users;
|
||||||
gsessions = sessions;
|
gsessions = sessions;
|
||||||
@@ -394,7 +396,7 @@ int load(struct users_list *users, struct sessions_list *sessions) {
|
|||||||
} else {
|
} else {
|
||||||
if (len == 1 && *seq == '\n') {
|
if (len == 1 && *seq == '\n') {
|
||||||
if (!launch(get_current_user().username, of_passwd.efield.content,
|
if (!launch(get_current_user().username, of_passwd.efield.content,
|
||||||
get_current_session(), &restore_all)) {
|
get_current_session(), &restore_all, &behavior)) {
|
||||||
print_passwd(box_start(), of_passwd.efield.length, true);
|
print_passwd(box_start(), of_passwd.efield.length, true);
|
||||||
ffield_cursor_focus();
|
ffield_cursor_focus();
|
||||||
}
|
}
|
||||||
@@ -498,15 +500,15 @@ static void print_passwd(struct uint_point origin, uint length, bool err) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void print_empty_row(uint w, uint n, char *edge1, char *edge2) {
|
static void print_empty_row(uint w, uint n, char *edge1, char *edge2) {
|
||||||
for (uint i = 0; i < n; i++) {
|
for (size_t i = 0; i < n; i++) {
|
||||||
printf("%s\x1b[%dC%s\x1b[%dD\x1b[1B", edge1, w, edge2, w + 2);
|
printf("%s\x1b[%dC%s\x1b[%dD\x1b[1B", edge1, w, edge2, w + 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void print_row(uint w, uint n, char *edge1, char *edge2, char *filler) {
|
static void print_row(uint w, uint n, char *edge1, char *edge2, char *filler) {
|
||||||
for (uint i = 0; i < n; i++) {
|
for (size_t i = 0; i < n; i++) {
|
||||||
printf("%s", edge1);
|
printf("%s", edge1);
|
||||||
for (uint i = 0; i < w; i++) {
|
for (size_t i = 0; i < w; i++) {
|
||||||
printf("%s", filler);
|
printf("%s", filler);
|
||||||
}
|
}
|
||||||
printf("%s\x1b[%dD\x1b[1B", edge2, w + 2);
|
printf("%s\x1b[%dD\x1b[1B", edge2, w + 2);
|
||||||
|
42
src/users.c
42
src/users.c
@@ -5,8 +5,8 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include <users.h>
|
#include "users.h"
|
||||||
#include <util.h>
|
#include "util.h"
|
||||||
|
|
||||||
static struct user __new_user(struct passwd *p) {
|
static struct user __new_user(struct passwd *p) {
|
||||||
struct user __user;
|
struct user __user;
|
||||||
@@ -20,43 +20,19 @@ static struct user __new_user(struct passwd *p) {
|
|||||||
return __user;
|
return __user;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const u_int8_t bs = 16;
|
|
||||||
static const u_int8_t unit_size = sizeof(struct user);
|
|
||||||
|
|
||||||
static u_int16_t alloc_size = bs;
|
|
||||||
static u_int16_t used_size = 0;
|
|
||||||
|
|
||||||
static struct user *users = NULL;
|
|
||||||
static struct users_list *__users_list = NULL;
|
|
||||||
|
|
||||||
struct users_list __list;
|
|
||||||
// This code is designed to be run purely single threaded
|
// This code is designed to be run purely single threaded
|
||||||
struct users_list *get_human_users() {
|
struct Vector get_human_users() {
|
||||||
if (users != NULL)
|
struct Vector users = vec_new();
|
||||||
return __users_list;
|
|
||||||
else
|
|
||||||
users = malloc(alloc_size * unit_size);
|
|
||||||
|
|
||||||
struct passwd *pwd;
|
struct passwd *pwd;
|
||||||
while ((pwd = getpwent()) != NULL) {
|
while ((pwd = getpwent()) != NULL) {
|
||||||
// practically impossible to reach this (== 0xffff)
|
if (!(pwd->pw_dir && strncmp(pwd->pw_dir, "/home/", 6) == 0))
|
||||||
// but will prevent break
|
|
||||||
if (used_size == 0xffff ||
|
|
||||||
!(pwd->pw_dir && strncmp(pwd->pw_dir, "/home/", 6) == 0))
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (used_size >= alloc_size) {
|
struct user *user_i = malloc(sizeof(struct user));
|
||||||
alloc_size += bs;
|
*user_i = __new_user(pwd);
|
||||||
users = realloc(users, alloc_size * unit_size);
|
vec_push(&users, user_i);
|
||||||
}
|
|
||||||
|
|
||||||
users[used_size] = __new_user(pwd);
|
|
||||||
used_size++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
users = realloc(users, used_size * unit_size);
|
return users;
|
||||||
|
|
||||||
__list.length = used_size;
|
|
||||||
__list.users = users;
|
|
||||||
return __users_list = &__list;
|
|
||||||
}
|
}
|
||||||
|
65
src/util.c
65
src/util.c
@@ -1,12 +1,13 @@
|
|||||||
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <keys.h>
|
#include "keys.h"
|
||||||
#include <ui.h>
|
#include "ui.h"
|
||||||
#include <util.h>
|
#include "util.h"
|
||||||
|
|
||||||
static int selret_magic();
|
static int selret_magic();
|
||||||
|
|
||||||
@@ -66,3 +67,61 @@ static int selret_magic() {
|
|||||||
timeout.tv_usec = 0;
|
timeout.tv_usec = 0;
|
||||||
return select(1, &set, NULL, NULL, &timeout);
|
return select(1, &set, NULL, NULL, &timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Vector shii
|
||||||
|
struct Vector vec_new() {
|
||||||
|
struct Vector vec;
|
||||||
|
vec_clear(&vec);
|
||||||
|
return vec;
|
||||||
|
}
|
||||||
|
|
||||||
|
int vec_push(struct Vector* vec, void* item) {
|
||||||
|
if (vec->length >= vec->alloc_len) {
|
||||||
|
uint32_t new_size = vec->alloc_len + vec->alloc_size;
|
||||||
|
void **new_location = realloc(vec->pages, vec->alloc_size);
|
||||||
|
if (new_location != NULL) {
|
||||||
|
vec->alloc_size = new_size;
|
||||||
|
vec->pages = new_location;
|
||||||
|
} else {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
vec->pages[vec->length] = item;
|
||||||
|
vec->length++;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void vec_free(struct Vector* vec) {
|
||||||
|
while(vec->length > 0)
|
||||||
|
free(vec->pages[--vec->length]);
|
||||||
|
|
||||||
|
vec_clear(vec);
|
||||||
|
}
|
||||||
|
|
||||||
|
void vec_clear(struct Vector* vec) {
|
||||||
|
free(vec->pages);
|
||||||
|
vec_reset(vec);
|
||||||
|
}
|
||||||
|
|
||||||
|
void vec_reset(struct Vector* vec) {
|
||||||
|
vec->length = 0;
|
||||||
|
vec->alloc_len = 0;
|
||||||
|
vec->alloc_size = 4096; // 4KiB page size?
|
||||||
|
vec->pages = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void* vec_pop(struct Vector* vec) {
|
||||||
|
if (vec->length == 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return vec->pages[--vec->length];
|
||||||
|
}
|
||||||
|
|
||||||
|
void* vec_get(struct Vector* vec, size_t index) {
|
||||||
|
if (index >= vec->length)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return vec->pages[index];
|
||||||
|
}
|
||||||
|
@@ -30,3 +30,6 @@ strings.s_wayland = wayland
|
|||||||
strings.s_xorg = xorg
|
strings.s_xorg = xorg
|
||||||
strings.s_shell = shell
|
strings.s_shell = shell
|
||||||
behavior.include_defshell = true
|
behavior.include_defshell = true
|
||||||
|
behavior.source = /etc/lidm.env
|
||||||
|
behavior.source = /etc/locale.conf
|
||||||
|
behavior.user_source = .lidm.env
|
||||||
|
@@ -30,3 +30,6 @@ strings.s_wayland = wayland
|
|||||||
strings.s_xorg = xorg
|
strings.s_xorg = xorg
|
||||||
strings.s_shell = shell
|
strings.s_shell = shell
|
||||||
behavior.include_defshell = true
|
behavior.include_defshell = true
|
||||||
|
behavior.source = /etc/lidm.env
|
||||||
|
behavior.source = /etc/locale.conf
|
||||||
|
behavior.user_source = .lidm.env
|
||||||
|
@@ -30,3 +30,6 @@ strings.s_wayland = wayland
|
|||||||
strings.s_xorg = xorg
|
strings.s_xorg = xorg
|
||||||
strings.s_shell = shell
|
strings.s_shell = shell
|
||||||
behavior.include_defshell = true
|
behavior.include_defshell = true
|
||||||
|
behavior.source = /etc/lidm.env
|
||||||
|
behavior.source = /etc/locale.conf
|
||||||
|
behavior.user_source = .lidm.env
|
||||||
|
@@ -30,3 +30,6 @@ strings.s_wayland = wayland
|
|||||||
strings.s_xorg = xorg
|
strings.s_xorg = xorg
|
||||||
strings.s_shell = shell
|
strings.s_shell = shell
|
||||||
behavior.include_defshell = true
|
behavior.include_defshell = true
|
||||||
|
behavior.source = /etc/lidm.env
|
||||||
|
behavior.source = /etc/locale.conf
|
||||||
|
behavior.user_source = .lidm.env
|
||||||
|
@@ -30,3 +30,6 @@ strings.s_wayland = wayland
|
|||||||
strings.s_xorg = xorg
|
strings.s_xorg = xorg
|
||||||
strings.s_shell = shell
|
strings.s_shell = shell
|
||||||
behavior.include_defshell = true
|
behavior.include_defshell = true
|
||||||
|
behavior.source = /etc/lidm.env
|
||||||
|
behavior.source = /etc/locale.conf
|
||||||
|
behavior.user_source = .lidm.env
|
||||||
|
@@ -30,3 +30,6 @@ strings.s_wayland = wayland
|
|||||||
strings.s_xorg = xorg
|
strings.s_xorg = xorg
|
||||||
strings.s_shell = shell
|
strings.s_shell = shell
|
||||||
behavior.include_defshell = true
|
behavior.include_defshell = true
|
||||||
|
behavior.source = /etc/lidm.env
|
||||||
|
behavior.source = /etc/locale.conf
|
||||||
|
behavior.user_source = .lidm.env
|
||||||
|
@@ -30,3 +30,6 @@ strings.s_wayland = wayland
|
|||||||
strings.s_xorg = xorg
|
strings.s_xorg = xorg
|
||||||
strings.s_shell = shell
|
strings.s_shell = shell
|
||||||
behavior.include_defshell = true
|
behavior.include_defshell = true
|
||||||
|
behavior.source = /etc/lidm.env
|
||||||
|
behavior.source = /etc/locale.conf
|
||||||
|
behavior.user_source = .lidm.env
|
||||||
|
@@ -30,3 +30,6 @@ strings.s_wayland = waywand
|
|||||||
strings.s_xorg = xworg
|
strings.s_xorg = xworg
|
||||||
strings.s_shell = swell
|
strings.s_shell = swell
|
||||||
behavior.include_defshell = true
|
behavior.include_defshell = true
|
||||||
|
behavior.source = /etc/lidm.env
|
||||||
|
behavior.source = /etc/locale.conf
|
||||||
|
behavior.user_source = .lidm.env
|
||||||
|
@@ -30,3 +30,6 @@ strings.s_wayland = wayland
|
|||||||
strings.s_xorg = xorg
|
strings.s_xorg = xorg
|
||||||
strings.s_shell = shell
|
strings.s_shell = shell
|
||||||
behavior.include_defshell = true
|
behavior.include_defshell = true
|
||||||
|
behavior.source = /etc/lidm.env
|
||||||
|
behavior.source = /etc/locale.conf
|
||||||
|
behavior.user_source = .lidm.env
|
||||||
|
Reference in New Issue
Block a user