opscode/chef — pull request #1455 by anandsuresh (2014-05-24 02:19:19+00:00)
Title: Only modify password when one has been specified

Obvious fix

The pw user provider attempts to modify the password on every call to manage_user. When the recipe does not provide a password for a "manage" action, this call fails with:

```
[2014-05-19T11:39:14-07:00] INFO: Processing user[some_user] action create (bash::default line 70)
[2014-05-19T11:39:14-07:00] DEBUG: user[some_user] setting shell to /usr/bin/bash
[2014-05-19T11:39:14-07:00] DEBUG: Executing pw usermod some_user -s '/usr/bin/bash'
[2014-05-19T11:39:14-07:00] DEBUG: ---- Begin output of pw usermod some_user -s '/usr/bin/bash' ----
[2014-05-19T11:39:14-07:00] DEBUG: STDOUT:
[2014-05-19T11:39:14-07:00] DEBUG: STDERR: pwd_mkdb: warning, unknown root shell
pwd_mkdb: warning, unknown root shell
[2014-05-19T11:39:14-07:00] DEBUG: ---- End output of pw usermod some_user -s '/usr/bin/bash' ----
[2014-05-19T11:39:14-07:00] DEBUG: Ran pw usermod some_user -s '/usr/bin/bash' returned 0
[2014-05-19T11:39:14-07:00] DEBUG: user[some_user] updating password

failed to handle resource --> :create user[some_user]

pw failed - #!
```

Consider the following code:
```
user some_user do
shell '/usr/bin/bash'
action :manage
end
```

The provider should only execute the modify_password function when a password has been specified for new_resource. This fix ensures that the provider does not crash and burn when a password has not been specified.