diff options
Diffstat (limited to 'systemd/nslcd_systemd.go')
-rw-r--r-- | systemd/nslcd_systemd.go | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/systemd/nslcd_systemd.go b/systemd/nslcd_systemd.go index 106323c..c5c8c65 100644 --- a/systemd/nslcd_systemd.go +++ b/systemd/nslcd_systemd.go @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Luke Shumaker <lukeshu@sbcglobal.net> +// Copyright (C) 2015-2016 Luke Shumaker <lukeshu@sbcglobal.net> // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -34,15 +34,15 @@ package nslcd_systemd import ( "fmt" - "lukeshu.com/git/go/libnslcd.git/proto/server" - "lukeshu.com/git/go/libsystemd.git/sd_daemon" - "lukeshu.com/git/go/libsystemd.git/sd_daemon/logger" - "lukeshu.com/git/go/libsystemd.git/sd_daemon/lsb" "net" "os" "os/signal" "sync" "syscall" + + "lukeshu.com/git/go/libnslcd.git/proto/server" + sd "lukeshu.com/git/go/libsystemd.git/sd_daemon" + "lukeshu.com/git/go/libsystemd.git/sd_daemon/lsb" ) type Backend interface { @@ -84,14 +84,14 @@ func handler(conn *net.UnixConn, backend nslcd_server.Backend) { defer conn.Close() cred, err := getpeercred(conn) if err != nil { - logger.Debug("Connection from unknown client") + sd.Log.Debug("Connection from unknown client") } else { - logger.Debug("Connection from pid=%v uid=%v gid=%v", - cred.Pid, cred.Uid, cred.Gid) + sd.Log.Debug(fmt.Sprintf("Connection from pid=%v uid=%v gid=%v", + cred.Pid, cred.Uid, cred.Gid)) } err = nslcd_server.HandleRequest(backend, conn, conn, cred) if err != nil { - logger.Notice("Error while handling request: %v", err) + sd.Log.Notice(fmt.Sprintf("Error while handling request: %v", err)) } } @@ -105,16 +105,16 @@ func Main(backend Backend) uint8 { err = backend.Init() if err != nil { - logger.Err("Could not initialize backend: %v", err) - sd.Notify(false, "STOPPING=1") + sd.Log.Err(fmt.Sprintf("Could not initialize backend: %v", err)) + sd.Notify(0, false, "STOPPING=1", nil) return lsb.EXIT_FAILURE } defer backend.Close() socket, err := get_socket() if err != nil { - logger.Err("%v", err) - sd.Notify(false, "STOPPING=1") + sd.Log.Err(fmt.Sprintf("%v", err)) + sd.Notify(0, false, "STOPPING=1", nil) return lsb.EXIT_NOTRUNNING } defer socket.Close() @@ -124,7 +124,7 @@ func Main(backend Backend) uint8 { for { conn, err := socket.Accept() if err != nil { - logger.Notice("%v", err) + sd.Log.Notice(fmt.Sprintf("%v", err)) } if conn != nil { sock <- conn.(*net.UnixConn) @@ -134,23 +134,23 @@ func Main(backend Backend) uint8 { var wg sync.WaitGroup defer wg.Wait() - defer sd.Notify(false, "STOPPING=1") - sd.Notify(false, "READY=1") + defer sd.Notify(0, false, "STOPPING=1", nil) + sd.Notify(0, false, "READY=1", nil) for { select { case sig := <-sigs: switch sig { case syscall.SIGTERM: - logger.Notice("Received SIGTERM, shutting down") + sd.Log.Notice("Received SIGTERM, shutting down") return lsb.EXIT_SUCCESS case syscall.SIGHUP: - sd.Notify(false, "RELOADING=1") + sd.Notify(0, false, "RELOADING=1", nil) err := backend.Reload() if err != nil { - logger.Notice("Could not reload backend: %s", err.Error()) + sd.Log.Notice(fmt.Sprintf("Could not reload backend: %s", err.Error())) return lsb.EXIT_NOTRUNNING } - sd.Notify(false, "READY=1") + sd.Notify(0, false, "READY=1", nil) } case conn := <-sock: wg.Add(1) |