summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bin/common.rb.in16
-rw-r--r--parabola-hackers.yml2
2 files changed, 14 insertions, 4 deletions
diff --git a/bin/common.rb.in b/bin/common.rb.in
index 7c457b8..3f5c557 100644
--- a/bin/common.rb.in
+++ b/bin/common.rb.in
@@ -1,4 +1,4 @@
-# Copyright 2016 Luke Shumaker <lukeshu@sbcglobal.net>.
+# Copyright 2016-2017 Luke Shumaker <lukeshu@sbcglobal.net>.
#
# This is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
@@ -14,6 +14,7 @@
# License along with this manual; if not, see
# <http://www.gnu.org/licenses/>.
+require 'set'
require 'yaml'
def cfg
@@ -26,10 +27,19 @@ def cfg
return @cfg
end
+def add_group(group_set, groupname)
+ return if group_set.include?(groupname)
+ group_set.add(groupname)
+ (cfg["groupgroups"][groupname] || []).each do |subgroupname|
+ add_group(group_set, subgroupname)
+ end
+end
+
def load_user_yaml(filename)
user = YAML::load(open(filename))
- groups = user["groups"] || []
- user["groups"] = groups.concat((groups & cfg["groupgroups"].keys).map{|g|cfg["groupgroups"][g]}.flatten)
+ groups = Set.new
+ (user["groups"] || []).each{|groupname| add_group(groups, groupname)}
+ user["groups"] = groups
return user
end
diff --git a/parabola-hackers.yml b/parabola-hackers.yml
index 04c5992..4dfb451 100644
--- a/parabola-hackers.yml
+++ b/parabola-hackers.yml
@@ -3,7 +3,7 @@
yamldir: "/var/lib/hackers-git/users"
# Which groups imply membership in other groups (since UNIX groups
-# can't be nested). Only one level of nesting is supported ATM.
+# can't be nested).
#
# That is, if you are in the 'hackers' group, you are also in the
# 'repo' and 'git' groups, even if they aren't listed.