mirror of
https://github.com/inspec/inspec
synced 2025-02-17 06:28:40 +00:00
read symlink destination file types
Signed-off-by: Dominik Richter <dominik.richter@gmail.com>
This commit is contained in:
parent
6f4f0b570c
commit
2c00423c3e
2 changed files with 21 additions and 6 deletions
|
@ -35,23 +35,23 @@ class Vulcano::Plugins::Backend
|
|||
# Additional methods for convenience
|
||||
|
||||
def file?
|
||||
type == :file
|
||||
target_type == :file
|
||||
end
|
||||
|
||||
def block_device?
|
||||
type == :block_device
|
||||
target_type == :block_device
|
||||
end
|
||||
|
||||
def character_device?
|
||||
type == :character_device
|
||||
target_type == :character_device
|
||||
end
|
||||
|
||||
def socket?
|
||||
type == :socket
|
||||
target_type == :socket
|
||||
end
|
||||
|
||||
def directory?
|
||||
type == :directory
|
||||
target_type == :directory
|
||||
end
|
||||
|
||||
def symlink?
|
||||
|
@ -59,7 +59,7 @@ class Vulcano::Plugins::Backend
|
|||
end
|
||||
|
||||
def pipe?
|
||||
type == :pipe?
|
||||
target_type == :pipe?
|
||||
end
|
||||
|
||||
def mode?(sth)
|
||||
|
@ -87,6 +87,15 @@ class Vulcano::Plugins::Backend
|
|||
|
||||
private
|
||||
|
||||
def target_type
|
||||
# Just return the type unless this is a symlink
|
||||
return type unless type == :symlink
|
||||
# Get the link's target type, i.e. the real destination's type
|
||||
return link_target.type unless link_target.nil?
|
||||
# Return unknown if we don't know where this is pointing to
|
||||
:unknown
|
||||
end
|
||||
|
||||
UNIX_MODE_OWNERS = {
|
||||
owner: 00700,
|
||||
group: 00070,
|
||||
|
|
|
@ -24,6 +24,12 @@ class Vulcano::Plugins::Backend
|
|||
)
|
||||
end
|
||||
|
||||
def link_target
|
||||
return @link_target unless @link_target.nil?
|
||||
return @link_target = nil if link_path.nil?
|
||||
@link_target = @backend.file(link_path)
|
||||
end
|
||||
|
||||
def link_path
|
||||
return nil unless symlink?
|
||||
@link_path ||= (
|
||||
|
|
Loading…
Add table
Reference in a new issue