Jira (BOLT-1176) Tasks run on Windows via PCP do not resolve all executable paths correctly

2 views
Skip to first unread message

William Hurt (JIRA)

unread,
Mar 12, 2019, 3:17:03 PM3/12/19
to puppe...@googlegroups.com
William Hurt created an issue
 
Puppet Task Runner / Bug BOLT-1176
Tasks run on Windows via PCP do not resolve all executable paths correctly
Issue Type: Bug Bug
Assignee: Unassigned
Components: bolt, Windows
Created: 2019/03/12 12:16 PM
Labels: windows powershell bolt tasks
Priority: Normal Normal
Reporter: William Hurt

When a PowerShell task is run on a Windows machine, there are differences in how it resolves paths to some executable files between runs via WinRM and PCP. 

When running a task that executes the following PowerShell snippet the results are as follows. Notice the path to puppet.bat resolves all the way down to the bat file:
 

(Get-Command puppet) | Select-object *
(Get-Command whoami) | Select-object *
whoami

 The result via WinRM:

HelpUri            : 
FileVersionInfo    : File:             C:\Program Files\Puppet Labs\Puppet\bin\puppet.bat
                     InternalName:     
                     OriginalFilename: 
                     FileVersion:      
                     FileDescription:  
                     Product:          
                     ProductVersion:   
                     Debug:            False
                     Patched:          False
                     PreRelease:       False
                     PrivateBuild:     False
                     SpecialBuild:     False
                     Language:         
                     
Path               : C:\Program Files\Puppet Labs\Puppet\bin\puppet.bat
Extension          : .bat
Definition         : C:\Program Files\Puppet Labs\Puppet\bin\puppet.bat
Source             : C:\Program Files\Puppet Labs\Puppet\bin\puppet.bat
Version            : 0.0.0.0
Visibility         : Public
OutputType         : {System.String}
Name               : puppet.bat
CommandType        : Application
ModuleName         : 
Module             : 
RemotingCapability : PowerShell
Parameters         : 
ParameterSets      : 
 
HelpUri            : 
FileVersionInfo    : File:             C:\Windows\system32\whoami.exe
                     InternalName:     whoami.exe
                     OriginalFilename: whoami.exe.mui
                     FileVersion:      10.0.14393.0 (rs1_release.160715-1616)
                     FileDescription:  whoami - displays logged on user information
                     Product:          Microsoft® Windows® Operating System
                     ProductVersion:   10.0.14393.0
                     Debug:            False
                     Patched:          False
                     PreRelease:       False
                     PrivateBuild:     False
                     SpecialBuild:     False
                     Language:         English (United States)
                     
Path               : C:\Windows\system32\whoami.exe
Extension          : .exe
Definition         : C:\Windows\system32\whoami.exe
Source             : C:\Windows\system32\whoami.exe
Version            : 10.0.14393.0
Visibility         : Public
OutputType         : {System.String}
Name               : whoami.exe
CommandType        : Application
ModuleName         : 
Module             : 
RemotingCapability : PowerShell
Parameters         : 
ParameterSets      : 
 
r5oifq86l1517gl\administrator

 
Result via PCP. Notice here that the path to the bat file is not shown. Only the folder it resides in:

HelpUri            : 
FileVersionInfo    : File:             C:\Program Files\Puppet 
                     Labs\Puppet\puppet\bin\puppet
                     InternalName:     
                     OriginalFilename: 
                     FileVersion:      
                     FileDescription:  
                     Product:          
                     ProductVersion:   
                     Debug:            False
                     Patched:          False
                     PreRelease:       False
                     PrivateBuild:     False
                     SpecialBuild:     False
                     Language:         
                     
Path               : C:\Program Files\Puppet Labs\Puppet\puppet\bin\puppet
Extension          : 
Definition         : C:\Program Files\Puppet Labs\Puppet\puppet\bin\puppet
Source             : C:\Program Files\Puppet Labs\Puppet\puppet\bin\puppet
Version            : 0.0.0.0
Visibility         : Public
OutputType         : {System.String}
Name               : puppet
CommandType        : Application
ModuleName         : 
Module             : 
RemotingCapability : PowerShell
Parameters         : 
ParameterSets      : 
 
HelpUri            : 
FileVersionInfo    : File:             C:\Windows\system32\whoami.exe
                     InternalName:     whoami.exe
                     OriginalFilename: whoami.exe.mui
                     FileVersion:      10.0.14393.0 (rs1_release.160715-1616)
                     FileDescription:  whoami - displays logged on user 
                     information
                     Product:          Microsoftr Windowsr Operating System
                     ProductVersion:   10.0.14393.0
                     Debug:            False
                     Patched:          False
                     PreRelease:       False
                     PrivateBuild:     False
                     SpecialBuild:     False
                     Language:         English (United States)
                     
Path               : C:\Windows\system32\whoami.exe
Extension          : .exe
Definition         : C:\Windows\system32\whoami.exe
Source             : C:\Windows\system32\whoami.exe
Version            : 10.0.14393.0
Visibility         : Public
OutputType         : {System.String}
Name               : whoami.exe
CommandType        : Application
ModuleName         : 
Module             : 
RemotingCapability : PowerShell
Parameters         : 
ParameterSets      : 
 
nt authority\system

The effect for the user is that they are unable to run some commands that they would otherwise expect to be able to run from a bolt task if the task is run via PCP.

The workaround is to invoke the full path to the file to be executed. Something like:

& 'C:\Program Files\Puppet Labs\Puppet\bin\puppet.bat' agent -t

But this puts the onus on the user to either trust that hard coded paths will work for well known programs, or to do the search for the program beforehand within the task.

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93)
Atlassian logo

Yasmin Rajabi (JIRA)

unread,
Aug 27, 2019, 2:55:03 PM8/27/19
to puppe...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages