From 7fdb6f9218723ebc3fab7e72068fe5e3611a5d0f Mon Sep 17 00:00:00 2001 From: Fugi Date: Fri, 1 Sep 2023 00:14:41 +0200 Subject: [PATCH] portunus: add patch to fix non-ascii character bug --- modules/ldap/0003-gecos-ascii-escape.patch | 24 ++++++++++++++++++++++ modules/ldap/default.nix | 1 + 2 files changed, 25 insertions(+) create mode 100644 modules/ldap/0003-gecos-ascii-escape.patch diff --git a/modules/ldap/0003-gecos-ascii-escape.patch b/modules/ldap/0003-gecos-ascii-escape.patch new file mode 100644 index 0000000..c3918cb --- /dev/null +++ b/modules/ldap/0003-gecos-ascii-escape.patch @@ -0,0 +1,24 @@ +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 + + import ( + "fmt" ++ "strconv" + ) + + // User represents a single user account. +@@ -86,9 +87,9 @@ func (u User) RenderToLDAP(suffix string, allGroups map[string]Group) LDAPObject + obj.Attributes["loginShell"] = []string{u.POSIX.LoginShell} + } + if u.POSIX.GECOS == "" { +- obj.Attributes["gecos"] = []string{u.FullName()} ++ obj.Attributes["gecos"] = []string{strconv.QuoteToASCII(u.FullName())} + } else { +- obj.Attributes["gecos"] = []string{u.POSIX.GECOS} ++ obj.Attributes["gecos"] = []string{strconv.QuoteToASCII(u.POSIX.GECOS)} + } + obj.Attributes["objectClass"] = append(obj.Attributes["objectClass"], "posixAccount") + } diff --git a/modules/ldap/default.nix b/modules/ldap/default.nix index 4e14c1c..7766f6a 100644 --- a/modules/ldap/default.nix +++ b/modules/ldap/default.nix @@ -59,6 +59,7 @@ in patches = [ ./0001-update-user-validation-regex.patch ./0002-both-ldap-and-ldaps.patch + ./0003-gecos-ascii-escape.patch ]; });