summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--nslcd_proto/io.go11
-rwxr-xr-xnslcd_server/func_handlerequest.go.gen6
-rwxr-xr-xnslcd_server/interface_backend.go.gen7
-rwxr-xr-xnslcd_server/type_nilbackend.go.gen5
-rw-r--r--nslcd_systemd/nslcd_systemd.go12
5 files changed, 20 insertions, 21 deletions
diff --git a/nslcd_proto/io.go b/nslcd_proto/io.go
index fa40be3..9252aca 100644
--- a/nslcd_proto/io.go
+++ b/nslcd_proto/io.go
@@ -23,7 +23,8 @@ import (
"io"
"net"
"reflect"
- "syscall"
+
+ "golang.org/x/sys/unix"
)
type NslcdError string
@@ -72,9 +73,9 @@ func Write(fd io.Writer, data interface{}) {
var af int32 = -1
switch len(data) {
case net.IPv4len:
- af = syscall.AF_INET
+ af = unix.AF_INET
case net.IPv6len:
- af = syscall.AF_INET6
+ af = unix.AF_INET6
}
var bytes []byte
if af < 0 {
@@ -141,9 +142,9 @@ func Read(fd io.Reader, data interface{}) {
Read(fd, &af)
var _len int32
switch af {
- case syscall.AF_INET:
+ case unix.AF_INET:
_len = net.IPv4len
- case syscall.AF_INET6:
+ case unix.AF_INET6:
_len = net.IPv6len
default:
panic(NslcdError(fmt.Sprintf("incorrect address family specified: %d", af)))
diff --git a/nslcd_server/func_handlerequest.go.gen b/nslcd_server/func_handlerequest.go.gen
index 4c58ae0..bef29c0 100755
--- a/nslcd_server/func_handlerequest.go.gen
+++ b/nslcd_server/func_handlerequest.go.gen
@@ -28,15 +28,15 @@ import (
"fmt"
"io"
"os"
- s "syscall"
+ "golang.org/x/sys/unix"
p "lukeshu.com/git/go/libnslcd.git/nslcd_proto"
)
var sensitive = "<omitted-from-log>"
// Handle a request to nslcd
-func HandleRequest(backend Backend, in io.Reader, out io.Writer, cred s.Ucred) (err error) {
+func HandleRequest(backend Backend, in io.Reader, out io.Writer, cred unix.Ucred) (err error) {
err = nil
defer func() {
if r := recover(); r != nil {
@@ -52,7 +52,7 @@ func HandleRequest(backend Backend, in io.Reader, out io.Writer, cred s.Ucred) (
return
}
-func handleRequest(backend Backend, in io.Reader, out io.Writer, cred s.Ucred) {
+func handleRequest(backend Backend, in io.Reader, out io.Writer, cred unix.Ucred) {
var version int32
p.Read(in, &version)
if version != p.NSLCD_VERSION {
diff --git a/nslcd_server/interface_backend.go.gen b/nslcd_server/interface_backend.go.gen
index 94a0433..bca8e17 100755
--- a/nslcd_server/interface_backend.go.gen
+++ b/nslcd_server/interface_backend.go.gen
@@ -24,8 +24,7 @@ cat <<EOF | gofmt
package nslcd_server
import (
- s "syscall"
-
+ "golang.org/x/sys/unix"
p "lukeshu.com/git/go/libnslcd.git/nslcd_proto"
)
@@ -34,7 +33,7 @@ import (
// that the nslcd server may reply to is implemented simply as a
// method that returns a channel of the resulting values.
type Backend interface {
- $(sed -rn 's/([^_]+)(.*)/\1\2(s.Ucred, p.Request_\1\2) <-chan p.\1/p' "$requests" | grep -v PAM)
- $(sed -rn 's/(PAM)(.*)/\1\2(s.Ucred, p.Request_\1\2) <-chan p.\1\2/p' "$requests")
+ $(sed -rn 's/([^_]+)(.*)/\1\2(unix.Ucred, p.Request_\1\2) <-chan p.\1/p' "$requests" | grep -v PAM)
+ $(sed -rn 's/(PAM)(.*)/\1\2(unix.Ucred, p.Request_\1\2) <-chan p.\1\2/p' "$requests")
}
EOF
diff --git a/nslcd_server/type_nilbackend.go.gen b/nslcd_server/type_nilbackend.go.gen
index 0127e51..8a8f1cc 100755
--- a/nslcd_server/type_nilbackend.go.gen
+++ b/nslcd_server/type_nilbackend.go.gen
@@ -24,8 +24,7 @@ cat <<EOF | gofmt
package nslcd_server
import (
- s "syscall"
-
+ "golang.org/x/sys/unix"
p "lukeshu.com/git/go/libnslcd.git/nslcd_proto"
)
@@ -35,7 +34,7 @@ import (
// databases.
type NilBackend struct{}
-$(< "$interface" sed -rn 's/^\t([^(]+)\(s.Ucred, ([^)]+)\) <-chan (\S+)$/func (o NilBackend) \1(s.Ucred, \2) <-chan \3 { r := make(chan \3); close(r); return r }/p')
+$(< "$interface" sed -rn 's/^\t([^(]+)\(unix.Ucred, ([^)]+)\) <-chan (\S+)$/func (o NilBackend) \1(unix.Ucred, \2) <-chan \3 { r := make(chan \3); close(r); return r }/p')
var _ Backend = NilBackend{}
EOF
diff --git a/nslcd_systemd/nslcd_systemd.go b/nslcd_systemd/nslcd_systemd.go
index eb545c2..35c9393 100644
--- a/nslcd_systemd/nslcd_systemd.go
+++ b/nslcd_systemd/nslcd_systemd.go
@@ -38,8 +38,8 @@ import (
"os"
"os/signal"
"sync"
- "syscall"
+ "golang.org/x/sys/unix"
"lukeshu.com/git/go/libnslcd.git/nslcd_server"
"lukeshu.com/git/go/libsystemd.git/sd_daemon"
"lukeshu.com/git/go/libsystemd.git/sd_daemon/lsb"
@@ -69,13 +69,13 @@ func get_socket() (socket net.Listener, err error) {
return
}
-func getpeercred(conn *net.UnixConn) (cred syscall.Ucred, err error) {
+func getpeercred(conn *net.UnixConn) (cred unix.Ucred, err error) {
file, err := conn.File()
if err != nil {
return
}
defer file.Close()
- _cred, err := syscall.GetsockoptUcred(int(file.Fd()), syscall.SOL_SOCKET, syscall.SO_PEERCRED)
+ _cred, err := unix.GetsockoptUcred(int(file.Fd()), unix.SOL_SOCKET, unix.SO_PEERCRED)
cred = *_cred
return
}
@@ -99,7 +99,7 @@ func Main(backend Backend) uint8 {
var err error = nil
sigs := make(chan os.Signal)
- signal.Notify(sigs, syscall.SIGTERM, syscall.SIGHUP)
+ signal.Notify(sigs, unix.SIGTERM, unix.SIGHUP)
disable_nss_module()
@@ -140,10 +140,10 @@ func Main(backend Backend) uint8 {
select {
case sig := <-sigs:
switch sig {
- case syscall.SIGTERM:
+ case unix.SIGTERM:
sd_daemon.Log.Notice("Received SIGTERM, shutting down")
return lsb.EXIT_SUCCESS
- case syscall.SIGHUP:
+ case unix.SIGHUP:
sd_daemon.Notify(0, false, "RELOADING=1", nil)
err := backend.Reload()
if err != nil {