summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile13
-rw-r--r--go/src/nshd/.gitignore1
-rw-r--r--go/src/nshd/main.go (renamed from go/src/nshd/main.go.in)5
-rw-r--r--go/src/nshd/nshd_files/.gitignore3
-rw-r--r--go/src/nshd/nshd_files/passwords.go (renamed from go/src/nshd/nshd_files/passwords.go.in)12
-rw-r--r--go/src/nshd/nshd_files/paths.go.in7
-rw-r--r--go/src/nshd/nshd_files/users.go (renamed from go/src/nshd/nshd_files/users.go.in)2
7 files changed, 20 insertions, 23 deletions
diff --git a/Makefile b/Makefile
index f1839b1..670d5ba 100644
--- a/Makefile
+++ b/Makefile
@@ -85,16 +85,9 @@ $(outdir)/nshd.service: $(var.)user $(var.)bindir
$(outdir)/nshd.sysusers: $(var.)user
$(outdir)/bin/common.rb: $(var.)conf_file
-$(outdir)/go/src/nshd/main.go: $(var.)conf_file
-$(outdir)/go/src/nshd/nshd_files/users.go: $(var.)bindir
-$(outdir)/go/src/nshd/nshd_files/passwords.go: $(var.)shadow_file
-
-goconf = \
- $(outdir)/go/src/nshd/main.go \
- $(outdir)/go/src/nshd/nshd_files/users.go \
- $(outdir)/go/src/nshd/nshd_files/passwords.go
-$(outdir)/go/bin/nshd: $(goconf) $(outdir)/$(files.generate)
-files.out.all += $(goconf)
+$(outdir)/go/src/nshd/nshd_files/paths.go: $(var.)bindir $(var.)conf_file $(var.)shadow_file
+$(outdir)/go/bin/nshd: go-generate $(outdir)/go/src/nshd/nshd_files/paths.go
+files.out.all += $(outdir)/go/src/nshd/nshd_files/paths.go
# Install
diff --git a/go/src/nshd/.gitignore b/go/src/nshd/.gitignore
deleted file mode 100644
index 00870e2..0000000
--- a/go/src/nshd/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/main.go
diff --git a/go/src/nshd/main.go.in b/go/src/nshd/main.go
index 17e65ca..2c94382 100644
--- a/go/src/nshd/main.go.in
+++ b/go/src/nshd/main.go
@@ -1,4 +1,4 @@
-// Copyright 2015-2016 Luke Shumaker <lukeshu@sbcglobal.net>.
+// Copyright 2015-2017 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
@@ -21,6 +21,7 @@ package main
import (
"os"
+ "nshd/nshd_files"
"nshd/nslcd_backend"
"git.lukeshu.com/go/libnslcd/nslcd_systemd"
@@ -28,7 +29,7 @@ import (
func main() {
backend := &nslcd_backend.Hackers{
- CfgFilename: "@conf_file@",
+ CfgFilename: nshd_files.ConfFile,
}
os.Exit(int(nslcd_systemd.Main(backend)))
}
diff --git a/go/src/nshd/nshd_files/.gitignore b/go/src/nshd/nshd_files/.gitignore
index 3be3f08..12de2b2 100644
--- a/go/src/nshd/nshd_files/.gitignore
+++ b/go/src/nshd/nshd_files/.gitignore
@@ -1,2 +1 @@
-/users.go
-/passwords.go
+/paths.go
diff --git a/go/src/nshd/nshd_files/passwords.go.in b/go/src/nshd/nshd_files/passwords.go
index 679f7c0..61c9e2b 100644
--- a/go/src/nshd/nshd_files/passwords.go.in
+++ b/go/src/nshd/nshd_files/passwords.go
@@ -34,10 +34,8 @@ import (
often used to indicate that the password is defined elsewhere
other - encrypted password, in crypt(3) format */
-const shadow_file = "@shadow_file@"
-
func LoadAllPasswords() (map[string]string, error) {
- file, err := os.Open(shadow_file)
+ file, err := os.Open(ShadowFile)
if err != nil {
return nil, err
}
@@ -53,14 +51,14 @@ func LoadAllPasswords() (map[string]string, error) {
}
cols := strings.SplitN(line, ":", 2)
if len(cols) != 2 {
- sd_daemon.Log.Err(fmt.Sprintf("hackers.git %s:%d: malformed line", shadow_file, i+1))
+ sd_daemon.Log.Err(fmt.Sprintf("hackers.git %s:%d: malformed line", ShadowFile, i+1))
continue
}
username := cols[0]
hash := cols[1]
if hash != "!" && !crypt.SaltOk(hash) {
hash = "!"
- sd_daemon.Log.Err(fmt.Sprintf("%s:%d: malformed hash for user: %s", shadow_file, i+1, username))
+ sd_daemon.Log.Err(fmt.Sprintf("%s:%d: malformed hash for user: %s", ShadowFile, i+1, username))
}
passwords[username] = hash
}
@@ -76,7 +74,7 @@ func SaveAllPasswords(passwords map[string]string) error {
}
sort.Strings(usernames)
- file, err := os.OpenFile(shadow_file+"-", os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0600)
+ file, err := os.OpenFile(ShadowFile+"-", os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0600)
if err != nil {
return err
}
@@ -93,5 +91,5 @@ func SaveAllPasswords(passwords map[string]string) error {
return err
}
- return os.Rename(shadow_file+"-", shadow_file)
+ return os.Rename(ShadowFile+"-", ShadowFile)
}
diff --git a/go/src/nshd/nshd_files/paths.go.in b/go/src/nshd/nshd_files/paths.go.in
new file mode 100644
index 0000000..652a37b
--- /dev/null
+++ b/go/src/nshd/nshd_files/paths.go.in
@@ -0,0 +1,7 @@
+package nshd_files
+
+const (
+ ConfFile = "@conf_file@"
+ ShadowFile = "@shadow_file@"
+ BinDir = "@bindir@"
+)
diff --git a/go/src/nshd/nshd_files/users.go.in b/go/src/nshd/nshd_files/users.go
index 51703fd..4fd3cd1 100644
--- a/go/src/nshd/nshd_files/users.go.in
+++ b/go/src/nshd/nshd_files/users.go
@@ -40,7 +40,7 @@ type User struct {
}
func LoadAllUsers() (users map[int32]User, err error) {
- contents, err := exec.Command("@bindir@/meta-cat").Output()
+ contents, err := exec.Command(BinDir + "/meta-cat").Output()
if err != nil {
return
}