[FACT-765] The gid fact is ill-constrained on Windows (ID.EXE is called if it exists) Created: 2014/12/04  Updated: 2016/01/19  Resolved: 2015/06/17

Status: Closed
Project: Facter
Component/s: Windows
Affects Version/s: None
Fix Version/s: FACT 2.4.5, FACT 3.0.0

Type: Bug Priority: Normal
Reporter: Reid Vandewiele Assignee: Unassigned
Resolution: Fixed Votes: 3
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Template:
Story Points: 1
Sprint: Client 2015-06-24
Release Notes: Bug Fix
Release Notes Summary: Facter will no longer attempt to invoke id.exe if found on the system. Doing so would cause an error resolving the gid fact.

 Description   

If there exists an id executable in a PATH Puppet is aware of when it runs on a Windows system that executable will be called when Facter tries to evaluate the gid fact.

For example, if I have an ID.EXE installed on the system, it will be called. If ID.EXE launches a graphical application, until the window is closed the Facter run is effectively held and will not continue. I can get the same behavior if I create an ID.BAT file that launches notepad.

The problem seems to be that the most generic version of the gid fact is constrained only on the existence of an id executable, regardless of operating system family.



 Comments   
Comment by Dima [ 2015/06/15 ]

We have this same problem on Puppet Enterprise agents (tested on 3.7.2 and 3.8.0), so it affects Enterprise customers as well. Looking forward to a fix.

In this case we have id.exe from the gnu win32 utilities in the path;

C:\ProgramData\PuppetLabs\puppet\puppet apply tests\init.pp
C:\Some Path\id.EXE: cannot find name for group ID 0
Notice: Compiled catalog for mysystem.puppetpoc.local in environment production in 1.51 seconds

Comment by Michael Smith [ 2015/06/15 ]

This will be fixed in Facter 3.

Comment by Reid Vandewiele [ 2015/06/15 ]

Since it was simple I've created a 2.x PR to resolve this. If for any reason another 2.x patch release ever goes out hopefully that can make it in.

At the very least there'll be a reference in this ticket for what code to look at to manually patch a fix.

Comment by Michael Smith [ 2015/06/15 ]

No future Facter 2.x release is planned, but when it is this ticket will get updated for that release as part of release review.

Comment by Reid Vandewiele [ 2015/06/16 ]

If anyone has a need to work around this issue prior to a patch release shipping, the following custom fact could be used to mitigate the problem.

When correctly installed in a module deployed to the puppet master, this custom gid fact resolution would take precedence over the built-in gid resolution on Windows servers.

Facter.add(:gid) do
  has_weight 100
  confine :kernel => 'windows'
  setcode do
    # this has to either be false or perhaps an empty string. It cannot
    # be nil or the incorret resolution will be used instead.
    false
  end
end

Running facter -p gid on the command line after pluginsync should then result in false being displayed instead of the id executable being run.

Comment by Kylo Ginsberg [ 2015/06/17 ]

Note for anyone catching up: this is intrinsically fixed by facter 3 (due to its implementation) and so was resolved. It was then reopened to see a 2.x fix implemented.

Comment by Shaigy Nixon [X] (Inactive) [ 2015/06/17 ]

Validated on 2.x on win2012r2-rubyx64 using source https://github.com/puppetlabs/facter/tree/2.x

$ cmd /c facter PATH
C:\cygwin64\usr\local\bin;C:\cygwin64\bin;C:\Program Files (x86)\Puppet Labs\Puppet Enterprise\bin;C:\Program Files\Puppet Labs\Puppet Enterprise\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\pstools;C:\cygwin64\bin
 
$ cat "C:\cygwin64\usr\local\bin\id.exe"
echo Hello
 
$ cmd /c facter gid
 
 
Administrator@qsjevb7fe418ri9 ~

Validated in facter 3.x on win2012r2-rubyx64

$ cmd /c facter path
C:\Program Files\Puppet Labs\Puppet\puppet\bin;C:\Program Files\Puppet Labs\Puppet\facter\bin;C:\Program Files\Puppet Labs\Puppet\hiera\bin;C:\Program Files\Puppet Labs\Puppet\mcollective\bin;C:\Program Files\Puppet Labs\Puppet\bin;C:\Program Files\Puppet Labs\Puppet\sys\ruby\bin;C:\Program Files\Puppet Labs\Puppet\sys\tools\bin;C:\cygwin64\usr\local\bin;C:\cygwin64\bin;C:\Program Files (x86)\Puppet Labs\Puppet\bin;C:\Program Files\Puppet Labs\Puppet\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\pstools;C:\cygwin64\bin
 
$ cat "C:\cygwin64\bin\id.bat"
echo Hello
 
$ cmd /c facter gid
 
 
Administrator@g03883bzfd9tn50 ~/facter

Generated at Sat Feb 22 05:42:50 PST 2020 using JIRA 7.7.1#77002-sha1:e75ca93d5574d9409c0630b81c894d9065296414.