serverspec/specinfra — pull request #278 by gongo (2014-12-09 13:54:29+00:00)
Title: Escape `useradd` parameters

## Problem

I'm using [itamae](https://github.com/ryotarai/itamae) and run following code to CentOS7:

```ruby
# user.rb
user 'gongo' do
password '$6$abcdefghijklmnop$foo/bar/baz'
end
```

Result:

```
INFO : Starting Itamae...
INFO : Recipe: /path/to/provision/user.rb
INFO : user[gongo]
INFO : action: create
```

But actual `gongo`'s password was wrong:

```
# getent shadow gongo
gongo:/bar/baz:16413:0:99999:7:::
```

## Cause

```ruby
Specinfra.command.get(:add_user, 'gongo', password: '$6$abcdefghijklmnop$foo/bar/baz')
#=> "useradd -p $6$abcdefghijklmnop$foo/bar/baz gongo"
```

Because the password hasn't been escaped, `$..` value has become empty.

```
$ echo $6$abcdefghijklmnop$foo/bar/baz
/bar/baz
```

## BTW

Rerun same code, the password become correct:

```
INFO : Starting Itamae...
INFO : Recipe: /path/to/provision/user.rb
INFO : user[gongo]
INFO : action: create
INFO : password will change from '/bar/baz' to '$6$abcdefghijklmnop$foo/bar/baz'
```

The password has been escaped [when update](https://github.com/serverspec/specinfra/blob/v2.10.1/lib/specinfra/command/base/user.rb#L64-L66).