Rename the identifiers that carried the upstream name
ci / fork-checks (pull_request) Successful in 16s
ci / build (pull_request) Successful in 7m53s

Everything clients, users and operators meet now carries the fork's name,
with no aliases (SPEC.md §2.4, changed here from "protocol identifiers
stay"):

- JMAP: upstream's registry capability is urn:inbuxa:jmap:registry, beside
  the fork's own urn:inbuxa:jmap.
- WebDAV lock and sync tokens are urn:inbuxa:dav*; clients resync once.
- Sieve: vnd.inbuxa.while and vnd.inbuxa.expressions. sieve-rs spells these
  into its compiler, so it's vendored (vendor/sieve-rs, 0.7.3) and patched in;
  a unit test fails if Cargo.lock ever moves past the vendored copy. The
  trusted runtime now names itself too, rather than answering sieve-rs's
  default.
- The web interface's OAuth client is inbuxa-webui. On every start the old
  stalwart-webui client is removed and any application naming it is moved
  over.
- The spam filter's blobs are INBUXA_SPAM_*; every start moves any left
  under the old keys, so a trained model survives.
- SQL stores and log files default to inbuxa, in the code and in the
  schema served to the admin (checksum regenerated).
- Settings are INBUXA_* only. A STALWART_* variable that's set where its
  INBUXA_* one isn't stops the server at startup, naming it.
- The version-upgrade messages link docs.inbuxa.org's migration page, and
  the OpenAPI description, smtp crate metadata and web-push test fixtures
  lose the name.

Kept on purpose, allowlisted with reasons: the OAuth key-derivation
contexts (renaming them would end every session and invalidate every
sealed client id) and the hashed application prefix.

Also fixes a latent start-up failure: ensure_client updated an existing
first-party client with a revision of 0, which the registry's assertion
never matches, so adding a redirect URI or changing the webmail secret
failed start-up. And the principal session test now expects
legacyProtocols (C-1, added 2026-09-21), which it had missed.

Tested: the server builds without warnings; common's 106 unit tests,
including the vendoring check; a new integration test for the two
start-up migrations; and the webdav, jmap, imap and SMTP Sieve suites.
This commit is contained in:
2026-09-22 19:33:02 -07:00
parent 4799d191a0
commit cc6f1eb298
129 changed files with 20504 additions and 168 deletions
@@ -0,0 +1,225 @@
/*
* SPDX-FileCopyrightText: 2020 Stalwart Labs Ltd <[email protected]>
*
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-SEL
*/
use crate::compiler::{
CompileError, Value, VariableType,
grammar::instruction::{CompilerState, Instruction},
lexer::{Token, word::Word},
};
use super::action_set::Modifier;
#[derive(Debug, Eq, PartialEq, Clone)]
#[cfg_attr(
any(test, feature = "serde"),
derive(serde::Serialize, serde::Deserialize)
)]
#[cfg_attr(
feature = "rkyv",
derive(rkyv::Serialize, rkyv::Deserialize, rkyv::Archive)
)]
pub(crate) struct ForEveryPart {
pub jz_pos: usize,
}
#[derive(Debug, Eq, PartialEq, Clone)]
#[cfg_attr(
any(test, feature = "serde"),
derive(serde::Serialize, serde::Deserialize)
)]
#[cfg_attr(
feature = "rkyv",
derive(rkyv::Serialize, rkyv::Deserialize, rkyv::Archive)
)]
pub(crate) struct Replace {
pub subject: Option<Value>,
pub from: Option<Value>,
pub replacement: Value,
pub mime: bool,
}
#[derive(Debug, Eq, PartialEq, Clone)]
#[cfg_attr(
any(test, feature = "serde"),
derive(serde::Serialize, serde::Deserialize)
)]
#[cfg_attr(
feature = "rkyv",
derive(rkyv::Serialize, rkyv::Deserialize, rkyv::Archive)
)]
pub(crate) struct Enclose {
pub subject: Option<Value>,
pub headers: Vec<Value>,
pub value: Value,
}
#[derive(Debug, Eq, PartialEq, Clone)]
#[cfg_attr(
any(test, feature = "serde"),
derive(serde::Serialize, serde::Deserialize)
)]
#[cfg_attr(
feature = "rkyv",
derive(rkyv::Serialize, rkyv::Deserialize, rkyv::Archive)
)]
pub(crate) struct ExtractText {
pub modifiers: Vec<Modifier>,
pub first: Option<usize>,
pub name: VariableType,
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[cfg_attr(
any(test, feature = "serde"),
derive(serde::Serialize, serde::Deserialize)
)]
#[cfg_attr(
feature = "rkyv",
derive(rkyv::Serialize, rkyv::Deserialize, rkyv::Archive)
)]
pub(crate) enum MimeOpts<T> {
Type,
Subtype,
ContentType,
Param(Vec<T>),
None,
}
impl CompilerState<'_> {
pub(crate) fn parse_replace(&mut self) -> Result<(), CompileError> {
let mut subject = None;
let mut from = None;
let replacement;
let mut mime = false;
loop {
let token_info = self.tokens.unwrap_next()?;
match token_info.token {
Token::Tag(Word::Mime) => {
self.validate_argument(1, None, token_info.line_num, token_info.line_pos)?;
mime = true;
}
Token::Tag(Word::Subject) => {
self.validate_argument(2, None, token_info.line_num, token_info.line_pos)?;
subject = self.parse_string()?.into();
}
Token::Tag(Word::From) => {
self.validate_argument(3, None, token_info.line_num, token_info.line_pos)?;
from = self.parse_string()?.into();
}
_ => {
replacement = self.parse_string_token(token_info)?;
break;
}
}
}
self.instructions.push(Instruction::Replace(Replace {
subject,
from,
replacement,
mime,
}));
Ok(())
}
pub(crate) fn parse_enclose(&mut self) -> Result<(), CompileError> {
let mut subject = None;
let mut headers = Vec::new();
let value;
loop {
let token_info = self.tokens.unwrap_next()?;
match token_info.token {
Token::Tag(Word::Subject) => {
self.validate_argument(1, None, token_info.line_num, token_info.line_pos)?;
subject = self.parse_string()?.into();
}
Token::Tag(Word::Headers) => {
self.validate_argument(2, None, token_info.line_num, token_info.line_pos)?;
headers = self.parse_strings(false)?;
}
_ => {
value = self.parse_string_token(token_info)?;
break;
}
}
}
self.instructions.push(Instruction::Enclose(Enclose {
subject,
headers,
value,
}));
Ok(())
}
pub(crate) fn parse_extracttext(&mut self) -> Result<(), CompileError> {
let mut modifiers = Vec::new();
let mut first = None;
let name;
let mut is_local = false;
loop {
let token_info = self.tokens.unwrap_next()?;
match token_info.token {
Token::Tag(Word::First) => {
self.validate_argument(1, None, token_info.line_num, token_info.line_pos)?;
first = self.tokens.expect_number(usize::MAX)?.into();
}
Token::Tag(
word @ (Word::Lower
| Word::Upper
| Word::LowerFirst
| Word::UpperFirst
| Word::QuoteWildcard
| Word::QuoteRegex
| Word::Length),
) => {
let modifier = word.into();
if !modifiers.contains(&modifier) {
modifiers.push(modifier);
}
}
Token::Tag(Word::Replace) => {
let find = self.tokens.unwrap_next()?;
let replace = self.tokens.unwrap_next()?;
modifiers.push(Modifier::Replace {
find: self.parse_string_token(find)?,
replace: self.parse_string_token(replace)?,
});
}
Token::Tag(Word::Local) => {
is_local = true;
}
_ => {
name = self.parse_variable_name(token_info, is_local)?;
break;
}
}
}
modifiers.sort_unstable_by_key(|m| std::cmp::Reverse(m.order()));
self.instructions
.push(Instruction::ExtractText(ExtractText {
modifiers,
first,
name,
}));
Ok(())
}
pub(crate) fn parse_mimeopts(&mut self, opts: Word) -> Result<MimeOpts<Value>, CompileError> {
Ok(match opts {
Word::Type => MimeOpts::Type,
Word::Subtype => MimeOpts::Subtype,
Word::ContentType => MimeOpts::ContentType,
Word::Param => MimeOpts::Param(self.parse_strings(false)?),
_ => MimeOpts::None,
})
}
}