Skip to content

Commit

Permalink
fix: permission mode of new node with minimum default acl (#4676)
Browse files Browse the repository at this point in the history
Signed-off-by: jiefenghuang <jiefeng@juicedata.io>
  • Loading branch information
jiefenghuang authored Apr 9, 2024
1 parent 063fb95 commit 12e64a9
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 10 deletions.
7 changes: 1 addition & 6 deletions pkg/meta/base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ func testACL(t *testing.T, m Meta) {
t.Fatalf("create %s: %s", subDir, st)
}
defer m.Rmdir(ctx, testDirIno, subDir2)
assert.Equal(t, uint16(0), attr2.Mode)

// subdir inherit default acl
rule3 = &aclAPI.Rule{}
Expand All @@ -386,12 +387,6 @@ func testACL(t *testing.T, m Meta) {
st = m.GetFacl(ctx, subDirIno2, aclAPI.TypeAccess, rule3)
assert.Equal(t, ENOATTR, st)

attr2 = &Attr{}
if st := m.GetAttr(ctx, subDirIno2, attr2); st != 0 {
t.Fatalf("getattr error: %s", st)
}
assert.Equal(t, rule.GetMode(), attr2.Mode)

// test cache all
sz := m.getBase().aclCache.Size()
err := m.getBase().en.cacheACLs(ctx)
Expand Down
2 changes: 1 addition & 1 deletion pkg/meta/random_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ func (m *fsMachine) create(_type uint8, parent Ino, name string, mode, umask uin

if rule.IsMinimal() {
// simple acl as default
n.mode = (mode & 0xFE00) | rule.GetMode()
n.mode = mode & (0xFE00 | rule.GetMode())
} else {
cRule := rule.ChildAccessACL(mode)
n.accACL = cRule
Expand Down
2 changes: 1 addition & 1 deletion pkg/meta/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -1255,7 +1255,7 @@ func (m *redisMeta) doMknod(ctx Context, parent Ino, name string, _type uint8, m

if rule.IsMinimal() {
// simple acl as default
attr.Mode = (mode & 0xFE00) | rule.GetMode()
attr.Mode = mode & (0xFE00 | rule.GetMode())
} else {
cRule := rule.ChildAccessACL(mode)
id, err := m.insertACL(ctx, tx, cRule)
Expand Down
2 changes: 1 addition & 1 deletion pkg/meta/sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -1335,7 +1335,7 @@ func (m *dbMeta) doMknod(ctx Context, parent Ino, name string, _type uint8, mode

if rule.IsMinimal() {
// simple acl as default
n.Mode = (mode & 0xFE00) | rule.GetMode()
n.Mode = mode & (0xFE00 | rule.GetMode())
} else {
cRule := rule.ChildAccessACL(mode)
id, err := m.insertACL(s, cRule)
Expand Down
2 changes: 1 addition & 1 deletion pkg/meta/tkv.go
Original file line number Diff line number Diff line change
Expand Up @@ -1147,7 +1147,7 @@ func (m *kvMeta) doMknod(ctx Context, parent Ino, name string, _type uint8, mode

if rule.IsMinimal() {
// simple acl as default
attr.Mode = (mode & 0xFE00) | rule.GetMode()
attr.Mode = mode & (0xFE00 | rule.GetMode())
} else {
cRule := rule.ChildAccessACL(mode)
id, err := m.insertACL(tx, cRule)
Expand Down

0 comments on commit 12e64a9

Please sign in to comment.