Skip to content

Commit

Permalink
Merge pull request redhat-openstack#225 from alphagov/strip-backslashes
Browse files Browse the repository at this point in the history
Strip backslashes from the output of rabbitmqctl
  • Loading branch information
cmurphy committed Dec 4, 2014
2 parents e2e70a7 + a6a98e4 commit 40af5f0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/puppet/provider/rabbitmq_user_permissions/rabbitmqctl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def self.users(name, vhost)
unless @users[name]
@users[name] = {}
rabbitmqctl('-q', 'list_user_permissions', name).split(/\n/).each do |line|
line = self::strip_backslashes(line)
if line =~ /^(\S+)\s+(\S*)\s+(\S*)\s+(\S*)$/
@users[name][$1] =
{:configure => $2, :read => $4, :write => $3}
Expand Down Expand Up @@ -51,7 +52,7 @@ def create
resource[:configure_permission] ||= "''"
resource[:read_permission] ||= "''"
resource[:write_permission] ||= "''"
rabbitmqctl('set_permissions', '-p', should_vhost, should_user, resource[:configure_permission], resource[:write_permission], resource[:read_permission])
rabbitmqctl('set_permissions', '-p', should_vhost, should_user, resource[:configure_permission], resource[:write_permission], resource[:read_permission])
end

def destroy
Expand Down Expand Up @@ -102,4 +103,9 @@ def set_permissions
end
end

def self.strip_backslashes(string)
# See: https://github.com/rabbitmq/rabbitmq-server/blob/v1_7/docs/rabbitmqctl.1.pod#output-escaping
string.gsub(/\\\\/, '\\')
end

end

0 comments on commit 40af5f0

Please sign in to comment.