Skip to content

Commit 8c6b0a9

Browse files
author
Paul C
committed
v16.2.1: fix login on yescrypt systems with static binary
The prebuilt musl binary cannot dlopen libcrypt.so, so the pure-Rust fallback is used. Added yescrypt ($y$) support to the fallback path, fixing login on Arch, CachyOS, Fedora 35+, and other modern distros.
1 parent cdc08a2 commit 8c6b0a9

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "wolfstack"
3-
version = "16.2.0"
3+
version = "16.2.1"
44
edition = "2024"
55
authors = ["Wolf Software Systems Ltd"]
66
description = "Server management platform for the Wolf software suite"
@@ -59,6 +59,7 @@ base64 = "0.22"
5959
urlencoding = "2"
6060
rand = "0.8"
6161
sha-crypt = "0.5"
62+
yescrypt = { version = "0.1.0-rc.5", features = ["password-hash"] }
6263
lettre = { version = "0.11", features = ["tokio1-rustls-tls", "smtp-transport", "builder"], default-features = false }
6364

6465
# S3 client (pure Rust — works on IBM Power/ppc64le, no C/C++ deps)

src/auth/mod.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,15 +204,19 @@ pub fn authenticate_user(username: &str, password: &str) -> bool {
204204
}
205205

206206
/// Verify a password against a stored hash.
207-
/// Uses native C crypt() via dlopen for yescrypt ($y$) and any other format,
208-
/// with pure-Rust fallback for $5$ and $6$ if libcrypt is unavailable.
207+
/// Uses native C crypt() via dlopen when available, with pure-Rust fallback
208+
/// for yescrypt ($y$), SHA-512 ($6$), and SHA-256 ($5$).
209209
fn verify_password(password: &str, stored_hash: &str) -> bool {
210-
// Try native C crypt() first — handles all formats including yescrypt
210+
// Try native C crypt() first — handles all formats
211211
if let Some(result) = native_crypt(password, stored_hash) {
212212
return result == stored_hash;
213213
}
214-
// Fallback: pure Rust for SHA-256/SHA-512 (works on systems without libcrypt)
215-
if stored_hash.starts_with("$6$") {
214+
// Fallback: pure Rust (needed for statically-linked / musl builds)
215+
if stored_hash.starts_with("$y$") {
216+
use yescrypt::Yescrypt;
217+
use yescrypt::password_hash::PasswordVerifier;
218+
return Yescrypt::default().verify_password(password.as_bytes(), stored_hash).is_ok();
219+
} else if stored_hash.starts_with("$6$") {
216220
sha_crypt::sha512_check(password, stored_hash).is_ok()
217221
} else if stored_hash.starts_with("$5$") {
218222
sha_crypt::sha256_check(password, stored_hash).is_ok()

0 commit comments

Comments
 (0)