choria-mcorpc-support 2.26.5 → 2.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
data/NOTICE ADDED
@@ -0,0 +1,6 @@
1
+ Choria Orchestrator
2
+
3
+ Copyright 2018 R.I.Pienaar <rip@devco.net>
4
+
5
+ This product includes software developed at
6
+ The Choria Project (https://choria.io).
data/README.md ADDED
@@ -0,0 +1,14 @@
1
+ # Choria MCollective RPC Ruby Support Libraries
2
+
3
+ These are stripped down versions of the [legacy Marionette Collective libraries](https://github.com/choria-legacy/marionette-collective) that
4
+ are used to facilitate hosting Ruby based MCollective Agents within the
5
+ Golang daemon as well as interact with a Choria network from the Ruby API
6
+ and `mco` CLI
7
+
8
+ It's not possible to run the old MCollective daemon using this code or the
9
+ resulting gem.
10
+
11
+ This fork was made off version `2.12.0` of The Marionette Collective and have
12
+ diverged since then, the changes made are not compatible with legacy MCollective.
13
+
14
+ For further information please see [https://choria.io](https://choria.io/)
data/Rakefile ADDED
@@ -0,0 +1,58 @@
1
+ require "rubygems/package_task"
2
+
3
+ spec = Gem::Specification.load('choria-mcorpc-support.gemspec')
4
+
5
+ Gem::PackageTask.new(spec) do |pkg|
6
+ pkg.need_tar = false
7
+ pkg.need_zip = false
8
+ pkg.package_dir = "build"
9
+ end
10
+
11
+ desc "Run spec tests"
12
+ task :test do
13
+ sh "bundle exec rubocop --config .rubocop.yml lib"
14
+ sh "bundle exec rspec"
15
+ end
16
+
17
+ desc "Update JSON DDL files"
18
+ task :update_ddl do
19
+ require "mcollective"
20
+
21
+ ["choria_util", "rpcutil", "scout"].each do |ddl|
22
+ ["ddl", "json"].each do |ext|
23
+ fname = "%s.%s" % [ddl, ext]
24
+ outfile = File.join("lib/mcollective/agent", fname)
25
+ url = "https://raw.githubusercontent.com/choria-io/go-choria/master/providers/agent/mcorpc/ddl/agent/%s" % fname
26
+
27
+ puts "Updating %s via %s" % [outfile, url]
28
+ system("curl -so %s %s" % [outfile, url])
29
+ end
30
+ end
31
+
32
+ Dir.glob("lib/mcollective/agent/*.ddl") do |ddlfile|
33
+ agent_dir = File.dirname(ddlfile)
34
+ agent_name = File.basename(ddlfile, ".ddl")
35
+ json_file = File.join(agent_dir, "%s.json" % agent_name)
36
+
37
+ next if agent_name =~ /^(choria_util|rpcutil|scout)/
38
+
39
+ ddl = MCollective::DDL.new(agent_name, :agent, false)
40
+ ddl.instance_eval(File.read(ddlfile))
41
+
42
+ data = {
43
+ "$schema" => "https://choria.io/schemas/mcorpc/ddl/v1/agent.json",
44
+ "metadata" => ddl.meta,
45
+ "actions" => []
46
+ }
47
+
48
+ ddl.actions.sort.each do |action|
49
+ data["actions"] << ddl.action_interface(action)
50
+ end
51
+
52
+ puts "Writing JSON DDL in %s" % json_file
53
+
54
+ File.open(json_file, "w") do |jddl|
55
+ jddl.print(JSON.pretty_generate(data))
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,21 @@
1
+ main_collective = mcollective
2
+ collectives = mcollective
3
+ libdir = /usr/libexec/mcollective
4
+ logger_type = console
5
+ loglevel = warn
6
+
7
+ # Plugins
8
+ securityprovider = psk
9
+ plugin.psk = unset
10
+
11
+ connector = activemq
12
+ plugin.activemq.pool.size = 1
13
+ plugin.activemq.pool.1.host = stomp1
14
+ plugin.activemq.pool.1.port = 6163
15
+ plugin.activemq.pool.1.user = mcollective
16
+ plugin.activemq.pool.1.password = marionette
17
+
18
+ # Facts
19
+ factsource = yaml
20
+ plugin.yaml = /etc/mcollective/facts.yaml
21
+
@@ -0,0 +1,2 @@
1
+ ---
2
+ mcollective: 1
@@ -0,0 +1,22 @@
1
+ main_collective = mcollective
2
+ collectives = mcollective
3
+ libdir = /usr/libexec/mcollective
4
+ logfile = /var/log/mcollective.log
5
+ loglevel = info
6
+ daemonize = 1
7
+
8
+ # Plugins
9
+ securityprovider = psk
10
+ plugin.psk = unset
11
+
12
+ connector = activemq
13
+ plugin.activemq.pool.size = 1
14
+ plugin.activemq.pool.1.host = stomp1
15
+ plugin.activemq.pool.1.port = 6163
16
+ plugin.activemq.pool.1.user = mcollective
17
+ plugin.activemq.pool.1.password = marionette
18
+
19
+ # Facts
20
+ factsource = yaml
21
+ plugin.yaml = /etc/mcollective/facts.yaml
22
+
File without changes
File without changes
@@ -274,17 +274,21 @@ module MCollective
274
274
  #
275
275
  # @param msg [Message]
276
276
  def publish_connected_directed(msg)
277
+ # The body and the headers are the same for every node, only the
278
+ # subject differs, so the JSON is built once rather than per node
279
+ headers = headers_for(msg)
280
+ data = {
281
+ "protocol" => "choria:transport:1",
282
+ "data" => msg.payload,
283
+ "headers" => headers
284
+ }.to_json
285
+
277
286
  msg.discovered_hosts.each do |node|
278
- target = target_for(msg, node)
279
- data = {
280
- "protocol" => "choria:transport:1",
281
- "data" => msg.payload,
282
- "headers" => target[:headers]
283
- }
287
+ target = make_target(msg.agent, msg.type, msg.collective, node)
284
288
 
285
- Log.debug("Sending a direct message to %s via NATS target '%s' for message type %s" % [node, target.inspect, msg.type])
289
+ Log.debug("Sending a direct message to %s via NATS target '%s' for message type %s" % [node, target, msg.type])
286
290
 
287
- connection.publish(target[:name], data.to_json, target[:headers]["reply-to"])
291
+ connection.publish(target, data, headers["reply-to"])
288
292
  end
289
293
  end
290
294
 
@@ -1,30 +1,3 @@
1
- # start_with? was introduced in 1.8.7, we need to support
2
- # 1.8.5 and 1.8.6
3
- class String
4
- unless method_defined?("start_with?")
5
- def start_with?(str)
6
- self[0..(str.length - 1)] == str
7
- end
8
- end
9
- end
10
-
11
- # Make arrays of Symbols sortable
12
- class Symbol
13
- include Comparable
14
-
15
- unless method_defined?("<=>")
16
- def <=>(other)
17
- to_s <=> other.to_s
18
- end
19
- end
20
- end
21
-
22
- # This provides an alias for RbConfig to Config for versions of Ruby older then
23
- # # version 1.8.5. This allows us to use RbConfig in place of the older Config in
24
- # # our code and still be compatible with at least Ruby 1.8.1.
25
- # require 'rbconfig'
26
- ::RbConfig = ::Config unless defined? ::RbConfig
27
-
28
1
  # a method # that walks an array in groups, pass a block to
29
2
  # call the block on each sub array
30
3
  class Array
@@ -63,97 +36,23 @@ class Array
63
36
  end
64
37
  end
65
38
 
66
- class String
67
- unless method_defined?(:bytes)
68
- def bytes(&block)
69
- # This should not be necessary, really ...
70
- return to_enum(:each_byte) unless block_given?
71
-
72
- each_byte(&block)
73
- end
74
- end
75
- end
76
-
77
- class Dir
78
- unless method_defined?(:mktmpdir)
79
- def self.mktmpdir(prefix_suffix=nil, tmpdir=nil)
80
- case prefix_suffix
81
- when nil
82
- prefix = "d"
83
- suffix = ""
84
- when String
85
- prefix = prefix_suffix
86
- suffix = ""
87
- when Array
88
- prefix = prefix_suffix[0]
89
- suffix = prefix_suffix[1]
90
- else
91
- raise ArgumentError, "unexpected prefix_suffix: #{prefix_suffix.inspect}"
92
- end
93
- tmpdir ||= Dir.tmpdir
94
- t = Time.now.strftime("%Y%m%d")
95
- n = nil
96
- begin
97
- path = "#{tmpdir}/#{prefix}#{t}-#{$$}-#{rand(0x100000000).to_s(36)}"
98
- path << "-#{n}" if n
99
- path << suffix
100
- Dir.mkdir(path, 0o700)
101
- rescue Errno::EEXIST
102
- n ||= 0
103
- n += 1
104
- retry
105
- end
106
-
107
- if block_given?
108
- begin
109
- yield path
110
- ensure
111
- FileUtils.remove_entry_secure path
112
- end
113
- else
114
- path
115
- end
116
- end
117
- end
118
-
119
- unless method_defined?(:tmpdir)
120
- def self.tmpdir
121
- tmp = "."
122
- [ENV["TMPDIR"], ENV["TMP"], ENV["TEMP"], "/tmp"].each do |dir|
123
- if dir && (stat = File.stat(dir)) && stat.directory? && stat.writable?
124
- tmp = dir
125
- break
126
- end rescue nil
127
- end
128
-
129
- File.expand_path(tmp)
130
- end
131
- end
132
- end
133
-
134
- # Reject all SSLv2 ciphers and all SSLv2 or SSLv3 handshakes by default
39
+ # Reject all SSLv2 ciphers and all SSLv2 or SSLv3 handshakes by default.
40
+ # The openssl gem freezes DEFAULT_PARAMS from 4.0 on, so the adjusted
41
+ # defaults are passed to set_params on each new context instead of being
42
+ # written into the shared hash.
135
43
  require "openssl"
136
44
  class OpenSSL::SSL::SSLContext # rubocop:disable Style/ClassAndModuleChildren
137
- if DEFAULT_PARAMS[:options]
138
- DEFAULT_PARAMS[:options] |= OpenSSL::SSL::OP_NO_SSLv2 | OpenSSL::SSL::OP_NO_SSLv3
139
- else
140
- DEFAULT_PARAMS[:options] = OpenSSL::SSL::OP_NO_SSLv2 | OpenSSL::SSL::OP_NO_SSLv3
141
- end
142
-
143
- # ruby 1.8.5 doesn't define this constant, but has it on by default
144
- DEFAULT_PARAMS[:options] |= OpenSSL::SSL::OP_DONT_INSERT_EMPTY_FRAGMENTS if defined?(OpenSSL::SSL::OP_DONT_INSERT_EMPTY_FRAGMENTS)
145
-
146
- DEFAULT_PARAMS[:ciphers] << ":!SSLv2" if DEFAULT_PARAMS[:ciphers]
147
-
148
45
  alias __mcollective_original_initialize initialize
149
46
  private :__mcollective_original_initialize
150
47
 
151
48
  def initialize(*args)
152
49
  __mcollective_original_initialize(*args)
153
- params = {
154
- :options => DEFAULT_PARAMS[:options],
155
- :ciphers => DEFAULT_PARAMS[:ciphers]
156
- }
50
+
51
+ options = DEFAULT_PARAMS[:options] | OpenSSL::SSL::OP_NO_SSLv2 | OpenSSL::SSL::OP_NO_SSLv3 | OpenSSL::SSL::OP_DONT_INSERT_EMPTY_FRAGMENTS
52
+
53
+ params = {:options => options}
54
+ params[:ciphers] = "#{DEFAULT_PARAMS[:ciphers]}:!SSLv2" if DEFAULT_PARAMS[:ciphers]
55
+
157
56
  set_params(params)
158
57
  end
159
58
  end
@@ -191,7 +191,7 @@ module MCollective
191
191
  end
192
192
 
193
193
  def render_template(infile, outfile)
194
- erb = ERB.new(File.read(infile), :safe_level => 0, :trim_mode => "-")
194
+ erb = ERB.new(File.read(infile), :trim_mode => "-")
195
195
  File.open(outfile, "w") do |f|
196
196
  f.puts erb.result(binding)
197
197
  end
@@ -80,7 +80,8 @@ module MCollective
80
80
  @collective = @client.collective
81
81
  @ttl = initial_options[:ttl] || Config.instance.ttl
82
82
  @publish_timeout = initial_options[:publish_timeout] || Config.instance.publish_timeout
83
- @threaded = initial_options[:threaded] || Config.instance.threaded
83
+ # an option given as false wins over the configuration, one absent or nil leaves it to the configuration
84
+ @threaded = initial_options[:threaded].nil? ? Config.instance.threaded : initial_options[:threaded]
84
85
 
85
86
  # if we can find a DDL for the service override
86
87
  # the timeout of the client so we always magically
@@ -185,8 +185,11 @@ module MCollective
185
185
  SSL.base64_encode(string)
186
186
  end
187
187
 
188
+ # Without the line break encode64 adds every 60 characters, which costs
189
+ # two bytes each once escaped inside the transport JSON and nothing to
190
+ # leave out, since the decoders accept unbroken base64
188
191
  def self.base64_encode(string)
189
- Base64.encode64(string)
192
+ Base64.strict_encode64(string)
190
193
  end
191
194
 
192
195
  # base 64 decode a string
@@ -196,8 +199,11 @@ module MCollective
196
199
 
197
200
  def self.base64_decode(string)
198
201
  # The Base 64 character set is A-Z a-z 0-9 + / =
199
- # Also allow for whitespace, but raise if we get anything else
200
- raise(ArgumentError, "invalid base64") if string !~ /^[A-Za-z0-9+\/=\s]+$/
202
+ # Also allow for whitespace, but raise if we get anything else.
203
+ # String#count checks a megabyte in well under a millisecond where
204
+ # a regex over the whole string took tens of milliseconds and a
205
+ # backtrack stack of its own size.
206
+ raise(ArgumentError, "invalid base64") if string.empty? || string.count("^A-Za-z0-9+/= \t\r\n\f\v") > 0
201
207
 
202
208
  Base64.decode64(string)
203
209
  end
@@ -259,22 +265,6 @@ module MCollective
259
265
  key = OpenSSL::X509::Certificate.new(File.read(key)).public_key
260
266
  end
261
267
 
262
- # Ruby < 1.9.3 had a bug where it does not correctly clear the
263
- # queue of errors while reading a key. It tries various ways
264
- # to read the key and each failing attempt pushes an error onto
265
- # the queue. With pubkeys only the 3rd attempt pass leaving 2
266
- # stale errors on the error queue.
267
- #
268
- # In 1.9.3 they fixed this by simply discarding the errors after
269
- # every attempt. So we simulate this fix here for older rubies
270
- # as without it we get SSL_read errors from the Stomp+TLS sessions
271
- #
272
- # We do this only on 1.8 relying on 1.9.3 to do the right thing
273
- # and we do not support 1.9 less than 1.9.3
274
- #
275
- # See http://bugs.ruby-lang.org/issues/4550
276
- OpenSSL.errors if Util.ruby_version =~ /^1.8/
277
-
278
268
  key
279
269
  when :private
280
270
  OpenSSL::PKey::RSA.new(File.read(key), passphrase)
@@ -755,13 +755,7 @@ module MCollective
755
755
 
756
756
  extra_chain_cert = cert_chain[1..-1]
757
757
 
758
- if OpenSSL::SSL::SSLContext.method_defined?(:add_certificate)
759
- context.add_certificate(cert, key, extra_chain_cert)
760
- else
761
- context.cert = OpenSSL::X509::Certificate.new(File.read(client_public_cert))
762
- context.key = OpenSSL::PKey::RSA.new(File.read(client_private_key))
763
- context.extra_chain_cert = extra_chain_cert
764
- end
758
+ context.add_certificate(cert, key, extra_chain_cert)
765
759
 
766
760
  context.verify_mode = OpenSSL::SSL::VERIFY_PEER
767
761
 
@@ -287,8 +287,9 @@ module MCollective
287
287
  begin
288
288
  Log.debug("Asserting '%s' over %d replies" % [@assertion, replies.size])
289
289
  result = JGrep.jgrep(jdata, @assertion)
290
- rescue
291
- Log.error("Assertion '%s' could not be matched: %s" % [@asssertion, expected])
290
+ rescue => e
291
+ Log.error("Assertion '%s' could not be matched: %s: %s" % [@assertion, e.class, e.to_s])
292
+ Log.debug(e.backtrace.join("\t\n"))
292
293
  end
293
294
 
294
295
  [result.size == expected, expected - result.size]
@@ -79,7 +79,10 @@ module MCollective
79
79
  legacy = File.join(aio_bin_path, "task_wrapper.exe")
80
80
  return legacy if File.exist?(legacy)
81
81
 
82
- File.join(aio_bin_path, "execution_wrapper.exe")
82
+ legacy_puppet = File.join(aio_bin_path, "execution_wrapper.exe")
83
+ return legacy_puppet if File.exist?(legacy_puppet)
84
+
85
+ File.join(aio_bin_path, "execution_wrapper.bat")
83
86
  else
84
87
  legacy = File.join(aio_bin_path, "task_wrapper")
85
88
  return legacy if File.exist?(legacy)
@@ -294,6 +297,7 @@ module MCollective
294
297
 
295
298
  pid = Process.fork
296
299
  if pid.nil?
300
+ Process.initgroups(run_as, u.gid)
297
301
  Process.gid = Process.egid = u.gid
298
302
  Process.uid = Process.euid = u.uid
299
303
  ENV.delete_if { |name| name !~ /^LC_/ }