Created
July 27, 2012 02:38
-
-
Save glarizza/3185900 to your computer and use it in GitHub Desktop.
Getting the ShadowHashData object in OS X 10.7 and 10.8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'puppet' | |
| require 'facter/util/plist' | |
| require 'pp' | |
| @@users_plist_dir = '/var/db/dslocal/nodes/Default/users' | |
| resource_name = 'glarizza' | |
| users_plist = Plist::parse_xml(`plutil -convert xml1 -o /dev/stdout #{@@users_plist_dir}/#{resource_name}.plist`) | |
| password_hash_plist = users_plist['ShadowHashData'][0].string | |
| IO.popen('plutil -convert xml1 -o - -', mode='r+') do |io| | |
| io.write password_hash_plist | |
| io.close_write | |
| @converted_plist = io.read | |
| end | |
| @plist_hash = Plist::parse_xml(@converted_plist) | |
| @plist_hash['SALTED-SHA512'].class # (StringIO in 10.7 or Nil in 10.8) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment