summaryrefslogtreecommitdiff
path: root/lib/chef/provider
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2017-03-31 23:14:40 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2017-03-31 23:14:40 -0700
commitf5ab1f1c6a8e5156e677c902ae67efb51976e3ca (patch)
treee0689082c04bb39b0299e181c60242731e39cc0b /lib/chef/provider
parent2fba74b2b07f9ae0899a784ce467632dbd8bbd67 (diff)
downloadchef-f5ab1f1c6a8e5156e677c902ae67efb51976e3ca.tar.gz
remove popen4 from cron resource + fix specs
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'lib/chef/provider')
-rw-r--r--lib/chef/provider/cron.rb23
1 files changed, 4 insertions, 19 deletions
diff --git a/lib/chef/provider/cron.rb b/lib/chef/provider/cron.rb
index 790849673d..bc1b1d97f3 100644
--- a/lib/chef/provider/cron.rb
+++ b/lib/chef/provider/cron.rb
@@ -201,29 +201,14 @@ class Chef
def read_crontab
crontab = nil
- status = popen4("crontab -l -u #{new_resource.user}") do |pid, stdin, stdout, stderr|
- crontab = stdout.read
- end
- if status.exitstatus > 1
- raise Chef::Exceptions::Cron, "Error determining state of #{new_resource.name}, exit: #{status.exitstatus}"
- end
- crontab
+ so = shell_out!("crontab -l -u #{new_resource.user}", returns: [0, 1])
+ return nil if so.exitstatus == 1
+ so.stdout
end
def write_crontab(crontab)
write_exception = false
- status = popen4("crontab -u #{new_resource.user} -", :waitlast => true) do |pid, stdin, stdout, stderr|
- begin
- stdin.write crontab
- rescue Errno::EPIPE => e
- # popen4 could yield while child has already died.
- write_exception = true
- Chef::Log.debug("#{e.message}")
- end
- end
- if status.exitstatus > 0 || write_exception
- raise Chef::Exceptions::Cron, "Error updating state of #{new_resource.name}, exit: #{status.exitstatus}"
- end
+ shell_out!("crontab -u #{new_resource.user} -", input: crontab)
end
def get_crontab_entry