summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2017-02-03 01:27:51 -0500
committerLuke Shumaker <lukeshu@sbcglobal.net>2017-02-03 01:27:51 -0500
commit026a77f92fd89f009eefee19a43c15d416f54cf7 (patch)
tree31363cfeb002ea8bb0872f3d2243796439ca189c
parent026a02b995bb0ae456c66c98f14ea0b2b761a1ea (diff)
Rename the Go packages to have a bit more taste.
-rw-r--r--Makefile20
-rw-r--r--go/nshd/.gitignore (renamed from go/cmd-nshd/.gitignore)0
-rw-r--r--go/nshd/main.go.in (renamed from go/cmd-nshd/main.go.in)4
-rw-r--r--go/nshd/nshd_files/.gitignore (renamed from go/parabola_hackers/.gitignore)0
-rw-r--r--go/nshd/nshd_files/passwords.go.in (renamed from go/parabola_hackers/passwords.go.in)2
-rw-r--r--go/nshd/nshd_files/users.go.in (renamed from go/parabola_hackers/users.go.in)6
-rw-r--r--go/nshd/nslcd_backend/db_config.go (renamed from go/parabola_hackers/nslcd_backend/db_config.go)2
-rw-r--r--go/nshd/nslcd_backend/db_group.go (renamed from go/parabola_hackers/nslcd_backend/db_group.go)8
-rw-r--r--go/nshd/nslcd_backend/db_pam.go (renamed from go/parabola_hackers/nslcd_backend/db_pam.go)12
-rw-r--r--go/nshd/nslcd_backend/db_passwd.go (renamed from go/parabola_hackers/nslcd_backend/db_passwd.go)15
-rw-r--r--go/nshd/nslcd_backend/db_shadow.go (renamed from go/parabola_hackers/nslcd_backend/db_shadow.go)2
-rw-r--r--go/nshd/nslcd_backend/hackers.go (renamed from go/parabola_hackers/nslcd_backend/hackers.go)15
-rw-r--r--go/nshd/nslcd_backend/util.go (renamed from go/parabola_hackers/nslcd_backend/util.go)2
-rw-r--r--go/nshd/util/util.go (renamed from go/parabola_hackers/util.go)2
14 files changed, 51 insertions, 39 deletions
diff --git a/Makefile b/Makefile
index 2453dbb..f7f51ac 100644
--- a/Makefile
+++ b/Makefile
@@ -75,21 +75,21 @@ $(outdir)/nshd.service: $(var)user $(var)bindir
$(outdir)/nshd.sysusers: $(var)user
$(outdir)/bin/common.rb: $(var)conf_file
-$(outdir)/.gopath/bin/cmd-nshd: \
- $(outdir)/go/cmd-nshd/main.go \
- $(outdir)/go/parabola_hackers/users.go \
- $(outdir)/go/parabola_hackers/passwords.go
-$(outdir)/go/cmd-nshd/main.go: $(var)conf_file
-$(outdir)/go/parabola_hackers/users.go: $(var)bindir
-$(outdir)/go/parabola_hackers/passwords.go: $(var)shadow_file
+$(outdir)/.gopath/bin/nshd: \
+ $(outdir)/go/nshd/main.go \
+ $(outdir)/go/nshd/nshd_files/users.go \
+ $(outdir)/go/nshd/nshd_files/passwords.go
+$(outdir)/go/nshd/main.go: $(var)conf_file
+$(outdir)/go/nshd/nshd_files/users.go: $(var)bindir
+$(outdir)/go/nshd/nshd_files/passwords.go: $(var)shadow_file
# Go: copy out of .gopath
$(outdir)/bin/nshd: \
-$(outdir)/bin/%: $(outdir)/.gopath/bin/cmd-%
+$(outdir)/bin/%: $(outdir)/.gopath/bin/%
cp -T $< $@
# Go: compile+link
-$(outdir)/.gopath/bin/cmd-nshd: \
-$(outdir)/.gopath/bin/cmd-%: FORCE go-generate
+$(outdir)/.gopath/bin/nshd: \
+$(outdir)/.gopath/bin/%: FORCE go-generate
GOPATH=$(abspath $(outdir)/.gopath) go install $(@F)
# C: compile
diff --git a/go/cmd-nshd/.gitignore b/go/nshd/.gitignore
index 00870e2..00870e2 100644
--- a/go/cmd-nshd/.gitignore
+++ b/go/nshd/.gitignore
diff --git a/go/cmd-nshd/main.go.in b/go/nshd/main.go.in
index 260f553..5564128 100644
--- a/go/cmd-nshd/main.go.in
+++ b/go/nshd/main.go.in
@@ -20,13 +20,13 @@ package main
import (
"os"
- hackers_nslcd_backend "parabola_hackers/nslcd_backend"
+ "nshd/nslcd_backend"
"git.lukeshu.com/go/libnslcd/nslcd_systemd"
)
func main() {
- backend := &hackers_nslcd_backend.Hackers{
+ backend := &nslcd_backend.Hackers{
CfgFilename: "@conf_file@",
}
os.Exit(int(nslcd_systemd.Main(backend)))
diff --git a/go/parabola_hackers/.gitignore b/go/nshd/nshd_files/.gitignore
index 3be3f08..3be3f08 100644
--- a/go/parabola_hackers/.gitignore
+++ b/go/nshd/nshd_files/.gitignore
diff --git a/go/parabola_hackers/passwords.go.in b/go/nshd/nshd_files/passwords.go.in
index 7065eb1..679f7c0 100644
--- a/go/parabola_hackers/passwords.go.in
+++ b/go/nshd/nshd_files/passwords.go.in
@@ -14,7 +14,7 @@
// License along with this manual; if not, see
// <http://www.gnu.org/licenses/>.
-package parabola_hackers
+package nshd_files
import (
"fmt"
diff --git a/go/parabola_hackers/users.go.in b/go/nshd/nshd_files/users.go.in
index 3a307be..51703fd 100644
--- a/go/parabola_hackers/users.go.in
+++ b/go/nshd/nshd_files/users.go.in
@@ -14,12 +14,14 @@
// License along with this manual; if not, see
// <http://www.gnu.org/licenses/>.
-package parabola_hackers
+package nshd_files
import (
"fmt"
"os/exec"
+ "nshd/util"
+
yaml "gopkg.in/yaml.v2"
p "git.lukeshu.com/go/libnslcd/nslcd_proto"
"git.lukeshu.com/go/libsystemd/sd_daemon"
@@ -126,7 +128,7 @@ func parseUser(_data interface{}) (ret User, err error) {
}
}
if !e {
- ret.Groups = Set2list(groups)
+ ret.Groups = util.Set2list(groups)
}
}
}
diff --git a/go/parabola_hackers/nslcd_backend/db_config.go b/go/nshd/nslcd_backend/db_config.go
index 556aa76..d00bf02 100644
--- a/go/parabola_hackers/nslcd_backend/db_config.go
+++ b/go/nshd/nslcd_backend/db_config.go
@@ -14,7 +14,7 @@
// License along with this manual; if not, see
// <http://www.gnu.org/licenses/>.
-package hackers_nslcd_backend
+package nslcd_backend
import (
p "git.lukeshu.com/go/libnslcd/nslcd_proto"
diff --git a/go/parabola_hackers/nslcd_backend/db_group.go b/go/nshd/nslcd_backend/db_group.go
index 41f049e..04c7e3b 100644
--- a/go/parabola_hackers/nslcd_backend/db_group.go
+++ b/go/nshd/nslcd_backend/db_group.go
@@ -14,10 +14,10 @@
// License along with this manual; if not, see
// <http://www.gnu.org/licenses/>.
-package hackers_nslcd_backend
+package nslcd_backend
import (
- "parabola_hackers"
+ "nshd/util"
p "git.lukeshu.com/go/libnslcd/nslcd_proto"
s "golang.org/x/sys/unix"
@@ -34,7 +34,7 @@ func (o *Hackers) groupByName(name string, users bool) p.Group {
}
var members_list []string
if users {
- members_list = parabola_hackers.Set2list(members_set)
+ members_list = util.Set2list(members_set)
} else {
members_list = make([]string, 0)
}
@@ -57,7 +57,7 @@ func (o *Hackers) groupByGid(gid int32, users bool) p.Group {
}
var members_list []string
if users {
- members_list = parabola_hackers.Set2list(members_set)
+ members_list = util.Set2list(members_set)
} else {
members_list = make([]string, 0)
}
diff --git a/go/parabola_hackers/nslcd_backend/db_pam.go b/go/nshd/nslcd_backend/db_pam.go
index 0538e70..b704620 100644
--- a/go/parabola_hackers/nslcd_backend/db_pam.go
+++ b/go/nshd/nslcd_backend/db_pam.go
@@ -14,12 +14,14 @@
// License along with this manual; if not, see
// <http://www.gnu.org/licenses/>.
-package hackers_nslcd_backend
+package nslcd_backend
import (
"fmt"
"os"
- "parabola_hackers"
+
+ "nshd/util"
+ "nshd/nshd_files"
s "golang.org/x/sys/unix"
p "git.lukeshu.com/go/libnslcd/nslcd_proto"
@@ -35,7 +37,7 @@ func checkPassword(password string, hash string) bool {
func hashPassword(newPassword string, oldHash string) string {
salt := oldHash
if salt == "!" {
- str, err := parabola_hackers.RandomString(crypt.SaltAlphabet, 8)
+ str, err := util.RandomString(crypt.SaltAlphabet, 8)
if err != nil {
sd_daemon.Log.Err("Could not generate a random string")
str = ""
@@ -118,7 +120,7 @@ func (o *Hackers) PAM_SessionOpen(cred s.Ucred, req p.Request_PAM_SessionOpen) <
go func() {
defer close(ret)
- sessionid, err := parabola_hackers.RandomString(alphabet, 24)
+ sessionid, err := util.RandomString(alphabet, 24)
if err != nil {
return
}
@@ -185,7 +187,7 @@ func (o *Hackers) PAM_PwMod(cred s.Ucred, req p.Request_PAM_PwMod) <-chan p.PAM_
passwords[ouser.Passwd.Name] = ouser.Passwd.PwHash
}
passwords[user.Passwd.Name] = user.Passwd.PwHash
- err := parabola_hackers.SaveAllPasswords(passwords)
+ err := nshd_files.SaveAllPasswords(passwords)
if err != nil {
sd_daemon.Log.Err(fmt.Sprintf("Writing passwords to disk: %v", err))
return
diff --git a/go/parabola_hackers/nslcd_backend/db_passwd.go b/go/nshd/nslcd_backend/db_passwd.go
index c5faf5c..ace127e 100644
--- a/go/parabola_hackers/nslcd_backend/db_passwd.go
+++ b/go/nshd/nslcd_backend/db_passwd.go
@@ -14,7 +14,7 @@
// License along with this manual; if not, see
// <http://www.gnu.org/licenses/>.
-package hackers_nslcd_backend
+package nslcd_backend
import (
p "git.lukeshu.com/go/libnslcd/nslcd_proto"
@@ -24,9 +24,16 @@ import (
/* Note that the output password hash value should be one of:
<empty> - no password set, allow login without password
! - used to prevent logins
- x - "valid" encrypted password that does not match any valid password
- often used to indicate that the password is defined elsewhere
- other - encrypted password, in crypt(3) format */
+ x - "valid" encrypted password that does not match any valid
+ password often used to indicate that the password is
+ defined elsewhere (i.e., in the shadow database)
+ other - encrypted password, in crypt(3) format
+
+ A "!" prefix on a password hash "locks" the account; therefore a a
+ hash of "!" says "no login"; while a hash of "x" says "you may log
+ in", but fails to authorize; passing the buck to the next database.
+
+ */
func (o *Hackers) Passwd_ByName(cred s.Ucred, req p.Request_Passwd_ByName) <-chan p.Passwd {
o.lock.RLock()
diff --git a/go/parabola_hackers/nslcd_backend/db_shadow.go b/go/nshd/nslcd_backend/db_shadow.go
index 58b13ec..ab1d68f 100644
--- a/go/parabola_hackers/nslcd_backend/db_shadow.go
+++ b/go/nshd/nslcd_backend/db_shadow.go
@@ -14,7 +14,7 @@
// License along with this manual; if not, see
// <http://www.gnu.org/licenses/>.
-package hackers_nslcd_backend
+package nslcd_backend
import (
p "git.lukeshu.com/go/libnslcd/nslcd_proto"
diff --git a/go/parabola_hackers/nslcd_backend/hackers.go b/go/nshd/nslcd_backend/hackers.go
index 9cff815..44107b2 100644
--- a/go/parabola_hackers/nslcd_backend/hackers.go
+++ b/go/nshd/nslcd_backend/hackers.go
@@ -14,15 +14,16 @@
// License along with this manual; if not, see
// <http://www.gnu.org/licenses/>.
-// Package hackers_nslcd_backend is an nslcd_server Backend that
+// Package nslcd_backend is an nslcd_server Backend that
// speaks to hackers.git.
-package hackers_nslcd_backend
+package nslcd_backend
import (
"fmt"
- "parabola_hackers"
"sync"
+ "nshd/nshd_files"
+
"git.lukeshu.com/go/libnslcd/nslcd_server"
"git.lukeshu.com/go/libnslcd/nslcd_systemd"
"git.lukeshu.com/go/libsystemd/sd_daemon"
@@ -39,7 +40,7 @@ type Hackers struct {
CfgFilename string
cfg config
- users map[int32]parabola_hackers.User
+ users map[int32]nshd_files.User
groups map[string]map[string]bool
}
@@ -61,7 +62,7 @@ func (o *Hackers) Close() {
o.lock.Lock()
defer o.lock.Unlock()
- o.users = make(map[int32]parabola_hackers.User, 0)
+ o.users = make(map[int32]nshd_files.User, 0)
o.groups = make(map[string]map[string]bool)
}
@@ -78,12 +79,12 @@ func (o *Hackers) Reload() error {
sd_daemon.Log.Info(fmt.Sprintf("hackers.git: pam_password_prohibit_message: %#v", o.cfg.Pam_password_prohibit_message))
sd_daemon.Log.Debug("hackers.git: Parsing user data")
- o.users, err = parabola_hackers.LoadAllUsers()
+ o.users, err = nshd_files.LoadAllUsers()
if err != nil {
return err
}
- passwords, err := parabola_hackers.LoadAllPasswords()
+ passwords, err := nshd_files.LoadAllPasswords()
if err != nil {
return err
}
diff --git a/go/parabola_hackers/nslcd_backend/util.go b/go/nshd/nslcd_backend/util.go
index a3b2b5d..aa29b03 100644
--- a/go/parabola_hackers/nslcd_backend/util.go
+++ b/go/nshd/nslcd_backend/util.go
@@ -14,7 +14,7 @@
// License along with this manual; if not, see
// <http://www.gnu.org/licenses/>.
-package hackers_nslcd_backend
+package nslcd_backend
import (
"io/ioutil"
diff --git a/go/parabola_hackers/util.go b/go/nshd/util/util.go
index 9a241db..4d3fd57 100644
--- a/go/parabola_hackers/util.go
+++ b/go/nshd/util/util.go
@@ -14,7 +14,7 @@
// License along with this manual; if not, see
// <http://www.gnu.org/licenses/>.
-package parabola_hackers
+package util
import (
"crypto/rand"