48 KiB
AD-Integrated Containerized Samba File Server
This repository provides a production-oriented Samba file server container that joins an existing Active Directory domain and exposes three SMB shares: Private, Data, and FSLogix.
Architecture
- Samba runs in ADS mode with
winbindidentity mapping. - Static shares:
\\server\Private->/data/private\\server\Data->/data/groups/data\\server\FSLogix->/data/fslogix
- Data folders and individual user permissions are managed in the admin web UI. AD remains the source of user identities and authentication.
- Data access uses Windows ACLs stored in Samba’s protected
/state/data-xattrs.tdb, with separate read, modify, and delete permissions. - Folder and permission records, normalized activity events, collector offsets, and web caches share one SQLite database at
/state/shares.db. - Managed folders are name-based while active and moved to archive through the admin UI:
- active:
/data/groups/data/<folderName> - archived folders:
/data/groups/archive/<folderName>
- active:
- Samba machine trust/key material is persisted in
/var/lib/sambato survive container recreation. - Container hostname is fixed (
SAMBA_HOSTNAME) to keep AD computer identity stable. - In bridge-mode Docker networking, startup can publish the host LAN IP in AD DNS with
AD_DNS_IP/AD_DNS_NAMEinstead of the container bridge IP. - NetBIOS name defaults to
ADSAMBAFSRVand is clamped to 15 characters (NETBIOS_NAMEoverride supported). - Setup prompts for well-known authorization groups by SID (
DOMAIN_USERS_SID,DOMAIN_ADMINS_SID) to avoid localized group names. FSLOGIX_GROUP_SIDcontrols who can access the default FSLogix share (defaults toDOMAIN_USERS_SID).- Startup resolves those SIDs to NSS group names via winbind, then uses those resolved groups in Samba
valid usersrules. - Samba
full_auditrecords successful and failed reads, writes, renames, and deletions on all three shares; FSLogix events are retained in a separate indexed activity stream. - A collector normalizes those four actions and persists them in indexed SQLite tables; activity is never automatically deleted.
- Samba retains deleted files for seven days in per-user recycle repositories on the same data volumes.
- The HTTPS file interface at
/lets AD users search accessible Data folders and their own Private folder. An independent background worker indexes text and recognizes scanned PDFs without changing original files. - The administration console at
/admin/...manages Data folders and individual user access, and provides statistics, logs, trash downloads/restores, manual backups, and share reconciliation. It also includes a fully client-side Typst PDF report. - Web sign-in validates the submitted username/password with Kerberos and issues an expiring JWT in a Secure, HttpOnly, SameSite=Strict cookie. Human AD users can sign in;
MSOL_*andkrbtgtaccounts are excluded. Administration pages and APIs require membership inDOMAIN_ADMINS_SID. The browser does not use NTLM/SPNEGO or Kerberos negotiation. - HTTPS certificates are requested from a configured local Smallstep CA and renewed automatically. Pre-issued certificate files are also supported.
- Optional remote backups are configured in the admin UI, including destination, scheduling and full-data encryption.
- Private home creation skips well-known/service accounts by default (including
krbtgt,msol_*,FileShare_ServiceAcc). - Reconciliation is executed:
- once on startup
- every 5 minutes via cron
- Backup is executed:
- manually through the Domain Admin web UI or CLI
- daily at the configured UTC hour when automatic backups are enabled in the UI
Data Folder Lifecycle
The Zugriffsverwaltung page creates top-level Data folders, assigns a permission level to each existing AD user individually per folder. It can archive folders and restore them without deleting their contents. AD accounts and passwords continue to be administered in AD.
| Level | Access |
|---|---|
| 0 | No access; folder hidden |
| 1 | Read only |
| 2 | Read, create, and edit; no delete |
| 3 | Read, create, edit, and delete |
No assignment means no access. Each user has an independent level per folder; level 0 revokes access. There are no access groups. Domain Admins retain full access. Only admins can rename or delete a top-level managed folder.
Level 2 blocks renaming and moving files or directories because SMB requires delete permission for those operations. Applications that save by deleting/replacing a file or renaming a temporary file require level 3. Level 2 still permits overwriting a file’s contents in place.
Saving applies ACL changes recursively when the effective policy changes and disconnects existing Data connections so clients reopen with the new permissions. Changes record the administrator, timestamp, action, and submitted policy in access_changes. The five-minute reconciler repairs folder roots and recovers interrupted access updates; REPAIR_DATA_ACLS=1 forces a full repair.
Upgrading from FS_* groups
On the first startup, existing active shares records are retained. Nested and primary-group memberships are expanded into a snapshot of individual user SIDs, each receiving level 3 on its existing folders. Folder identities and data are retained. An unresolved group or member stops migration with an error so an incomplete import cannot silently remove access.
Legacy GUID directories stored as /data/groups/<objectGUID> are moved into /data/groups/data/<folderName> (or archive for inactive records) before ACL reconciliation. Existing target directories are preserved; collisions receive a unique folder name. Moves use an atomic no-overwrite rename on the existing volume and retain file inodes and contents. A committed move journal recovers interruptions between filesystem and database updates. This layout repair also runs when the access migration was already marked complete, preserving saved individual permissions and avoiding another AD import. Missing or ambiguous paths stop recovery without creating empty replacements or deleting either path.
After import, AD group renames, membership changes, deletion, and new FS_* groups do not change Data folders or access. Manage subsequent changes in the web UI. User assignments are keyed by SID, so renaming an AD account retains its assignments; recreating an account under the same username does not inherit them.
Installations using the previous app-local group model are upgraded atomically to individual assignments. The highest prior group grant is retained per user and folder, with existing direct assignments taking precedence, including level 0. Archived folder assignments are preserved. Group tables and group mutation actions are removed.
A new installation starts without assignments. Existing untracked Data directories are adopted with admin-only access. Previously archived folders remain archived and need explicit permissions before users can access them after restoration.
The Data share uses Samba Windows ACL checks instead of POSIX ACLs. Keep its data volumes private to the container; direct local or NFS access is outside this permission model. The protected TDB store avoids requiring extra container capabilities. After restoring Data to different filesystem inodes, run reconciliation with REPAIR_DATA_ACLS=1 to rebuild ACL records. Trash restoration applies the current folder policy before exposing the restored file.
File Search and PDF Recognition
Users sign in at / with their existing AD credentials using username, DOMAIN\username, or username@domain. Domain-qualified names accept the configured AD DNS domain/realm; the short NetBIOS domain is accepted only with the DOMAIN\username spelling. The file view provides live search by filename and content, folder and file-type filters, grid/list views, previews, and downloads of the original files. Grid and list entries show file metadata without extracted content snippets. Only Domain Admins see the administration link and can use management pages and APIs under /admin/...; old administration URLs redirect there. Administrative APIs are under /admin/api/..., while sign-in, session, and document endpoints remain under /api/.... This upgrade expires existing web sessions.
The catalog includes active Data folders and each user's own Private folder. Every search, detail, preview, and download request checks current individual folder permissions. Revoking access or archiving a folder takes effect without waiting for reindexing. Domain Admins can see all active Data folders, but the user file view still shows only their own Private folder. Archived folders, recycle repositories, FSLogix profiles, symlinks, nested mounts, and special files are excluded. Thumbs.db (case-insensitive) and Office lock files whose names start with ~$ are omitted from results, counts and file-type filters in both Data and Private folders. Upgrades remove their existing catalog entries without deleting original files. Private files additionally require ownership and read/traverse permissions for the signed-in user's mapped Unix identity.
Linux filesystem events update the filename catalog as files change, with periodic scans recovering missed events. Text extraction and OCR run through a persistent background queue; files become searchable by filename before content extraction finishes. Search updates while typing, and open views refresh every two seconds to show completed extraction. Full-text queries match word prefixes and ignore accents; filename-only queries also match substrings.
Search stays in SQLite. FTS5 indexes text together with folder and file-type tokens; a compact character index also covers filename substrings and one- or two-character searches. Composite B-tree indexes cover folder/type filters and the UI's name, newest-first and oldest-first sorting. Pagination uses filter-bound cursors. Name and date sorting seek into their B-tree indexes; relevance uses FTS5's native ordered stream so ongoing OCR updates cannot invalidate a saved score threshold. Counts, file-type options and queue progress use incrementally maintained summaries. Broad text searches show a lower bound rather than delay results for an exact count. Large Private folders use bounded, current permission checks for facets and page candidates; their totals may also be lower bounds. Original files are checked before an item is returned, and current permissions are checked again for previews and downloads.
The first start after this upgrade rebuilds the derived search indexes and summaries once. It preserves document IDs, previews, OCR jobs, pause state, permissions and original files. python3 scripts/benchmark-document-search --rows 2000000 creates an isolated synthetic catalog and measures 64 combinations of search scope, sorting and folder/type filters plus deep cursor pages for metadata and relevance ordering. It uses a small original-file fixture rather than creating two million physical files. --database /tmp/adfs-search-benchmark.db retains that disposable catalog for repeat runs.
Content search indexes only PDFs, Word documents (docx, odt) and PowerPoint presentations (pptx, odp). All file types remain searchable by filename, including text, Markdown, spreadsheets and images. Existing extracted content from excluded types is removed from the derived search index on upgrade; original files and filename entries remain intact. PDFs and common images receive a first-page/image thumbnail. PDFs open in a fullscreen dialog with the locally bundled Mozilla PDF.js viewer, including page navigation, zoom, thumbnails and search within native PDF text. PDF loading and byte-range requests check current folder access. Legacy binary Office formats (doc, ppt) remain searchable by filename. Extracted text is limited to 2 MiB per file; encrypted, damaged, or oversized documents may have no searchable content.
Only PDF pages that themselves contain raster images and little extracted text are queued for local OCR using Poppler and Tesseract, with German and English enabled by default. Search OCR renders those pages at 300 DPI, capped at 3500 pixels on the longest side, instead of inheriting high DPI from embedded logos or rebuilding an OCR PDF. Each render and recognition step has a 30-second timeout. Photos can still require a recognition attempt to establish whether they contain text; text-free pages finish without adding search content. Native text remains searchable while OCR is pending. OCR text is used for search. No file type displays a separate extracted document-text panel in its dialog. The PDF viewer displays the original PDF. Downloads always return the original file. No OCR replacement or separate OCR PDF is published. Failed jobs retry with backoff, and pending work survives restarts.
Parsers run as an unprivileged service account on temporary copies, with filesystem/network restrictions and resource limits. This requires a Linux kernel with Landlock enabled (Linux 5.13 or newer) on x86-64 or ARM64. If isolation is unavailable, extraction fails closed while filename search remains available; the worker logs the reason. OCR needs no external service or additional container capabilities.
The derived index and previews live in /state/documents (DOCUMENT_STATE_ROOT override), separate from the managed-access database. The directory is accessible only to the service. Backups retain all original files and access records, and omit this rebuildable cache. Restoring a backup rebuilds the catalog automatically. Allow space for extracted text, previews, and temporary OCR work; the first indexing pass runs asynchronously.
Domain Admins monitor the worker at /admin/documents: current file and phase, completed/total files, text/OCR queues, retries, heartbeat, last catalog scan, and recent activity. Pause and resume controls stop both catalog updates and extraction. Pausing interrupts an active parser and its child processes, discards its temporary workspace, and keeps the original queue phase for resumption. Existing indexed files remain searchable subject to current access rules. The pause flag survives container restarts. Control events record the administrator in the document activity history; status and control APIs are restricted to administrators. This derived worker history and its pause flag are omitted with the document cache from backups.
| Variable | Default | Purpose |
|---|---|---|
DOCUMENT_SCAN_SECONDS |
30 |
Recovery scan interval; filesystem events handle intervening changes |
DOCUMENT_OCR_LANGUAGE |
deu+eng |
Installed Tesseract languages used for OCR |
DOCUMENT_OCR_TIMEOUT_SECONDS |
600 |
Maximum runtime for an OCR job |
DOCUMENT_OCR_DPI |
300 |
OCR render resolution (150–400 DPI), subject to the pixel cap |
DOCUMENT_OCR_MAX_DIMENSION |
3500 |
Maximum OCR image width/height (1500–5000 pixels); originals are unchanged |
DOCUMENT_OCR_PAGE_TIMEOUT_SECONDS |
30 |
Maximum runtime per page render or recognition step (5–120 seconds) |
DOCUMENT_MAX_FILE_MB |
512 |
Largest file copied for extraction; larger files use filename search |
DOCUMENT_MAX_PDF_PAGES |
500 |
Maximum PDF page count for extraction |
These settings are configured under Dokumentindex und OCR at /admin/settings. Their internal names below also identify imported legacy settings.
Shared SQLite State Database
The default database path is /state/shares.db; STATE_DB_PATH can override it. SHARE_DB_PATH remains a backward-compatible fallback.
The database contains:
shares: managed folder lifecycle and ACL reconciliation state;access_users,folder_permissions,access_settings, andaccess_changes: managed access rules, cached AD identities, migration state, and administrative change history;audit_events: normalized read, write, move, and delete events;audit_sources: Samba log inode/offset checkpoints;audit_event_dedup: bounded, persistent fingerprints for restart-safe main-read and FSLogix-event deduplication;audit_daily_totals,audit_daily_counts, andaudit_daily_facets: compact materialized metadata for fast activity counts and filters;audit_paths,audit_paths_fts, andaudit_path_events: deduplicated trigram path search with an incrementally maintained event mapping;audit_rollup_state: bounded legacy-event backfill progress;web_cache: cached storage scan results.
Activity pages use UTC epoch seconds, keyset pagination, and compact indexes for time, scalar filters, and selective substring path searches. Exact scalar-filter counts and facets read the daily rollups instead of scanning raw events. WAL mode allows the collector, reconciler, scanner, and read-only web requests to operate concurrently.
Standard SQLite does not provide transparent general-purpose compression, so this project deliberately does not depend on a non-core compression VFS. Structured columns avoid repeated JSON field names and make indexed queries much cheaper; the state volume still needs capacity for retained activity.
AD Requirements
- Existing AD DS domain reachable from the Docker host.
- An AD account with permission to join the server to the domain and read directory users/groups.
FileShare_ServiceAccountmust be allowed to join computers to the domain (net ads join) in your AD policy.- Directory reads use machine-account LDAP (
net ads search -P); join credentials are only used as a fallback LDAP bind path. - Existing AD users are selectable by the administrator; no AD group naming convention is required for new Data folders.
- Machine-account LDAP reads provide the user list and the one-time legacy membership import.
DNS Requirements
- Container must resolve AD DNS records (especially SRV records for domain controllers).
DOMAINshould resolve from inside the container.- Preferred setup: Docker host uses AD-integrated DNS or forwards to AD DNS.
- If Docker bridge networking is used, set
AD_DNS_IPto the Docker host LAN IP that clients should use for SMB, not the container172.xaddress. - When
AD_DNS_IPis set, domain join uses--no-dns-updates; each container startup unregisters/re-registersAD_DNS_NAME -> AD_DNS_IPin AD DNS using the machine account. - Configure the host LAN address used for AD DNS registration in the web setup or server settings.
Time Sync Requirements
Kerberos requires close time alignment.
- Docker host clock must be synchronized (NTP/chrony/systemd-timesyncd).
- AD domain controllers must also be time-synchronized.
- If join/authentication fails unexpectedly, check time skew first.
Repository Layout
Dockerfiledocker-compose.ymlsetup.env.exampleREADME.mdapp/init.shapp/reconcile_shares.pyapp/access_control.pyapp/backup_to_destination.pyapp/audit_collector.pyapp/audit_store.pyapp/state_db.pyapp/web_ui.pyapp/documents.pyapp/document_index.pyapp/extract_document.pyapp/web/etc/samba/smb.confdev/(disposable AD DC, backup target, SMB client, seed data, and E2E assertions)scripts/devscripts/test-e2e
Local Preview
Run a complete disposable environment with Docker or Podman:
./scripts/dev
The launcher builds the current application and starts an isolated, run-scoped network containing:
- a real Samba AD DC for
DEV.TEST, seeded with users, nested groups, and threeFS_*groups; - a real Smallstep CA whose ACME provisioner issues the web UI certificate for
files.localhost; - an authenticated rsync daemon used by the normal backup implementation;
- the actual file-server image, joined to the dummy domain;
- a continuous SMB client that exercises reads, writes, renames, and deletions, including activity from an excluded dummy service account.
The disposable AD DC is compatible with rootless Podman: its development-only internal ID range stays inside the standard 65,536-entry user namespace, and SYSVOL ACL metadata is stored in xattr_tdb because an unprivileged container cannot write the security.NTACL namespace. These compatibility settings apply only to dev/ad-dc.Dockerfile; the production file-server image and real AD remain unchanged.
The preview starts with group, Private, and FSLogix data. The client keeps current activity moving, while a real backup runs immediately and repeats in the background. Open the URL and use the credentials printed by the launcher. Defaults are:
URL: https://files.localhost:8443
Username: DEV\previewadmin
Password: PreviewAdmin123!
The generated CA is intentionally disposable. scripts/dev prints the temporary root certificate path so it can be trusted only for the duration of that run. Ctrl-C stops and removes all run-scoped containers, volumes, the network, and the temporary root. A watchdog performs the same cleanup if the parent script is killed.
To test first-launch onboarding with empty configuration and data, run:
./scripts/dev --onboarding
Open http://files.localhost:8080/. This mode starts the same disposable AD, CA, and rsync target, but supplies no application configuration through environment variables and skips file seeding, automatic domain join, the SMB activity client, and the backup driver. Only the external HTTPS port mapping is recorded for correct setup links and browser origin checks.
The launcher prints both setup codes, the ACME directory, the root certificate file to upload, domain credentials, group names, and the optional backup destination. Configure HTTPS first, temporarily trust the disposable CA root, then follow the link to https://files.localhost:8443/ to complete domain setup. Configure backups afterwards in /admin/settings. Each launch starts fresh; Ctrl-C removes that run's configuration and test data. --onboarding and --e2e are mutually exclusive.
Neither the dummy DC nor the application container receives extra capabilities.
Useful overrides:
| Variable | Default | Purpose |
|---|---|---|
DEV_HTTPS_PORT |
8443 |
HTTPS port bound to host loopback |
DEV_HTTP_PORT |
8080 |
HTTP setup port bound to host loopback in --onboarding mode |
DEV_WEB_HOSTNAME |
files.localhost |
HTTPS name validated by the disposable ACME CA |
DEV_SKIP_BUILD |
0 |
Set to 1 to reuse already-built local images |
DEV_CA_IMAGE |
docker.io/smallstep/step-ca:latest |
CA image; pin a tag or digest for reproducible CI |
DEV_SERVER_IMAGE |
ad-ds-simple-file-server-dev:latest |
Local file-server image name |
DEV_AD_IMAGE |
ad-ds-simple-file-server-ad-dev:latest |
Local AD/client image name |
DEV_BACKUP_IMAGE |
ad-ds-simple-file-server-backup-dev:latest |
Local rsync target image name |
DEV_REALM |
DEV.TEST |
Dummy Kerberos realm |
DEV_WORKGROUP |
DEV |
Dummy NetBIOS domain |
DEV_DNS_DOMAIN |
dev.test |
Dummy AD DNS zone |
DEV_BASE_DN |
DC=dev,DC=test |
Dummy directory base DN |
DEV_ADMIN_USER |
previewadmin |
Seeded Domain Admin login |
DEV_ADMIN_PASSWORD |
PreviewAdmin123! |
Seeded Domain Admin password |
DEV_USER_PASSWORD |
PreviewUser123! |
Shared password for seeded non-admin users |
DEV_SEED_MB |
8 |
MiB per large seed file |
DEV_ACTIVITY_INTERVAL_SECONDS |
4 |
Delay between SMB activity batches |
DEV_BACKUP_INTERVAL_SECONDS |
120 |
Delay between completed preview backups |
DEV_ARCHIVE_PASSWORD |
PreviewArchive123! |
Dummy password for encrypted group archives |
DEV_BACKUP_AUTO_ENABLED |
true |
Environment-only automatic-backup setting passed to the file server |
DEV_REALM, DEV_DNS_DOMAIN, and DEV_BASE_DN describe the same domain and must be changed together.
End-to-End Tests
Run the same disposable stack headlessly with extensive assertions:
./scripts/test-e2e
The E2E suite verifies:
- CA-issued TLS, hostname validation, HSTS, and CSP;
- anonymous rejection, bad credentials, valid non-admin rejection, real Domain Admin login, JWT claims, bearer use, cookie flags, tamper rejection, and logout;
- domain trust, one-time legacy folder/membership migration, and individual folder assignments;
- legacy GUID-path migration with file hash/inode checks, and real container restart after an already-completed access migration;
- individual user assignments, all four SMB access levels, hidden-folder behavior, inheritance, ACL-edit rejection, revocation, and archive/restore;
- SMB allow/deny behavior and real file operations;
- Data, Private, and FSLogix usage aggregation;
- high-level
full_auditingestion for all four actions, service-account exclusion, filters, facets, and pagination; - shared SQLite schema, integrity, indexes, legacy-log removal, and main-read and FSLogix-event deduplication across interleaved events and collector polls;
- real Samba recycle handling plus authenticated trash listing, streamed download, and restore;
- real rsync transfer progress, completed backup status, log output, remote snapshot marker, and per-group encrypted non-solid 7z archives;
- anonymous action rejection plus authenticated manual backup and reconciliation actions, terminal progress, and live reconciliation output;
- overview and system-health aggregation;
- the log-free PDF report snapshot plus local Typst wrapper, WebAssembly, font MIME types, and immutable caching.
The runner returns non-zero on the first failed assertion, prints bounded logs from every run-scoped service, and always removes its containers, volumes, network, and temporary CA root. Set DEV_SKIP_BUILD=1 for a fast rerun against existing local images.
Browser checks for access administration
tests/access_ui_smoke.mjs drives Chromium with Playwright against the real frontend and a simulated API containing representative folders and 80 AD users. It checks individual permission editing, user search and access filters, unsaved-change protection, failed saves and retries, preserved selection, folder creation, archive/restore, layouts from 390 to 1500 pixels wide, and consistency with the existing admin control styles. It writes desktop and mobile screenshots for visual review.
With Playwright available to Node:
node tests/access_ui_smoke.mjs
PLAYWRIGHT_MODULE can point to an external Playwright installation; PLAYWRIGHT_BROWSERS_PATH selects its browser cache. SCREENSHOT_DIR chooses the screenshot destination; otherwise the runner creates a temporary directory and prints its path. These browser checks use fixture data; scripts/test-e2e verifies the real AD/SMB backend.
Setup
No environment file is required. Run ./setup to build and start the service, then open http://<server>/. HTTP exposes only HTTPS configuration: enter the separate HTTPS setup code from docker compose logs samba, choose the HTTPS hostname and ACME directory URL, and optionally upload a PEM root CA certificate. Public CAs use the system trust bundle. The ACME CA must resolve the hostname and reach its HTTP-01 challenge on port 80.
Once issuance succeeds, follow the HTTPS link. Enter the second, independent setup code from the container log. This code is used only over HTTPS. Configure the AD realm, NetBIOS domain, controller, domain-join/LDAP credentials and server names. After the domain join succeeds, select the AD groups for login, administration and FSLogix, and verify an account in the selected administrator group. Folder permissions remain individual assignments.
The web UI remains available if joining AD fails. Correct the settings and retry without removing any data volumes. The setup capability stops working after completion. Domain-join credentials are retained for LDAP; use an account with the necessary directory read and join permissions, or replace its credentials in administration after joining.
Administrators manage server settings at /admin/settings and backup destinations, schedules, retention and encryption at /admin/backup. Settings are stored in the root-only /state/configuration.db. Backup changes apply to the next run. Other changes restart the service processes, preserving files and the existing domain join; active SMB connections may reconnect. Switching to a different AD domain is deliberately rejected after setup.
For an existing installation, run ./setup or ./redeploy: the previous container’s resolved configuration is imported once when available; otherwise, its .env is imported without executing it. The original domain join, storage paths, access database, volumes, backup password, destinations and backup history are preserved. A configured installation ignores later .env edits. An unconfigured installation can also import its old file from the HTTPS setup screen. Keep the same Compose project name and volume names during the upgrade. Never use docker compose down -v on retained data.
Compose publishes fixed ports 80 and 443, plus SMB 139 and 445. A deployment requiring different host ports can use a Compose override; it does not configure application credentials or backup destinations. TLS, AD settings and backup configuration are managed in the browser.
SMB Shares
Private
- Share:
\\server\Private - Root path:
/data/private - Per-user path:
/data/private/<samAccountName> - Script ensures user directories exist and assigns ownership through winbind identity resolution.
- Root
/data/privateis enforced read/execute-only (0555) to prevent folder creation directly under\\server\Private. - SMB-side ACL changes on
\\server\Privateare blocked (nt acl support = no). - Auto-creation skips well-known/service/non-login accounts (disabled, locked, or expired).
- Each private user tree is reconciled recursively to homogeneous permissions (dirs
0700, files0600, user/admin ACLs). - Permissions:
- owner user: full control
- Domain Admins: ACL full control
- mode:
700
hide unreadable = yes+ ACLs enforce that users only see their own folder.
Data
- Share:
\\server\Data - Path:
/data/groups/data - Contains the active top-level folders created or imported into the admin UI.
- Windows ACLs enforce each user’s effective level, including separate delete rights.
- Samba’s
acl_xattrandxattr_tdbmodules retain the ACLs in a protected store. Local access to the underlying volumes must remain restricted. - New files and directories inherit the managed ACL. Users cannot change ACLs or take ownership to grant themselves more access.
- Normal reconciliation refreshes each folder root; recursive repair runs when its effective permission signature changes, is missing, or
REPAIR_DATA_ACLS=1is set. - Dot-prefixed folder names are allowed and are not hidden over SMB.
- No guest access.
FSLogix
- Share:
\\server\FSLogix - Path:
/data/fslogix - Access for authenticated users in configurable
FSLOGIX_GROUP_SID(default:DOMAIN_USERS_SID, resolved through winbind). - Semantics intentionally differ from
Data: only the share root is reconciled (03770+ ACL defaults), while user-created profile container folders/files are not recursively normalized. - Samba masks are profile-container oriented (
create mask = 0600,directory mask = 0700) so profile payload stays user-private by default.
Seven-Day Trash
Deletes through the Private, Data, and FSLogix SMB shares are intercepted by Samba's recycle VFS and moved into .trash/<user> on the same source volume. Moving on the same filesystem avoids copying even large profile containers. The original directory tree is retained, repeated deletions receive versioned names, and the deletion time is stored as the recycled file's modification time.
The repository root is owned by root, vetoed from SMB access, and excluded from usage accounting and remote backup snapshots. Temporary *.tmp files and document lock files beginning with ~$ are deleted normally instead of being retained; cleanup also purges any such entries left by an older configuration. Every hour—and once during container startup—the cleanup job permanently removes entries older than seven days. TRASH_RETENTION_DAYS defaults to 7 and may be set from 1 to 365.
Domain Admins can use Papierkorb in the web console to filter and list retained files, stream-download them, or restore them to their original path. Restore is a same-filesystem link/unlink operation, so it is fast for large files and preserves file metadata. It never overwrites an existing file; a conflict is reported and the retained copy remains in the bin.
Web Administration Console
Open https://<WEB_HOSTNAME>/ after setup to search files. Domain Admins can open the administration console at /admin/; its APIs require membership in the group identified by DOMAIN_ADMINS_SID. The form accepts DOMAIN\username, username@realm, or an unqualified username (which is qualified with WORKGROUP).
The console is intentionally operational and plain:
- Overview: current capacity totals, active folder count, recent activity, and backup state.
- Zugriffsverwaltung: create/archive/restore Data folders and assign levels 0–3 to existing AD users individually per folder.
- Data usage: cached recursive size of every top-level
/Datagroup folder. - User usage: per-user
/Private + /FSLogixtotals with component sizes. - Activity: dynamic date, user, share, action, result, and path filters with pagination.
- Trash: list seven-day recycle entries across all shares, download a retained file, or restore it without overwriting an existing path.
- Share reconciliation: manually force reconciliation and follow its phase, progress bar, current group, and live output.
- Backups: manually start a backup and follow live progress, active transfer rows, snapshot name, trigger, and recent output.
- PDF report: storage totals and every storage row, individual folder/user assignments, current backup state, system checks, and TLS certificate data.
- System: domain trust, Samba configuration, TLS certificate, scanner, and activity database health.
The PDF report deliberately excludes the activity log and backup log. Its dedicated snapshot endpoint removes those fields before returning data. Typst, its WebAssembly compiler, and the report fonts are shipped with the application; Typst source and PDF bytes are created only in the authenticated browser and are never uploaded to another service. The first export downloads roughly 22 MiB of compiler/font assets, which are then cached as immutable files. The CSP grants only 'wasm-unsafe-eval' for WebAssembly compilation and does not enable JavaScript 'unsafe-eval'.
The mutation endpoints under /admin/api/ manage Data access, restore retained files, control indexing, or start an immediate backup/share reconciliation. They require an active Domain Admin session and CSRF protection. Restore cannot overwrite a live file. Backup schedules, destinations, retention and encryption are configured through /admin/backup, without redeploying.
Authentication and sessions
- Credentials are submitted only over HTTPS. The password is passed to
kinitthrough stdin, is never placed in a process argument, and the temporary Kerberos credential cache is immediately removed. - After Kerberos succeeds, the service resolves the account SID, Unix UID and complete group SID set through winbind. Human AD users can sign in; only members of
DOMAIN_ADMINS_SIDreceive administration access. Sessions recheck that identity through winbind on their first request afterWEB_AUTH_RECHECK_SECONDS(default 60 seconds). Directory failures deny data and administration requests; directory caching can delay visibility of an AD change. - Authentication is form-based; the browser never performs NTLM, SPNEGO, or Kerberos negotiation.
- JWTs use HMAC-SHA256, default to eight hours, and are accepted from the protected cookie or an
Authorization: Bearerheader. An active session entry in SQLite is also required. Logout removes that entry immediately, including for bearer-token reuse, and revocation survives restarts. Logout also works during directory outages. Existing sessions issued before this upgrade require a new login. - Every POST requires
application/json. Browser requests must originate from the exact configured HTTPS origin, derived fromWEB_HOSTNAMEand the externalWEB_HTTPS_PORT(default 443), or explicitly listed inWEB_TRUSTED_ORIGINS. The service ignores Host and forwarded headers when determining trusted origins. Authenticated changes and logout require the session'scsrfTokenfrom login orGET /api/sessioninX-CSRF-Token. Login requiresX-CSRF-Token: login; origin-less API clients must use an explicit bearer token and the session's CSRF token for authenticated changes. No cross-origin CORS access is granted. - Login attempts are reserved atomically before authentication, with separate five-minute limits for client address and target account across client addresses. Successful logins consume a reservation and do not reset either limit. Case variations and the supported domain-qualified spellings of an account share a budget.
- TLS handshakes run in bounded connection workers, outside the accept loop, with a five-second timeout. Request I/O also has a timeout.
- Responses set HSTS, a restrictive Content Security Policy, clickjacking protection, and MIME sniffing protection. APIs and ordinary UI assets use no-store caching; pinned Typst compiler/font assets use immutable long-term caching.
HTTPS and certificate management
The HTTP onboarding step accepts only an ACME directory URL without credentials, a hostname and an optional PEM root CA upload. Its setup code cannot access the HTTPS configuration API. HTTP rejects login, AD settings, backup settings and every administrative action. After onboarding, ordinary HTTP requests redirect to HTTPS; the ACME challenge route remains available for renewals. Challenges are forwarded to a loopback-only responder.
In /admin/settings, choose ACME, Smallstep CA, uploaded certificate/key PEM, or a self-signed certificate. ACME and CA credentials, custom trust roots, renewal intervals and uploaded private keys are entered over HTTPS. A temporary self-signed certificate keeps HTTPS setup reachable before managed issuance succeeds. Uploaded certificate/key pairs are validated before replacing working files. Certificate changes reload the HTTPS listener.
The client uses step ca certificate --acme --root --standalone. Automatic ACME renewal checks default to every 900 seconds. If using a private CA, also install its root in clients' trust stores. Certificate provisioning errors leave the web setup available for correction.
Activity Database
Samba emits selected high-level full_audit operations for Private, Data, and FSLogix, and the collector stores them durably:
- it tails every
/var/log/samba/log.*source and stores inode/byte offsets transactionally inaudit_sources, so source progress and inserted events commit together; - each event records a UTC timestamp, user, client address/name, share, result, path, and one of
read,write,move, ordelete; - directory listings, sessions, metadata access, file-open/create noise, and all other VFS operations are discarded; users ending in a configured
AUDIT_SKIP_USER_SUFFIXESvalue are also discarded; - FSLogix profile-container events are retained and queried through their own partial indexes, API route, and UI log instead of appearing in the main activity stream;
- identical main-stream reads and identical FSLogix events within the same UTC second are collapsed regardless of intervening events, log source, or collector polling cycle; Data/Private writes remain distinct, and the 48-hour fingerprint window can be tuned with
AUDIT_DEDUP_WINDOW_SECONDS; - activity pages read only
limit + 1indexed rows and use a stable time/id cursor; - exact counts for date, user, share, action, and result filters and all facet lists come from daily rollups;
- selective substring path searches use the deduplicated trigram index and skip an expensive exact count while more pages exist;
- while a legacy backfill is running, pages return immediately without raw-table count or facet scans and expose indexing progress;
- collector inserts and rollup updates are batched in one transaction;
- no activity retention deletion is performed.
Collection starts even when the web UI is disabled. Existing databases remain queryable while the collector backfills rollups, path IDs, path-event mappings, and recent main-read and FSLogix-event deduplication in bounded chunks after prioritizing each live append. On the first collector start after the legacy archive migration, recognized daily .jsonl/.jsonl.gz files and the old collector state file under /state/audit are deleted without import. Existing raw Samba log content is then processed using the current action, suffix, and deduplication policy.
Backups
Configure backups entirely in /admin/backup: destination, automatic daily start hour (UTC), retention counts and optional encryption. Supported targets are rsync, SFTP, SMB and WebDAV; for example sftp://backupuser:password@backup.example.com/exports/samba. URL-encode reserved characters in credentials. Stored destination passwords are never returned to the browser; the UI shows only the protocol, server and path. Removing the destination disables future backups without deleting remote history.
Backups include Private files, active and archived Data folders, FSLogix, persistent server configuration/access records and Samba private state. Both SQLite databases use integrity-checked online snapshots. The rebuildable document index and previews, and retained trash, are omitted. Originals remain unchanged. The UI provides manual start, progress, current transfers and logs. Configuration and key changes are blocked while a backup is running.
When encryption is enabled, all sources—including credentials and server state—are staged as AES-256 7z archives with encrypted filenames/headers. Only encrypted archives and public format/key identifiers are uploaded. Generate a 24-word recovery phrase and confirm you recorded it before activating the key. It is displayed once, never persisted as a phrase, and expires after 15 minutes if not confirmed. The server retains the derived key so unattended backups work; protect the state volume and the Docker host accordingly. Encrypted staging requires space for a complete compressed backup.
Key renewal creates a separate keys/<key-id>/snapshots/ generation. Existing backups stay in their previous location and require their previous phrase or legacy password. Retention affects only the active generation; older key generations are never pruned by a new key. Losing an old phrase or password makes that generation unrecoverable. Disabling encryption after using a generated key writes a separate plain/ generation, keeping encrypted history separate. Existing installations retain their previous backup format/password until encryption is deliberately enabled or renewed.
Retention defaults are 3 daily, 2 weekly, 2 monthly and 1 yearly snapshots. Each tier selects its newest eligible snapshots; the union is kept. Snapshot names are UTC timestamps, and an incomplete upload is not marked complete. A interrupted job is detected from the backup lock rather than shown as running indefinitely.
To recover a generated-key archive offline, use python3 app/restore_backup.py ARCHIVE.7z NEW_RECOVERY_DIRECTORY with Python and 7z installed. The tool prompts for the phrase without echoing it, derives the key and extracts only into a new directory. Inspect the files before copying anything into live volumes. It refuses to overwrite an existing recovery directory. Legacy archives still use their original archive password.
The versioned key format is adfs-backup-archive-v1: standard BIP39 English phrase/checksum and seed derivation (empty BIP39 passphrase), then PBKDF2-HMAC-SHA512 with that seed as the password, ASCII salt adfs-backup-archive-v1, one iteration, 32-byte output, lowercase hexadecimal. This becomes the archive password used by 7z's own AES-256 key derivation. The key identifier is the first 24 hexadecimal characters of SHA-256 of that ASCII password. The wordlist and license are bundled, so offline recovery does not depend on a network service.
Useful Commands
docker compose logs -f samba
docker compose logs -f samba | grep -E '\\[web\\]|\\[audit\\]'
docker compose exec samba python3 /app/reconcile_shares.py
docker compose exec samba python3 /app/run_service.py backup_to_destination.py
docker compose exec samba sqlite3 /state/shares.db 'PRAGMA quick_check;'
docker compose exec samba sqlite3 /state/shares.db 'SELECT action, count(*) FROM audit_events GROUP BY action;'
docker compose exec samba testparm -s
docker compose exec samba sh -lc 'tail -n 200 /var/log/samba/log.*'
docker compose exec samba sh -lc 'tail -n 200 /var/log/backup.log'
docker compose exec samba python3 -m json.tool /state/backup-status.json
docker compose exec samba python3 -m json.tool /state/reconcile-status.json
Troubleshooting
Domain join fails
-
Verify the stored domain-join/LDAP credentials in
/admin/settings. -
Verify DNS resolution from container:
docker compose exec samba getent hosts "$DOMAIN" -
Verify time sync on host and AD DCs.
-
Verify NetBIOS name length is <= 15:
docker compose exec samba testparm -s | grep -i 'netbios name'
AD DNS points at 172.x
-
This means Samba registered the container bridge IP.
-
Set the AD DNS registration address and name in
/admin/settings→ Server und DNS. -
Recreate/restart the container so startup re-registers AD DNS:
docker compose up -d --force-recreate samba
Winbind user/group resolution fails
-
Check trust:
docker compose exec samba wbinfo -t -
List users/groups:
docker compose exec samba wbinfo -u docker compose exec samba wbinfo -g
Data folders or access missing
-
Check Zugriffsverwaltung: the folder must be active, and the user must have an individual assignment.
-
Level 0 revokes access. Changes to AD
FS_*membership do not change imported individual assignments. -
Check the reconciliation status and logs if the one-time import or an ACL update fails:
docker compose exec samba python3 /app/reconcile_shares.py docker compose exec samba tail -n 100 /var/log/reconcile.log -
Inspect Windows ACLs with
smbcacls //server/Data '<folder>' -U 'DOMAIN\admin';getfacldoes not show the enforced Data permissions.
Data folder permissions are incorrect
-
Normal reconciliation avoids walking every file when the resolved ACL signature is unchanged.
-
Force a recursive repair for all active Data group folders with:
docker compose exec samba sh -lc 'REPAIR_DATA_ACLS=1 python3 /app/reconcile_shares.py' -
After a successful repair, later cron runs return to root-only Data ACL refreshes unless group ACLs change again.
Startup fails with Unsafe managed folder path: /data/groups/<GUID>
This indicates a legacy GUID directory still referenced by an already-migrated database. Update the application code/image and restart using the existing volumes:
docker compose stop samba
docker compose build samba
docker compose up -d --no-deps samba
docker compose logs --tail=100 samba
Startup repairs stored legacy paths without reimporting AD membership. It logs Migrated legacy folder without overwriting data for each completed move. Keep /state and all data volumes; do not remove volumes or reset the managed migration marker. If recovery reports a missing source or conflicting source/destination, both data paths remain untouched for inspection.
acl_xattr.so or full_audit.so module load error
-
If logs show
Error loading module .../vfs/acl_xattr.so(orfull_audit.so), your running image is missing Samba VFS modules. -
Rebuild and restart with the updated image:
docker compose down docker compose up -d --build -
Verify modules exist:
docker compose exec samba sh -lc 'mods="$(smbd -b | sed -n "s/^ *MODULESDIR: //p" | head -n1)/vfs"; ls -1 "$mods"/acl_xattr.so "$mods"/full_audit.so'
Permissions in Private share are incorrect
-
Re-run reconciliation to rebuild private directories and ACLs:
docker compose exec samba python3 /app/reconcile_shares.py -
Check identity resolution for a user:
docker compose exec samba id 'EXAMPLE\\alice'
Notes
- User data is never automatically deleted.
- Folders archived in the admin UI are moved to
/data/groups/archive; AD group deletion does not move folders. - Data and state survive container restarts via named Docker volumes (
/data/*,/state,/var/lib/samba).