summaryrefslogtreecommitdiff
path: root/src/nshd/hackers_git
diff options
context:
space:
mode:
Diffstat (limited to 'src/nshd/hackers_git')
-rw-r--r--src/nshd/hackers_git/db_config.go4
-rw-r--r--src/nshd/hackers_git/hackers.go11
-rw-r--r--src/nshd/hackers_git/hackers_watch.go15
3 files changed, 13 insertions, 17 deletions
diff --git a/src/nshd/hackers_git/db_config.go b/src/nshd/hackers_git/db_config.go
index 55faa18..fde16b3 100644
--- a/src/nshd/hackers_git/db_config.go
+++ b/src/nshd/hackers_git/db_config.go
@@ -13,8 +13,8 @@ func (o *Hackers) Config_Get(cred p.Ucred, req p.Request_Config_Get) p.Config_En
switch req.Key {
case p.NSLCD_CONFIG_PAM_PASSWORD_PROHIBIT_MESSAGE:
- if o.cfg.Pam_password_prohibit_message != "" {
- val = &o.cfg.Pam_password_prohibit_message
+ if o.Cfg.Pam_password_prohibit_message != "" {
+ val = &o.Cfg.Pam_password_prohibit_message
}
}
diff --git a/src/nshd/hackers_git/hackers.go b/src/nshd/hackers_git/hackers.go
index 88f27ed..9e3976b 100644
--- a/src/nshd/hackers_git/hackers.go
+++ b/src/nshd/hackers_git/hackers.go
@@ -22,7 +22,7 @@ type Config struct {
type Hackers struct {
util.NullBackend
- cfg Config
+ Cfg Config
lock sync.RWMutex
users map[int32]user
@@ -38,20 +38,17 @@ type Hackers struct {
var _ nslcd_systemd.Backend = &Hackers{}
var _ nslcd_proto.Backend = &Hackers{}
-func NewHackers(config Config) *Hackers {
- o := Hackers{
- cfg: config,
- }
+func (o *Hackers) Init() error {
err := o.Reload()
if err != nil {
logger.Err("Could not initialize hackers.git: %v", err)
- return nil
+ return err
}
go func() {
defer lsb.Recover()
o.worker()
}()
- return &o
+ return nil
}
func (o *Hackers) Close() {
diff --git a/src/nshd/hackers_git/hackers_watch.go b/src/nshd/hackers_git/hackers_watch.go
index 8e3834e..919a578 100644
--- a/src/nshd/hackers_git/hackers_watch.go
+++ b/src/nshd/hackers_git/hackers_watch.go
@@ -62,9 +62,9 @@ func (o *Hackers) reload() (err error) {
o.close()
o.in_fd, err = inotify.InotifyInit() ; if err != nil { return }
o.in_wd_home, err = o.in_fd.AddWatch("/home" , in_DIR|in_CHILD_ADD); if err != nil { return }
- o.in_wd_yaml, err = o.in_fd.AddWatch(o.cfg.Yamldir, in_DIR|in_CHILD_ANY); if err != nil { return }
+ o.in_wd_yaml, err = o.in_fd.AddWatch(o.Cfg.Yamldir, in_DIR|in_CHILD_ANY); if err != nil { return }
- filenames, err := filepath.Glob(o.cfg.Yamldir + "/*.yml")
+ filenames, err := filepath.Glob(o.Cfg.Yamldir + "/*.yml")
o.users = make(map[int32]user, len(filenames))
o.groups = make(map[string]map[string]bool)
o.in_uid2wd = make(map[int32]inotify.Wd, len(filenames))
@@ -152,9 +152,9 @@ func worker_error(format string, a ...interface{}) {
}
func (o *Hackers) worker() {
- err := os.Chdir(o.cfg.Yamldir)
+ err := os.Chdir(o.Cfg.Yamldir)
if err != nil {
- worker_error("failed to load %q: %v", o.cfg.Yamldir, err)
+ worker_error("failed to load %q: %v", o.Cfg.Yamldir, err)
}
for event, err := o.in_fd.Read(); err == nil; event, err = o.in_fd.Read() {
switch event.Wd {
@@ -166,16 +166,15 @@ func (o *Hackers) worker() {
worker_error("failed to reload hackers.git yaml directory: %v", err)
}
- err = os.Chdir(o.cfg.Yamldir)
+ err = os.Chdir(o.Cfg.Yamldir)
if err != nil {
- worker_error("failed to load %q: %v", o.cfg.Yamldir, err)
+ worker_error("failed to load %q: %v", o.Cfg.Yamldir, err)
}
} else if event.Mask&in_CHILD_ANY != 0 {
if event.Name == nil {
panic("recieved child event from inotify, but no child name")
}
- filename := o.cfg.Yamldir + "/" + *event.Name
- o.load_yaml_file(filename)
+ o.load_yaml_file(o.Cfg.Yamldir + "/" + *event.Name, true)
} else {
panic("recieved non-subscribed inotify event from kernel")
}