Skip to content

Commit

Permalink
always enable home creation for users
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed Aug 28, 2024
1 parent f645a9b commit f6af641
Showing 1 changed file with 16 additions and 35 deletions.
51 changes: 16 additions & 35 deletions pkg/storage/fs/cephfs/cephfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,22 +89,13 @@ func New(ctx context.Context, m map[string]interface{}) (fs storage.FS, err erro
}

func (fs *cephfs) GetHome(ctx context.Context) (string, error) {
if fs.conf.DisableHome {
return "", errtypes.NotSupported("cephfs: GetHome disabled by config")
}

log := appctx.GetLogger(ctx)
user := fs.makeUser(ctx)

log.Debug().Interface("user", user).Msg("GetHome for user")
return user.home, nil
}

func (fs *cephfs) CreateHome(ctx context.Context) (err error) {
if fs.conf.DisableHome {
return errtypes.NotSupported("cephfs: CreateHome disabled by config")
}

log := appctx.GetLogger(ctx)

user := fs.makeUser(ctx)
Expand All @@ -119,37 +110,27 @@ func (fs *cephfs) CreateHome(ctx context.Context) (err error) {

log.Debug().Interface("stat", stat).Msgf("home is %s")

// TODO: create home only on: no such file or directory error
return nil
// TODO(labkode): for now we always try to create the home directory even if it exists.
// One needs to check for "no such of file or directory" error to short-cut.

/*
err = walkPath(user.home, func(path string) error {
return fs.adminConn.adminMount.MakeDir(path, fs.conf.DirPerms)
}, false)
if err != nil {
return getRevaError(err)
}
err = fs.adminConn.adminMount.Chown(user.home, uint32(user.UidNumber), uint32(user.GidNumber))
if err != nil {
return getRevaError(err)
}
err = fs.adminConn.adminMount.SetXattr(user.home, "ceph.quota.max_bytes", []byte(fmt.Sprint(fs.conf.UserQuotaBytes)), 0)
if err != nil {
return getRevaError(err)
}
err = walkPath(user.home, func(path string) error {
return fs.adminConn.adminMount.MakeDir(path, fs.conf.DirPerms)
}, false)
if err != nil {
return getRevaError(err)
}

user.op(func(cv *cacheVal) {
err = cv.mount.MakeDir(removeLeadingSlash(fs.conf.ShareFolder), fs.conf.DirPerms)
if err != nil && err.Error() == errFileExists {
err = nil
}
})
err = fs.adminConn.adminMount.Chown(user.home, uint32(user.UidNumber), uint32(user.GidNumber))
if err != nil {
return getRevaError(err)
}

err = fs.adminConn.adminMount.SetXattr(user.home, "ceph.quota.max_bytes", []byte(fmt.Sprint(fs.conf.UserQuotaBytes)), 0)
if err != nil {
return getRevaError(err)
*/
}

return nil
}

func (fs *cephfs) CreateDir(ctx context.Context, ref *provider.Reference) error {
Expand Down

0 comments on commit f6af641

Please sign in to comment.