Merge pull request 'Fork/rename upstream identifiers' (#22) from fork/rename-upstream-identifiers into main
Reviewed-on: #22
This commit was merged in pull request #22.
This commit is contained in:
@@ -143,7 +143,9 @@ impl Scripting {
|
||||
.with_cpu_limit(trusted.max_cpu_cycles as usize)
|
||||
.with_max_nested_includes(trusted.max_nested_includes as usize)
|
||||
.with_max_received_headers(trusted.max_received_headers as usize)
|
||||
.with_default_duplicate_expiry(trusted.duplicate_expiry.into_inner().as_secs());
|
||||
.with_default_duplicate_expiry(trusted.duplicate_expiry.into_inner().as_secs())
|
||||
// inbuxa: without it, `environment "name"` answers sieve-rs's default
|
||||
.with_env_variable("name", types::brand_server!());
|
||||
trusted_runtime.set_local_hostname(local_hostname.clone());
|
||||
untrusted_runtime.set_local_hostname(local_hostname);
|
||||
|
||||
@@ -279,3 +281,23 @@ impl Clone for Scripting {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use sieve::compiler::grammar::Capability;
|
||||
|
||||
// inbuxa: sieve-rs is vendored (vendor/sieve-rs) to carry the fork's
|
||||
// name in its Sieve extensions. If Cargo.lock moves sieve-rs past the
|
||||
// vendored version, Cargo drops the patch with only a warning and
|
||||
// upstream's spelling comes back; this fails instead.
|
||||
#[test]
|
||||
fn sieve_extensions_carry_the_fork_name() {
|
||||
for (capability, name) in [
|
||||
(Capability::While, "vnd.inbuxa.while"),
|
||||
(Capability::Expressions, "vnd.inbuxa.expressions"),
|
||||
] {
|
||||
assert_eq!(capability.to_string(), name);
|
||||
assert_eq!(Capability::parse(name), capability);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -514,12 +514,12 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn index_is_rewritten_with_the_prefix_and_client_id() {
|
||||
let meta = oauth_client_id_meta("stalwart-webui");
|
||||
let meta = oauth_client_id_meta("inbuxa-webui");
|
||||
let html = String::from_utf8(rewrite_index(INDEX, "admin", Some(&meta))).unwrap();
|
||||
|
||||
assert!(html.contains("<base href=\"/admin/\" />"), "{html}");
|
||||
assert!(
|
||||
html.contains("<meta name=\"oauth-client-id\" content=\"stalwart-webui\" />"),
|
||||
html.contains("<meta name=\"oauth-client-id\" content=\"inbuxa-webui\" />"),
|
||||
"{html}"
|
||||
);
|
||||
assert!(html.contains("<title>Portal</title>"), "{html}");
|
||||
@@ -541,7 +541,7 @@ mod tests {
|
||||
#[test]
|
||||
fn index_without_a_placeholder_is_left_alone() {
|
||||
let bundle = "<head>\n <base href=\"/\" />\n</head>";
|
||||
let meta = oauth_client_id_meta("stalwart-webui");
|
||||
let meta = oauth_client_id_meta("inbuxa-webui");
|
||||
let html = String::from_utf8(rewrite_index(bundle, "admin", Some(&meta))).unwrap();
|
||||
|
||||
assert_eq!(html, "<head>\n <base href=\"/admin/\" />\n</head>");
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
//! that ship with it are registered for it, on every start:
|
||||
//!
|
||||
//! - the web interface the server serves itself (`Application`, `/admin` and
|
||||
//! `/account`), as its OAuth client id, `stalwart-webui` unless the
|
||||
//! `/account`), as its OAuth client id, `inbuxa-webui` unless the
|
||||
//! application names another;
|
||||
//! - INBUXA Admin hosted elsewhere, as `inbuxa-admin`, when `INBUXA_ADMIN_URL`
|
||||
//! is set;
|
||||
@@ -29,7 +29,7 @@ use directory::core::secret::{hash_secret, verify_secret_hash};
|
||||
use registry::{
|
||||
schema::{
|
||||
enums::{PasswordHashAlgorithm, ServiceProtocol},
|
||||
prelude::{ObjectType, Property, UTCDateTime},
|
||||
prelude::{Object, ObjectInner, ObjectType, Property, UTCDateTime},
|
||||
structs::{Application, OAuthClient, SystemSettings},
|
||||
},
|
||||
types::map::Map,
|
||||
@@ -40,9 +40,12 @@ use store::registry::{
|
||||
};
|
||||
|
||||
/// The client id the upstream web interface uses when its application names none.
|
||||
pub const WEB_INTERFACE_CLIENT_ID: &str = "stalwart-webui";
|
||||
pub const WEB_INTERFACE_CLIENT_ID: &str = "inbuxa-webui";
|
||||
pub const ADMIN_CLIENT_ID: &str = "inbuxa-admin";
|
||||
pub const WEBMAIL_CLIENT_ID: &str = "ihasmail-inbuxa";
|
||||
/// The web interface's client id before the fork renamed it (SPEC §2.4).
|
||||
/// Only ever read to retire it.
|
||||
const LEGACY_WEB_INTERFACE_CLIENT_ID: &str = "stalwart-webui";
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct FirstPartyClient {
|
||||
@@ -187,6 +190,7 @@ fn env(name: &str) -> Option<String> {
|
||||
}
|
||||
|
||||
pub(crate) async fn ensure_first_party_clients(bp: &mut Bootstrap) -> trc::Result<()> {
|
||||
retire_legacy_web_interface_client(bp).await?;
|
||||
let system = bp.setting_infallible::<SystemSettings>().await;
|
||||
let base_url = base_url(bp, &system);
|
||||
let applications = bp
|
||||
@@ -213,6 +217,56 @@ pub(crate) async fn ensure_first_party_clients(bp: &mut Bootstrap) -> trc::Resul
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// An install from before the rename, upstream's or this fork's, has the web
|
||||
/// interface registered as `stalwart-webui`, and may
|
||||
/// have an application naming it. The application is moved to the current id
|
||||
/// and the old client removed, so the old id stops working rather than
|
||||
/// living on as an alias; anyone signed in to the web interface signs in
|
||||
/// again. Runs on every start and does nothing once both are gone.
|
||||
async fn retire_legacy_web_interface_client(bp: &mut Bootstrap) -> trc::Result<()> {
|
||||
for app in bp.list_infallible::<Application>().await {
|
||||
if app.object.oauth_client_id.as_deref() != Some(LEGACY_WEB_INTERFACE_CLIENT_ID) {
|
||||
continue;
|
||||
}
|
||||
let mut updated = app.object.clone();
|
||||
updated.oauth_client_id = Some(WEB_INTERFACE_CLIENT_ID.to_string());
|
||||
// The old object carries its revision: the write asserts on it.
|
||||
let current = Object::with_revision(ObjectInner::from(app.object), app.revision);
|
||||
let result = bp
|
||||
.registry
|
||||
.write(RegistryWrite::update(app.id.id(), &updated.into(), ¤t))
|
||||
.await?;
|
||||
if !matches!(result, RegistryWriteResult::Success(_)) {
|
||||
return Err(trc::StoreEvent::UnexpectedError
|
||||
.into_err()
|
||||
.details("Failed to move an application to the renamed web interface client.")
|
||||
.reason(result.to_string())
|
||||
.caused_by(trc::location!()));
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(object_id) = bp
|
||||
.registry
|
||||
.primary_key(
|
||||
ObjectType::OAuthClient.into(),
|
||||
Property::ClientId,
|
||||
LEGACY_WEB_INTERFACE_CLIENT_ID.as_bytes().to_vec(),
|
||||
)
|
||||
.await?
|
||||
{
|
||||
let result = bp.registry.write(RegistryWrite::delete(object_id)).await?;
|
||||
if !matches!(result, RegistryWriteResult::Success(_)) {
|
||||
return Err(trc::StoreEvent::UnexpectedError
|
||||
.into_err()
|
||||
.details("Failed to remove the web interface's pre-rename OAuth client.")
|
||||
.reason(result.to_string())
|
||||
.caused_by(trc::location!()));
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn ensure_client(bp: &mut Bootstrap, client: FirstPartyClient) -> trc::Result<()> {
|
||||
let existing = match bp
|
||||
.registry
|
||||
@@ -223,15 +277,18 @@ async fn ensure_client(bp: &mut Bootstrap, client: FirstPartyClient) -> trc::Res
|
||||
)
|
||||
.await?
|
||||
{
|
||||
// inbuxa: read as an Object, keeping the revision the update below
|
||||
// asserts on (a bare OAuthClient converts back with revision 0, which
|
||||
// never matches, so any update failed start-up).
|
||||
Some(object_id) => bp
|
||||
.registry
|
||||
.object::<OAuthClient>(object_id.id())
|
||||
.get(object_id)
|
||||
.await?
|
||||
.map(|object| (object_id.id(), object)),
|
||||
.map(|object| (object_id.id(), object.revision, OAuthClient::from(object))),
|
||||
None => None,
|
||||
};
|
||||
|
||||
let result = if let Some((id, current)) = existing {
|
||||
let result = if let Some((id, revision, current)) = existing {
|
||||
let mut updated = current.clone();
|
||||
for uri in &client.redirect_uris {
|
||||
if !updated.redirect_uris.contains(uri) {
|
||||
@@ -255,8 +312,9 @@ async fn ensure_client(bp: &mut Bootstrap, client: FirstPartyClient) -> trc::Res
|
||||
if updated == current {
|
||||
return Ok(());
|
||||
}
|
||||
let current = Object::with_revision(ObjectInner::from(current), revision);
|
||||
bp.registry
|
||||
.write(RegistryWrite::update(id, &updated.into(), ¤t.into()))
|
||||
.write(RegistryWrite::update(id, &updated.into(), ¤t))
|
||||
.await?
|
||||
} else {
|
||||
let secret = match &client.secret {
|
||||
|
||||
@@ -23,8 +23,8 @@ pub mod defaults;
|
||||
pub mod first_party;
|
||||
pub mod restore;
|
||||
|
||||
pub const SPAM_TRAINER_KEY: &[u8] = "STALWART_SPAM_TRAIN_DATA.lz4".as_bytes();
|
||||
pub const SPAM_CLASSIFIER_KEY: &[u8] = "STALWART_SPAM_CLASSIFIER_MODEL.lz4".as_bytes();
|
||||
pub const SPAM_TRAINER_KEY: &[u8] = "INBUXA_SPAM_TRAIN_DATA.lz4".as_bytes();
|
||||
pub const SPAM_CLASSIFIER_KEY: &[u8] = "INBUXA_SPAM_CLASSIFIER_MODEL.lz4".as_bytes();
|
||||
|
||||
pub async fn fetch_resource(
|
||||
url: &str,
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
* SPDX-FileCopyrightText: 2020 Stalwart Labs LLC <[email protected]>
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-SEL
|
||||
*
|
||||
* Modified by Coffey Labs in 2026 for INBUXA.
|
||||
*/
|
||||
|
||||
use base64::{Engine, engine::general_purpose::URL_SAFE_NO_PAD};
|
||||
@@ -313,16 +315,16 @@ B4yDfR2rGOd2H6Kv3fQNHPj9Nu5Tks8QYMLzrX8ONCNoFnNUQl9S0r0QS6phVqD0
|
||||
#[test]
|
||||
fn contact_is_normalized_to_a_uri() {
|
||||
for (input, expected) in [
|
||||
("hello@stalw.art", Some("mailto:hello@stalw.art")),
|
||||
(" hello@stalw.art ", Some("mailto:hello@stalw.art")),
|
||||
("mailto:hello@stalw.art", Some("mailto:hello@stalw.art")),
|
||||
("MAILTO:hello@stalw.art", Some("MAILTO:hello@stalw.art")),
|
||||
("hello@example.org", Some("mailto:hello@example.org")),
|
||||
(" hello@example.org ", Some("mailto:hello@example.org")),
|
||||
("mailto:hello@example.org", Some("mailto:hello@example.org")),
|
||||
("MAILTO:hello@example.org", Some("MAILTO:hello@example.org")),
|
||||
(
|
||||
"https://stalw.art/contact",
|
||||
Some("https://stalw.art/contact"),
|
||||
"https://example.org/contact",
|
||||
Some("https://example.org/contact"),
|
||||
),
|
||||
("stalw.art", None),
|
||||
("http://stalw.art", None),
|
||||
("example.org", None),
|
||||
("http://example.org", None),
|
||||
("tel:+123456789", None),
|
||||
("", None),
|
||||
] {
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
* SPDX-FileCopyrightText: 2020 Stalwart Labs LLC <[email protected]>
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-SEL
|
||||
*
|
||||
* Modified by Coffey Labs in 2026 for INBUXA.
|
||||
*/
|
||||
|
||||
use super::ETag;
|
||||
@@ -490,7 +492,7 @@ impl LockRequestHandler for Server {
|
||||
for cond in &if_.list {
|
||||
match cond {
|
||||
Condition::StateToken { token, .. } => {
|
||||
if token.starts_with("urn:stalwart:davsync:") {
|
||||
if token.starts_with("urn:inbuxa:davsync:") {
|
||||
needs_sync_token = true;
|
||||
} else {
|
||||
needs_lock_token = true;
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
* SPDX-FileCopyrightText: 2020 Stalwart Labs LLC <[email protected]>
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-SEL
|
||||
*
|
||||
* Modified by Coffey Labs in 2026 for INBUXA.
|
||||
*/
|
||||
|
||||
use crate::{DavError, DavResourceName};
|
||||
@@ -181,12 +183,12 @@ impl OwnedUri<'_> {
|
||||
impl Urn {
|
||||
pub fn try_extract_sync_id(token: &str) -> Option<&str> {
|
||||
token
|
||||
.strip_prefix("urn:stalwart:davsync:")
|
||||
.strip_prefix("urn:inbuxa:davsync:")
|
||||
.map(|x| x.split_once(':').map(|(x, _)| x).unwrap_or(x))
|
||||
}
|
||||
|
||||
pub fn parse(input: &str) -> Option<Self> {
|
||||
let inbox = input.strip_prefix("urn:stalwart:")?;
|
||||
let inbox = input.strip_prefix("urn:inbuxa:")?;
|
||||
let (kind, id) = inbox.split_once(':')?;
|
||||
match kind {
|
||||
"davlock" => u64::from_str_radix(id, 16).ok().map(Urn::Lock),
|
||||
@@ -223,12 +225,12 @@ impl Urn {
|
||||
impl Display for Urn {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Urn::Lock(id) => write!(f, "urn:stalwart:davlock:{id:x}",),
|
||||
Urn::Lock(id) => write!(f, "urn:inbuxa:davlock:{id:x}",),
|
||||
Urn::Sync { id, seq } => {
|
||||
if *seq == 0 {
|
||||
write!(f, "urn:stalwart:davsync:{id:x}")
|
||||
write!(f, "urn:inbuxa:davsync:{id:x}")
|
||||
} else {
|
||||
write!(f, "urn:stalwart:davsync:{id:x}:{seq:x}")
|
||||
write!(f, "urn:inbuxa:davsync:{id:x}:{seq:x}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ pub enum Capability {
|
||||
FileNode = 1 << 15,
|
||||
#[serde(rename(serialize = "urn:ietf:params:jmap:mail:share"))]
|
||||
MailShare = 1 << 16,
|
||||
#[serde(rename(serialize = "urn:stalwart:jmap"))]
|
||||
#[serde(rename(serialize = "urn:inbuxa:jmap:registry"))]
|
||||
Stalwart = 1 << 17,
|
||||
#[serde(rename(serialize = "urn:ietf:params:jmap:webpush-vapid"))]
|
||||
WebPushVapid = 1 << 18,
|
||||
@@ -353,7 +353,7 @@ impl Capability {
|
||||
Capability::PrincipalsAvailability => "urn:ietf:params:jmap:principals:availability",
|
||||
Capability::FileNode => "urn:ietf:params:jmap:filenode",
|
||||
Capability::MailShare => "urn:ietf:params:jmap:mail:share",
|
||||
Capability::Stalwart => "urn:stalwart:jmap",
|
||||
Capability::Stalwart => "urn:inbuxa:jmap:registry",
|
||||
Capability::WebPushVapid => "urn:ietf:params:jmap:webpush-vapid",
|
||||
Capability::EmailPush => "urn:ietf:params:jmap:emailpush",
|
||||
Capability::Inbuxa => "urn:inbuxa:jmap",
|
||||
@@ -501,7 +501,7 @@ impl Capability {
|
||||
"urn:ietf:params:jmap:contacts:parse" => Capability::ContactsParse,
|
||||
"urn:ietf:params:jmap:calendars:parse" => Capability::CalendarsParse,
|
||||
"urn:ietf:params:jmap:mail:share" => Capability::MailShare,
|
||||
"urn:stalwart:jmap" => Capability::Stalwart,
|
||||
"urn:inbuxa:jmap:registry" => Capability::Stalwart,
|
||||
"urn:ietf:params:jmap:webpush-vapid" => Capability::WebPushVapid,
|
||||
"urn:ietf:params:jmap:emailpush" => Capability::EmailPush,
|
||||
"urn:inbuxa:jmap" => Capability::Inbuxa,
|
||||
|
||||
@@ -208,7 +208,7 @@ pub(crate) async fn bootstrap_set(
|
||||
.with_description(concat!(
|
||||
"The selected data store contains information from an older version. ",
|
||||
"Please follow the upgrade instructions at ",
|
||||
"https://github.com/stalwartlabs/stalwart/blob/main/UPGRADING/v0_16.md"
|
||||
"https://docs.inbuxa.org/install/migrating/"
|
||||
)),
|
||||
);
|
||||
break;
|
||||
@@ -679,7 +679,7 @@ fn build_default_bootstrap(server: &Server) -> Bootstrap {
|
||||
directory: DirectoryBootstrap::Internal,
|
||||
tracer: Tracer::Log(TracerLog {
|
||||
path: "/var/log/inbuxa/".to_string(),
|
||||
prefix: "stalwart".to_string(),
|
||||
prefix: "inbuxa".to_string(),
|
||||
ansi: true,
|
||||
enable: true,
|
||||
..Default::default()
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
* SPDX-FileCopyrightText: 2020 Stalwart Labs LLC <[email protected]>
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-SEL
|
||||
*
|
||||
* Modified by Coffey Labs in 2026 for INBUXA.
|
||||
*/
|
||||
|
||||
#![warn(clippy::large_futures)]
|
||||
@@ -19,6 +21,10 @@ pub mod destroy;
|
||||
pub mod v016;
|
||||
|
||||
pub async fn try_migrate(server: &Server) -> trc::Result<()> {
|
||||
// inbuxa: before the version check, which returns early on a current
|
||||
// store, and before migrate_v0_16, which reads the renamed key.
|
||||
rename_spam_blobs(server).await?;
|
||||
|
||||
match server
|
||||
.store()
|
||||
.get_value::<u32>(AnyKey {
|
||||
@@ -36,14 +42,14 @@ pub async fn try_migrate(server: &Server) -> trc::Result<()> {
|
||||
Some(0..=4) => {
|
||||
abort(concat!(
|
||||
"You must first upgrade to version 0.15, please read ",
|
||||
"https://github.com/stalwartlabs/stalwart/blob/main/UPGRADING/v0_16.md"
|
||||
"https://docs.inbuxa.org/install/migrating/"
|
||||
));
|
||||
}
|
||||
Some(5) => {
|
||||
if !server.registry().is_recovery_mode() {
|
||||
abort(concat!(
|
||||
"Upgrading to version 0.16 is a multi-step process, please read ",
|
||||
"https://github.com/stalwartlabs/stalwart/blob/main/UPGRADING/v0_16.md"
|
||||
"https://docs.inbuxa.org/install/migrating/"
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -61,7 +67,7 @@ pub async fn try_migrate(server: &Server) -> trc::Result<()> {
|
||||
} else {
|
||||
abort(concat!(
|
||||
"You must first upgrade to version 0.15, please read ",
|
||||
"https://github.com/stalwartlabs/stalwart/blob/main/UPGRADING/v0_16.md"
|
||||
"https://docs.inbuxa.org/install/migrating/"
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -134,3 +140,47 @@ async fn is_new_install(server: &Server) -> trc::Result<bool> {
|
||||
|
||||
Ok(true)
|
||||
}
|
||||
|
||||
/// inbuxa: the spam filter's trainer and model blobs, under the names they
|
||||
/// had before the fork renamed them (SPEC §2.4), paired with the current ones.
|
||||
const RENAMED_SPAM_BLOBS: [(&[u8], &[u8]); 2] = [
|
||||
(b"STALWART_SPAM_TRAIN_DATA.lz4", common::manager::SPAM_TRAINER_KEY),
|
||||
(
|
||||
b"STALWART_SPAM_CLASSIFIER_MODEL.lz4",
|
||||
common::manager::SPAM_CLASSIFIER_KEY,
|
||||
),
|
||||
];
|
||||
|
||||
/// Moves each spam blob from its pre-rename key to the current one, so a
|
||||
/// trained model survives the rename. A blob already under the current key
|
||||
/// wins and the old one is just removed; with neither, nothing happens.
|
||||
async fn rename_spam_blobs(server: &Server) -> trc::Result<()> {
|
||||
let blobs = server.blob_store();
|
||||
for (old, new) in RENAMED_SPAM_BLOBS {
|
||||
let Some(data) = blobs
|
||||
.get_blob(old, 0..usize::MAX)
|
||||
.await
|
||||
.caused_by(trc::location!())?
|
||||
else {
|
||||
continue;
|
||||
};
|
||||
if blobs
|
||||
.get_blob(new, 0..usize::MAX)
|
||||
.await
|
||||
.caused_by(trc::location!())?
|
||||
.is_none()
|
||||
{
|
||||
blobs
|
||||
.put_blob(new, &data, server.core.email.compression)
|
||||
.await
|
||||
.caused_by(trc::location!())?;
|
||||
}
|
||||
blobs.delete_blob(old).await.caused_by(trc::location!())?;
|
||||
trc::event!(
|
||||
Server(trc::ServerEvent::Startup),
|
||||
Details = "Moved a spam filter blob to its renamed key",
|
||||
Key = new,
|
||||
);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
* SPDX-FileCopyrightText: 2020 Stalwart Labs LLC <hello@stalw.art>
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-SEL
|
||||
*
|
||||
* Modified by Coffey Labs in 2026 for INBUXA.
|
||||
*/
|
||||
|
||||
// This file is auto-generated. Do not edit directly.
|
||||
@@ -10372,8 +10374,8 @@ impl EnumImpl for SieveCapability {
|
||||
b"spamtest" => SieveCapability::Spamtest,
|
||||
b"spamtestplus" => SieveCapability::Spamtestplus,
|
||||
b"virustest" => SieveCapability::Virustest,
|
||||
b"vnd.stalwart.while" => SieveCapability::VndStalwartWhile,
|
||||
b"vnd.stalwart.expressions" => SieveCapability::VndStalwartExpressions,
|
||||
b"vnd.inbuxa.while" => SieveCapability::VndStalwartWhile,
|
||||
b"vnd.inbuxa.expressions" => SieveCapability::VndStalwartExpressions,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10426,8 +10428,8 @@ impl EnumImpl for SieveCapability {
|
||||
SieveCapability::Spamtest => "spamtest",
|
||||
SieveCapability::Spamtestplus => "spamtestplus",
|
||||
SieveCapability::Virustest => "virustest",
|
||||
SieveCapability::VndStalwartWhile => "vnd.stalwart.while",
|
||||
SieveCapability::VndStalwartExpressions => "vnd.stalwart.expressions",
|
||||
SieveCapability::VndStalwartWhile => "vnd.inbuxa.while",
|
||||
SieveCapability::VndStalwartExpressions => "vnd.inbuxa.expressions",
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29622,8 +29622,8 @@ impl Default for MySqlSettings {
|
||||
Self {
|
||||
host: Default::default(),
|
||||
port: 3306u64,
|
||||
database: "stalwart".to_string(),
|
||||
auth_username: Some("stalwart".to_string()),
|
||||
database: "inbuxa".to_string(),
|
||||
auth_username: Some("inbuxa".to_string()),
|
||||
auth_secret: Default::default(),
|
||||
}
|
||||
}
|
||||
@@ -29780,8 +29780,8 @@ impl Default for MySqlStore {
|
||||
read_replicas: Default::default(),
|
||||
host: Default::default(),
|
||||
port: 3306u64,
|
||||
database: "stalwart".to_string(),
|
||||
auth_username: Some("stalwart".to_string()),
|
||||
database: "inbuxa".to_string(),
|
||||
auth_username: Some("inbuxa".to_string()),
|
||||
auth_secret: Default::default(),
|
||||
}
|
||||
}
|
||||
@@ -29942,7 +29942,7 @@ impl Default for NatsCoordinator {
|
||||
no_echo: true,
|
||||
use_tls: false,
|
||||
auth_secret: Default::default(),
|
||||
auth_username: Some("stalwart".to_string()),
|
||||
auth_username: Some("inbuxa".to_string()),
|
||||
credentials: Default::default(),
|
||||
}
|
||||
}
|
||||
@@ -31125,8 +31125,8 @@ impl Default for PostgreSqlSettings {
|
||||
Self {
|
||||
host: Default::default(),
|
||||
port: 5432u64,
|
||||
database: "stalwart".to_string(),
|
||||
auth_username: Some("stalwart".to_string()),
|
||||
database: "inbuxa".to_string(),
|
||||
auth_username: Some("inbuxa".to_string()),
|
||||
auth_secret: Default::default(),
|
||||
options: Default::default(),
|
||||
}
|
||||
@@ -31270,8 +31270,8 @@ impl Default for PostgreSqlStore {
|
||||
read_replicas: Default::default(),
|
||||
host: Default::default(),
|
||||
port: 5432u64,
|
||||
database: "stalwart".to_string(),
|
||||
auth_username: Some("stalwart".to_string()),
|
||||
database: "inbuxa".to_string(),
|
||||
auth_username: Some("inbuxa".to_string()),
|
||||
auth_secret: Default::default(),
|
||||
options: Default::default(),
|
||||
}
|
||||
@@ -32576,7 +32576,7 @@ impl Default for RedisClusterStore {
|
||||
Self {
|
||||
urls: Map::new(vec!["redis://127.0.0.1".to_string()]),
|
||||
timeout: Duration::from_millis(10000),
|
||||
auth_username: Some("stalwart".to_string()),
|
||||
auth_username: Some("inbuxa".to_string()),
|
||||
auth_secret: Default::default(),
|
||||
max_retry_wait: Default::default(),
|
||||
min_retry_wait: Default::default(),
|
||||
@@ -32743,7 +32743,7 @@ impl Default for RedisSentinelStore {
|
||||
urls: Map::new(vec!["redis://127.0.0.1:26379".to_string()]),
|
||||
service_name: "mymaster".to_string(),
|
||||
timeout: Duration::from_millis(10000),
|
||||
auth_username: Some("stalwart".to_string()),
|
||||
auth_username: Some("inbuxa".to_string()),
|
||||
auth_secret: Default::default(),
|
||||
sentinel_username: Default::default(),
|
||||
sentinel_secret: Default::default(),
|
||||
@@ -46308,7 +46308,7 @@ impl Default for TracerLog {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
path: Default::default(),
|
||||
prefix: "stalwart".to_string(),
|
||||
prefix: "inbuxa".to_string(),
|
||||
rotate: LogRotateFrequency::Daily,
|
||||
ansi: true,
|
||||
multiline: false,
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
[package]
|
||||
name = "smtp"
|
||||
description = "Stalwart SMTP Server"
|
||||
description = "inbuxa SMTP server"
|
||||
authors = [ "Stalwart Labs LLC <[email protected]>"]
|
||||
repository = "https://github.com/stalwartlabs/smtp-server"
|
||||
homepage = "https://stalw.art/smtp"
|
||||
homepage = "https://inbuxa.org"
|
||||
keywords = ["smtp", "email", "mail", "server"]
|
||||
categories = ["email"]
|
||||
license = "AGPL-3.0-only OR LicenseRef-SEL"
|
||||
|
||||
@@ -27,7 +27,7 @@ impl RegistryStore {
|
||||
// variable, so it's ignored there, and loudly.
|
||||
if !inner.env_recovery_mode && inner.env_recovery_admin.take().is_some() {
|
||||
eprintln!();
|
||||
eprintln!("⚠️ INBUXA_RECOVERY_ADMIN (or STALWART_RECOVERY_ADMIN) is set, but the");
|
||||
eprintln!("⚠️ INBUXA_RECOVERY_ADMIN is set, but the");
|
||||
eprintln!(" server is configured and not in recovery mode, so it is ignored.");
|
||||
eprintln!(" Remove it from the environment. To use it for recovery, also set");
|
||||
eprintln!(" INBUXA_RECOVERY_MODE=1.");
|
||||
|
||||
@@ -47,22 +47,32 @@ macro_rules! brand_url {
|
||||
}
|
||||
|
||||
/// Reads one of the server's environment variables by its unprefixed name,
|
||||
/// such as `RECOVERY_ADMIN`.
|
||||
/// such as `RECOVERY_ADMIN`, from `INBUXA_<name>`.
|
||||
///
|
||||
/// `INBUXA_<name>` wins. `STALWART_<name>` is still read when the new name
|
||||
/// isn't set, so an existing Stalwart install moves over without editing its
|
||||
/// environment, and a warning says which variable to rename.
|
||||
/// The upstream prefix isn't read (SPEC §2.4). An install moved over from
|
||||
/// upstream that still sets it stops here with the variable to rename, rather
|
||||
/// than starting on defaults the operator didn't choose.
|
||||
pub fn env_var(name: &str) -> Result<String, std::env::VarError> {
|
||||
match std::env::var(format!("INBUXA_{name}")) {
|
||||
Err(std::env::VarError::NotPresent) => {
|
||||
let legacy = std::env::var(format!("STALWART_{name}"));
|
||||
if legacy.is_ok() {
|
||||
eprintln!("Warning: STALWART_{name} is deprecated; set INBUXA_{name} instead.");
|
||||
}
|
||||
legacy
|
||||
}
|
||||
found => found,
|
||||
let found = std::env::var(format!("INBUXA_{name}"));
|
||||
if matches!(found, Err(std::env::VarError::NotPresent))
|
||||
&& let Some(legacy) = legacy_setting(name, |var| std::env::var_os(var).is_some())
|
||||
{
|
||||
eprintln!(
|
||||
"Error: {legacy} is set, but inbuxa reads INBUXA_{name}. Rename it and start again \
|
||||
(https://docs.inbuxa.org/install/migrating/)."
|
||||
);
|
||||
std::process::exit(1);
|
||||
}
|
||||
found
|
||||
}
|
||||
|
||||
/// The environment prefix upstream reads. Only ever used to refuse it.
|
||||
const LEGACY_ENV_PREFIX: &str = "STALWART";
|
||||
|
||||
/// The upstream-prefixed variable for `name`, if it's set.
|
||||
fn legacy_setting(name: &str, is_set: impl Fn(&str) -> bool) -> Option<String> {
|
||||
let legacy = format!("{LEGACY_ENV_PREFIX}_{name}");
|
||||
is_set(&legacy).then_some(legacy)
|
||||
}
|
||||
|
||||
/// INBUXA's own version, dated like the rest of its family: `YYYY.M.D`, with
|
||||
@@ -90,3 +100,16 @@ macro_rules! brand_version_full {
|
||||
concat!($crate::brand_version!(), " (upstream ", env!("CARGO_PKG_VERSION"), ")")
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::{LEGACY_ENV_PREFIX, legacy_setting};
|
||||
|
||||
#[test]
|
||||
fn an_upstream_setting_is_named_for_renaming() {
|
||||
let old = format!("{LEGACY_ENV_PREFIX}_RECOVERY_ADMIN");
|
||||
let set = |var: &str| var == old;
|
||||
assert_eq!(legacy_setting("RECOVERY_ADMIN", set), Some(old.clone()));
|
||||
assert_eq!(legacy_setting("HOSTNAME", set), None);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user