summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean E. Millichamp <sean@bruenor.org>2008-11-06 10:43:19 -0500
committerJames Turnbull <james@lovedthanlost.net>2008-11-14 09:52:18 +1100
commit71a9e60396b1a4964c21308ce3a8bdddc97a721e (patch)
treeeb7db60bdebc18d623d990c46277e78091ebe920
parent3a5dcab28682a1bbf1b71b2d1de39008468b1ca6 (diff)
downloadpuppet-71a9e60396b1a4964c21308ce3a8bdddc97a721e.tar.gz
puppet-71a9e60396b1a4964c21308ce3a8bdddc97a721e.tar.xz
puppet-71a9e60396b1a4964c21308ce3a8bdddc97a721e.zip
Fixes relating to transition to native SELinux bindings
-rw-r--r--lib/puppet/type/file/selcontext.rb7
-rw-r--r--lib/puppet/util/selinux.rb11
2 files changed, 16 insertions, 2 deletions
diff --git a/lib/puppet/type/file/selcontext.rb b/lib/puppet/type/file/selcontext.rb
index d5111caf8..982910c04 100644
--- a/lib/puppet/type/file/selcontext.rb
+++ b/lib/puppet/type/file/selcontext.rb
@@ -50,6 +50,13 @@ module Puppet
end
end
+ selcontext = self.should
+
+ if selcontext == :absent
+ # This is only valid for create states...
+ return nil
+ end
+
self.set_selinux_context(@resource[:path], @should, name)
return :file_changed
end
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