Skip to content

Commit

Permalink
usermanagement: prohibit empty ssh keys
Browse files Browse the repository at this point in the history
previously we allowed ssh keys as empty strings `''`. This doesn't make
sense and breaks the `accounts_ssh_authorized_keys_line_parser()`
function.
  • Loading branch information
bastelfreak committed May 7, 2024
1 parent ea2f809 commit fa366af
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ Default value: `'0600'`

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

Data type: `Array[String]`
Data type: `Array[String[1]]`

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

#### `accounts_ssh_authorized_keys_line_parser(String $str)`
#### `accounts_ssh_authorized_keys_line_parser(String[1] $str)`

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

##### `str`

Data type: `String`
Data type: `String[1]`

ssh authorized_keys line string

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# @example Calling the function
# accounts_ssh_authorized_keys_line_parser_string('options ssh-rsa AAAA... comment)
dispatch :accounts_ssh_authorized_keys_line_parser_string do
param 'String', :str
param 'String[1]', :str
end

def accounts_ssh_authorized_keys_line_parser_string(str)
Expand Down
4 changes: 2 additions & 2 deletions manifests/key_management.pp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
Accounts::User::Name $sshkey_group = $group,
Accounts::User::Name $sshkey_owner = $user,
Variant[Integer[0],String] $sshkey_mode = '0600',
Array[String] $sshkeys = [],
Array[String[1]] $sshkeys = [],
Optional[Stdlib::Unixpath] $user_home = undef,
) {
if $user_home {
Expand Down Expand Up @@ -98,7 +98,7 @@
}

if $sshkeys != [] {
$sshkeys.each |$sshkey| {
$sshkeys.each |String[1] $sshkey| {
accounts::manage_keys { "${sshkey} for ${user}":
ensure => $ensure,
keyspec => $sshkey,
Expand Down
2 changes: 1 addition & 1 deletion manifests/manage_keys.pp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#
define accounts::manage_keys (
Stdlib::Unixpath $key_file,
String $keyspec,
String[1] $keyspec,
Accounts::User::Name $user,
Enum['absent','present'] $ensure = 'present',
Accounts::User::Name $key_owner = $user,
Expand Down
2 changes: 1 addition & 1 deletion manifests/user.pp
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@
Optional[Accounts::User::Name] $sshkey_group = $group,
Optional[Accounts::User::Name] $sshkey_owner = $name,
Variant[Integer[0],String] $sshkey_mode = '0600',
Array[String] $sshkeys = [],
Array[String[1]] $sshkeys = [],
Boolean $system = false,
Optional[Accounts::User::Uid] $uid = undef,
) {
Expand Down

0 comments on commit fa366af

Please sign in to comment.