summaryrefslogtreecommitdiff
path: root/src/nshd/hackers_git/db_pam.go
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2016-06-17 11:49:22 -0400
committerLuke Shumaker <lukeshu@sbcglobal.net>2016-06-17 11:49:22 -0400
commitc191af11616a3306b8e0a3650b6972eb61d2aba1 (patch)
treef5014a271d2c4c429113f4129d1d14ef73854470 /src/nshd/hackers_git/db_pam.go
parent896fdc18c430d8f6a5e5bd417b9ab0d3254941da (diff)
rearrange the go packages a bit
Diffstat (limited to 'src/nshd/hackers_git/db_pam.go')
-rw-r--r--src/nshd/hackers_git/db_pam.go100
1 files changed, 0 insertions, 100 deletions
diff --git a/src/nshd/hackers_git/db_pam.go b/src/nshd/hackers_git/db_pam.go
deleted file mode 100644
index 977104e..0000000
--- a/src/nshd/hackers_git/db_pam.go
+++ /dev/null
@@ -1,100 +0,0 @@
-// Copyright 2015 Luke Shumaker <lukeshu@sbcglobal.net>.
-//
-// This is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License as
-// published by the Free Software Foundation; either version 2 of
-// the License, or (at your option) any later version.
-//
-// This software 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 General Public License for more details.
-//
-// You should have received a copy of the GNU General Public
-// License along with this manual; if not, see
-// <http://www.gnu.org/licenses/>.
-
-package hackers_git
-
-import (
- "crypto/rand"
- p "lukeshu.com/git/go/libnslcd.git/proto"
- "math/big"
- s "syscall"
-)
-
-func (o *Hackers) PAM_Authentication(cred s.Ucred, req p.Request_PAM_Authentication) <-chan p.PAM_Authentication {
- o.lock.RLock()
- ret := make(chan p.PAM_Authentication)
- go func() {
- defer o.lock.RUnlock()
- defer close(ret)
-
- uid := o.name2uid(req.UserName)
- if uid < 0 {
- return
- }
-
- user := o.users[uid]
- obj := p.PAM_Authentication{
- AuthenticationResult: p.NSLCD_PAM_AUTH_ERR,
- UserName: "",
- AuthorizationResult: p.NSLCD_PAM_AUTH_ERR,
- AuthorizationError: "",
- }
- if check_password(req.Password, user.passwd.PwHash) {
- obj.AuthenticationResult = p.NSLCD_PAM_SUCCESS
- obj.AuthorizationResult = obj.AuthenticationResult
- obj.UserName = user.passwd.Name
- }
- ret <- obj
- }()
- return ret
-}
-
-func (o *Hackers) PAM_Authorization(cred s.Ucred, req p.Request_PAM_Authorization) <-chan p.PAM_Authorization {
- o.lock.RLock()
- ret := make(chan p.PAM_Authorization)
- go func() {
- defer o.lock.RUnlock()
- defer close(ret)
-
- uid := o.name2uid(req.UserName)
- if uid < 0 {
- return
- }
- ret <- p.PAM_Authorization{
- Result: p.NSLCD_PAM_SUCCESS,
- Error: "",
- }
- }()
- return ret
-}
-
-const alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
-
-var alphabet_len = big.NewInt(int64(len(alphabet)))
-
-func (o *Hackers) PAM_SessionOpen(cred s.Ucred, req p.Request_PAM_SessionOpen) <-chan p.PAM_SessionOpen {
- ret := make(chan p.PAM_SessionOpen)
- go func() {
- defer close(ret)
-
- var sessionid [24]byte
- for i := 0; i < len(sessionid); i++ {
- bigint, err := rand.Int(rand.Reader, alphabet_len)
- if err != nil {
- return
- }
- sessionid[i] = alphabet[bigint.Int64()]
- }
- ret <- p.PAM_SessionOpen{SessionID: string(sessionid[:])}
- }()
- return ret
-}
-
-func (o *Hackers) PAM_SessionClose(cred s.Ucred, req p.Request_PAM_SessionClose) <-chan p.PAM_SessionClose {
- ret := make(chan p.PAM_SessionClose)
- go close(ret)
- return ret
-}