Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

isReadableByUser logic change #71

Merged
merged 3 commits into from
Jan 2, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions server/irods.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import (
"github.com/cyverse/go-irodsclient/config"
ifs "github.com/cyverse/go-irodsclient/fs"
"github.com/cyverse/go-irodsclient/irods/types"
"github.com/cyverse/go-irodsclient/irods/util"
"github.com/rs/zerolog"
)

Expand Down Expand Up @@ -203,14 +202,10 @@ func NewIRODSAccount(logger zerolog.Logger, manager *config.ICommandsEnvironment
func IsReadableByUser(logger zerolog.Logger, filesystem *ifs.FileSystem,
userName string, userZone string, rodsPath string) (_ bool, err error) {
var acl []*types.IRODSAccess
var pathZone string

if acl, err = filesystem.ListACLs(rodsPath); err != nil {
return false, err
}
if pathZone, err = util.GetIRODSZone(rodsPath); err != nil {
return false, err
}

var userGroups []*types.IRODSUser
userGroups, err = filesystem.ListUserGroups(userName)
Expand Down Expand Up @@ -248,7 +243,7 @@ func IsReadableByUser(logger zerolog.Logger, filesystem *ifs.FileSystem,

// There is permission directly for the user
if ac.UserType == types.IRODSUserRodsUser || ac.UserType == types.IRODSUserRodsAdmin {
if effectiveUserZone == pathZone && ac.UserName == userName && (hasRead || hasOwn) {
if effectiveUserZone == userZone && ac.UserName == userName && (hasRead || hasOwn) {
logger.Trace().
Str("path", rodsPath).
Str("user", userName).
Expand All @@ -269,7 +264,6 @@ func IsReadableByUser(logger zerolog.Logger, filesystem *ifs.FileSystem,
Str("zone", userZone).
Str("ac_user", ac.UserName).
Str("effective_zone", effectiveUserZone).
Str("path_zone", pathZone).
Str("ac_level", string(ac.AccessLevel)).
Bool("read", hasRead).
Bool("own", hasOwn).
Expand All @@ -281,7 +275,7 @@ func IsReadableByUser(logger zerolog.Logger, filesystem *ifs.FileSystem,
// Check if user in the group of this AC (ac.UserName is the name of the AC's group, unfortunately)
_, userInGroup := userGroupLookup[ac.UserName]

if effectiveUserZone == pathZone && userInGroup && (hasRead || hasOwn) {
if effectiveUserZone == userZone && userInGroup && (hasRead || hasOwn) {
logger.Trace().
Str("path", rodsPath).
Str("user", userName).
Expand Down
Loading