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

Local transport on Windows creates LinuxFile instead of WindowsFile #189

Closed
tpcwang opened this issue Aug 22, 2017 · 1 comment
Closed
Labels
Platform: Local Platform: Windows Priority: Medium Should be addressed in 3 business days Type: Bug Feature not working as expected

Comments

@tpcwang
Copy link

tpcwang commented Aug 22, 2017

InSpec's file resource behaves strangely when running locally on Windows because LinuxFile is used instead of WindowsFile. This causes various methods to fail with error like so:

>inspec shell -c "file(\"C:\\log\").type"
C:/opscode/inspec/embedded/lib/ruby/gems/2.3.0/gems/inspec-1.33.13/lib/inspec/profile_context.rb:144:in `instance_eval': undefined method `name' for nil:NilClass (NoMethodError)
        from C:/opscode/inspec/embedded/lib/ruby/gems/2.3.0/gems/train-0.26.1/lib/train/transports/local_file.rb:75:in `stat'
        from C:/opscode/inspec/embedded/lib/ruby/gems/2.3.0/gems/train-0.26.1/lib/train/extras/file_unix.rb:49:in `block (2 levels) in <class:UnixFile>'
        from C:/opscode/inspec/embedded/lib/ruby/gems/2.3.0/gems/inspec-1.33.13/lib/resources/file.rb:52:in `call'
        from C:/opscode/inspec/embedded/lib/ruby/gems/2.3.0/gems/inspec-1.33.13/lib/resources/file.rb:52:in `block (2 levels) in <class:FileResource>'
        from (eval):1:in `load_with_context'
        from C:/opscode/inspec/embedded/lib/ruby/gems/2.3.0/gems/inspec-1.33.13/lib/inspec/profile_context.rb:144:in `instance_eval'
        from C:/opscode/inspec/embedded/lib/ruby/gems/2.3.0/gems/inspec-1.33.13/lib/inspec/profile_context.rb:144:in `load_with_context'
        from C:/opscode/inspec/embedded/lib/ruby/gems/2.3.0/gems/inspec-1.33.13/lib/inspec/profile_context.rb:130:in `load_control_file'
        from C:/opscode/inspec/embedded/lib/ruby/gems/2.3.0/gems/inspec-1.33.13/lib/inspec/runner.rb:215:in `eval_with_virtual_profile'
        from C:/opscode/inspec/embedded/lib/ruby/gems/2.3.0/gems/inspec-1.33.13/lib/inspec/cli.rb:254:in `run_command'
        from C:/opscode/inspec/embedded/lib/ruby/gems/2.3.0/gems/inspec-1.33.13/lib/inspec/cli.rb:204:in `shell_func'
        from C:/opscode/inspec/embedded/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
        from C:/opscode/inspec/embedded/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
        from C:/opscode/inspec/embedded/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
        from C:/opscode/inspec/embedded/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
        from C:/opscode/inspec/embedded/lib/ruby/gems/2.3.0/gems/inspec-1.33.13/bin/inspec:12:in `<top (required)>'
        from C:/opscode/inspec/bin/inspec:62:in `load'
        from C:/opscode/inspec/bin/inspec:62:in `<main>'

See Train::Transports::Local::Connection.file
@files[path] ||= File.new(self, path)

Should there be conditional logic to create WindowsFile when running locally on Windows?

tpcwang pushed a commit to tpcwang/train that referenced this issue Aug 23, 2017
tpcwang pushed a commit to tpcwang/train that referenced this issue Aug 23, 2017
tpcwang pushed a commit to tpcwang/train that referenced this issue Aug 23, 2017
tpcwang pushed a commit to tpcwang/train that referenced this issue Aug 23, 2017
tpcwang pushed a commit to tpcwang/train that referenced this issue Aug 23, 2017
tpcwang pushed a commit to tpcwang/train that referenced this issue Aug 23, 2017
tpcwang pushed a commit to tpcwang/train that referenced this issue Aug 23, 2017
tpcwang pushed a commit to tpcwang/train that referenced this issue Aug 23, 2017
tpcwang pushed a commit to tpcwang/train that referenced this issue Aug 23, 2017
Local and remote transports expose different file interfaces. This
is because local transport uses LinuxFile with some methods
overriden with Ruby's File calls whereas remote transport uses
the appropriate file classes from Train::Extras. This causes
problems when users are running locally on Windows because some
LinuxFile implementations are not appropriate there.

There are two potential compat breaks with this change:
1. pw_username is no longer provided for local transport
2. pw_groupname is no longer provided for local transport

These are not available for remote transport, so this doesn't
seem like it should be a problem for clients.
tpcwang pushed a commit to tpcwang/train that referenced this issue Aug 23, 2017
Local and remote transports expose different file interfaces. This
is because local transport uses LinuxFile with some methods
overriden with Ruby's File calls whereas remote transport uses
the appropriate file classes from Train::Extras. This causes
problems when users are running locally on Windows because some
LinuxFile implementations are not appropriate there.

There are two potential compat breaks with this change:
1. pw_username is no longer provided for local transport
2. pw_groupname is no longer provided for local transport

These are not available for remote transport, so this doesn't
seem like it should be a problem for clients.

Signed-off-by: Ted Wang <ted.wang@ni.com>
@clintoncwolfe clintoncwolfe added Platform/Windows Type: Bug Feature not working as expected and removed Platform: Windows labels Mar 19, 2019
@kekaichinose kekaichinose added the Priority: Medium Should be addressed in 3 business days label Aug 30, 2019
@kekaichinose
Copy link

Thank you for filing this issue. As with many large open source projects, we have a backlog of bugs and issues of varying user impact. Some issues are perpetually subject to lower priority than others in our backlog. We have reviewed the issue, and we have determined this a very low priority when considered in the context of the entire backlog. We have elected to close it as "Declined" due to competing priorities.

We very much appreciate you bringing this to our attention.

Thank you!
Chef InSpec Team

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Platform: Local Platform: Windows Priority: Medium Should be addressed in 3 business days Type: Bug Feature not working as expected
Projects
None yet
Development

No branches or pull requests

5 participants