Skip to content

Commit

Permalink
(boxen#21) Throw error if recovery_message contains '
Browse files Browse the repository at this point in the history
Previously, if you declared an `osx::recovery_message` resource that
contained an apostrophe/single-quote ('), the exec used to set the
recovery message would fail (because the exec references the message
within single quotes).

This commit will call the fail() function if a recovery_message contains
an apostrophe and alert the user to the failure.  The spec was also updated
and worked for me in 1.8.7 and 1.9.3
  • Loading branch information
Gary Larizza committed Jun 27, 2013
1 parent f8ca939 commit e932901
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
9 changes: 9 additions & 0 deletions manifests/recovery_message.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
#
Expand Down
11 changes: 11 additions & 0 deletions spec/defines/recovery_message_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit e932901

Please sign in to comment.