From b59794abe888c023c2393051584763bf5e3e9566 Mon Sep 17 00:00:00 2001 From: Edward Garbade Date: Thu, 15 Apr 2021 13:33:44 -0400 Subject: [PATCH] Treat values as simple/array based on local lens 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 --- lib/puppet/provider/ssh_config/augeas.rb | 2 +- lib/puppet/provider/sshd_config/augeas.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/puppet/provider/ssh_config/augeas.rb b/lib/puppet/provider/ssh_config/augeas.rb index 6ba4589..0f5851f 100644 --- a/lib/puppet/provider/ssh_config/augeas.rb +++ b/lib/puppet/provider/ssh_config/augeas.rb @@ -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) diff --git a/lib/puppet/provider/sshd_config/augeas.rb b/lib/puppet/provider/sshd_config/augeas.rb index de3c2f9..3bcb43b 100644 --- a/lib/puppet/provider/sshd_config/augeas.rb +++ b/lib/puppet/provider/sshd_config/augeas.rb @@ -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)