Created
August 4, 2012 05:42
-
-
Save glarizza/3254889 to your computer and use it in GitHub Desktop.
Reading Users Plist with RubyCocoa
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 'osx/cocoa' | |
| require 'pp' | |
| include OSX | |
| users_plist_dir = '/var/db/dslocal/nodes/Default/users' | |
| resource_name = 'gary' | |
| users_plist = OSX::NSMutableDictionary.dictionaryWithContentsOfFile("#{users_plist_dir}/#{resource_name}.plist") | |
| pp users_plist | |
| pp users_plist['ShadowHashData'] | |
| pp users_plist['ShadowHashData'].first | |
| # Getting the embedded binary plist | |
| embedded_bplist = NSPropertyListSerialization.objc_send( | |
| :propertyListFromData, users_plist['ShadowHashData'][0], | |
| :mutabilityOption, NSPropertyListMutableContainersAndLeaves, | |
| :format, nil, | |
| :errorDescription, nil) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment