From 3e0496f6a05f813d48cf7041e8ea7eef51b506b4 Mon Sep 17 00:00:00 2001 From: Matt Bostock Date: Mon, 11 Aug 2014 15:01:13 +0100 Subject: [PATCH 1/3] 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 From 7bddb6111f09efd218bef7500da4a4f9668853a8 Mon Sep 17 00:00:00 2001 From: Matt Bostock Date: Tue, 26 Aug 2014 19:15:27 +0100 Subject: [PATCH 2/3] Use shorter URL for RabbitMQ documentation As suggested in https://github.com/puppetlabs/puppetlabs-rabbitmq/pull/225. --- lib/puppet/provider/rabbitmq_user_permissions/rabbitmqctl.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/puppet/provider/rabbitmq_user_permissions/rabbitmqctl.rb b/lib/puppet/provider/rabbitmq_user_permissions/rabbitmqctl.rb index 9e330c7de..1959591a6 100644 --- a/lib/puppet/provider/rabbitmq_user_permissions/rabbitmqctl.rb +++ b/lib/puppet/provider/rabbitmq_user_permissions/rabbitmqctl.rb @@ -104,7 +104,7 @@ def set_permissions end def self.strip_backslashes(string) - # See: https://github.com/rabbitmq/rabbitmq-server/blob/16418a9488e15c4d8ef3bfa9fce69190fb8ec796/docs/rabbitmqctl.1.pod#output-escaping + # See: https://github.com/rabbitmq/rabbitmq-server/blob/v1_7/docs/rabbitmqctl.1.pod#output-escaping string.gsub(/\\\\/, '\\') end From a6a98e4ab722a01ca47a39ca371eccbcfa4888b6 Mon Sep 17 00:00:00 2001 From: Matt Bostock Date: Mon, 1 Dec 2014 16:12:17 +0000 Subject: [PATCH 3/3] Remove trailing whitespace --- lib/puppet/provider/rabbitmq_user_permissions/rabbitmqctl.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/puppet/provider/rabbitmq_user_permissions/rabbitmqctl.rb b/lib/puppet/provider/rabbitmq_user_permissions/rabbitmqctl.rb index 1959591a6..360850629 100644 --- a/lib/puppet/provider/rabbitmq_user_permissions/rabbitmqctl.rb +++ b/lib/puppet/provider/rabbitmq_user_permissions/rabbitmqctl.rb @@ -52,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