Skip to content

Commit ae0d8d9

Browse files
Gustedzeripath
Gusted
andauthored
Let MinUnitAccessMode return correct perm (#18675)
- Don't let `TypeExternalTracker` or `TypeExternalWiki` influence the minimal permission, as they won't be higher than read. So even if all the other ones are write, these 2 will ensure that's not higher than read. - Partially resolves #18572 (Point 1,2,5?) Co-authored-by: zeripath <[email protected]>
1 parent f8b21ac commit ae0d8d9

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

models/unit/unit.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,12 @@ func AllUnitKeyNames() []string {
328328
// MinUnitAccessMode returns the minial permission of the permission map
329329
func MinUnitAccessMode(unitsMap map[Type]perm.AccessMode) perm.AccessMode {
330330
res := perm.AccessModeNone
331-
for _, mode := range unitsMap {
331+
for t, mode := range unitsMap {
332+
// Don't allow `TypeExternal{Tracker,Wiki}` to influence this as they can only be set to READ perms.
333+
if t == TypeExternalTracker || t == TypeExternalWiki {
334+
continue
335+
}
336+
332337
// get the minial permission great than AccessModeNone except all are AccessModeNone
333338
if mode > perm.AccessModeNone && (res == perm.AccessModeNone || mode < res) {
334339
res = mode

0 commit comments

Comments
 (0)