Skip to content

Commit

Permalink
(PE-15036) Fix Windows permission inheritance
Browse files Browse the repository at this point in the history
Prior to this commit there was an issue where the inherit permission
value on the `client_datadir` folder was being lost, causing the folder
to be inaccessible to the MCO/PCP daemons.

This commit ensures that directory has the proper inherit permission,
if it appears that it does not have it. For more details: PE-15036
  • Loading branch information
Brandon High committed Apr 20, 2016
1 parent e7eee94 commit 36ea4bf
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/facter/settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@
end
end

Facter.add('puppet_client_datadir') do
setcode do
Puppet.settings['client_datadir']
end
end

Facter.add('mco_confdir') do
setcode do
File.expand_path(File.join(Puppet.settings['confdir'],'../../mcollective/etc'))
Expand Down
7 changes: 7 additions & 0 deletions manifests/windows/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,11 @@
command => "${::system32}\\cmd.exe /c start /b ${_cmd_location} /c \"${_installbat}\" ${::puppet_agent_pid}",
path => $::path,
}

# PE-15037 Cache dir loses inheritable SYSTEM perms
exec { 'fix inheritable SYSTEM perms':
command => "${::system32}\\icacls.exe ${::puppet_client_datadir} /grant \"SYSTEM:(OI)(CI)(F)\"",
unless => "${::system32}\\icacls.exe ${::puppet_client_datadir} | findstr \"SYSTEM:(OI)(CI)(F)\"",
require => Exec['install_puppet.bat'],
}
}
12 changes: 12 additions & 0 deletions spec/classes/puppet_agent_windows_install_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
it { is_expected.to contain_file('C:\tmp\install_puppet.bat').with_content(
%r[#{Regexp.escape("msiexec.exe /qn /norestart /i \"#{values[:appdata]}\\Puppetlabs\\packages\\puppet-agent-#{values[:expect_arch]}.msi\"")}])
}
it { is_expected.to contain_exec('fix inheritable SYSTEM perms') }
end
end

Expand All @@ -64,6 +65,7 @@

it { is_expected.not_to contain_class('puppet_agent::windows::install') }
it { is_expected.not_to contain_file('c:\tmp\install_puppet.bat') }
it { is_expected.not_to contain_exec('fix inheritable SYSTEM perms') }
end

context 'with out of date aio_agent_version' do
Expand All @@ -76,6 +78,7 @@
it { is_expected.to contain_file('C:\tmp\install_puppet.bat').with_content(
%r[#{Regexp.escape("msiexec.exe /qn /norestart /i \"#{values[:appdata]}\\Puppetlabs\\packages\\puppet-agent-#{values[:expect_arch]}.msi\"")}])
}
it { is_expected.to contain_exec('fix inheritable SYSTEM perms') }
end
end
end
Expand All @@ -90,6 +93,7 @@
/msiexec.exe \/qn \/norestart \/i "https:\/\/alternate.com\/puppet-agent.msi"/)
is_expected.to contain_file('C:\tmp\install_puppet.bat').with_content(/\/l\*v "C:\\tmp\\puppet-\d+_\d+_\d+-\d+_\d+-installer.log"/)
}
it { is_expected.to contain_exec('fix inheritable SYSTEM perms') }
end
describe 'C:/tmp/puppet-agent-x64.msi' do
let(:params) { global_params.merge(
Expand All @@ -100,6 +104,7 @@
/msiexec.exe \/qn \/norestart \/i "C:\\tmp\\puppet-agent-x64\.msi"/)
is_expected.to contain_file('C:\tmp\install_puppet.bat').with_content(/\/l\*v "C:\\tmp\\puppet-\d+_\d+_\d+-\d+_\d+-installer.log"/)
}
it { is_expected.to contain_exec('fix inheritable SYSTEM perms') }
end
describe 'C:\Temp/ Folder\puppet-agent-x64.msi' do
let(:params) { global_params.merge(
Expand All @@ -110,6 +115,7 @@
/msiexec.exe \/qn \/norestart \/i "C:\\Temp Folder\\puppet-agent-x64\.msi"/)
is_expected.to contain_file('C:\tmp\install_puppet.bat').with_content(/\/l\*v "C:\\tmp\\puppet-\d+_\d+_\d+-\d+_\d+-installer.log"/)
}
it { is_expected.to contain_exec('fix inheritable SYSTEM perms') }
end
describe 'C:/Temp/ Folder/puppet-agent-x64.msi' do
let(:params) { global_params.merge(
Expand All @@ -120,6 +126,7 @@
/msiexec.exe \/qn \/norestart \/i "C:\\Temp Folder\\puppet-agent-x64\.msi"/)
is_expected.to contain_file('C:\tmp\install_puppet.bat').with_content(/\/l\*v "C:\\tmp\\puppet-\d+_\d+_\d+-\d+_\d+-installer.log"/)
}
it { is_expected.to contain_exec('fix inheritable SYSTEM perms') }
end
describe '\\\\garded\c$\puppet-agent-x64.msi' do
let(:params) { global_params.merge(
Expand All @@ -130,6 +137,7 @@
/msiexec.exe \/qn \/norestart \/i "\\\\garded\\c\$\\puppet-agent-x64\.msi"/)
is_expected.to contain_file('C:\tmp\install_puppet.bat').with_content(/\/l\*v "C:\\tmp\\puppet-\d+_\d+_\d+-\d+_\d+-installer.log"/)
}
it { is_expected.to contain_exec('fix inheritable SYSTEM perms') }
end
describe 'default source' do
it {
Expand All @@ -145,6 +153,7 @@
it {
is_expected.to_not contain_file('C:\tmp\puppet-agent.msi')
}
it { is_expected.to contain_exec('fix inheritable SYSTEM perms') }
end
describe 'puppet:///puppet_agent/puppet-agent-1.1.0-x86.msi' do
let(:params) { global_params.merge(
Expand All @@ -156,6 +165,7 @@
/msiexec.exe \/qn \/norestart \/i "C:\\tmp\\puppet-agent.msi"/
)
}
it { is_expected.to contain_exec('fix inheritable SYSTEM perms') }
end
end
context 'arch =>' do
Expand Down Expand Up @@ -211,6 +221,7 @@
} }

}
it { is_expected.to contain_exec('fix inheritable SYSTEM perms') }
end
describe 'x86' do
let(:facts) { facts.merge({:rubyplatform => 'x86_64'}) }
Expand All @@ -221,6 +232,7 @@
} }

}
it { is_expected.to contain_exec('fix inheritable SYSTEM perms') }
end
end
end
Expand Down

0 comments on commit 36ea4bf

Please sign in to comment.