summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nshd/hackers_git/hackers_watch.go16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/nshd/hackers_git/hackers_watch.go b/src/nshd/hackers_git/hackers_watch.go
index 919a578..c10ec78 100644
--- a/src/nshd/hackers_git/hackers_watch.go
+++ b/src/nshd/hackers_git/hackers_watch.go
@@ -70,7 +70,7 @@ func (o *Hackers) reload() (err error) {
o.in_uid2wd = make(map[int32]inotify.Wd, len(filenames))
o.in_wd2uid = make(map[inotify.Wd]int32, len(filenames))
for _, filename := range filenames {
- o.load_yaml_file(filename)
+ o.load_yaml_file(filename, false)
}
err = nil
@@ -97,14 +97,16 @@ func (o *Hackers) del_user_from_group(username string, groupname string) {
}
}
-func (o *Hackers) load_yaml_file(filename string) {
+func (o *Hackers) load_yaml_file(filename string, uselock bool) {
logger.Debug("hackers.git: Loading YAML file: %s", filename)
user, err := parse_user_yaml(filename)
uid := user.passwd.UID
if err == nil {
logger.Debug("hackers.git: -> User %d added/updated", uid)
- o.lock.Lock()
- defer o.lock.Unlock()
+ if uselock {
+ o.lock.Lock()
+ defer o.lock.Unlock()
+ }
if olduser, found := o.users[uid]; found {
for _, groupname := range olduser.groups {
o.del_user_from_group(olduser.passwd.Name, groupname)
@@ -118,8 +120,10 @@ func (o *Hackers) load_yaml_file(filename string) {
} else if uid >= 0 {
// User became invalid
logger.Debug("hackers.git: -> User %d invalidated: %v", uid, err)
- o.lock.Lock()
- defer o.lock.Unlock()
+ if uselock {
+ o.lock.Lock()
+ defer o.lock.Unlock()
+ }
if wd, found := o.in_uid2wd[uid]; found {
o.unwatchHomedir(wd)
}