diff options
author | Luke Shumaker <lukeshu@sbcglobal.net> | 2015-09-05 20:55:52 -0600 |
---|---|---|
committer | Luke Shumaker <lukeshu@sbcglobal.net> | 2015-09-05 20:55:52 -0600 |
commit | 3390e7d50e49a7e4478a057608525fef8fc1b1db (patch) | |
tree | 9cef6308fa203d93d9125ecc58ebf282ebd34173 | |
parent | 922e4f2ab556fdf1773c8a98bef27f98535e00f7 (diff) |
hackers_git:parse_user_yaml(): prune duplicate group names
-rw-r--r-- | src/nshd/hackers_git/hackers_parse.go | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/nshd/hackers_git/hackers_parse.go b/src/nshd/hackers_git/hackers_parse.go index 858347e..f7baa68 100644 --- a/src/nshd/hackers_git/hackers_parse.go +++ b/src/nshd/hackers_git/hackers_parse.go @@ -81,19 +81,24 @@ func parse_user_yaml(filename string) (ret user, err error) { } else if ary, isTyp := iface.([]interface{}); !isTyp { errs = append(errs, "\"groups\" is not an array") } else { - groups := make([]string, len(ary)) + groups := make(map[string]bool, len(ary)) e := false - for i, iface := range ary { + for _, iface := range ary { if str, isTyp := iface.(string); !isTyp { errs = append(errs, "\"group\" item is not an array") e = true break } else { - groups[i] = str + groups[str] = true } } if !e { - ret.groups = groups + ret.groups = make([]string, len(groups)) + var i uint = 0 + for group, _ := range groups { + ret.groups[i] = group + i++ + } } } } |