Spiegel von
https://github.com/dani-garcia/vaultwarden.git
synchronisiert 2024-11-22 05:10:29 +01:00
check if SENDMAIL_COMMAND is valid using 'which' crate
Dieser Commit ist enthalten in:
Ursprung
b7c4316c77
Commit
8cc6dac893
3 geänderte Dateien mit 36 neuen und 20 gelöschten Zeilen
12
Cargo.lock
generiert
12
Cargo.lock
generiert
|
@ -3230,6 +3230,7 @@ dependencies = [
|
||||||
"url",
|
"url",
|
||||||
"uuid",
|
"uuid",
|
||||||
"webauthn-rs",
|
"webauthn-rs",
|
||||||
|
"which",
|
||||||
"yubico",
|
"yubico",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -3396,6 +3397,17 @@ dependencies = [
|
||||||
"untrusted",
|
"untrusted",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "which"
|
||||||
|
version = "4.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2441c784c52b289a054b7201fc93253e288f094e2f4be9058343127c4226a269"
|
||||||
|
dependencies = [
|
||||||
|
"either",
|
||||||
|
"libc",
|
||||||
|
"once_cell",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "widestring"
|
name = "widestring"
|
||||||
version = "0.5.1"
|
version = "0.5.1"
|
||||||
|
|
|
@ -151,6 +151,7 @@ semver = "1.0.16"
|
||||||
# Allow overriding the default memory allocator
|
# Allow overriding the default memory allocator
|
||||||
# Mainly used for the musl builds, since the default musl malloc is very slow
|
# Mainly used for the musl builds, since the default musl malloc is very slow
|
||||||
mimalloc = { version = "0.1.34", features = ["secure"], default-features = false, optional = true }
|
mimalloc = { version = "0.1.34", features = ["secure"], default-features = false, optional = true }
|
||||||
|
which = "4.4.0"
|
||||||
|
|
||||||
# Strip debuginfo from the release builds
|
# Strip debuginfo from the release builds
|
||||||
# Also enable thin LTO for some optimizations
|
# Also enable thin LTO for some optimizations
|
||||||
|
|
|
@ -749,31 +749,34 @@ fn validate_config(cfg: &ConfigItems) -> Result<(), Error> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if cfg.use_sendmail {
|
if cfg.use_sendmail {
|
||||||
if let Some(ref command) = cfg.sendmail_command {
|
let command = cfg.sendmail_command.as_deref().unwrap_or("sendmail");
|
||||||
let path = std::path::Path::new(&command);
|
|
||||||
|
|
||||||
if !path.is_absolute() {
|
let mut path = std::path::PathBuf::from(command);
|
||||||
err!(format!("path to sendmail command `{path:?}` is not absolute"));
|
|
||||||
|
if !path.is_absolute() {
|
||||||
|
match which::which(command) {
|
||||||
|
Ok(result) => path = result,
|
||||||
|
Err(_) => err!(format!("sendmail command {command:?} not found in $PATH")),
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
match path.metadata() {
|
match path.metadata() {
|
||||||
Err(err) if err.kind() == std::io::ErrorKind::NotFound => {
|
Err(err) if err.kind() == std::io::ErrorKind::NotFound => {
|
||||||
err!(format!("sendmail command not found at `{path:?}`"))
|
err!(format!("sendmail command not found at `{path:?}`"))
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
err!(format!("failed to access sendmail command at `{path:?}`: {err}"))
|
||||||
|
}
|
||||||
|
Ok(metadata) => {
|
||||||
|
if metadata.is_dir() {
|
||||||
|
err!(format!("sendmail command at `{path:?}` isn't a directory"));
|
||||||
}
|
}
|
||||||
Err(err) => {
|
|
||||||
err!(format!("failed to access sendmail command at `{path:?}`: {err}"))
|
|
||||||
}
|
|
||||||
Ok(metadata) => {
|
|
||||||
if metadata.is_dir() {
|
|
||||||
err!(format!("sendmail command at `{path:?}` isn't a directory"));
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
{
|
{
|
||||||
use std::os::unix::fs::PermissionsExt;
|
use std::os::unix::fs::PermissionsExt;
|
||||||
if !metadata.permissions().mode() & 0o111 != 0 {
|
if !metadata.permissions().mode() & 0o111 != 0 {
|
||||||
err!(format!("sendmail command at `{path:?}` isn't executable"));
|
err!(format!("sendmail command at `{path:?}` isn't executable"));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Laden …
In neuem Issue referenzieren