diff --git a/manifests/recovery_message.pp b/manifests/recovery_message.pp index b13948a..44ef2bc 100644 --- a/manifests/recovery_message.pp +++ b/manifests/recovery_message.pp @@ -10,6 +10,15 @@ $kextdir = '/System/Library/Extensions' $eficachedir = '/System/Library/Caches/com.apple.corestorage/EFILoginLocalizations' + # The recovery message cannot contain an apostrophe (') because we're passing + # it into a single-quoted exec. If it does contain an apostrophe, fail and + # alert the user + if "'" in $value { + fail("Your osx::recovery_message declaration contains an apostrophe ('),", + "which will cause the exec used to set the message to fail. Please", + "remove the apostrophe and try again. Your message: \"${value}\"") + } + # The CoreStorage kext cache needs to be updated so the recovery message # is displayed on the FDE pre-boot screen. # diff --git a/spec/defines/recovery_message_spec.rb b/spec/defines/recovery_message_spec.rb index ce71447..b6a3790 100644 --- a/spec/defines/recovery_message_spec.rb +++ b/spec/defines/recovery_message_spec.rb @@ -58,4 +58,15 @@ }) end end + + context 'Given a value with an apostrophe' do + let(:title) { "Jack's message with an apostrophe" } + let(:error) { "Your osx::recovery_message declaration contains an apostrophe" } + + it do + expect { + should contain_exec('Set OS X Recovery Message NVRAM Variable') + }.to raise_error(Puppet::Error, /#{error}/) + end + end end