summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nshd/hackers_git/main.go112
-rw-r--r--src/nshd/main.go21
-rw-r--r--src/nslcd_proto/Makefile2
-rw-r--r--src/nslcd_proto/nslcd_h.go10
4 files changed, 118 insertions, 27 deletions
diff --git a/src/nshd/hackers_git/main.go b/src/nshd/hackers_git/main.go
new file mode 100644
index 0000000..9e71710
--- /dev/null
+++ b/src/nshd/hackers_git/main.go
@@ -0,0 +1,112 @@
+package hackers_git
+
+import (
+ _ "golang.org/x/exp/inotify"
+ _ "gopkg.in/yaml.v2"
+ p "nslcd_proto"
+ "nslcd_systemd"
+ "sync"
+)
+
+type Hackers struct {
+ p.NullBackend
+ lock *sync.RWMutex
+ pam_password_prohibit_message string
+}
+
+var _ nslcd_systemd.Backend = &Hackers{}
+var _ p.Backend = &Hackers{}
+//
+func (o *Hackers) Reload() {
+ o.lock.Lock()
+ defer o.lock.Unlock()
+ // TODO
+}
+
+func NewHackers(yamlDir string) *Hackers {
+ // TODO
+ var hackers Hackers
+
+ var lock sync.RWMutex
+ hackers.lock = &lock
+
+ go inotify_watcher(yamlDir)
+
+ return &hackers
+}
+
+func inotify_watcher(yamlDir string) {
+ // TODO
+}
+
+//
+func (o *Hackers) Config_Get(cred p.Ucred, req p.Request_Config_Get) p.Config_Enumerator {
+ var val *string = nil
+
+ switch req {
+ case p.NSLCD_CONFIG_PAM_PASSWORD_PROHIBIT_MESSAGE:
+ val = &o.pam_password_prohibit_message
+ }
+
+ if val != nil {
+ return p.New_Config_List([]p.Config{p.Config(*val)})
+ } else {
+ return p.Config_Ø{}
+ }
+}
+//
+func (o *Hackers) Passwd_ByName(cred p.Ucred, req p.Request_Passwd_ByName) p.Passwd_Enumerator {
+ // TODO
+ return nil
+}
+func (o *Hackers) Passwd_ByUID(cred p.Ucred, req p.Request_Passwd_ByUID) p.Passwd_Enumerator {
+ // TODO
+ return nil
+}
+func (o *Hackers) Passwd_All(cred p.Ucred, req p.Request_Passwd_All) p.Passwd_Enumerator {
+ // TODO
+ return nil
+}
+//
+func (o *Hackers) Shadow_ByName(cred p.Ucred, req p.Request_Shadow_ByName) p.Shadow_Enumerator {
+ // TODO
+ return nil
+}
+func (o *Hackers) Shadow_All(cred p.Ucred, req p.Request_Shadow_All) p.Shadow_Enumerator {
+ // TODO
+ return nil
+}
+//
+func (o *Hackers) Group_ByName(cred p.Ucred, req p.Request_Group_ByName) p.Group_Enumerator {
+ // TODO
+ return nil
+}
+func (o *Hackers) Group_ByGid(cred p.Ucred, req p.Request_Group_ByGid) p.Group_Enumerator {
+ // TODO
+ return nil
+}
+func (o *Hackers) Group_ByMember(cred p.Ucred, req p.Request_Group_ByMember) p.Group_Enumerator {
+ // TODO
+ return nil
+}
+func (o *Hackers) Group_All(cred p.Ucred, req p.Request_Group_All) p.Group_Enumerator {
+ // TODO
+ return nil
+}
+//
+func (o *Hackers) PAM_Authentication(cred p.Ucred, req p.Request_PAM_Authentication) p.PAM_Authentication_Enumerator {
+ // TODO
+ return nil
+}
+func (o *Hackers) PAM_Authorization(cred p.Ucred, req p.Request_PAM_Authorization) p.PAM_Authorization_Enumerator {
+ // TODO
+ return nil
+}
+func (o *Hackers) PAM_SessionOpen(cred p.Ucred, req p.Request_PAM_SessionOpen) p.PAM_SessionOpen_Enumerator {
+ // TODO
+ return nil
+}
+func (o *Hackers) PAM_SessionClose(cred p.Ucred, req p.Request_PAM_SessionClose) p.PAM_SessionClose_Enumerator {
+ // TODO
+ return nil
+}
diff --git a/src/nshd/main.go b/src/nshd/main.go
index 8230734..d31160f 100644
--- a/src/nshd/main.go
+++ b/src/nshd/main.go
@@ -1,28 +1,11 @@
package main
import (
- _ "golang.org/x/exp/inotify"
- _ "gopkg.in/yaml.v2"
- "nslcd_proto"
+ "nshd/hackers_git"
"nslcd_systemd"
)
-type hackersBackend struct {
- nslcd_proto.NullBackend
-}
-
-var _ nslcd_systemd.Backend = &hackersBackend{}
-
-func (o *hackersBackend) Reload() {
- // TODO
-}
-
-func newHackersBackend() *hackersBackend {
- // TODO
- return &hackersBackend{}
-}
-
func main() {
- backend := newHackersBackend()
+ backend := hackers_git.NewHackers("/var/cache/parabola-hackers/users")
nslcd_systemd.Main(backend)
}
diff --git a/src/nslcd_proto/Makefile b/src/nslcd_proto/Makefile
index 96defbd..53b4424 100644
--- a/src/nslcd_proto/Makefile
+++ b/src/nslcd_proto/Makefile
@@ -32,7 +32,7 @@ $d/enumerator-list.mk: $d/responses.txt $d/Makefile
< $< sed -rn 's|.*|generate += $$d/enumerator@&.go|p' > $@
$d/requests.txt: $d/nslcd_h.go $d/Makefile
- < $< grep -Eo 'Request_([^_ ]+)(_\S+)?' | sed 's/^Request_//' > $@
+ < $< grep -Eo '\btype Request_([^_ ]+)(_\S+)?' | sed 's/^type Request_//' > $@
$d/responses.txt: $d/interface_backend.go $d/Makefile
< $< sed -rn 's/.* (\S+)_Enumerator$$/\1/p' | sort -u > $@
diff --git a/src/nslcd_proto/nslcd_h.go b/src/nslcd_proto/nslcd_h.go
index 4034472..394e91c 100644
--- a/src/nslcd_proto/nslcd_h.go
+++ b/src/nslcd_proto/nslcd_h.go
@@ -80,19 +80,15 @@ type void struct{}
const NSLCD_VERSION int32 = 0x00000002
/* Get a NSLCD configuration option. There is one request parameter: */
-type Request_Config_Get struct {
- Key int32
-}
+type Request_Config_Get int32 /* NSLCD_CONFIG_* */
/* the result value is: */
-type Config struct {
- Value string /* interpretation depending on request */
-}
+type Config string /* interpretation depending on request */
const NSLCD_ACTION_CONFIG_GET int32 = 0x00010001
const (
/* return the message, if any, that is presented to the user when password
modification through PAM is prohibited */
- NSLCD_CONFIG_PAM_PASSWORD_PROHIBIT_MESSAGE int32 = 1
+ NSLCD_CONFIG_PAM_PASSWORD_PROHIBIT_MESSAGE Request_Config_Get = 1
)
/* Email alias (/etc/aliases) NSS requests. The result values for a