Skip to content
This repository has been archived by the owner on Dec 31, 2024. It is now read-only.

Commit

Permalink
yet another attempt to work around exec umask issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshua Hoblitt committed Feb 28, 2014
1 parent 75e9d57 commit ab70ece
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
32 changes: 22 additions & 10 deletions manifests/add_cert_and_key.pp
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,28 @@
# downcase and change spaces into _s
$pkcs12_name = downcase(regsubst("${nickname}.p12", '[\s]', '_', 'GM'))

# the exec type in older versions of puppet don't support the umask param so
# we have to inline it in the command string
exec {"generate_pkcs12_${title}":
command => "umask 7077 && /usr/bin/openssl pkcs12 -export -in ${cert} -inkey ${key} -password 'file:${certdir}/nss-password.txt' -out '${certdir}/${pkcs12_name}' -name '${nickname}'",
creates => "${certdir}/${pkcs12_name}",
subscribe => File["${certdir}/nss-password.txt"],
require => [
Nsstools::Create[$certdir],
Class['nsstools'],
],
# the exec type in older versions of puppet don't support the umask param
if versioncmp($::puppetversion, '3.4.0') >= 0 {
exec {"generate_pkcs12_${title}":
command => "/usr/bin/openssl pkcs12 -export -in ${cert} -inkey ${key} -password 'file:${certdir}/nss-password.txt' -out '${certdir}/${pkcs12_name}' -name '${nickname}'",
creates => "${certdir}/${pkcs12_name}",
subscribe => File["${certdir}/nss-password.txt"],
umask => '7077',
require => [
Nsstools::Create[$certdir],
Class['nsstools'],
],
}
} else {
exec {"generate_pkcs12_${title}":
command => "/usr/bin/openssl pkcs12 -export -in ${cert} -inkey ${key} -password 'file:${certdir}/nss-password.txt' -out '${certdir}/${pkcs12_name}' -name '${nickname}'",
creates => "${certdir}/${pkcs12_name}",
subscribe => File["${certdir}/nss-password.txt"],
require => [
Nsstools::Create[$certdir],
Class['nsstools'],
],
}
}

exec { "add_pkcs12_${title}":
Expand Down
4 changes: 2 additions & 2 deletions spec/defines/nsstools_add_cert_and_key_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
context 'generate_pkcs12' do
it do
should contain_exec('generate_pkcs12_Server-Cert').with(
:command => "umask 7077 && /usr/bin/openssl pkcs12 -export -in /tmp/server.cert -inkey /tmp/server.key -password 'file:/dne/nss-password.txt' -out '/dne/server-cert.p12' -name 'Server-Cert'",
:command => "/usr/bin/openssl pkcs12 -export -in /tmp/server.cert -inkey /tmp/server.key -password 'file:/dne/nss-password.txt' -out '/dne/server-cert.p12' -name 'Server-Cert'",
:require => [
'Nsstools::Create[/dne]',
'Class[Nsstools]'
Expand Down Expand Up @@ -58,7 +58,7 @@
context 'generate_pkcs12' do
it do
should contain_exec('generate_pkcs12_foo').with(
:command => "umask 7077 && /usr/bin/openssl pkcs12 -export -in /tmp/server.cert -inkey /tmp/server.key -password 'file:/dne/nss-password.txt' -out '/dne/server-cert.p12' -name 'Server-Cert'",
:command => "/usr/bin/openssl pkcs12 -export -in /tmp/server.cert -inkey /tmp/server.key -password 'file:/dne/nss-password.txt' -out '/dne/server-cert.p12' -name 'Server-Cert'",
:require => [
'Nsstools::Create[/dne]',
'Class[Nsstools]'
Expand Down

0 comments on commit ab70ece

Please sign in to comment.