Skip to content
This repository has been archived by the owner on Jul 16, 2024. It is now read-only.

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add post create home hook for eos storage driver (cs3org#3234)
Browse files Browse the repository at this point in the history
gmgigi96 authored and vascoguita committed Oct 18, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent da22957 commit 76de64f
Showing 3 changed files with 22 additions and 1 deletion.
3 changes: 3 additions & 0 deletions changelog/unreleased/post-create-home-hook-eos.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Enhancement: Add post create home hook for eos storage driver

https://github.com/cs3org/reva/pull/3234
6 changes: 6 additions & 0 deletions pkg/storage/utils/eosfs/config.go
Original file line number Diff line number Diff line change
@@ -144,6 +144,9 @@ type Config struct {
// revisions-related operations.
ImpersonateOwnerforRevisions bool `mapstructure:"impersonate_owner_for_revisions"`

// Whether to enable the post create home hook
EnablePostCreateHomeHook bool `mapstructure:"enable_post_create_home_hook"`

// HTTP connections to EOS: max number of idle conns
MaxIdleConns int `mapstructure:"max_idle_conns"`

@@ -168,4 +171,7 @@ type Config struct {
// TokenExpiry stores in seconds the time after which generated tokens will expire
// Default is 3600
TokenExpiry int

// Path of the script to run after an user home folder has been created
OnPostCreateHomeHook string `mapstructure:"on_post_create_home_hook"`
}
14 changes: 13 additions & 1 deletion pkg/storage/utils/eosfs/eosfs.go
Original file line number Diff line number Diff line change
@@ -25,6 +25,7 @@ import (
"io"
"net/url"
"os"
"os/exec"
"path"
"regexp"
"strconv"
@@ -1480,7 +1481,13 @@ func (fs *eosfs) createNominalHome(ctx context.Context) error {
return err
}

return err
if fs.conf.EnablePostCreateHomeHook {
if err := fs.runPostCreateHomeHook(ctx); err != nil {
return errors.Wrap(err, "eosfs: error running post create home hook")
}
}

return nil
}

func (fs *eosfs) CreateHome(ctx context.Context) error {
@@ -1499,6 +1506,11 @@ func (fs *eosfs) CreateHome(ctx context.Context) error {
return nil
}

func (fs *eosfs) runPostCreateHomeHook(ctx context.Context) error {
user := ctxpkg.ContextMustGetUser(ctx)
return exec.Command(fs.conf.OnPostCreateHomeHook, user.Username).Run()
}

func (fs *eosfs) createUserDir(ctx context.Context, u *userpb.User, path string, recursiveAttr bool) error {
rootAuth, err := fs.getRootAuth(ctx)
if err != nil {

0 comments on commit 76de64f

Please sign in to comment.