Ok, but I'd like to suggest a few changes (feel free to disregard,
especially if problematic):
> +require 'pathname'
> +
> module Puppet::Util::SELinux
>
> def selinux_support?
> @@ -185,9 +187,25 @@ module Puppet::Util::SELinux
> return mntpoint
> end
>
> + def realpath(path)
> + pn = Pathname.new(path)
> + begin
> + pn.realpath.to_s
> + rescue
> + # standard realpath fails if the file doesn't exist,
> + # so we recurse to the parent directory and try again
> + realpath(pn.dirname.to_s) + '/' + pn.basename.to_s
> + end
> + end
>
I'd rather File.join(realpath(pn.dirname),pn.basename) over the explicit
'/', and explicit testing of pn.exists? rather than using the rescue as an
expected code path. Perhaps something along these lines? (warning, e-mail
code, never been tried)
def realpath(path)
path,rest = Pathname.new(path),[]
path,rest = path.dirname,[path.basename]+rest while !path.exists?
File.join(path.realpath,*rest)
end
end
Note that (IIRC) you can File.join directly on Pathnames, you don't need to
to_s them.
-- Markus
--
You received this message because you are subscribed to the Google Groups
"Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-dev?hl=en.