Skip to content

Commit bae5c27

Browse files
committed
Correctly pass in arguments as a single array
Previously it used << with an array that ended up with a nested array. Now it correctly uses += resulting in a single flat array. Fixes: 6e1c856 ("Pass openssl commands as an array")
1 parent 41513a9 commit bae5c27

File tree

4 files changed

+25
-25
lines changed

4 files changed

+25
-25
lines changed

lib/puppet/provider/x509_cert/openssl.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,14 @@ def create
6666
'-out', resource[:path]
6767
]
6868
if resource[:ca]
69-
options << ['-extfile', resource[:template]]
70-
options << ['-CAcreateserial']
71-
options << ['-CA', resource[:ca]]
72-
options << ['-CAkey', resource[:cakey]]
69+
options += ['-extfile', resource[:template]]
70+
options += ['-CAcreateserial']
71+
options += ['-CA', resource[:ca]]
72+
options += ['-CAkey', resource[:cakey]]
7373
else
74-
options << ['-signkey', resource[:private_key]]
74+
options += ['-signkey', resource[:private_key]]
7575
if resource[:req_ext]
76-
options << [
76+
options += [
7777
'-extensions', 'v3_req',
7878
'-extfile', resource[:template]
7979
]
@@ -92,8 +92,8 @@ def create
9292

9393
password = resource[:cakey_password] || resource[:password]
9494

95-
options << ['-passin', "pass:#{password}"] if password
96-
options << ['-extensions', 'v3_req'] if resource[:req_ext] != :false
95+
options += ['-passin', "pass:#{password}"] if password
96+
options += ['-extensions', 'v3_req'] if resource[:req_ext] != :false
9797
openssl options
9898
end
9999

lib/puppet/provider/x509_request/openssl.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ def create
3535
'-out', resource[:path]
3636
]
3737

38-
options << ['-passin', "pass:#{resource[:password]}"] if resource[:password]
39-
options << ['-nodes'] unless resource[:encrypted]
38+
options += ['-passin', "pass:#{resource[:password]}"] if resource[:password]
39+
options += ['-nodes'] unless resource[:encrypted]
4040

4141
openssl options
4242
end

spec/unit/puppet/provider/x509_cert/openssl_spec.rb

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
'-days', 3650,
4040
'-key', '/tmp/foo.key',
4141
'-out', '/tmp/foo.crt',
42-
['-extensions', 'v3_req']
42+
'-extensions', 'v3_req',
4343
])
4444
resource.provider.create
4545
end
@@ -55,8 +55,8 @@
5555
'-days', 3650,
5656
'-key', '/tmp/foo.key',
5757
'-out', '/tmp/foo.crt',
58-
['-passin', 'pass:2x6${'],
59-
['-extensions', 'v3_req']
58+
'-passin', 'pass:2x6${',
59+
'-extensions', 'v3_req',
6060
])
6161
resource.provider.create
6262
end
@@ -74,11 +74,11 @@
7474
'-days', 3650,
7575
'-in', '/tmp/foo.csr',
7676
'-out', '/tmp/foo.crt',
77-
['-extfile', '/tmp/foo.cnf'],
78-
['-CAcreateserial'],
79-
['-CA', '/tmp/foo-ca.crt'],
80-
['-CAkey', '/tmp/foo-ca.key'],
81-
['-extensions', 'v3_req']
77+
'-extfile', '/tmp/foo.cnf',
78+
'-CAcreateserial',
79+
'-CA', '/tmp/foo-ca.crt',
80+
'-CAkey', '/tmp/foo-ca.key',
81+
'-extensions', 'v3_req',
8282
])
8383
resource.provider.create
8484
end
@@ -96,12 +96,12 @@
9696
'-days', 3650,
9797
'-in', '/tmp/foo.csr',
9898
'-out', '/tmp/foo.crt',
99-
['-extfile', '/tmp/foo.cnf'],
100-
['-CAcreateserial'],
101-
['-CA', '/tmp/foo-ca.crt'],
102-
['-CAkey', '/tmp/foo-ca.key'],
103-
['-passin', 'pass:5i;6%'],
104-
['-extensions', 'v3_req']
99+
'-extfile', '/tmp/foo.cnf',
100+
'-CAcreateserial',
101+
'-CA', '/tmp/foo-ca.crt',
102+
'-CAkey', '/tmp/foo-ca.key',
103+
'-passin', 'pass:5i;6%',
104+
'-extensions', 'v3_req',
105105
])
106106
resource.provider.create
107107
end

spec/unit/puppet/provider/x509_request/openssl_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
'-key', '/tmp/foo.key',
4646
'-config', '/tmp/foo.cnf',
4747
'-out', '/tmp/foo.csr',
48-
['-passin', 'pass:2x6${']
48+
'-passin', 'pass:2x6${',
4949
])
5050
resource.provider.create
5151
end

0 commit comments

Comments
 (0)