File tree 1 file changed +18
-5
lines changed 1 file changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -43,13 +43,26 @@ func hasPermissionToDir(info os.FileInfo) bool {
43
43
return true
44
44
}
45
45
46
+ // Group perms only apply if you're not the owner of the directory.
46
47
gid , _ := strconv .Atoi (user .Gid )
47
- // other users in group (g)
48
- if perm & 0o010 != 0 && st .Uid != uint32 (uid ) && st .Gid == uint32 (gid ) {
49
- return true
48
+ inGroup := st .Gid == uint32 (gid )
49
+ if st .Uid != uint32 (uid ) {
50
+ gids , _ := user .GroupIds ()
51
+ for _ , gid := range gids {
52
+ gid , _ := strconv .Atoi (gid )
53
+ if st .Gid == uint32 (gid ) {
54
+ // other users in group (g)
55
+ if perm & 0o010 != 0 {
56
+ return true
57
+ }
58
+ inGroup = true
59
+ }
60
+ }
50
61
}
51
- // remaining users (o)
52
- if perm & 0o001 != 0 && st .Uid != uint32 (uid ) && st .Gid != uint32 (gid ) {
62
+
63
+ // remaining users (o) -- only apply if you're not the owner and none of
64
+ // your groups match its group.
65
+ if perm & 0o001 != 0 && st .Uid != uint32 (uid ) && ! inGroup {
53
66
return true
54
67
}
55
68
You can’t perform that action at this time.
0 commit comments