From 5aa2dc8085d65c8cfcc46a02ee74ddb9d9032e62 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 18 Dec 2016 03:59:10 -0500 Subject: Rename packages to make goimports happy. BREAKING CHANGE. --- nslcd_server/.gitignore | 3 + nslcd_server/Makefile | 37 ++++++++++ nslcd_server/doc.go | 25 +++++++ nslcd_server/func_handlerequest.go.gen | 120 +++++++++++++++++++++++++++++++++ nslcd_server/interface_backend.go.gen | 40 +++++++++++ nslcd_server/type_nilbackend.go.gen | 41 +++++++++++ 6 files changed, 266 insertions(+) create mode 100644 nslcd_server/.gitignore create mode 100644 nslcd_server/Makefile create mode 100644 nslcd_server/doc.go create mode 100755 nslcd_server/func_handlerequest.go.gen create mode 100755 nslcd_server/interface_backend.go.gen create mode 100755 nslcd_server/type_nilbackend.go.gen (limited to 'nslcd_server') diff --git a/nslcd_server/.gitignore b/nslcd_server/.gitignore new file mode 100644 index 0000000..ff46733 --- /dev/null +++ b/nslcd_server/.gitignore @@ -0,0 +1,3 @@ +/func_handlerequest.go +/interface_backend.go +/type_nilbackend.go diff --git a/nslcd_server/Makefile b/nslcd_server/Makefile new file mode 100644 index 0000000..f1ff20f --- /dev/null +++ b/nslcd_server/Makefile @@ -0,0 +1,37 @@ +# Copyright (C) 2015-2016 Luke Shumaker +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301 USA + +files.src.gen += interface_backend.go +files.src.gen += func_handlerequest.go +files.src.gen += type_nilbackend.go + +files.generate: $(files.src.gen) +maintainer-clean: + rm -f -- $(files.src.gen) +.PHONY: files.generate maintainer-clean + +%.go: %.go.gen + ./$^ > $@ + +interface_backend.go: ../nslcd_proto/requests.txt +func_handlerequest.go: ../nslcd_proto/requests.txt +type_nilbackend.go: interface_backend.go + +../nslcd_proto/requests.txt: + $(MAKE) -C $(@D) $(@F) + +.DELETE_ON_ERROR: diff --git a/nslcd_server/doc.go b/nslcd_server/doc.go new file mode 100644 index 0000000..1cf7552 --- /dev/null +++ b/nslcd_server/doc.go @@ -0,0 +1,25 @@ +// Copyright (C) 2015-2016 Luke Shumaker +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +// 02110-1301 USA + +//go:generate make + +// Package nslcd_server is a framework for implementing an nslcd +// server. +// +// You write an implementation of the Backend interface, then pass +// that to the HandleRequest function for each connection. +package nslcd_server diff --git a/nslcd_server/func_handlerequest.go.gen b/nslcd_server/func_handlerequest.go.gen new file mode 100755 index 0000000..4c58ae0 --- /dev/null +++ b/nslcd_server/func_handlerequest.go.gen @@ -0,0 +1,120 @@ +#!/usr/bin/env bash +# -*- Mode: Go -*- +# Copyright (C) 2015 Luke Shumaker +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301 USA + +requests=$1 +printf '//' +printf ' %q' "$0" "$@" +printf '\n// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT\n\n' +cat < 0 {' + echo ' _req.OldPassword = sensitive' + echo '}' + echo '_req.NewPassword = sensitive' + echo 'fmt.Fprintf(os.Stderr, "Request: %#v\n", _req)' + ;; + PAM_UserMod) + echo '_req := req' + echo '_req.Password = sensitive' + echo 'fmt.Fprintf(os.Stderr, "Request: %#v\n", _req)' + ;; + *) + echo 'fmt.Fprintf(os.Stderr, "Request: %#v\n", req)' + ;; + esac + ) + _ch := backend.${request}(cred, req) + go func() { + defer close(ch) + for obj := range _ch { + ch <- obj + } + }() +EOT +done < "$requests" +) + default: + close(ch) + panic(p.NslcdError(fmt.Sprintf("Unknown request action: %#08x", action))) + } + p.Write(out, p.NSLCD_VERSION) + p.Write(out, action) + + for result := range ch { + p.Write(out, p.NSLCD_RESULT_BEGIN) + p.Write(out, result) + } + p.Write(out, p.NSLCD_RESULT_END) +} +EOF diff --git a/nslcd_server/interface_backend.go.gen b/nslcd_server/interface_backend.go.gen new file mode 100755 index 0000000..94a0433 --- /dev/null +++ b/nslcd_server/interface_backend.go.gen @@ -0,0 +1,40 @@ +#!/usr/bin/env bash +# Copyright (C) 2015 Luke Shumaker +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301 USA + +requests=$1 +printf '//' +printf ' %q' "$0" "$@" +printf '\n// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT\n\n' +cat < +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301 USA + +interface=$1 +printf '//' +printf ' %q' "$0" "$@" +printf '\n// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT\n\n' +cat <