94 Commits
Author SHA1 Message Date
Nicola Murino 55e443d29e drop the dead nolint directives
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
2026-09-09 12:37:54 +02:00
Nicola Murino 80383acf38 dataprovider: refuse the login if a group setting uses %role% without a role
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
2026-09-06 17:30:33 +02:00
Nicola Murino ffeec76674 webdav: return the correct ETag after upload, or no ETag if unavailable
Fixes #2282

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
2026-08-27 15:27:27 +02:00
Nicola Murino fb4558540d guard the state the servers publish while they initialize
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
2026-08-24 21:31:36 +02:00
Nicola Murino b4698f1f4d dataprovider: refuse to delete referenced folders, roles and groups
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
2026-08-24 18:27:56 +02:00
Nicola Murino d54965865e replace golangci-lint with staticcheck, errcheck and unparam
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
2026-08-24 15:07:16 +02:00
Nicola Murino d389a3b048 common: apply the name filter wherever a directory is created
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
2026-08-12 21:56:15 +02:00
Nicola Murino db5cda1388 webdavd: key the user cache on the stored username
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
2026-08-12 21:17:07 +02:00
Nicola Murino 0da768877c dataprovider: apply the anonymous restrictions at runtime
they were applied during the validation

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
2026-08-12 21:13:05 +02:00
Nicola Murino 6cce58233c virtual folders: add subpath support
A virtual folder mapping can now re-root the mount onto a sub-path of
the folder: the mount at the virtual path serves the folder starting
from the configured subpath, which stays invisible in the virtual tree.
The same folder can be mapped multiple times with distinct subpaths;
quota remains a property of the whole folder, so every mapping must use
the same limits.

Supported for local, encrypted, S3, GCS, Azure Blob and SFTP folders.

Fixes #2037

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
2026-07-18 16:19:43 +02:00
Nicola Murino bafb7e7d6a modernize the codebase to current Go idioms
Apply the fixes suggested by the modernize analyzers enabled by
default in gopls v0.23: range over int, errors.AsType, min/max,
slices.Backward/Contains, maps.Copy, strings.Cut/CutPrefix/CutSuffix/
SplitSeq, fmt.Appendf, WaitGroup.Go and b.Loop in tests, new(expr)
instead of to.Ptr, removal of ineffective omitempty tags on nested
struct fields.

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
2026-07-13 20:52:29 +02:00
Nicola Murino 13c9f698c9 fix error detection for HTTP and WebDAV uploads
Fixes #2260

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
2026-07-09 17:27:49 +02:00
Nicola Murino efb80ff44d test: remove the user before the home dir in the remaining cleanups
The previous commit fixed the test cases failing on Windows, but which
cleanup loses the race is not deterministic: a client disconnection is
processed after the client returns, so removing the home dir before
deleting the user fails if the connection still holds the fs root when
os.RemoveAll runs. TestResume passed in one CI run and failed in the
next one on the same unchanged code.

Swap the order in all the remaining cleanups: deleting the user first
disconnects it and httpdtest.RemoveUser waits for its connections to be
removed, so the fs roots are released before the home dir removal.

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
2026-07-06 19:20:59 +02:00
Nicola Murino 7d7a6e6217 test: release the fs roots before removing the test home dirs
On Windows the home dir cannot be removed while a filesystem root is
open

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
2026-07-06 18:48:38 +02:00
Nicola Murino 661d77f47b vfs: migrate OsFs/CryptFs to os.Root and remove temp_path
Confine all local filesystem access to an os.Root, with path resoultion
enforced by the underlying OS.

Behavior changes an upgrading deployment may notice:

- temp_path is removed and ignored if still configured. Its purpose
  was to stage files (atomic uploads, scratch and streaming data)
  outside the user's storage and rename them into place, and that is
  fundamentally incompatible with the confinement: an os.Root cannot
  rename a file in from outside the root, so every staged upload would
  degrade to a full copy-then-delete even when temp_path is on the
  same filesystem, defeating the very atomicity the option existed to
  provide. It was not a great idea before this change either: a
  temp_path on a different device already turned the final rename into
  a silent full copy. Staged and scratch files (the atomic upload
  temporary, the CryptFs download pipe backing file) now live in the
  storage root itself, on the same filesystem as the data, so the
  final rename stays atomic.

- Cross-folder / cross-root renames are no longer atomic. A rename
  spanning the home and a local virtual folder, or two local folders,
  falls back to copy-then-delete: slower for large data even on the
  same device, and a midway failure can leave a partial tree at the
  destination. Symlinks and other non-regular entries inside a moved
  directory are skipped, not copied, and the rename still reports
  success. File mode bits are not preserved; regular files keep their
  modification time, directories do not.

- Absolute symlinks created outside SFTPGo, or by versions predating
  this change, are no longer traversable and Readlink rejects them with
  permission denied, even when the target is inside the root: os.Root
  refuses an absolute link target regardless of where it points.
  Symlinks created through SFTPGo are stored relative to the link
  directory and keep working.

