Jira (PUP-10248) windows pidlock can raise access denied

1 view
Skip to first unread message

Josh Cooper (JIRA)

unread,
Jan 23, 2020, 1:17:05 AM1/23/20
to puppe...@googlegroups.com
Josh Cooper created an issue
 
Puppet / Bug PUP-10248
windows pidlock can raise access denied
Issue Type: Bug Bug
Assignee: Unassigned
Created: 2020/01/22 10:16 PM
Priority: Normal Normal
Reporter: Josh Cooper

If puppet is running in the background as a service, and you run puppet agent -t in the foreground, then the foreground process may not have permission to open the process token for the background process running as LocalSystem resulting in an ugly error message:

c:\Program Files\Puppet Labs\Puppet\puppet\lib\ruby\vendor_ruby\puppet>puppet agent -t --trace
Error: Could not run Puppet configuration client: OpenProcess(2000, 0, 1604):  Access is denied.
c:/Program Files/Puppet Labs/Puppet/puppet/lib/ruby/vendor_ruby/puppet/util/windows/process.rb:73:in `open_process'
c:/Program Files/Puppet Labs/Puppet/puppet/lib/ruby/vendor_ruby/puppet/util/windows/process.rb:125:in `get_process_image_name_by_pid'
c:/Program Files/Puppet Labs/Puppet/puppet/lib/ruby/vendor_ruby/puppet/util/pidlock.rb:69:in `clear_if_stale'
c:/Program Files/Puppet Labs/Puppet/puppet/lib/ruby/vendor_ruby/puppet/util/pidlock.rb:11:in `locked?'
c:/Program Files/Puppet Labs/Puppet/puppet/lib/ruby/vendor_ruby/puppet/util/pidlock.rb:20:in `lock'
c:/Program Files/Puppet Labs/Puppet/puppet/lib/ruby/vendor_ruby/puppet/agent/locker.rb:19:in `lock'

Puppet should either interpret that to mean "the pid specified in the lockfile is still running" or it needs to enable the SeDebugPrivilege prior to calling OpenProcess like we do when managing file DACLs. The latter is the only way to detect if the process id is puppet or something else that's now reusing that pid:

with_privilege(SE_DEBUG_PRIVILEGE) do
  open_process(PROCESS_QUERY_INFORMATION, false, pid) do |phandle|
    ...
  end
end

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

Josh Cooper (JIRA)

unread,
Jan 23, 2020, 1:06:04 PM1/23/20
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Team: Night's Watch

Josh Cooper (JIRA)

unread,
Jan 23, 2020, 1:06:04 PM1/23/20
to puppe...@googlegroups.com
Josh Cooper updated an issue
If puppet is running in the background as a service, and you run {{puppet agent -t}} in the foreground, then the foreground process may not have permission to open the process token for the background process running as {{LocalSystem}} resulting in an ugly error message:

{noformat}

c:\Program Files\Puppet Labs\Puppet\puppet\lib\ruby\vendor_ruby\puppet>puppet agent -t --trace
Error: Could not run Puppet configuration client: OpenProcess(2000, 0, 1604):  Access is denied.
c:/Program Files/Puppet Labs/Puppet/puppet/lib/ruby/vendor_ruby/puppet/util/windows/process.rb:73:in `open_process'
c:/Program Files/Puppet Labs/Puppet/puppet/lib/ruby/vendor_ruby/puppet/util/windows/process.rb:125:in `get_process_image_name_by_pid'
c:/Program Files/Puppet Labs/Puppet/puppet/lib/ruby/vendor_ruby/puppet/util/pidlock.rb:69:in `clear_if_stale'
c:/Program Files/Puppet Labs/Puppet/puppet/lib/ruby/vendor_ruby/puppet/util/pidlock.rb:11:in `locked?'
c:/Program Files/Puppet Labs/Puppet/puppet/lib/ruby/vendor_ruby/puppet/util/pidlock.rb:20:in `lock'
c:/Program Files/Puppet Labs/Puppet/puppet/lib/ruby/vendor_ruby/puppet/agent/locker.rb:19:in `lock'
{noformat}

Puppet should either interpret that to mean "the pid specified in the lockfile is still running" or it needs to enable the {{SeDebugPrivilege}} prior to calling {{OpenProcess}} like we do when managing file DACLs. The
latter former is the only way unable to detect tell if the running process id is puppet /ruby or something else some other process that 's is now reusing that the stale pid , which is the problem we had originally. Might be able to run {{tasklist}} to get the command line, though enabling the debug privilege would definitely detect if the process id is puppet :

{code:ruby}

with_privilege(SE_DEBUG_PRIVILEGE) do
  open_process(PROCESS_QUERY_INFORMATION, false, pid) do |phandle|
    ...
  end
end
{code}

Mihai Buzgau (JIRA)

unread,
Jan 28, 2020, 11:21:04 AM1/28/20
to puppe...@googlegroups.com
Mihai Buzgau updated an issue
Change By: Mihai Buzgau
Sprint: PR - Triage

Mihai Buzgau (Jira)

unread,
Mar 18, 2020, 6:10:03 AM3/18/20
to puppe...@googlegroups.com
Mihai Buzgau updated an issue
Change By: Mihai Buzgau
Story Points: 3
This message was sent by Atlassian Jira (v8.5.2#805002-sha1:a66f935)
Atlassian logo

Mihai Buzgau (Jira)

unread,
Mar 18, 2020, 6:10:04 AM3/18/20
to puppe...@googlegroups.com
Mihai Buzgau updated an issue
Change By: Mihai Buzgau
Sprint: PR NW - Triage 2020-04-01

Luchian Nemes (Jira)

unread,
Mar 19, 2020, 4:19:04 AM3/19/20
to puppe...@googlegroups.com
Luchian Nemes assigned an issue to Luchian Nemes
Change By: Luchian Nemes
Assignee: Luchian Nemes

Gabriel Nagy (Jira)

unread,
Mar 20, 2020, 5:47:03 AM3/20/20
to puppe...@googlegroups.com
Gabriel Nagy assigned an issue to Gabriel Nagy
Change By: Gabriel Nagy
Assignee: Luchian Nemes Gabriel Nagy

Mihai Buzgau (Jira)

unread,
Apr 1, 2020, 3:51:03 AM4/1/20
to puppe...@googlegroups.com
Mihai Buzgau updated an issue
Change By: Mihai Buzgau
Sprint: NW - 2020-04-01 , NW - 2020-04-15

Gabriel Nagy (Jira)

unread,
Apr 7, 2020, 11:28:03 AM4/7/20
to puppe...@googlegroups.com
Gabriel Nagy updated an issue
Change By: Gabriel Nagy
Release Notes: Bug Fix
Release Notes Summary: Use `SeDebugPrivilege` on Windows when opening a lockfile PID in order to determine whether the process is a Puppet process.

Gabriel Nagy (Jira)

unread,
Apr 23, 2020, 8:01:03 AM4/23/20
to puppe...@googlegroups.com
Gabriel Nagy updated an issue
Change By: Gabriel Nagy
Fix Version/s: PUP 6.15.0
Fix Version/s: PUP 5.5.20

Claire Cadman (Jira)

unread,
Apr 27, 2020, 8:34:03 AM4/27/20
to puppe...@googlegroups.com
Claire Cadman updated an issue
Change By: Claire Cadman
Labels: doc_reviewed
Reply all
Reply to author
Forward
0 new messages