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

Setting recovery message with nvram exec will fail if it contains an apostrophe #21

Open
glarizza opened this issue Jun 26, 2013 · 5 comments

Comments

@glarizza
Copy link
Contributor

Note this line in the exec --> https://github.com/boxen/puppet-osx/blob/master/manifests/recovery_message.pp#L46

Because the value is wrapped in single-quotes, if you declare an osx::recovery_message resource that contains a single-quote/apostrophe in its title, the exec will fail. Removing the apostrophe fixes the exec failure.

I'm not sure of the solution here - maybe wrapping in double-quotes instead of single quotes (which displaces the issue to double-quotes), or possibly a function that searches for apostrophes and escapes them?

@ocxo
Copy link
Contributor

ocxo commented Jun 27, 2013

I'd probably just manually escape quotes in osx::recovery_message and be done with it. What do you think about adding a note to the readme about this?

@bleything
Copy link
Contributor

Elsewhere @wfarr mentioned a shell quoting function we could use. Assuming I'm remembering that correctly, that's the right solution.

@ocxo
Copy link
Contributor

ocxo commented Jun 27, 2013

Nice. I don't think it warrants additional code IMO but if there is something we can tap into let's do it.

On Jun 27, 2013, at 10:27 AM, Ben Bleything [email protected] wrote:

Elsewhere @wfarr mentioned a shell quoting function we could use. Assuming I'm remembering that correctly, that's the right solution.


Reply to this email directly or view it on GitHub.

glarizza pushed a commit to glarizza/puppet-osx that referenced this issue Jun 27, 2013
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
@glarizza
Copy link
Contributor Author

There is the shellquote function, but I don't think it solves this problem. I filed #23 which should cover us for now.

@wfarr
Copy link
Contributor

wfarr commented Jun 27, 2013

I think if we're gonna re-do this, I'd like to see us approach solving the problem permanently.

Right now, we're relying on RubyCocoa and all sorts of stuff to set the recovery message. Stuff that's also going away in 10.9.

It's time to write some C.

Though, yes, shell quote is useful here.

ocxo pushed a commit that referenced this issue Nov 2, 2013
(#21) Throw error if recovery_message contains '
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

4 participants