From 81bc051de0b7b195cff6b26c04e1f898bb6c3613 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 20 Dec 2014 02:09:31 -0500 Subject: ssh-list-authorized-keys: buffer the output to avoid EPIPE --- bin/ssh-list-authorized-keys | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'bin/ssh-list-authorized-keys') diff --git a/bin/ssh-list-authorized-keys b/bin/ssh-list-authorized-keys index bb153e1..6a03c8d 100755 --- a/bin/ssh-list-authorized-keys +++ b/bin/ssh-list-authorized-keys @@ -18,10 +18,13 @@ end users = all_users.find_all{|u| usernames.include?(u["username"]) or not ((u["groups"]||[]) & groupnames).empty?} +# Buffer the output to avoid EPIPE when the reader hangs up early +output="" users.each do |user| if user["ssh_keys"] user["ssh_keys"].each do |addr,key| - puts "#{key} #{user["fullname"]} (#{user["username"]}) <#{addr}>" + output+="#{key} #{user["fullname"]} (#{user["username"]}) <#{addr}>\n" end end end +print output -- cgit v1.2.3-54-g00ecf