From f11244ff80ae8b5db8bf7a964b4258e9541f3ce5 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 28 Aug 2024 12:41:03 +0200 Subject: [PATCH] do not diff between user and non user access --- .../http/services/owncloud/ocdav/ocdav.go | 18 +++++++-------- pkg/storage/fs/cephfs/connections.go | 13 ++++++----- pkg/storage/fs/cephfs/options.go | 22 +++++++++---------- pkg/storage/fs/cephfs/user.go | 10 +++------ 4 files changed, 30 insertions(+), 33 deletions(-) diff --git a/internal/http/services/owncloud/ocdav/ocdav.go b/internal/http/services/owncloud/ocdav/ocdav.go index 1f61a3ed2a..0b14453dfb 100644 --- a/internal/http/services/owncloud/ocdav/ocdav.go +++ b/internal/http/services/owncloud/ocdav/ocdav.go @@ -30,7 +30,6 @@ import ( "time" gateway "github.com/cs3org/go-cs3apis/cs3/gateway/v1beta1" - userpb "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1" "github.com/cs3org/reva/pkg/appctx" "github.com/cs3org/reva/pkg/errtypes" @@ -42,7 +41,6 @@ import ( "github.com/cs3org/reva/pkg/sharedconf" "github.com/cs3org/reva/pkg/storage/favorite" "github.com/cs3org/reva/pkg/storage/favorite/registry" - "github.com/cs3org/reva/pkg/storage/utils/templates" "github.com/cs3org/reva/pkg/utils/cfg" "github.com/pkg/errors" ) @@ -297,14 +295,16 @@ func applyLayout(ctx context.Context, ns string, useLoggedInUserNS bool, request // is not the same as the logged in user. In that case, we'll treat fileOwner // as the username whose files are to be accessed and use that in the // namespace template. - u, ok := appctx.ContextGetUser(ctx) - if !ok || !useLoggedInUserNS { - requestUserID, _ := router.ShiftPath(requestPath) - u = &userpb.User{ - Username: requestUserID, + /* + u, ok := appctx.ContextGetUser(ctx) + if !ok || !useLoggedInUserNS { + requestUserID, _ := router.ShiftPath(requestPath) + u = &userpb.User{ + Username: requestUserID, + } } - } - return templates.WithUser(u, ns) + return templates.WithUser(u, ns) + */ } func addAccessHeaders(w http.ResponseWriter, r *http.Request) { diff --git a/pkg/storage/fs/cephfs/connections.go b/pkg/storage/fs/cephfs/connections.go index cfc8f6bca0..6a04748e85 100644 --- a/pkg/storage/fs/cephfs/connections.go +++ b/pkg/storage/fs/cephfs/connections.go @@ -204,7 +204,7 @@ func newConn(user *User) *cacheVal { } if user != nil { //nil creates admin conn - fmt.Println("debugging new connection: ", user.UidNumber) + fmt.Println("creating admin connection: debugging new connection for user: ", user.UidNumber) perm = goceph.NewUserPerm(int(user.UidNumber), int(user.GidNumber), []int{}) if err = mount.SetMountPerms(perm); err != nil { return destroyCephConn(mount, perm) @@ -215,11 +215,14 @@ func newConn(user *User) *cacheVal { return destroyCephConn(mount, perm) } - if user != nil && !user.fs.conf.DisableHome { - if err = mount.ChangeDir(user.fs.conf.Root); err != nil { - return destroyCephConn(mount, perm) + // TODO(labkode): we leave the mount on the fs root + /* + if user != nil && !user.fs.conf.DisableHome { + if err = mount.ChangeDir(user.fs.conf.Root); err != nil { + return destroyCephConn(mount, perm) + } } - } + */ return &cacheVal{ perm: perm, diff --git a/pkg/storage/fs/cephfs/options.go b/pkg/storage/fs/cephfs/options.go index c33e76eb89..6f7290b47e 100644 --- a/pkg/storage/fs/cephfs/options.go +++ b/pkg/storage/fs/cephfs/options.go @@ -29,18 +29,16 @@ import ( // Options for the cephfs module type Options struct { - ClientID string `mapstructure:"client_id"` - Config string `mapstructure:"config"` - GatewaySvc string `mapstructure:"gatewaysvc"` - IndexPool string `mapstructure:"index_pool"` - Keyring string `mapstructure:"keyring"` - Root string `mapstructure:"root"` - ShadowFolder string `mapstructure:"shadow_folder"` - ShareFolder string `mapstructure:"share_folder"` - UploadFolder string `mapstructure:"uploads"` - UserLayout string `mapstructure:"user_layout"` - - DisableHome bool `mapstructure:"disable_home"` + ClientID string `mapstructure:"client_id"` + Config string `mapstructure:"config"` + GatewaySvc string `mapstructure:"gatewaysvc"` + IndexPool string `mapstructure:"index_pool"` + Keyring string `mapstructure:"keyring"` + Root string `mapstructure:"root"` + ShadowFolder string `mapstructure:"shadow_folder"` + ShareFolder string `mapstructure:"share_folder"` + UploadFolder string `mapstructure:"uploads"` + UserLayout string `mapstructure:"user_layout"` DirPerms uint32 `mapstructure:"dir_perms"` FilePerms uint32 `mapstructure:"file_perms"` UserQuotaBytes uint64 `mapstructure:"user_quota_bytes"` diff --git a/pkg/storage/fs/cephfs/user.go b/pkg/storage/fs/cephfs/user.go index 8e4ad666a7..c611aa4075 100644 --- a/pkg/storage/fs/cephfs/user.go +++ b/pkg/storage/fs/cephfs/user.go @@ -53,13 +53,9 @@ type User struct { func (fs *cephfs) makeUser(ctx context.Context) *User { u := appctx.ContextMustGetUser(ctx) - home := fs.conf.Root - if !fs.conf.DisableHome { - home = filepath.Join(fs.conf.Root, templates.WithUser(u, fs.conf.UserLayout)) - fmt.Println("debugging makeUser", home) - } - - fmt.Println("debugging makeUser user", home) + // home := fs.conf.Root + home = filepath.Join(fs.conf.Root, templates.WithUser(u, fs.conf.UserLayout)) + fmt.Println("debugging makeUser", home) return &User{u, fs, ctx, home} }