From e2352d510f8282771753625cba322dbf0b0020d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=20Luka=20=C5=A0ijanec?= Date: Thu, 6 Jun 2024 18:48:38 +0200 Subject: listen on custom network (ex. unix socket) --- main.go | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'main.go') diff --git a/main.go b/main.go index 9685b3e..bc83365 100644 --- a/main.go +++ b/main.go @@ -7,7 +7,7 @@ import ( "fmt" "github.com/msteinert/pam" "github.com/nmcclain/asn1-ber" - "github.com/nmcclain/ldap" + "4a.si/ldap" "log" "net" "os" @@ -19,12 +19,13 @@ type Backend struct { ldap.Binder ldap.Searcher ldap.Closer - logger *log.Logger - Listen string - PAMServiceName string - PeopleDN string - GroupsDN string - BindAdminDN string + logger *log.Logger + Listen string + Network string + PAMServiceName string + PeopleDN string + GroupsDN string + BindAdminDN string BindAdminPassword string } @@ -33,6 +34,7 @@ func main() { var logfile = flag.String("l", "", "Log file (STDOUT if blank)") flag.Parse() var backend = Backend{} + backend.Network = "tcp" { confighandle, err := os.Open(*configfile) if err != nil { @@ -74,8 +76,8 @@ func main() { l.BindFunc("", backend) l.SearchFunc("", backend) l.CloseFunc("", backend) - backend.logger.Printf("LDAP server listen: %s", backend.Listen) - if err := l.ListenAndServe(backend.Listen); err != nil { + backend.logger.Printf("LDAP server listen: %s, network %s", backend.Listen, backend.Network) + if err := l.ListenAndServe(backend.Listen, backend.Network); err != nil { backend.logger.Printf("LDAP server listen failed: %s", err.Error()) os.Exit(1) } -- cgit v1.2.3