fruitbasket/modules/ldap/0003-gecos-ascii-escape.patch

27 lines
935 B
Diff
Raw Normal View History

2024-03-05 15:10:20 +01:00
diff --git a/internal/ldap/object.go b/internal/ldap/object.go
index d4e5c6f..fcefec7 100644
--- a/internal/ldap/object.go
+++ b/internal/ldap/object.go
@@ -8,6 +8,7 @@ package ldap
import (
"fmt"
2024-03-05 15:10:20 +01:00
+ "regexp"
2024-03-05 15:10:20 +01:00
"github.com/majewsky/portunus/internal/core"
)
@@ -94,10 +95,11 @@ func renderUser(u core.User, dnSuffix string, allGroups []core.Group) Object {
if u.POSIX.LoginShell != "" {
obj.Attributes["loginShell"] = []string{u.POSIX.LoginShell}
}
2024-03-05 15:10:20 +01:00
+ var nonASCII = regexp.MustCompile("[^\\x00-\\x7F]")
if u.POSIX.GECOS == "" {
- obj.Attributes["gecos"] = []string{u.FullName()}
2024-03-05 15:10:20 +01:00
+ obj.Attributes["gecos"] = []string{nonASCII.ReplaceAllString(u.FullName(), "")}
} else {
- obj.Attributes["gecos"] = []string{u.POSIX.GECOS}
2024-03-05 15:10:20 +01:00
+ obj.Attributes["gecos"] = []string{nonASCII.ReplaceAllString(u.POSIX.GECOS, "")}
}
obj.Attributes["objectClass"] = append(obj.Attributes["objectClass"], "posixAccount")
}