I'm attempting to create a 'Sharing Only' account in an OS X app.
I've tried code based on examples like these:
Can user accounts be managed via the command line?
What steps are needed to create a new user from the command line on mountain lion?
without success.
From System Preferences -> Users and Groups -> Advanced Options for 'Sharing Only' account:
Home directory: /dev/null
Since /dev/null discards streams directed to it, substitution in place of '/Users/NewUser' into above code doesn't work.
Best Answer
Based on bispymusic's answer to a previous question:
As with the script it's based on, you'll either need to run it with
sudo
, or prefix eachdscl
command withsudo
. Be sure to adjust the account name, RealName, password, and UniqueID (and probably the hint and picture). Note that the critical attributes to make this a sharing-only account are the UserShell and NFSHomeDirectory attributes -- leave these as I have them.It's a bit confusing that all of the lines refer to /Users/sharinguser (or whatever account name you choose) despite this not existing in the filesystem -- this is because it doesn't refer to a file path, but to the path to a record in OS X's directory service. The filesystem and OS X directory services both use the same path notation, but actually have very little to do with each other. Thus, the home directory path can be set to /dev/null while the account's path directory service stays normal.