add file uid and gid accessors

This commit is contained in:
Dominik Richter 2016-03-31 02:23:23 +02:00
parent d086102c79
commit 419b6a087c

View file

@ -4,6 +4,8 @@
# author: Christoph Hartmann
# license: All rights reserved
require 'shellwords'
module Inspec::Resources
class FileResource < Inspec.resource(1) # rubocop:disable Metrics/ClassLength
name 'file'
@ -89,6 +91,20 @@ module Inspec::Resources
end
end
# TODO: This is temporary and must be moved to train
def uid
res = inspec.command('stat '+Shellwords.escape(@path)+' -c %u')
return nil if res.exit_status != 0 || res.stdout.empty?
res.stdout.to_i
end
# TODO: This is temporary and must be moved to train
def gid
res = inspec.command('stat '+Shellwords.escape(@path)+' -c %u')
return nil if res.exit_status != 0 || res.stdout.empty?
res.stdout.to_i
end
def to_s
"File #{path}"
end