diff --git a/CLAUDE.md b/CLAUDE.md index 6cff80b..46db442 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -40,11 +40,11 @@ LD_PRELOAD=/usr/lib/libgtk4-layer-shell.so ./target/release/moonlock - `auth.rs` — PAM-Authentifizierung via Raw FFI (unsafe extern "C" conv callback, msg_style-aware, Zeroizing>) - `fingerprint.rs` — fprintd D-Bus Listener (Rc>, self-wiring g-signal via connect_local) - `users.rs` — Aktuellen User via nix getuid, Avatar-Loading mit Symlink-Rejection -- `power.rs` — Reboot/Shutdown via /usr/bin/loginctl +- `power.rs` — Reboot/Shutdown via /usr/bin/systemctl - `i18n.rs` — Locale-Erkennung und String-Tabellen (DE/EN), faillock_warning mit konfigurierbarem max_attempts - `config.rs` — TOML-Config (background_path, fingerprint_enabled als Option) + Wallpaper-Fallback - `lockscreen.rs` — GTK4 UI, PAM-Auth via gio::spawn_blocking, Fingerprint-Indikator, Zeroizing für Passwort, Power-Confirm -- `main.rs` — Entry Point, Panic-Hook, Root-Check, ext-session-lock-v1 (Pflicht in Release), Multi-Monitor +- `main.rs` — Entry Point, Panic-Hook, Root-Check, ext-session-lock-v1 (Pflicht in Release), Multi-Monitor, systemd-Journal-Logging ## Sicherheit diff --git a/Cargo.lock b/Cargo.lock index 2284076..2179842 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,65 +2,6 @@ # It is not intended for manual editing. version = 4 -[[package]] -name = "aho-corasick" -version = "1.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301" -dependencies = [ - "memchr", -] - -[[package]] -name = "anstream" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "824a212faf96e9acacdbd09febd34438f8f711fb84e09a8916013cd7815ca28d" -dependencies = [ - "anstyle", - "anstyle-parse", - "anstyle-query", - "anstyle-wincon", - "colorchoice", - "is_terminal_polyfill", - "utf8parse", -] - -[[package]] -name = "anstyle" -version = "1.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "940b3a0ca603d1eade50a4846a2afffd5ef57a9feac2c0e2ec2e14f9ead76000" - -[[package]] -name = "anstyle-parse" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52ce7f38b242319f7cabaa6813055467063ecdc9d355bbb4ce0c68908cd8130e" -dependencies = [ - "utf8parse", -] - -[[package]] -name = "anstyle-query" -version = "1.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc" -dependencies = [ - "windows-sys", -] - -[[package]] -name = "anstyle-wincon" -version = "3.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d" -dependencies = [ - "anstyle", - "once_cell_polyfill", - "windows-sys", -] - [[package]] name = "anyhow" version = "1.0.102" @@ -124,35 +65,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" -[[package]] -name = "colorchoice" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d07550c9036bf2ae0c684c4297d503f838287c83c53686d05370d0e139ae570" - -[[package]] -name = "env_filter" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32e90c2accc4b07a8456ea0debdc2e7587bdd890680d71173a15d4ae604f6eef" -dependencies = [ - "log", - "regex", -] - -[[package]] -name = "env_logger" -version = "0.11.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0621c04f2196ac3f488dd583365b9c09be011a4ab8b9f37248ffcc8f6198b56a" -dependencies = [ - "anstream", - "anstyle", - "env_filter", - "jiff", - "log", -] - [[package]] name = "equivalent" version = "1.0.2" @@ -610,42 +522,12 @@ dependencies = [ "serde_core", ] -[[package]] -name = "is_terminal_polyfill" -version = "1.70.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695" - [[package]] name = "itoa" version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" -[[package]] -name = "jiff" -version = "0.2.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a3546dc96b6d42c5f24902af9e2538e82e39ad350b0c766eb3fbf2d8f3d8359" -dependencies = [ - "jiff-static", - "log", - "portable-atomic", - "portable-atomic-util", - "serde_core", -] - -[[package]] -name = "jiff-static" -version = "0.2.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a8c8b344124222efd714b73bb41f8b5120b27a7cc1c75593a6ff768d9d05aa4" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "khronos_api" version = "3.1.0" @@ -693,9 +575,8 @@ dependencies = [ [[package]] name = "moonlock" -version = "0.4.1" +version = "0.4.2" dependencies = [ - "env_logger", "gdk-pixbuf", "gdk4", "gio", @@ -707,6 +588,7 @@ dependencies = [ "log", "nix", "serde", + "systemd-journal-logger", "tempfile", "toml 0.8.23", "zeroize", @@ -730,12 +612,6 @@ version = "1.21.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" -[[package]] -name = "once_cell_polyfill" -version = "1.70.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" - [[package]] name = "pango" version = "0.22.0" @@ -772,21 +648,6 @@ version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" -[[package]] -name = "portable-atomic" -version = "1.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c33a9471896f1c69cecef8d20cbe2f7accd12527ce60845ff44c153bb2a21b49" - -[[package]] -name = "portable-atomic-util" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "091397be61a01d4be58e7841595bd4bfedb15f1cd54977d79b8271e94ed799a3" -dependencies = [ - "portable-atomic", -] - [[package]] name = "prettyplease" version = "0.2.37" @@ -830,35 +691,6 @@ version = "6.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" -[[package]] -name = "regex" -version = "1.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e10754a14b9137dd7b1e3e5b0493cc9171fdd105e0ab477f51b72e7f3ac0e276" -dependencies = [ - "aho-corasick", - "memchr", - "regex-automata", - "regex-syntax", -] - -[[package]] -name = "regex-automata" -version = "0.4.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e1dd4122fc1595e8162618945476892eefca7b88c52820e74af6262213cae8f" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", -] - -[[package]] -name = "regex-syntax" -version = "0.8.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc897dd8d9e8bd1ed8cdad82b5966c3e0ecae09fb1907d58efaa013543185d0a" - [[package]] name = "rustc_version" version = "0.4.1" @@ -984,6 +816,16 @@ dependencies = [ "version-compare", ] +[[package]] +name = "systemd-journal-logger" +version = "2.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7266304d24ca5a4b230545fc558c80e18bd3e1d2eb1be149b6bcd04398d3e79c" +dependencies = [ + "log", + "rustix", +] + [[package]] name = "target-lexicon" version = "0.13.3" @@ -1116,12 +958,6 @@ version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" -[[package]] -name = "utf8parse" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" - [[package]] name = "version-compare" version = "0.2.1" diff --git a/Cargo.toml b/Cargo.toml index be9134e..525bafe 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "moonlock" -version = "0.4.1" +version = "0.4.2" edition = "2024" description = "A secure Wayland lockscreen with GTK4, PAM and fingerprint support" license = "MIT" @@ -18,7 +18,7 @@ nix = { version = "0.29", features = ["user"] } zeroize = { version = "1", features = ["derive"] } libc = "0.2" log = "0.4" -env_logger = "0.11" +systemd-journal-logger = "2.2" [dev-dependencies] tempfile = "3" diff --git a/pkg/PKGBUILD b/pkg/PKGBUILD index 943cb05..bdb9492 100644 --- a/pkg/PKGBUILD +++ b/pkg/PKGBUILD @@ -4,7 +4,7 @@ # Maintainer: Dominik Kressler pkgname=moonlock-git -pkgver=0.4.0.r0.g0000000 +pkgver=0.4.1.r1.g78bcf90 pkgrel=1 pkgdesc="A secure Wayland lockscreen with GTK4, PAM and fingerprint support" arch=('x86_64') @@ -15,6 +15,7 @@ depends=( 'gtk4-layer-shell' 'gtk-session-lock' 'pam' + 'systemd-libs' ) makedepends=( 'git' diff --git a/src/main.rs b/src/main.rs index 5fb89e2..c679fc3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -120,22 +120,11 @@ fn activate_without_lock( } fn setup_logging() { - let mut builder = env_logger::Builder::from_default_env(); - builder.filter_level(log::LevelFilter::Info); - - let log_dir = PathBuf::from("/var/cache/moonlock"); - if log_dir.is_dir() { - let log_file = log_dir.join("moonlock.log"); - if let Ok(file) = std::fs::OpenOptions::new() - .create(true) - .append(true) - .open(&log_file) - { - builder.target(env_logger::Target::Pipe(Box::new(file))); - } - } - - builder.init(); + systemd_journal_logger::JournalLog::new() + .unwrap() + .install() + .unwrap(); + log::set_max_level(log::LevelFilter::Info); } fn install_panic_hook() { diff --git a/src/power.rs b/src/power.rs index 6b50e88..fef7c0f 100644 --- a/src/power.rs +++ b/src/power.rs @@ -1,4 +1,4 @@ -// ABOUTME: Power actions — reboot and shutdown via loginctl. +// ABOUTME: Power actions — reboot and shutdown via systemctl. // ABOUTME: Wrappers around system commands for the lockscreen UI. use std::fmt; @@ -22,11 +22,10 @@ impl fmt::Display for PowerError { impl std::error::Error for PowerError {} fn run_command(action: &'static str, program: &str, args: &[&str]) -> Result<(), PowerError> { - let child = Command::new(program) + let output = Command::new(program) .args(args) - .spawn() - .map_err(|e| PowerError::CommandFailed { action, message: e.to_string() })?; - let output = child.wait_with_output() + .stderr(std::process::Stdio::piped()) + .output() .map_err(|e| PowerError::CommandFailed { action, message: e.to_string() })?; if !output.status.success() { let stderr = String::from_utf8_lossy(&output.stderr); @@ -37,8 +36,8 @@ fn run_command(action: &'static str, program: &str, args: &[&str]) -> Result<(), Ok(()) } -pub fn reboot() -> Result<(), PowerError> { run_command("reboot", "/usr/bin/systemctl", &["reboot"]) } -pub fn shutdown() -> Result<(), PowerError> { run_command("shutdown", "/usr/bin/systemctl", &["poweroff"]) } +pub fn reboot() -> Result<(), PowerError> { run_command("reboot", "/usr/bin/systemctl", &["--no-ask-password", "reboot"]) } +pub fn shutdown() -> Result<(), PowerError> { run_command("shutdown", "/usr/bin/systemctl", &["--no-ask-password", "poweroff"]) } #[cfg(test)] mod tests {