From e2bebdb069b45bd8deb04536bd4772bfec3376b7 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Thu, 27 Aug 2015 00:51:59 -0600 Subject: wip --- src/nshd/hackers_git/db_config.go | 21 +++++++ src/nshd/hackers_git/db_group.go | 28 ++++++++++ src/nshd/hackers_git/db_pam.go | 28 ++++++++++ src/nshd/hackers_git/db_passwd.go | 22 ++++++++ src/nshd/hackers_git/db_shadow.go | 16 ++++++ src/nshd/hackers_git/hackers.go | 40 ++++++++++++++ src/nshd/hackers_git/main.go | 112 -------------------------------------- 7 files changed, 155 insertions(+), 112 deletions(-) create mode 100644 src/nshd/hackers_git/db_config.go create mode 100644 src/nshd/hackers_git/db_group.go create mode 100644 src/nshd/hackers_git/db_pam.go create mode 100644 src/nshd/hackers_git/db_passwd.go create mode 100644 src/nshd/hackers_git/db_shadow.go create mode 100644 src/nshd/hackers_git/hackers.go delete mode 100644 src/nshd/hackers_git/main.go diff --git a/src/nshd/hackers_git/db_config.go b/src/nshd/hackers_git/db_config.go new file mode 100644 index 0000000..9ed978f --- /dev/null +++ b/src/nshd/hackers_git/db_config.go @@ -0,0 +1,21 @@ +package hackers_git + +import p "nslcd_proto" + +func (o *Hackers) Config_Get(cred p.Ucred, req p.Request_Config_Get) p.Config_Enumerator { + o.lock.RLock() + defer o.lock.RUnlock() + + 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_Ø{} + } +} diff --git a/src/nshd/hackers_git/db_group.go b/src/nshd/hackers_git/db_group.go new file mode 100644 index 0000000..5277094 --- /dev/null +++ b/src/nshd/hackers_git/db_group.go @@ -0,0 +1,28 @@ +package hackers_git + +import p "nslcd_proto" + +func (o *Hackers) Group_ByName(cred p.Ucred, req p.Request_Group_ByName) p.Group_Enumerator { + o.lock.RLock() + defer o.lock.RUnlock() + // TODO + return nil +} +func (o *Hackers) Group_ByGid(cred p.Ucred, req p.Request_Group_ByGid) p.Group_Enumerator { + o.lock.RLock() + defer o.lock.RUnlock() + // TODO + return nil +} +func (o *Hackers) Group_ByMember(cred p.Ucred, req p.Request_Group_ByMember) p.Group_Enumerator { + o.lock.RLock() + defer o.lock.RUnlock() + // TODO + return nil +} +func (o *Hackers) Group_All(cred p.Ucred, req p.Request_Group_All) p.Group_Enumerator { + o.lock.RLock() + defer o.lock.RUnlock() + // TODO + return nil +} diff --git a/src/nshd/hackers_git/db_pam.go b/src/nshd/hackers_git/db_pam.go new file mode 100644 index 0000000..a133e88 --- /dev/null +++ b/src/nshd/hackers_git/db_pam.go @@ -0,0 +1,28 @@ +package hackers_git + +import p "nslcd_proto" + +func (o *Hackers) PAM_Authentication(cred p.Ucred, req p.Request_PAM_Authentication) p.PAM_Authentication_Enumerator { + o.lock.RLock() + defer o.lock.RUnlock() + // TODO + return nil +} +func (o *Hackers) PAM_Authorization(cred p.Ucred, req p.Request_PAM_Authorization) p.PAM_Authorization_Enumerator { + o.lock.RLock() + defer o.lock.RUnlock() + // TODO + return nil +} +func (o *Hackers) PAM_SessionOpen(cred p.Ucred, req p.Request_PAM_SessionOpen) p.PAM_SessionOpen_Enumerator { + o.lock.RLock() + defer o.lock.RUnlock() + // TODO + return nil +} +func (o *Hackers) PAM_SessionClose(cred p.Ucred, req p.Request_PAM_SessionClose) p.PAM_SessionClose_Enumerator { + o.lock.RLock() + defer o.lock.RUnlock() + // TODO + return nil +} diff --git a/src/nshd/hackers_git/db_passwd.go b/src/nshd/hackers_git/db_passwd.go new file mode 100644 index 0000000..f0a0257 --- /dev/null +++ b/src/nshd/hackers_git/db_passwd.go @@ -0,0 +1,22 @@ +package hackers_git + +import p "nslcd_proto" + +func (o *Hackers) Passwd_ByName(cred p.Ucred, req p.Request_Passwd_ByName) p.Passwd_Enumerator { + o.lock.RLock() + defer o.lock.RUnlock() + // TODO + return nil +} +func (o *Hackers) Passwd_ByUID(cred p.Ucred, req p.Request_Passwd_ByUID) p.Passwd_Enumerator { + o.lock.RLock() + defer o.lock.RUnlock() + // TODO + return nil +} +func (o *Hackers) Passwd_All(cred p.Ucred, req p.Request_Passwd_All) p.Passwd_Enumerator { + o.lock.RLock() + defer o.lock.RUnlock() + // TODO + return nil +} diff --git a/src/nshd/hackers_git/db_shadow.go b/src/nshd/hackers_git/db_shadow.go new file mode 100644 index 0000000..199d89e --- /dev/null +++ b/src/nshd/hackers_git/db_shadow.go @@ -0,0 +1,16 @@ +package hackers_git + +import p "nslcd_proto" + +func (o *Hackers) Shadow_ByName(cred p.Ucred, req p.Request_Shadow_ByName) p.Shadow_Enumerator { + o.lock.RLock() + defer o.lock.RUnlock() + // TODO + return nil +} +func (o *Hackers) Shadow_All(cred p.Ucred, req p.Request_Shadow_All) p.Shadow_Enumerator { + o.lock.RLock() + defer o.lock.RUnlock() + // TODO + return nil +} diff --git a/src/nshd/hackers_git/hackers.go b/src/nshd/hackers_git/hackers.go new file mode 100644 index 0000000..99af135 --- /dev/null +++ b/src/nshd/hackers_git/hackers.go @@ -0,0 +1,40 @@ +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 +} diff --git a/src/nshd/hackers_git/main.go b/src/nshd/hackers_git/main.go deleted file mode 100644 index 9e71710..0000000 --- a/src/nshd/hackers_git/main.go +++ /dev/null @@ -1,112 +0,0 @@ -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 -} -- cgit v1.2.2