Skip to content

Commit 883ba88

Browse files
authored
Merge pull request #483 from bastelfreak/empty
usermanagement: prohibit empty ssh keys
2 parents 927c433 + 9fab5e9 commit 883ba88

File tree

6 files changed

+9
-9
lines changed

6 files changed

+9
-9
lines changed

REFERENCE.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ Default value: `'0600'`
505505

506506
##### <a name="-accounts--user--sshkeys"></a>`sshkeys`
507507

508-
Data type: `Array[String]`
508+
Data type: `Array[String[1]]`
509509

510510
An array of SSH public keys associated with the user. These should be
511511
complete public key strings that include the type, content and name of the
@@ -559,7 +559,7 @@ The returned options element can by an empty string.
559559
accounts_ssh_authorized_keys_line_parser_string('options ssh-rsa AAAA... comment)
560560
```
561561

562-
#### `accounts_ssh_authorized_keys_line_parser(String $str)`
562+
#### `accounts_ssh_authorized_keys_line_parser(String[1] $str)`
563563

564564
Parse an ssh authorized_keys line string into an array using its expected
565565
pattern by using a combination of regex matching and extracting the substring
@@ -580,7 +580,7 @@ accounts_ssh_authorized_keys_line_parser_string('options ssh-rsa AAAA... comment
580580

581581
##### `str`
582582

583-
Data type: `String`
583+
Data type: `String[1]`
584584

585585
ssh authorized_keys line string
586586

lib/puppet/functions/accounts_ssh_authorized_keys_line_parser.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# @example Calling the function
1313
# accounts_ssh_authorized_keys_line_parser_string('options ssh-rsa AAAA... comment)
1414
dispatch :accounts_ssh_authorized_keys_line_parser_string do
15-
param 'String', :str
15+
param 'String[1]', :str
1616
end
1717

1818
def accounts_ssh_authorized_keys_line_parser_string(str)

manifests/key_management.pp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
Accounts::User::Name $sshkey_group = $group,
4343
Accounts::User::Name $sshkey_owner = $user,
4444
Variant[Integer[0],String] $sshkey_mode = '0600',
45-
Array[String] $sshkeys = [],
45+
Array[String[1]] $sshkeys = [],
4646
Optional[Stdlib::Unixpath] $user_home = undef,
4747
) {
4848
if $user_home {
@@ -98,7 +98,7 @@
9898
}
9999

100100
if $sshkeys != [] {
101-
$sshkeys.each |$sshkey| {
101+
$sshkeys.each |String[1] $sshkey| {
102102
accounts::manage_keys { "${sshkey} for ${user}":
103103
ensure => $ensure,
104104
keyspec => $sshkey,

manifests/manage_keys.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#
2121
define accounts::manage_keys (
2222
Stdlib::Unixpath $key_file,
23-
String $keyspec,
23+
String[1] $keyspec,
2424
Accounts::User::Name $user,
2525
Enum['absent','present'] $ensure = 'present',
2626
Accounts::User::Name $key_owner = $user,

manifests/user.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@
213213
Optional[Accounts::User::Name] $sshkey_group = $group,
214214
Optional[Accounts::User::Name] $sshkey_owner = $name,
215215
Variant[Integer[0],String] $sshkey_mode = '0600',
216-
Array[String] $sshkeys = [],
216+
Array[String[1]] $sshkeys = [],
217217
Boolean $system = false,
218218
Optional[Accounts::User::Uid] $uid = undef,
219219
) {

spec/functions/accounts_ssh_authorized_keys_line_parser_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
}
99

1010
it {
11-
expect(subject).to run.with_params('').and_raise_error(ArgumentError, %r{Wrong Keyline format!})
11+
expect(subject).to run.with_params('').and_raise_error(ArgumentError, %r{'accounts_ssh_authorized_keys_line_parser' parameter 'str' expects a String\[1\] value, got String})
1212
}
1313

1414
it {

0 commit comments

Comments
 (0)