summaryrefslogtreecommitdiff
path: root/nslcd_server/func_handlerequest.go.gen
diff options
context:
space:
mode:
Diffstat (limited to 'nslcd_server/func_handlerequest.go.gen')
-rwxr-xr-xnslcd_server/func_handlerequest.go.gen26
1 files changed, 16 insertions, 10 deletions
diff --git a/nslcd_server/func_handlerequest.go.gen b/nslcd_server/func_handlerequest.go.gen
index e7e2dcc..40e00c0 100755
--- a/nslcd_server/func_handlerequest.go.gen
+++ b/nslcd_server/func_handlerequest.go.gen
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
# -*- Mode: Go -*-
-# Copyright (C) 2015-2016 Luke Shumaker <lukeshu@sbcglobal.net>
+# Copyright (C) 2015-2017 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
@@ -35,12 +35,18 @@ import (
const sensitive = "<omitted-from-log>"
+func maybePanic(err error) {
+ if err != nil {
+ panic(err)
+ }
+}
+
// Handle a request to nslcd
func HandleRequest(backend Backend, in io.Reader, out io.Writer, cred unix.Ucred) (err error) {
defer func() {
if r := recover(); r != nil {
switch r := r.(type) {
- case error:
+ case p.NslcdError:
err = r
default:
panic(r)
@@ -53,12 +59,12 @@ func HandleRequest(backend Backend, in io.Reader, out io.Writer, cred unix.Ucred
func handleRequest(backend Backend, in io.Reader, out io.Writer, cred unix.Ucred) {
var version int32
- p.Read(in, &version)
+ maybePanic(p.Read(in, &version))
if version != p.NSLCD_VERSION {
panic(p.NslcdError(fmt.Sprintf("Version mismatch: server=%#08x client=%#08x", p.NSLCD_VERSION, version)))
}
var action int32
- p.Read(in, &action)
+ maybePanic(p.Read(in, &action))
ch := make(chan interface{})
switch action {
@@ -67,7 +73,7 @@ while read -r request; do
cat <<EOT
case p.NSLCD_ACTION_${request^^}:
var req p.Request_${request}
- p.Read(in, &req)
+ maybePanic(p.Read(in, &req))
$(
case "$request" in
PAM_Authentication)
@@ -107,13 +113,13 @@ done < "$requests"
close(ch)
panic(p.NslcdError(fmt.Sprintf("Unknown request action: %#08x", action)))
}
- p.Write(out, p.NSLCD_VERSION)
- p.Write(out, action)
+ maybePanic(p.Write(out, p.NSLCD_VERSION))
+ maybePanic(p.Write(out, action))
for result := range ch {
- p.Write(out, p.NSLCD_RESULT_BEGIN)
- p.Write(out, result)
+ maybePanic(p.Write(out, p.NSLCD_RESULT_BEGIN))
+ maybePanic(p.Write(out, result))
}
- p.Write(out, p.NSLCD_RESULT_END)
+ maybePanic(p.Write(out, p.NSLCD_RESULT_END))
}
EOF