- Execute-only home directories (e.g. mode 0111) are unusable:
  os.OpenRoot requires read permission, so every operation fails with
  permission denied until the directory is made readable, where
  previously only the listing failed. Since the root open is retried on
  demand, fixing the permissions (or creating a missing home
  externally) makes the same connection work again without
  reconnecting.

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
2026-07-06 13:08:12 +02:00
Nicola Murino 8f23f217b8 fix symlink test cases
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
2026-06-20 22:03:33 +02:00
Nicola Murino fa9c047619 Add dedicated setting to control symlink creation
Symlink creation is now disabled by default

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
2026-06-20 20:46:50 +02:00
Nicola Murino bf4b8f3446 remove some premature optimizations
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
2026-06-08 12:56:38 +02:00
Nicola Murino 02e312f39c fs: enforce a configurable minimum entropy for data-encryption secrets
The CryptFs passphrase and the S3 SSE-C key are used directly as
data-at-rest encryption key material, yet they were accepted with no
strength check, so an operator could protect encrypted data with a
trivially guessable secret.

Add common.secret_min_entropy (default 80): when one of these
secrets is submitted in plain text it must pass a minimum-entropy
check before it is encrypted and stored. The check runs on
plain-text input, so secrets that are already stored keep working even
if the threshold is later raised. The estimate is a heuristic used to
reject obviously weak input, not a measure of cryptographic strength:
always supply key material generated by a CSPRNG.

Thanks to Vishal Shukla (@shukla304) for the report.

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
2026-05-18 19:46:19 +02:00
Nicola Murino 4bf1090bd3 transfers: count per-host transfer limit per client IP, not per user
Fixes #2237

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
2026-05-18 18:00:42 +02:00
Nicola Murino e3b2780655 webdav: ignore port for unix domain sockets
Fixes #2151

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
2026-01-24 10:32:11 +01:00
Nicola Murino ddbe40cefa HTTPD, WebDAV: use http.ResponseController
backport from Enterprise edition

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
2025-08-02 18:00:45 +02:00
Nicola Murino 0265c4c4a1 update deps
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
2025-05-31 20:30:58 +02:00
Nicola Murino 2255c5f000 upgrade golangci-lint to v2
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
2025-03-29 11:36:19 +01:00
Nicola Murino bf0961458c remove some unnecessary string conversions
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
2025-01-04 11:58:37 +01:00
Nicola Murino e21c989038 logs: add a specific log structure for successful logins
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
2024-12-07 10:29:33 +01:00
Nicola Murino 0f073a40fd logger: add cipher suite
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
2024-11-13 18:33:07 +01:00
Nicola Murino ae1487d733 fix connection limits
an SFTP client can start multiple transfers on a single connection

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
2024-10-26 21:18:19 +02:00
Nicola Murino dc42680e1c add pipeReaderAt and pipeWriterAt interfaces
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
2024-08-25 17:35:28 +02:00
Nicola Murino 2fbf608895 S3: add SSE customer key
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
2024-08-15 10:09:06 +02:00
Nicola Murino d783ffc13f fix new lint warnings
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
2024-08-14 08:46:18 +02:00
Nicola Murino 68e62d3d9b httpd: allow to use proxy protocol
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
2024-08-10 21:02:38 +02:00
Nicola Murino 81433e00d1 event action: add update modtime to fs rename
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
2024-08-09 20:18:33 +02:00
Nicola Murino d94f80c8da replace utils.Contains with slices.Contains
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
2024-07-24 18:27:13 +02:00
Nicola Murino fef388d8cb don't track quota for private virtual folders
they are included within the user quota.
This is a backward incompatible change.

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
2024-07-13 21:02:40 +02:00
Nicola Murino 92849ca473 quota: move user and folder management to a common method
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
2024-07-13 19:30:40 +02:00
Nicola Murino 1d60505629 fix test case failure on macOS with bolt provider
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
2024-06-19 10:45:14 +02:00
Nicola Murino 50a3c0d911 defender: allow to impose a delay between login attempts
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
2024-05-18 10:35:54 +02:00
Nicola Murino 5d24d665bd add an util method to convert []byte to string
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
2024-05-08 19:01:58 +02:00
Nicola Murino d3f42e39db move server version setting to common section
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
2024-05-01 19:42:09 +02:00
Nicola Murino 456517af87 notifier plugin: add support for login succeeded events
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
2024-04-10 18:39:08 +02:00
Nicola Murino ad75543172 fix some new lint warnings
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
2024-02-15 21:13:45 +01:00
Nicola Murino 1ff55bbfa7 add DirLister interface
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
2024-02-15 20:53:56 +01:00
Nicola Murino eec9c449d4 vfs: make PipeReader an interface
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
2024-01-24 19:59:50 +01:00
Nicola Murino d939a82225 user: add TLS certificates
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
2024-01-14 21:36:23 +01:00
Nicola Murino 113724f340 Merge branch 'main' of github.com:drakkan/sftpgo
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
2024-01-10 20:01:54 +01:00
Nicola Murino 9cde0909b0 test cases: replace expired TLS certificates
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
2024-01-10 19:53:48 +01:00
Nicola Murino 784b7585c1 remove end year from Copyright notice in files
so we don't have to update all the files every year

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
2024-01-01 11:31:45 +01:00
Nicola Murino 7da5d8fcea config: rename protocols to tls_protocols
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
2023-10-28 12:42:05 +02:00
Nicola Murino 4a15775f65 allow to configure ALPN protocols
Fixes #1406

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
2023-10-28 12:35:26 +02:00