Fix boot sequence errors, enable instant Chrony online sync, and add timezone UI

- Boot sequence cleanups:
  - Scope ModemManager's musl shared-plugin LD_PRELOAD to the child daemon via
    supervise_daemon_args="--env LD_PRELOAD=..." so OpenRC helpers and plugins
    start cleanly with zero "symbol not found" errors.
  - Link XLibre fbdev_drv.so against libfbdevhw.so and libshadow.so, pin
    libxfont2 in rootfs-packages.txt, populate /usr/share/fonts/*/fonts.dir,
    provide XKeysymDB entries, create ~/.cache before dmenu_run, disable TearFree
    for ShadowFB modesetting, and avoid D-Bus autolaunch collision with
    ModemManager.
  - Enable CONFIG_SYN_COOKIES=y and disable IPMI_HANDLER in
    geminux-mt6797x.config, add /etc/sysctl.d/00-alpine.conf, drop x86
    kernel.nmi_watchdog from 99-geminux-power.conf, and disable module
    load/unload in zram-init for built-in zram.
  - Add MT6797 ALSA UCM2 DL2/DL3/UL2/UL3/UL_MONO_1 backend DAI routes in
    HiFi.conf and apply 0006-mt6797-boot-cleanups.patch (stk3310 ID 0x11,
    mt6797-fm firmware search path, mt6797_mac_wq, and pre-auth TX abort).
- Chrony immediate online time sync:
  - Enable FAST_STARTUP, configure makestep 1.0 -1 with sourcedir
    /etc/chrony/sources.d, and trigger burst/waitsync/makestep/hwclock on
    NetworkManager interface up via 30-geminux-chrony.
- Date, Time & Timezone UI:
  - Add geminux-datetime libgemui X11 utility with zoneinfo browser, live
    search, region filters, and NTP sync trigger.
  - Add doas-authorized geminux-tzctl helper with zoneinfo validation and
    update geminux-statusd to reload /etc/timezone cleanly under musl.
This commit is contained in:
Luxferre committed 2026-11-22 23:34:44 +02:00
1 parent 6aea73cbeb
commit 8843558f3b
65 files changed
+1060 -37

No files matched your search

+6 -2
View File
@@ -23,7 +23,8 @@ BINS = \
geminux-leds \
geminux-power-audit \
geminux-checkpw \
geminux-wifi-nvram
geminux-wifi-nvram \
geminux-tzctl
all: $(BINS)
@@ -57,6 +58,9 @@ geminux-power-audit: geminux-power-audit.c
geminux-checkpw: geminux-checkpw.c
$(CC) $(CFLAGS) -o $@ $<
geminux-tzctl: geminux-tzctl.c geminux-tz-valid.h
$(CC) $(CFLAGS) -o $@ geminux-tzctl.c
geminux-wifi-nvram: geminux-wifi-nvram.c geminux-wifi-nvram-core.c geminux-wifi-nvram-core.h
$(CC) $(CFLAGS) -o $@ geminux-wifi-nvram.c geminux-wifi-nvram-core.c
@@ -65,7 +69,7 @@ install: all
cp -f geminux-power-ctl geminux-statusd geminux-touchd geminux-modem-ctl \
geminux-bt-obex geminux-power-audit $(DESTDIR)$(PREFIX)/bin/
cp -f geminux-powerd geminux-ccci-daemon geminux-leds \
geminux-checkpw geminux-wifi-nvram $(DESTDIR)$(PREFIX)/sbin/
geminux-checkpw geminux-wifi-nvram geminux-tzctl $(DESTDIR)$(PREFIX)/sbin/
chmod 0755 $(DESTDIR)$(PREFIX)/bin/geminux-* $(DESTDIR)$(PREFIX)/sbin/geminux-*
clean:
+17 -3
View File
@@ -16,6 +16,7 @@
#include <time.h>
#include <unistd.h>
#include <X11/Xlib.h>
#include "geminux-tz-valid.h"
static int read_line(const char *path, char *buf, size_t sz) {
FILE *f = fopen(path, "r");
@@ -89,6 +90,14 @@ static void update_status(Display *dpy) {
else if (iface_up("ccmni0") || iface_up("ccmni1")) snprintf(net, sizeof(net), "LTE:UP");
else snprintf(net, sizeof(net), "Net:OFF");
char tz[128] = {0};
if (read_line("/etc/timezone", tz, sizeof(tz)) == 0 && geminux_tz_name_valid(tz)) {
setenv("TZ", tz, 1);
} else {
unsetenv("TZ");
}
tzset();
time_t now = time(NULL);
struct tm tm;
localtime_r(&now, &tm);
@@ -167,14 +176,18 @@ int main(void) {
if (errno == EINTR) continue;
break;
}
bool dirty = false;
bool dirty = false, realign = false;
for (int i = 0; i < n; i++) {
int fd = events[i].data.fd;
if (fd == sig_fd) {
struct signalfd_siginfo si;
while (read(sig_fd, &si, sizeof(si)) > 0) {
if (si.ssi_signo == SIGUSR1) dirty = true;
else running = false;
if (si.ssi_signo == SIGUSR1) {
dirty = true;
realign = true;
} else {
running = false;
}
}
} else {
char drain[1024];
@@ -182,6 +195,7 @@ int main(void) {
dirty = true;
}
}
if (running && realign && tmr_fd >= 0) arm_minute_timer(tmr_fd);
if (running && dirty) update_status(dpy);
}
+42
View File
@@ -0,0 +1,42 @@
#ifndef GEMINUX_TZ_VALID_H
#define GEMINUX_TZ_VALID_H
#include <fcntl.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
static inline bool geminux_tz_name_valid(const char *tz) {
size_t len;
if (!tz) return false;
len = strlen(tz);
if (len == 0 || len > 95) return false;
if (tz[0] == '/' || tz[len - 1] == '/') return false;
if (strstr(tz, "..") != NULL || strstr(tz, "//") != NULL) return false;
for (size_t i = 0; i < len; i++) {
unsigned char c = (unsigned char)tz[i];
bool ok = (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') ||
(c >= '0' && c <= '9') || c == '_' || c == '+' || c == '-' || c == '/';
if (!ok) return false;
}
return true;
}
static inline bool geminux_tz_file_valid(const char *zoneinfo_root, const char *tz) {
if (!zoneinfo_root || !zoneinfo_root[0] || !geminux_tz_name_valid(tz)) return false;
char path[512];
int n = snprintf(path, sizeof(path), "%s/%s", zoneinfo_root, tz);
if (n < 0 || (size_t)n >= sizeof(path)) return false;
struct stat st;
if (stat(path, &st) != 0 || !S_ISREG(st.st_mode)) return false;
int fd = open(path, O_RDONLY);
if (fd < 0) return false;
char hdr[4];
ssize_t r = read(fd, hdr, sizeof(hdr));
close(fd);
return r == 4 && memcmp(hdr, "TZif", 4) == 0;
}
#endif
+129
View File
@@ -0,0 +1,129 @@
#define _POSIX_C_SOURCE 200809L
#include "geminux-tz-valid.h"
#include <errno.h>
#include <fcntl.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <unistd.h>
static int run_argv(const char *const argv[], bool quiet) {
pid_t pid = fork();
if (pid < 0) return -1;
if (pid == 0) {
if (quiet) {
int devnull = open("/dev/null", O_RDWR);
if (devnull >= 0) {
dup2(devnull, STDOUT_FILENO);
dup2(devnull, STDERR_FILENO);
close(devnull);
}
}
execvp(argv[0], (char *const *)argv);
_exit(127);
}
int status = 0;
while (waitpid(pid, &status, 0) < 0) {
if (errno != EINTR) return -1;
}
if (WIFEXITED(status)) return WEXITSTATUS(status);
return 1;
}
static int write_file_atomic(const char *path, const char *content, mode_t mode) {
char tmp[512];
snprintf(tmp, sizeof(tmp), "%s.tmp", path);
int fd = open(tmp, O_WRONLY | O_CREAT | O_TRUNC, mode);
if (fd < 0) return -1;
size_t len = strlen(content);
size_t off = 0;
while (off < len) {
ssize_t w = write(fd, content + off, len - off);
if (w < 0) {
if (errno == EINTR) continue;
close(fd);
unlink(tmp);
return -1;
}
off += (size_t)w;
}
close(fd);
chmod(tmp, mode);
if (rename(tmp, path) != 0) {
unlink(tmp);
return -1;
}
return 0;
}
static int cmd_set(const char *tz) {
if (!geminux_tz_file_valid("/usr/share/zoneinfo", tz)) {
fprintf(stderr, "geminux-tzctl: invalid timezone '%s'\n", tz ? tz : "");
return 1;
}
char target[512];
snprintf(target, sizeof(target), "/usr/share/zoneinfo/%s", tz);
unlink("/etc/localtime.tmp");
if (symlink(target, "/etc/localtime.tmp") != 0 ||
rename("/etc/localtime.tmp", "/etc/localtime") != 0) {
unlink("/etc/localtime.tmp");
perror("geminux-tzctl: localtime");
return 1;
}
char line[128];
snprintf(line, sizeof(line), "%s\n", tz);
if (write_file_atomic("/etc/timezone", line, 0644) != 0) {
perror("geminux-tzctl: /etc/timezone");
return 1;
}
mkdir("/run/geminux", 0755);
write_file_atomic("/run/geminux/timezone", line, 0644);
const char *pk[] = {"pkill", "-USR1", "geminux-statusd", NULL};
run_argv(pk, true);
return 0;
}
static int cmd_sync(void) {
const char *st_argv[] = {"rc-service", "chronyd", "status", NULL};
if (run_argv(st_argv, true) != 0) {
const char *start_argv[] = {"rc-service", "chronyd", "start", NULL};
run_argv(start_argv, true);
}
const char *reload_argv[] = {"chronyc", "reload", "sources", NULL};
run_argv(reload_argv, true);
const char *online_argv[] = {"chronyc", "online", NULL};
run_argv(online_argv, true);
const char *burst_argv[] = {"chronyc", "burst", "4/4", NULL};
run_argv(burst_argv, true);
const char *wait_argv[] = {"chronyc", "waitsync", "20", "0", "0", "0.5", NULL};
int wrc = run_argv(wait_argv, true);
const char *step_argv[] = {"chronyc", "makestep", NULL};
int src = run_argv(step_argv, true);
const char *hw_argv[] = {"hwclock", "-w", "-u", NULL};
run_argv(hw_argv, true);
const char *pk[] = {"pkill", "-USR1", "geminux-statusd", NULL};
run_argv(pk, true);
return (wrc == 0 && src == 0) ? 0 : 1;
}
int main(int argc, char **argv) {
if (argc == 3 && strcmp(argv[1], "set") == 0) {
return cmd_set(argv[2]);
}
if (argc == 2 && strcmp(argv[1], "sync") == 0) {
return cmd_sync();
}
fprintf(stderr, "Usage: %s <set TIMEZONE | sync>\n", argv[0]);
return 1;
}