Skip to content

Commit ea82f3b

Browse files
authored
Merge pull request #8611 from smortex/freebsd-service-trunc
(maint) Fix rc-scripts edition on FreeBSD when managing services
2 parents b91e53a + 7d13402 commit ea82f3b

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

lib/puppet/provider/service/freebsd.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def rc_replace(service, rcvar, yesno)
7474
if Puppet::FileSystem.exist?(filename)
7575
s = File.read(filename)
7676
if s.gsub!(/^(#{rcvar}(_enable)?)=\"?(YES|NO)\"?/, "\\1=\"#{yesno}\"")
77-
File.open(filename, File::WRONLY) { |f| f << s }
77+
Puppet::FileSystem.replace_file(filename) { |f| f << s }
7878
self.debug("Replaced in #{filename}")
7979
success = true
8080
end

spec/unit/provider/service/freebsd_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
allow(Puppet::FileSystem).to receive(:exist?).with('/etc/rc.conf').and_return(true)
8383
allow(File).to receive(:read).with('/etc/rc.conf').and_return("openntpd_enable=\"NO\"\nntpd_enable=\"NO\"\n")
8484
fh = double('fh')
85-
allow(File).to receive(:open).with('/etc/rc.conf', File::WRONLY).and_yield(fh)
85+
allow(Puppet::FileSystem).to receive(:replace_file).with('/etc/rc.conf').and_yield(fh)
8686
expect(fh).to receive(:<<).with("openntpd_enable=\"NO\"\nntpd_enable=\"YES\"\n")
8787
allow(Puppet::FileSystem).to receive(:exist?).with('/etc/rc.conf.local').and_return(false)
8888
allow(Puppet::FileSystem).to receive(:exist?).with('/etc/rc.conf.d/ntpd').and_return(false)

0 commit comments

Comments
 (0)