From 1fe51d4ad5cebcc562797f55c87bbbf910394f57 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Tue, 18 Jun 2024 17:52:21 +0100 Subject: [PATCH] Don't delete temporary file before using it --- lib/puppet/provider/openldap_global_conf/olc.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/puppet/provider/openldap_global_conf/olc.rb b/lib/puppet/provider/openldap_global_conf/olc.rb index be528fc4..496a1c68 100644 --- a/lib/puppet/provider/openldap_global_conf/olc.rb +++ b/lib/puppet/provider/openldap_global_conf/olc.rb @@ -78,12 +78,13 @@ def create t << "add: olc#{resource[:name]}\n" t << "olc#{resource[:name]}: #{resource[:value]}\n" end - t.close Puppet.debug(File.read(t.path)) begin ldapmodify(t.path) rescue Exception => e raise Puppet::Error, "LDIF content:\n#{File.read t.path}\nError message: #{e.message}" + ensure + t.close end @property_hash[:ensure] = :present end @@ -99,12 +100,13 @@ def destroy else t << "delete: olc#{name}\n" end - t.close Puppet.debug(File.read(t.path)) begin ldapmodify(t.path) rescue Exception => e raise Puppet::Error, "LDIF content:\n#{File.read t.path}\nError message: #{e.message}" + ensure + t.close end @property_hash.clear end @@ -139,12 +141,13 @@ def value=(value) t << "replace: olc#{name}\n" t << "olc#{name}: #{value}\n" end - t.close Puppet.debug(File.read(t.path)) begin ldapmodify(t.path) rescue Exception => e raise Puppet::Error, "LDIF content:\n#{File.read t.path}\nError message: #{e.message}" + ensure + t.close end @property_hash[:value] = value end