make file resource follow links and provide method to get to the original link object

This commit is contained in:
Alex Pop 2016-04-21 21:42:45 +01:00 committed by Dominik Richter
parent dd7ba570f3
commit 3ab53e940d

View file

@ -22,10 +22,18 @@ module Inspec::Resources
"
include MountParser
attr_reader :file, :path, :mount_options
attr_reader :file, :path, :mount_options, :link_source
def initialize(path)
@path = path
@file = inspec.backend.file(@path)
f = inspec.backend.file(path)
if f.symlink?
@path = f.link_path
return skip_resource "#{path} link cannot be followed, possible loop." if @path == ''
@file = inspec.backend.file(@path)
@link_source = f
else
@path = path
@file = f
end
end
%w{