summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJesse Wolfe <jes5199@gmail.com>2009-11-24 09:09:07 -0800
committerJames Turnbull <james@lovedthanlost.net>2009-11-25 12:02:42 +1100
commit9a41c35a5160dbba10ec00f3ed45bafad3ebd06a (patch)
treea26ccc25d7213877fb85d1c311ec46fa186cf2f7 /lib
parent562909281f2e0bd21fed922600027f0e9a47f5ec (diff)
downloadpuppet-9a41c35a5160dbba10ec00f3ed45bafad3ebd06a.tar.gz
puppet-9a41c35a5160dbba10ec00f3ed45bafad3ebd06a.tar.xz
puppet-9a41c35a5160dbba10ec00f3ed45bafad3ebd06a.zip
Fixing #2791 fs_find should follow symlinks
Symlinks confuse the "What file system am I on?" logic. This patch just runs the paths through a beefed up version of the standard 'realpath' method. Includes some of Markus's suggested changes. Signed-off-by: Jesse Wolfe <jes5199@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/util/selinux.rb21
1 files changed, 16 insertions, 5 deletions
diff --git a/lib/puppet/util/selinux.rb b/lib/puppet/util/selinux.rb
index 25d86f77e..3eff03996 100644
--- a/lib/puppet/util/selinux.rb
+++ b/lib/puppet/util/selinux.rb
@@ -13,6 +13,8 @@ rescue LoadError
# Nothing
end
+require 'pathname'
+
module Puppet::Util::SELinux
def selinux_support?
@@ -185,9 +187,19 @@ module Puppet::Util::SELinux
return mntpoint
end
+ def realpath(path)
+ path, rest = Pathname.new(path), []
+ path, rest = path.dirname, [path.basename] + rest while ! path.exist?
+ File.join( path.realpath, *rest )
+ end
+
+ def parent_directory(path)
+ Pathname.new(path).dirname.to_s
+ end
+
# Internal helper function to return which type of filesystem a
# given file path resides on
- def find_fs(file)
+ def find_fs(path)
unless mnts = read_mounts()
return nil
end
@@ -198,13 +210,12 @@ module Puppet::Util::SELinux
# Just in case: return something if you're down to "/" or ""
# Remove the last slash and everything after it,
# and repeat with that as the file for the next loop through.
- ary = file.split('/')
- while not ary.empty? do
- path = ary.join('/')
+ path = realpath(path)
+ while not path.empty? do
if mnts.has_key?(path)
return mnts[path]
end
- ary.pop
+ path = parent_directory(path)
end
return mnts['/']
end