Skip to content

Commit

Permalink
Add no_set_xattr flag
Browse files Browse the repository at this point in the history
  • Loading branch information
iychoi committed Dec 15, 2023
1 parent b7c1659 commit 2f21a34
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cmd/commons/args.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ func SetCommonFlags(command *cobra.Command) {
command.Flags().Duration("metadata_cache_timeout", commons.MetadataCacheTimeoutDefault, "Set file system metadata cache timeout")
command.Flags().Duration("metadata_cache_cleanup_time", commons.MetadataCacheCleanupTimeDefault, "Set file system metadata cache cleanup time")
command.Flags().Bool("no_permission_check", false, "Disable permission check for performance")
command.Flags().Bool("no_set_xattr", false, "Disable set xattr")
command.Flags().Bool("no_transaction", false, "Disable transaction for performance")

command.Flags().Int("uid", -1, "Set UID of file/directory owner")
Expand Down Expand Up @@ -485,6 +486,12 @@ func ProcessCommonFlags(command *cobra.Command, args []string) (*commons.Config,
config.NoPermissionCheck = noPermissionCheck
}

noSetXattrFlag := command.Flags().Lookup("no_set_xattr")
if noSetXattrFlag != nil {
noSetXattr, _ := strconv.ParseBool(noSetXattrFlag.Value.String())
config.NoSetXattr = noSetXattr
}

noTransactionFlag := command.Flags().Lookup("no_transaction")
if noTransactionFlag != nil {
noTransaction, _ := strconv.ParseBool(noTransactionFlag.Value.String())
Expand Down
2 changes: 2 additions & 0 deletions commons/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ type Config struct {
Resource string `yaml:"resource,omitempty"`
PathMappings []irodsfs_common_vpath.VPathMapping `yaml:"path_mappings"`
NoPermissionCheck bool `yaml:"no_permission_check"`
NoSetXattr bool `yaml:"no_set_xattr"`
UID int `yaml:"uid"`
GID int `yaml:"gid"`
SystemUser string `yaml:"system_user"`
Expand Down Expand Up @@ -131,6 +132,7 @@ func NewDefaultConfig() *Config {
Resource: "",
PathMappings: []irodsfs_common_vpath.VPathMapping{},
NoPermissionCheck: false,
NoSetXattr: false,
UID: uid,
GID: gid,
SystemUser: systemUser,
Expand Down
4 changes: 4 additions & 0 deletions irodsfs/dir.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,10 @@ func (dir *Dir) Setxattr(ctx context.Context, attr string, data []byte, flags ui
logger.Infof("Calling Setxattr (%d) - %q", operID, dir.path)
defer logger.Infof("Called Setxattr (%d) - %q", operID, dir.path)

if dir.fs.config.NoSetXattr {
return syscall.EACCES
}

if IsUnhandledAttr(attr) {
return syscall.EACCES
}
Expand Down
4 changes: 4 additions & 0 deletions irodsfs/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,10 @@ func (file *File) Setxattr(ctx context.Context, attr string, data []byte, flags
logger.Infof("Calling Setxattr (%d) - %q", operID, file.path)
defer logger.Infof("Called Setxattr (%d) - %q", operID, file.path)

if file.fs.config.NoSetXattr {
return syscall.EACCES
}

if IsUnhandledAttr(attr) {
return syscall.EINVAL
}
Expand Down

0 comments on commit 2f21a34

Please sign in to comment.