Skip to content

Commit

Permalink
return owner for files on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-rock committed Aug 16, 2016
1 parent 1a38adc commit 0b39f5a
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion lib/train/extras/file_windows.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,26 @@ def mounted
nil
end

# PS C:\> Get-Acl .\test | select owner,group,audit | ConvertTo-Json
# {
# "Owner": "BUILTIN\\Administrators",
# "Group": "DEFAULT-CHEF-WI\\None",
# }
def owner
cmd = @backend.run_command(
"Get-Acl '#{@spath}' | select owner, group | ConvertTo-Json"
)
begin
owner = JSON.parse(cmd.stdout)
rescue JSON::ParserError => _e
return nil
end

# check that we got a response
return nil if owner.nil? || owner['Owner'].nil?
owner['Owner']
end

def type
if attributes.include?('Archive')
return :file
Expand All @@ -61,7 +81,7 @@ def type
end

%w{
mode owner group uid gid mtime size selinux_label
mode group uid gid mtime size selinux_label
}.each do |field|
define_method field.to_sym do
nil
Expand Down

0 comments on commit 0b39f5a

Please sign in to comment.