use portunus from nixos-unstable

This commit is contained in:
Lyn Fugmann 2024-03-05 15:10:20 +01:00
parent 8e8cc54f75
commit 2d7ed61384
Signed by: fugi
GPG key ID: 4472A20091BFA792
7 changed files with 107 additions and 64 deletions

View file

@ -1,24 +1,26 @@
diff --git a/internal/core/user.go b/internal/core/user.go
index e74ccfe..291c75b 100644
--- a/internal/core/user.go
+++ b/internal/core/user.go
@@ -8,6 +8,7 @@ package core
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"
+ "strconv"
)
+ "regexp"
// User represents a single user account.
@@ -86,9 +87,9 @@ func (u User) RenderToLDAP(suffix string, allGroups map[string]Group) LDAPObject
"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}
}
+ var nonASCII = regexp.MustCompile("[^\\x00-\\x7F]")
if u.POSIX.GECOS == "" {
- obj.Attributes["gecos"] = []string{u.FullName()}
+ obj.Attributes["gecos"] = []string{strconv.QuoteToASCII(u.FullName())}
+ obj.Attributes["gecos"] = []string{nonASCII.ReplaceAllString(u.FullName(), "")}
} else {
- obj.Attributes["gecos"] = []string{u.POSIX.GECOS}
+ obj.Attributes["gecos"] = []string{strconv.QuoteToASCII(u.POSIX.GECOS)}
+ obj.Attributes["gecos"] = []string{nonASCII.ReplaceAllString(u.POSIX.GECOS, "")}
}
obj.Attributes["objectClass"] = append(obj.Attributes["objectClass"], "posixAccount")
}