From 61fc766d07e5252b9618c6548ea714649ab54a54 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 15 Jun 2016 13:03:50 -0400 Subject: Pull tool configuration into a hackers-git.yml --- bin/ssh-list-authorized-keys | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'bin/ssh-list-authorized-keys') diff --git a/bin/ssh-list-authorized-keys b/bin/ssh-list-authorized-keys index 6a03c8d..5e178e1 100755 --- a/bin/ssh-list-authorized-keys +++ b/bin/ssh-list-authorized-keys @@ -1,22 +1,17 @@ #!/usr/bin/env ruby # Usage: ssh-list-authorized-keys [username] -cfg_groups = [ "repo", "git" ] -###################################################################### -require 'set' -require 'yaml' +load "#{File.dirname(__FILE__)}/common.rb" -all_users = Dir.glob("users/*.yml").map{|f|YAML::load(open(f))} -users = Set.new +all_users = load_all_users -groupnames = ARGV & cfg_groups +groupnames = ARGV & cfg["ssh_pseudo_users"] usernames = ARGV & all_users.map{|u|u["username"]} -unless groupnames.empty? - groupnames.push("hackers") -end - -users = all_users.find_all{|u| usernames.include?(u["username"]) or not ((u["groups"]||[]) & groupnames).empty?} +users = all_users.find_all{|u| + # [ username was listed ] or [ the user is in a listed group ] + usernames.include?(u["username"]) or not (u["groups"] & groupnames).empty? +} # Buffer the output to avoid EPIPE when the reader hangs up early output="" -- cgit v1.2.3-54-g00ecf