summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nshd/hackers_git/db_passwd.go9
-rw-r--r--src/nshd/hackers_git/gid.go6
-rw-r--r--src/nshd/hackers_git/hackers.go2
-rw-r--r--src/nshd/hackers_git/hackers_parse.go4
-rw-r--r--src/nshd/hackers_git/hackers_watch.go6
-rw-r--r--src/nshd/hackers_git/set.go11
6 files changed, 23 insertions, 15 deletions
diff --git a/src/nshd/hackers_git/db_passwd.go b/src/nshd/hackers_git/db_passwd.go
index 2cfaccd..719ff3f 100644
--- a/src/nshd/hackers_git/db_passwd.go
+++ b/src/nshd/hackers_git/db_passwd.go
@@ -69,19 +69,16 @@ func (o *allPasswdEnumerator) GenericGetNext() (n *interface{}, err error) {
return
}
-func (o *Hackers) newAllPasswdEnumerator() *allPasswdEnumerator {
+func (o *Hackers) Passwd_All(cred p.Ucred, req p.Request_Passwd_All) p.Passwd_Enumerator {
o.lock.RLock()
e := allPasswdEnumerator{
uids: make([]int32, len(o.users)),
backend: o,
done: false,
}
+ i := uint(0)
for uid, _ := range o.users {
- e.uids = append(e.uids, uid)
+ e.uids[i] = uid
}
return &e
}
-
-func (o *Hackers) Passwd_All(cred p.Ucred, req p.Request_Passwd_All) p.Passwd_Enumerator {
- return o.newAllPasswdEnumerator()
-}
diff --git a/src/nshd/hackers_git/gid.go b/src/nshd/hackers_git/gid.go
index ff95309..ee8c10d 100644
--- a/src/nshd/hackers_git/gid.go
+++ b/src/nshd/hackers_git/gid.go
@@ -11,11 +11,11 @@ func name2gid(name string) int32 {
}
}
-func gid2name(gid int32) string {
+func gid2name(gid int32) (string, bool) {
gr, err := getgr.ByGid(gid)
if gr == nil || err != nil {
- return ""
+ return "", false
} else {
- return gr.Name
+ return gr.Name, true
}
}
diff --git a/src/nshd/hackers_git/hackers.go b/src/nshd/hackers_git/hackers.go
index 83ef482..f84b110 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 map[string]bool
+ groups []string
}
type Config struct {
diff --git a/src/nshd/hackers_git/hackers_parse.go b/src/nshd/hackers_git/hackers_parse.go
index 77b9a13..46c878e 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(map[string]bool, 0)
+ ret.groups = make([]string, 0)
} else if ary, isTyp := iface.([]interface{}); !isTyp {
errs = append(errs, "\"groups\" is not an array")
} else {
@@ -93,7 +93,7 @@ func parse_user_yaml(filename string) (ret user, err error) {
}
}
if !e {
- ret.groups = groups
+ ret.groups = set2list(groups)
}
}
}
diff --git a/src/nshd/hackers_git/hackers_watch.go b/src/nshd/hackers_git/hackers_watch.go
index f5029de..8e3834e 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)
diff --git a/src/nshd/hackers_git/set.go b/src/nshd/hackers_git/set.go
new file mode 100644
index 0000000..9faf0f4
--- /dev/null
+++ b/src/nshd/hackers_git/set.go
@@ -0,0 +1,11 @@
+package hackers_git
+
+func set2list(set map[string]bool) []string {
+ list := make([]string, len(set))
+ i := uint(0)
+ for item, _ := range set {
+ list[i] = item
+ i++
+ }
+ return list
+}