summaryrefslogtreecommitdiffstats
path: root/lib/puppet/util/selinux.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/puppet/util/selinux.rb')
-rw-r--r--lib/puppet/util/selinux.rb11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/puppet/util/selinux.rb b/lib/puppet/util/selinux.rb
index b181b3556..0df137370 100644
--- a/lib/puppet/util/selinux.rb
+++ b/lib/puppet/util/selinux.rb
@@ -44,8 +44,15 @@ module Puppet::Util::SELinux
unless selinux_support?
return nil
end
- filestat = File.lstat(file)
- retval = Selinux.matchpathcon(file, filestat.mode)
+ # If the file exists we should pass the mode to matchpathcon for the most specific
+ # matching. If not, we can pass a mode of 0.
+ begin
+ filestat = File.lstat(file)
+ mode = filestat.mode
+ rescue Errno::ENOENT
+ mode = 0
+ end
+ retval = Selinux.matchpathcon(file, mode)
if retval == -1
return nil
end