Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

return owner for files on windows #132

Merged
merged 1 commit into from
Aug 17, 2016
Merged

Conversation

chris-rock
Copy link
Contributor

@chris-rock chris-rock commented Aug 16, 2016

This PR implements the owner methods for file/directory on Windows platforms. Once this is done, you can read our the owner via InSpec:

  describe directory('C:/opscode/chef') do
    its('owner') { should cmp 'NT AUTHORITY\SYSTEM'}
  end
  describe directory('C:/opscode/chef') do
    it { should be_owned_by 'NT AUTHORITY\SYSTEM' }
  end
  describe directory('C:/notthere') do
    its('owner') { should eq nil}
  end

# }
def owner
cmd = @backend.run_command(
"Get-Acl '#{@spath}' | select owner, group | ConvertTo-Json"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you just want the owner, you can just return stdout from Get-Acl '#{@spath}' | select -expand Owner

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh, nice, lets use that instead.

@chris-rock chris-rock force-pushed the chris-rock/windows-file-owner branch from 0b39f5a to 1d4ac6f Compare August 16, 2016 14:22
@chris-rock
Copy link
Contributor Author

Thanks @ksubrama for the tip, that made the implementation much easier

@chris-rock chris-rock force-pushed the chris-rock/windows-file-owner branch from 1d4ac6f to ac63068 Compare August 16, 2016 14:27
@chris-rock chris-rock force-pushed the chris-rock/windows-file-owner branch from ac63068 to 4634882 Compare August 17, 2016 09:44
@chris-rock
Copy link
Contributor Author

I am going to ignore the travis test for fedora, since this is combination of docker and travis.

@chris-rock chris-rock merged commit 758dc61 into master Aug 17, 2016
@chris-rock chris-rock deleted the chris-rock/windows-file-owner branch August 17, 2016 11:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants