summaryrefslogtreecommitdiff
path: root/src/nshd/hackers_git/hackers_watch.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/nshd/hackers_git/hackers_watch.go')
-rw-r--r--src/nshd/hackers_git/hackers_watch.go29
1 files changed, 14 insertions, 15 deletions
diff --git a/src/nshd/hackers_git/hackers_watch.go b/src/nshd/hackers_git/hackers_watch.go
index aec1f65..be4af40 100644
--- a/src/nshd/hackers_git/hackers_watch.go
+++ b/src/nshd/hackers_git/hackers_watch.go
@@ -2,7 +2,6 @@ package hackers_git
import (
"inotify"
- p "nslcd_proto"
"os"
"path/filepath"
"sd_daemon/logger"
@@ -19,7 +18,7 @@ const (
)
func (o *Hackers) watchHomedir(uid int32) {
- wd, err := o.in_fd.AddWatch(o.users[uid].HomeDir, in_DIR|in_CHILD_ANY)
+ wd, err := o.in_fd.AddWatch(o.users[uid].passwd.HomeDir, in_DIR|in_CHILD_ANY)
if err == nil {
oldwd, found := o.in_uid2wd[uid]
if found && oldwd != wd {
@@ -29,7 +28,7 @@ func (o *Hackers) watchHomedir(uid int32) {
o.in_wd2uid[wd] = uid
} else {
delete(o.in_uid2wd, uid)
- logger.Info("could not watch: %s", o.users[uid].HomeDir)
+ logger.Info("could not watch: %s", o.users[uid].passwd.HomeDir)
}
}
func (o *Hackers) unwatchHomedir(wd inotify.Cint) {
@@ -62,7 +61,7 @@ func (o *Hackers) close() {
}
o.in_wd_home = -1
o.in_wd_yaml = -1
- o.users = make(map[int32]p.Passwd, 0)
+ o.users = make(map[int32]user, 0)
o.in_uid2wd = make(map[int32]inotify.Cint, 0)
o.in_wd2uid = make(map[inotify.Cint]int32, 0)
}
@@ -74,17 +73,17 @@ func (o *Hackers) reload() (err error) {
o.in_wd_yaml, err = o.in_fd.AddWatch(o.cfg.Yamldir, in_DIR|in_CHILD_ANY); if err != nil { return }
files, err := filepath.Glob(o.cfg.Yamldir + "/*.yml")
- o.users = make(map[int32]p.Passwd, len(files))
+ o.users = make(map[int32]user, len(files))
o.in_uid2wd = make(map[int32]inotify.Cint, len(files))
o.in_wd2uid = make(map[inotify.Cint]int32, len(files))
for _, file := range files {
logger.Debug("Loading yaml file: %s", file)
user, err := load_user_yaml(file)
if err == nil {
- o.users[user.UID] = user
+ o.users[user.passwd.UID] = user
logger.Debug("... success")
- o.watchHomedir(user.UID)
- o.passwords[user.UID] = load_user_password(user.HomeDir + "/.password")
+ o.watchHomedir(user.passwd.UID)
+ o.passwords[user.passwd.UID] = load_user_password(user.passwd.HomeDir + "/.password")
} else {
logger.Debug("... error")
}
@@ -94,13 +93,13 @@ func (o *Hackers) reload() (err error) {
return
}
-func (o *Hackers) worker_handle_user_add(user p.Passwd) {
+func (o *Hackers) worker_handle_user_add(user user) {
o.lock.Lock()
defer o.lock.Unlock()
- o.users[user.UID] = user
- o.watchHomedir(user.UID)
- o.passwords[user.UID] = load_user_password(user.HomeDir + "/.password")
+ o.users[user.passwd.UID] = user
+ o.watchHomedir(user.passwd.UID)
+ o.passwords[user.passwd.UID] = load_user_password(user.passwd.HomeDir + "/.password")
}
func (o *Hackers) worker_handle_user_del(uid int32) {
@@ -124,7 +123,7 @@ func (o *Hackers) worker_handle_passwd(uid int32) {
o.lock.Lock()
defer o.lock.Unlock()
- o.passwords[uid] = load_user_password(o.users[uid].HomeDir + "/.password")
+ o.passwords[uid] = load_user_password(o.users[uid].passwd.HomeDir + "/.password")
}
func worker_error(format string, a ...interface{}) {
@@ -156,9 +155,9 @@ func (o *Hackers) worker() {
if err == nil {
// User added/updated
o.worker_handle_user_add(user)
- } else if user.UID >= 0 {
+ } else if user.passwd.UID >= 0 {
// User became invalid
- o.worker_handle_user_del(user.UID)
+ o.worker_handle_user_del(user.passwd.UID)
}
} else {
panic("recieved non-subscribed inotify event from kernel")