Skip to content

Commit

Permalink
do not diff between user and non user access
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed Aug 28, 2024
1 parent f6af641 commit f11244f
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 33 deletions.
18 changes: 9 additions & 9 deletions internal/http/services/owncloud/ocdav/ocdav.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
)
Expand Down Expand Up @@ -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) {
Expand Down
13 changes: 8 additions & 5 deletions pkg/storage/fs/cephfs/connections.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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,
Expand Down
22 changes: 10 additions & 12 deletions pkg/storage/fs/cephfs/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
10 changes: 3 additions & 7 deletions pkg/storage/fs/cephfs/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
}

Expand Down

0 comments on commit f11244f

Please sign in to comment.