summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThayne McCombs <thayne@lucidchart.com>2022-08-05 10:27:17 -0600
committerThayne McCombs <thayne@lucidchart.com>2022-08-05 10:27:17 -0600
commitab1b49d7b0529bcd9be1a434915007e74a6c447d (patch)
tree9a3607e76bc6a99fefa100d0c822d512c7d2eecd
parent042a25badeca5e4a87f157b6bdbd6a32499d1c7b (diff)
downloadchef-ab1b49d7b0529bcd9be1a434915007e74a6c447d.tar.gz
Add newline to end of sysctl files
If the sysctl file doesn't end with a newline, then Ubuntu's CIS audit won't correctly detect the sysctl configuration. Also, it is UNIX best practice to include a newline at the end of the last line of text files. Obvious fix. Signed-off-by: Thayne McCombs <thayne@lucid.co>
-rw-r--r--lib/chef/resource/sysctl.rb2
-rw-r--r--spec/unit/resource/sysctl_spec.rb4
2 files changed, 3 insertions, 3 deletions
diff --git a/lib/chef/resource/sysctl.rb b/lib/chef/resource/sysctl.rb
index 97f919fbc9..61f3686ccc 100644
--- a/lib/chef/resource/sysctl.rb
+++ b/lib/chef/resource/sysctl.rb
@@ -187,7 +187,7 @@ class Chef
sysctl_lines << "#{new_resource.key} = #{new_resource.value}"
- sysctl_lines.join("\n")
+ sysctl_lines.join("\n") + "\n"
end
end
diff --git a/spec/unit/resource/sysctl_spec.rb b/spec/unit/resource/sysctl_spec.rb
index 47556f5ee8..42b0c77d83 100644
--- a/spec/unit/resource/sysctl_spec.rb
+++ b/spec/unit/resource/sysctl_spec.rb
@@ -62,14 +62,14 @@ describe Chef::Resource::Sysctl do
context "when comment is a String" do
it "Returns content for use with a file resource" do
resource.comment("This sets foo / bar on our system")
- expect(provider.contruct_sysctl_content).to eql("# This sets foo / bar on our system\nfoo = bar")
+ expect(provider.contruct_sysctl_content).to eql("# This sets foo / bar on our system\nfoo = bar\n")
end
end
context "when comment is an Array" do
it "Returns content for use with a file resource" do
resource.comment(["This sets foo / bar on our system", "We need for baz"])
- expect(provider.contruct_sysctl_content).to eql("# This sets foo / bar on our system\n# We need for baz\nfoo = bar")
+ expect(provider.contruct_sysctl_content).to eql("# This sets foo / bar on our system\n# We need for baz\nfoo = bar\n")
end
end
end