improve shadow password handling on SmartOS

Fixes #9874
Also fixes an unreported error that when half of this fix is applied
password setting succeeds but appears to fail due to lack of reading
password hashes from the shadow file.
Merge pull request #9911 from nshalman/smartos-shadow-0.17

improve shadow password handling on SmartOS