Avoid traceback in mac_user.py when user.chhome is invoked from a user state (#35901)

* mac_user.py: Avoid traceback in chhome func

* Add warning about lack of Windows/Mac support for createhome
This commit is contained in:
Erik Johnson 2016-09-01 12:44:47 -05:00 committed by Nicole Thomas
parent 2da501071e
commit 678f10cf8b
2 changed files with 17 additions and 5 deletions

View File

@ -272,7 +272,7 @@ def chshell(name, shell):
return info(name).get('shell') == shell
def chhome(name, home):
def chhome(name, home, **kwargs):
'''
Change the home directory of the user
@ -282,6 +282,13 @@ def chhome(name, home):
salt '*' user.chhome foo /Users/foo
'''
kwargs = salt.utils.clean_kwargs(**kwargs)
persist = kwargs.pop('persist', False)
if kwargs:
salt.utils.invalid_kwargs(kwargs)
if persist:
log.info('Ignoring unsupported \'persist\' argument to user.chhome')
pre_info = info(name)
if not pre_info:
raise CommandExecutionError('User {0!r} does not exist'.format(name))

View File

@ -259,10 +259,15 @@ def present(name,
This also the location of the home directory to create if createhome is
set to True.
createhome
If False, the home directory will not be created if it doesn't exist.
Please note that directories leading up to the home directory
will NOT be created, Default is ``True``.
createhome : True
If set to ``False``, the home directory will not be created if it
doesn't already exist.
.. warning::
Not supported on Windows or Mac OS.
Additionally, parent directories will *not* be created. The parent
directory for ``home`` must already exist.
password
A password hash to set for the user. This field is only supported on