mirror of
https://github.com/inspec/inspec
synced 2024-11-27 07:00:39 +00:00
make file resource follow links and provide method to get to the original link object
This commit is contained in:
parent
dd7ba570f3
commit
3ab53e940d
1 changed files with 11 additions and 3 deletions
|
@ -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{
|
||||
|
|
Loading…
Reference in a new issue