don't allow admins to change their own permissions

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
Nicola Murino
2024-11-09 20:24:35 +01:00
parent 30fb1d6240
commit ef98ee7d11
7 changed files with 24 additions and 33 deletions

View File

@@ -40,6 +40,7 @@ import (
"path/filepath"
"regexp"
"runtime"
"slices"
"strconv"
"strings"
"time"
@@ -127,18 +128,6 @@ var bytesSizeTable = map[string]uint64{
"e": eByte,
}
// Remove removes an element from a string slice and
// returns the modified slice
func Remove(elems []string, val string) []string {
for idx, v := range elems {
if v == val {
elems[idx] = elems[len(elems)-1]
return elems[:len(elems)-1]
}
}
return elems
}
// IsStringPrefixInSlice searches a string prefix in a slice and returns true
// if a matching prefix is found
func IsStringPrefixInSlice(obj string, list []string) bool {
@@ -921,3 +910,18 @@ func ReadConfigFromFile(name, configDir string) (string, error) {
}
return strings.TrimSpace(BytesToString(val)), nil
}
// SlicesEqual checks if the provided slices contain the same elements,
// also in different order.
func SlicesEqual(s1, s2 []string) bool {
if len(s1) != len(s2) {
return false
}
for _, v := range s1 {
if !slices.Contains(s2, v) {
return false
}
}
return true
}