From 3e0496f6a05f813d48cf7041e8ea7eef51b506b4 Mon Sep 17 00:00:00 2001 From: Matt Bostock Date: Mon, 11 Aug 2014 15:01:13 +0100 Subject: [PATCH] Strip backslashes from the output of rabbitmqctl 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]: https://github.com/rabbitmq/rabbitmq-server/commit/60c14baa96118e587b12716b49f7d66e487a5939#diff-b96d4e7ccd3d984656b8ab3534e6b460 --- .../provider/rabbitmq_user_permissions/rabbitmqctl.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/puppet/provider/rabbitmq_user_permissions/rabbitmqctl.rb b/lib/puppet/provider/rabbitmq_user_permissions/rabbitmqctl.rb index 9d5f1e098..9e330c7de 100644 --- a/lib/puppet/provider/rabbitmq_user_permissions/rabbitmqctl.rb +++ b/lib/puppet/provider/rabbitmq_user_permissions/rabbitmqctl.rb @@ -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} @@ -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