diff --git a/storage/bolt/users.go b/storage/bolt/users.go index 33f67abb..f37b707b 100644 --- a/storage/bolt/users.go +++ b/storage/bolt/users.go @@ -4,6 +4,7 @@ import ( "errors" "fmt" "reflect" + "regexp" "github.com/asdine/storm/v3" "github.com/asdine/storm/v3/q" @@ -44,7 +45,11 @@ func (st usersBackend) GetBy(i interface{}) (user *users.User, err error) { func (st usersBackend) GetByScope(scope string) (*users.User, error) { user := &users.User{} - err := st.db.Select(q.Eq("Scope", scope)).First(user) + // Match case-insensitively: on a case-insensitive filesystem two scopes + // that differ only in case (e.g. /users/Alice and /users/alice) resolve to + // the same home directory, so they must be treated as a collision. + pattern := "(?i)^" + regexp.QuoteMeta(scope) + "$" + err := st.db.Select(q.Re("Scope", pattern)).First(user) if err != nil { if errors.Is(err, storm.ErrNotFound) { return nil, fberrors.ErrNotExist