summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2015-09-07 13:01:01 -0600
committerLuke Shumaker <lukeshu@sbcglobal.net>2015-09-07 13:01:01 -0600
commitce1dc46501556778e73fb120b92873750fab5cf3 (patch)
treef155bd1328cac0ea748f9145a15dada07c37cce8 /src
parent8a72892249cab1c8323b6e402684036364e1825d (diff)
manage each users list of groups as a set instead of a list
Diffstat (limited to 'src')
-rw-r--r--src/nshd/hackers_git/hackers.go2
-rw-r--r--src/nshd/hackers_git/hackers_parse.go9
-rw-r--r--src/nshd/hackers_git/hackers_watch.go6
3 files changed, 6 insertions, 11 deletions
diff --git a/src/nshd/hackers_git/hackers.go b/src/nshd/hackers_git/hackers.go
index c62c476..2bc2fb2 100644
--- a/src/nshd/hackers_git/hackers.go
+++ b/src/nshd/hackers_git/hackers.go
@@ -12,7 +12,7 @@ import (
type user struct {
passwd nslcd_proto.Passwd
- groups []string
+ groups map[string]bool
}
type Config struct {
diff --git a/src/nshd/hackers_git/hackers_parse.go b/src/nshd/hackers_git/hackers_parse.go
index f7baa68..77b9a13 100644
--- a/src/nshd/hackers_git/hackers_parse.go
+++ b/src/nshd/hackers_git/hackers_parse.go
@@ -77,7 +77,7 @@ func parse_user_yaml(filename string) (ret user, err error) {
}
if iface, isSet := data["groups"]; !isSet {
- ret.groups = make([]string, 0)
+ ret.groups = make(map[string]bool, 0)
} else if ary, isTyp := iface.([]interface{}); !isTyp {
errs = append(errs, "\"groups\" is not an array")
} else {
@@ -93,12 +93,7 @@ func parse_user_yaml(filename string) (ret user, err error) {
}
}
if !e {
- ret.groups = make([]string, len(groups))
- var i uint = 0
- for group, _ := range groups {
- ret.groups[i] = group
- i++
- }
+ ret.groups = groups
}
}
}
diff --git a/src/nshd/hackers_git/hackers_watch.go b/src/nshd/hackers_git/hackers_watch.go
index 96e0480..2e5eb75 100644
--- a/src/nshd/hackers_git/hackers_watch.go
+++ b/src/nshd/hackers_git/hackers_watch.go
@@ -106,11 +106,11 @@ func (o *Hackers) load_yaml_file(filename string) {
o.lock.Lock()
defer o.lock.Unlock()
if olduser, found := o.users[uid]; found {
- for _, groupname := range olduser.groups {
+ for groupname, _ := range olduser.groups {
o.del_user_from_group(olduser.passwd.Name, groupname)
}
}
- for _, groupname := range user.groups {
+ for groupname, _ := range user.groups {
o.add_user_to_group(user.passwd.Name, groupname)
}
o.users[uid] = user
@@ -124,7 +124,7 @@ func (o *Hackers) load_yaml_file(filename string) {
o.unwatchHomedir(wd)
}
if olduser, found := o.users[uid]; found {
- for _, groupname := range olduser.groups {
+ for groupname, _ := range olduser.groups {
o.del_user_from_group(olduser.passwd.Name, groupname)
}
delete(o.users, uid)