Issue #20302 has been updated by Josh Cooper.

Henrik Lindberg wrote:
> So, if I understand the problem correctly, the provider selection mechanism 
> relies on files having *nix executable bit set. in order to consider them (I 
> am guessing that it is relying on a shell to honor shebang script files that 
> are executable).

Yep, it's often the case that a provider specifies a `:command` and gives 
either an absolute path or just a command name. Both cases call into 
`Puppet::Util.which` which tests if the resulting absolute path is executable, 
in the `S_IXUSR` sense.

> Since the concept "executable bit" is missing on Windows a  more elaborate 
> detection method is required if there is the need to truthfully answer if a 
> file is executable (if so, by which "shell"?

Actually, Windows has fine grain ACLs, and can grant (or deny) `FILE_EXECUTE` 
permission. But I don't think Ruby 1.8 or 1.9 checks that.
 
> I can see different ways to fix this:
> * call utility executable? that on Windows does what Ruby 1.8 does

Yes, that's the crux of this ticket. Find out why `File.executable?` is true on 
ruby 1.8 (enabling the acceptance test to pass), whereas it's false on ruby 1.9

> * call utility executable? that on Windows checks if File.executable? or 
> readable? and conforms to what we expect of a script file to consider it 
> executable (whatever that is)
> * change the provider search to be based on something other than being 
> "executable"
> 
> Is the description of the problem accurate?

A secondary issue is to check where else we rely on `File.executable?`, such as 
`Facter::Util.which`, and also things like `FileTest`, `File.stat`, etc.

>  Are there other ways to fix this?

We may want to just skip the executable check on Windows (in the `which` 
methods). The "correct" way to check access is to call 
[AccessCheck](http://msdn.microsoft.com/en-us/library/windows/desktop/aa374815(v=vs.85\).aspx)
 but it's a little complicated.

----------------------------------------
Bug #20302: Windows File.executable? now returns false on ruby 1.9
https://projects.puppetlabs.com/issues/20302#change-90010

* Author: Josh Cooper
* Status: Accepted
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 3.2.0
* Affected Puppet version: 3.2.0-rc1
* Keywords: windows
* Branch: 
----------------------------------------
There are various places in facter and puppet where we rely on File.executable? 
to return true, e.g. Puppet::Util.which?. In ruby 1.8, it always returned true, 
provided you could read the file. In 1.9, the file extension needs to be 
`.exe`, `.bat`, etc. The change was made in MRI ruby here: 
<http://bugs.ruby-lang.org/issues/show/2135>

However, this change can cause providers to no longer be suitable under ruby 
1.9, such as: 
<https://github.com/puppetlabs/puppet/blob/master/acceptance/tests/ticket_6907_use_provider_in_same_run_it_becomes_suitable.rb>.


-- 
You have received this notification because you have either subscribed to it, 
or are involved in it.
To change your notification preferences, please click here: 
http://projects.puppetlabs.com/my/account

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Bugs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/puppet-bugs?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to