Skip to content

Commit

Permalink
Strip backslashes from the output of rabbitmqctl
Browse files Browse the repository at this point in the history
The output of `rabbitmqctl(1)` escapes backslashes. This was documented
in the `rabbitmqctl` man page[1] but was removed when the manpage was
converted to DocBook XML[2].

This change causes extraneous backslashes to be stripped to prevent
this module from misreading escaped characters in regular expressions
and repeatedly applying the same change.

[1]:
https://github.com/rabbitmq/rabbitmq-server/blob/16418a9488e15c4d8ef3bfa9fce69190fb8ec796/docs/rabbitmqctl.1.pod#output-escaping
[2]:
rabbitmq/rabbitmq-server@60c14ba#diff-b96d4e7ccd3d984656b8ab3534e6b460
  • Loading branch information
mattbostock committed Dec 1, 2014
1 parent 61991d7 commit 3e0496f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions 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 @@ -102,4 +103,9 @@ def set_permissions
end
end

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

end

0 comments on commit 3e0496f

Please sign in to comment.