Skip to content

Commit

Permalink
Treat values as simple/array based on local lens
Browse files Browse the repository at this point in the history
This code previously used an explicitly defined list of labels that were
treated as arrays and not simple values. This broke the sshd_config
provider for users with a version of the sshd lens from augeas 1.9.0 or
newer. To avoid breaking support for older users, and to be
forward-compatible with new versions of augeas that are aware of
additional array values, this change determines if a label is an array
or simple value by testing what the underlying augeas provider returns
  • Loading branch information
tedgarb committed Feb 15, 2024
1 parent d818ef6 commit b59794a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/puppet/provider/ssh_config/augeas.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def self.get_value(aug, pathx)
end

def self.set_value(aug, base, path, label, value)
if label =~ %r{Ciphers|SendEnv|MACs|(HostKey|Kex)Algorithms|GlobalKnownHostsFile|PubkeyAcceptedKeyTypes}i
if parsed_as?("#{label} FOO\n", "#{label}/1", lens)
set_array_value(aug, path, value)
else
set_simple_value(aug, base, path, label, value)
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/provider/sshd_config/augeas.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def self.get_value(aug, pathx)
end

def self.set_value(aug, base, path, label, value)
if label =~ %r{^(((Allow|Deny)(Groups|Users))|AcceptEnv|MACs|(HostKey|Kex)Algorithms|Ciphers)$}i
if parsed_as?("#{label} FOO\n", "#{label}/1", lens)
set_array_value(aug, base, path, label, value)
else
set_simple_value(aug, base, path, label, value)
Expand Down

0 comments on commit b59794a

Please sign in to comment.