Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

usermanagement: prohibit empty ssh keys #483

Merged
merged 2 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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| {
Ramesh7 marked this conversation as resolved.
Show resolved Hide resolved
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
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
}

it {
expect(subject).to run.with_params('').and_raise_error(ArgumentError, %r{Wrong Keyline format!})
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})
}

it {
Expand Down
Loading