Commit Graph
23 Commits
Author SHA1 Message Date
Chris LuandClaude Opus 5.5 ebd90c3a45 fips140=only: SHA-256 in place of MD5 and SHA-1 so the server starts and serves S3 (#12855)
* util: SHA-256 stands in for MD5 and SHA-1 under fips140=only

GODEBUG=fips140=only panics on MD5 and SHA-1. NewMd5 and NewSha1 return
those hashes as before, and under fips140=only SHA-256 cut to the same
size, so digests keep their length. Md5, HashStringToLong and HashToInt32
use NewMd5.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* filer stores: hash directory keys with NewMd5 and NewSha1

leveldb2, leveldb3, rocksdb and arangodb hash directory keys with MD5,
tikv with SHA-1, which GODEBUG=fips140=only refuses, so the filer
panicked at startup. They now use util.NewMd5 and util.NewSha1.

Keys made under fips140=only differ from MD5 keys, so leveldb2 and
leveldb3 mark an empty database opened under fips140=only and refuse a
database whose keys are of the other kind instead of showing it empty.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* operation, volume: no Content-MD5 checks under fips140=only

Under GODEBUG=fips140=only the uploader's digest is not an MD5, so it is
no longer sent as Content-MD5, which volume servers outside that mode
would reject; the digest still becomes the chunk ETag. A Go volume
server in that mode keeps a client's Content-MD5 unchecked instead of
panicking.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* s3api, filer: ETags and content digests with util.NewMd5

ETags, entry Md5 attributes and chunk digests now use util.Md5 and
util.NewMd5, so under GODEBUG=fips140=only they are SHA-256 cut to 16
bytes instead of panicking. That digest cannot check a client's
Content-MD5, so in that mode Content-MD5 is accepted unchecked, and the
filer stops returning Content-MD5.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* s3api, iam, master: SHA-1 names with util.NewSha1

Multipart upload ids, IAM policy ids, the OIDC provider, audit and
session revocation file names, and the master's read-only copy dir hash
names with SHA-1. They now use util.NewSha1, which GODEBUG=fips140=only
turns into truncated SHA-256.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* postgres, oidc, update: refuse MD5 and SHA-1 checks under fips140=only

PostgreSQL md5 authentication, OIDC TLS thumbprints (SHA-1 by
definition) and weed update's MD5 check of the download cannot run
under GODEBUG=fips140=only. They now fail with an error saying so
instead of panicking.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* s3api: no empty-body MD5 when Content-MD5 is not checked

Under fips140=only a bodyless signed request still reached md5.Sum(nil)
before the nil check and panicked.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* s3api: empty copy part ETag from the digest it stores

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* util: skip the native MD5 test under fips140=only

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* s3sink: no Content-MD5 under fips140=only

The entry's Md5 attribute is truncated SHA-256 there, which an S3
destination checking Content-MD5 would reject.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* iam: move OIDC provider and revocation records to this mode's name

The record names hash the ARN or JTI with util.NewSha1, which differs
under GODEBUG=fips140=only. On the first use of a filer, each store
renames records whose name does not match the one derived from their
content, so lookups, revocation checks and deletes find records written
in the other mode.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* iam: test the rename with the names each fips140 mode derives

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* iam: rename a record only if it is unchanged, under its new name's lock

Two processes renaming after a mode switch could both list a record; if
one renamed it and the provider was then deleted, the other wrote it
back. The rename is now one filer transaction locked on the new name,
like the stores' conditional writes, that requires the old entry to be
unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 10:38:38 -08:00
7y-9 7bbd28634a fix(util): return full uint64 randomness (#9864)
Problem: RandomUint64 generated eight random bytes but returned int32, truncating the value before mount file and directory handles converted it to uint64. This reduced handle entropy to 32 bits and produced sign-extended handle values.\n\nRoot cause: the helper cast BytesToUint64 to int32 and exposed int32 as its return type.\n\nFix: make RandomUint64 return uint64 and return the full BytesToUint64 result.\n\nReproduction: go test ./weed/util -run TestRandomUint64ReturnsUint64 -count=1 failed before the fix because RandomUint64() had kind int32.\n\nValidation: gofmt -w weed/util/bytes.go weed/util/bytes_test.go; git diff --check; go test ./weed/util -run TestRandomUint64ReturnsUint64 -count=1; go test ./weed/util -count=1; go test ./weed/mount -count=1; git diff --cached --check
2026-06-08 22:07:24 -07:00
Chris Lu 65d557cbb0 fix(util): guard BytesToUint{16,32,64} against short input (#9713)
* fix(util): guard BytesToUint{16,32,64} against short input

length is computed as uint, so length-1 on an empty slice underflows
to MaxUint and the loop indexes b[0] on a zero-length slice. BytesToUint16
also indexed b[0]/b[1] with no length check. All call sites today gate
the slice length explicitly, so this hardens the API for new callers
rather than fixing a live crash.

Return 0 on short input, matching the existing variable-length contract.

* BytesToUint16: match variable-length contract of the 32/64 helpers

A 1-byte slice should return uint16(b[0]) rather than 0, matching how
BytesToUint32 and BytesToUint64 treat short input.
2026-05-27 11:29:01 -07:00
Chris Lu 995dfc4d5d chore: remove ~50k lines of unreachable dead code (#8913)
* chore: remove unreachable dead code across the codebase

Remove ~50,000 lines of unreachable code identified by static analysis.

Major removals:
- weed/filer/redis_lua: entire unused Redis Lua filer store implementation
- weed/wdclient/net2, resource_pool: unused connection/resource pool packages
- weed/plugin/worker/lifecycle: unused lifecycle plugin worker
- weed/s3api: unused S3 policy templates, presigned URL IAM, streaming copy,
  multipart IAM, key rotation, and various SSE helper functions
- weed/mq/kafka: unused partition mapping, compression, schema, and protocol functions
- weed/mq/offset: unused SQL storage and migration code
- weed/worker: unused registry, task, and monitoring functions
- weed/query: unused SQL engine, parquet scanner, and type functions
- weed/shell: unused EC proportional rebalance functions
- weed/storage/erasure_coding/distribution: unused distribution analysis functions
- Individual unreachable functions removed from 150+ files across admin,
  credential, filer, iam, kms, mount, mq, operation, pb, s3api, server,
  shell, storage, topology, and util packages

* fix(s3): reset shared memory store in IAM test to prevent flaky failure

TestLoadIAMManagerFromConfig_EmptyConfigWithFallbackKey was flaky because
the MemoryStore credential backend is a singleton registered via init().
Earlier tests that create anonymous identities pollute the shared store,
causing LookupAnonymous() to unexpectedly return true.

Fix by calling Reset() on the memory store before the test runs.

* style: run gofmt on changed files

* fix: restore KMS functions used by integration tests

* fix(plugin): prevent panic on send to closed worker session channel

The Plugin.sendToWorker method could panic with "send on closed channel"
when a worker disconnected while a message was being sent. The race was
between streamSession.close() closing the outgoing channel and sendToWorker
writing to it concurrently.

Add a done channel to streamSession that is closed before the outgoing
channel, and check it in sendToWorker's select to safely detect closed
sessions without panicking.
2026-04-03 16:04:27 -07:00
Konstantin Lebedev 01b3125815 [shell]: volume balance capacity by min volume density (#8026)
volume balance by min volume density and active volumes
2026-02-19 13:30:59 -08:00
chrislu 57dc39c451 randomizing next file handle id 2024-08-07 10:42:00 -07:00
bingoohuang cf552417a7 minFreeSpace refactored 2021-04-27 10:37:24 +08:00
bingoohuang 31f1cdeac2 minFreeSpace argument allows size like 10GiB 2021-04-26 18:48:34 +08:00
Chris Lu c31b254248 mount: shortcut when there is only one chunk 2020-10-20 23:48:29 -07:00
Chris Lu 1012df7bb5 switch hardlink id from int64 to bytes 2020-09-24 11:11:42 -07:00
Chris Lu 5e239afdfc hardlink works now 2020-09-24 03:06:48 -07:00
Chris Lu ca658a97c5 add signatures to messages to avoid double processing 2020-08-28 23:48:48 -07:00
Chris Lu e74dc4e4bc add back fs node cache for renaming 2020-08-09 21:56:09 -07:00
Chris Lu 20e2ac1add filer: store md5 metadata for files uploaded by filer
fix https://github.com/chrislusf/seaweedfs/issues/1412
2020-08-06 10:04:17 -07:00
bingoohuang accb4964b7 util.BytesToHumanReadable 2020-05-29 10:00:07 +08:00
Chris Lu 00b993a234 add util for md5 2020-04-08 22:30:38 -07:00
Chris Lu 50a5018b7f writing meta logs is working 2020-03-30 01:19:33 -07:00
Chris Lu 39edcfde4c filer: set inode
avoid "getcwd: No such file or directory"
2020-01-19 12:06:19 -08:00
Chris Lu 35d471a818 Revert "use std encoding lib" 2019-08-23 07:59:09 -07:00
divinerapier e798e4e9c5 use std encoding lib
Signed-off-by: divinerapier <poriter.coco@gmail.com>
2019-08-19 18:07:54 +08:00
Chris Lu 5ce6bbf076 directory structure change to work with glide
glide has its own requirements. My previous workaround caused me some
code checkin errors. Need to fix this.
2016-06-02 18:09:14 -07:00
Chris Lu 5071f528f6 testing compilation with remove package 2013-02-10 03:49:51 -08:00
Chris Lu ab6fb13ad7 avoid the "src" folder 2013-02-10 03:25:35 -08:00