Stalwart-migrate: --owner is never applied to a filesystem blob store (spam-model blobs left root-owned)

Issue Description

After a 0.16.27 → 1.0.0 migration with stalwart-migrate 1.0.1 run as root with --owner 587:587 (our stalwart user), the target RocksDB store was owned correctly, but two files the tool wrote into the shared filesystem blob store (blob_mode=Shared) were left as root:root 0644:

blob/53/54/41/4c/57/knkectcxifjfix7tkbau7x7ukjausts3iraviqjonr0di          1,311,148 bytes
blob/53/54/41/4c/57/knkectcxifjfix7tkbau7x7djravgu7jizeukus3jvhuirkmfzwhuna  525,255 bytes

These are the spam classifier’s model and training data (keys STALWART_SPAM_…). Both were written at 11:29:14Z, the second the verification at the end of run --final finished. A walk of the whole blob tree (3.6M entries) found no other file or directory not owned by stalwart, so it is only these two.

1.0 can read them (0644), so spam scoring works with the migrated model, but it cannot replace them. The spam filter maintenance task has failed with EACCES on every attempt since the first start.

The code is unchanged in 1.0.6. --owner is applied to target.created_paths(), and the v1 target registers only the data store’s own path there (crates/target-v1/src/target.rs lines 96–98: the RocksDB directory or the SQLite file, OwnedPaths::None otherwise). A filesystem blob store is never in that list. With blob_mode=Shared, only the files the tool writes into the existing blob store are affected, which here were the two spam-model blobs. From reading the code (I have not tested it), blob_mode=Copy into a new filesystem blob store would leave every copied blob root-owned.

Expected Behavior

--owner applies to everything the tool creates for the target, including the filesystem blob store (or what it writes into a shared one), so that the 1.0 server, running as that user, can later overwrite it.

Actual Behavior

The two spam-model blobs stay root:root. From the first start, SpamFilterMaintenance fails with “Permission denied (os error 13)” in crates/store/src/dispatch/blob.rs:201 (called from crates/spam-filter/src/modules/classifier.rs:582), is marked stalled, and is retried as a transient failure forever (“Task still retrying after repeated transient failures”). The classifier therefore never updates.

chown stalwart:stalwart on the two files fixes it. At the task’s next scheduled retry the server rewrote both blobs (updated model, new sizes), no further errors were logged, and the task left the retry state.

Reproduction Steps

  1. 0.16.27 with RocksDB data store and a filesystem blob store, with a trained spam classifier.
  2. Run stalwart-migrate prepare, then run, then run --final, all as root with --owner <uid>:<gid> of the account the server runs as, reusing the filesystem blob store (blob_mode=Shared), target a new RocksDB directory.
  3. Start 1.0 as that account.
  4. find <blob store> ! -user <account> lists the two spam-model blobs; the log shows the maintenance error below at each run of the task.

Relevant Log Output

2026-10-27T23:29:55Z INFO Task queued for processing (task-manager.task-queued) type = "SpamFilterMaintenance"
2026-10-27T23:29:55Z ERROR Filesystem error (store.filesystem-error) reason = "Permission denied (os error 13)", causedBy = "crates/store/src/dispatch/blob.rs:201", causedBy = "crates/spam-filter/src/modules/classifier.rs:582", details = "Failed to perform spam filter maintenance task"
2026-10-27T23:41:39Z WARN Task stalled (task-manager.task-stalled) taskId = 9033666212818168441, name = "SpamFilterMaintenance", reason = "Filesystem error (store.filesystem-error): reason = Permission denied (os error 13), causedBy = crates/store/src/dispatch/blob.rs:201, causedBy = crates/spam-filter/src/modules/classifier.rs:582 …"

(13 such errors between 2026-10-27T23:29Z and 2026-10-28T16:51Z.)

Stalwart Version

v1.x

Installation Method

Binary (Linux)

Database Backend

RocksDB

Blob Storage

Filesystem

Search Engine

Internal

Directory Backend

Internal

Additional Context

Linux aarch64 (Debian-based), Stalwart 1.0.0 running as a dedicated user (587:587) under systemd. Migrated with stalwart-migrate 1.0.1, run as root with --owner 587:587 and --concurrency 4 --account-split 2 (the segfault workaround from topic 2060), final run with --allow-errors for 85 spam training samples whose blobs were already missing in 0.16.

Two smaller points:

  • The docs could tell users of a shared blob store to check ownership after the migration, e.g. with find <blob store> ! -user <account>.
  • A permanent EACCES is classified as a transient failure, so the task retries indefinitely instead of failing visibly.

I have reviewed the documentation and FAQ and confirm that my issue is NOT addressed there.

on

I have searched this support forum (open and closed topics) and confirm this is not a duplicate.

on

I understand that topics in this category are triaged by a bot first but a human reply will follow up. If I’d prefer a human-only reply, I’ll add the no-ai tag to my topic.

on

Thanks for the detailed report. I couldn’t check the stalwart-migrate source, because it isn’t in the repos I can search. I can only confirm what the docs say about --owner, and your diagnosis is plausible but unverified on my side.

The migration guide describes --owner as giving “the files of the new store” to the stalwart user. It doesn’t say that it covers a filesystem blob store, whether shared or copied. That matches what you found: the flag applies only to the data store’s own path. I found nothing in the docs about checking blob ownership after a shared-blob migration.

Your chown stalwart:stalwart fix on the two spam-model blobs is the right workaround. For other shared-blob users, running find <blob store> ! -user stalwart after the migration and fixing any hits with chown should avoid the same EACCES in SpamFilterMaintenance.

I found no authoritative answer on whether this is a bug in the tool, or on how EACCES should be classified in task retries. A staff member will need to confirm both.

This is an automated reply from the Stalwart Help Bot. Other community members may follow up if this answer is incomplete or wrong.

Hi,

The tool only applied --owner to the data store path (the RocksDB directory or the SQLite file), never to a file system blob store. With a shared store that left exactly the files the tool writes there owned by root: the two spam model blobs from the final step and, if any accounts had them, the converted Sieve scripts. In copy mode, as you guessed, it would have left every copied blob and directory root-owned, and rollback had the same gap.

This is fixed for the next stalwart-migrate release. With --owner, every run and rollback now also walks each file system blob store the target configuration defines (including the members of a sharded store, with --path-map applied) and hands over to the given owner the files and directories the tool itself created. Files that were already there keep their owner, so 0.16’s blobs in a shared store aren’t touched.

Your chown on the two files was the right fix for your migration, and there’s nothing else to do. Anyone in the same spot can find the affected files with:

find <blob store> -user root

I’m leaving the task retry as it is. The permission error can be fixed from outside, and when it was, the next retry picked it up without a restart, which is what you saw.