Module Expr Str ImportFrom alias ImportFrom alias Import alias Import alias Import alias Import alias ImportFrom alias Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign NameStore Str FunctionDef arguments args defaults body If UnaryOpNot Call AttributeLoad AttributeLoad NameLoad attr attr body Return TupleLoad NameLoad Str Return NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore Call AttributeLoad Str attr NameLoad TryExcept body Assign NameStore Call AttributeLoad AttributeLoad AttributeLoad NameLoad attr attr attr NameLoad handlers ExceptHandler type NameLoad name NameStore body If CompareIn Call AttributeLoad Str attr NameLoad AttributeLoad NameLoad attr body Raise Call NameLoad Call AttributeLoad Str attr NameLoad Raise Call NameLoad Call AttributeLoad Str attr AttributeLoad NameLoad attr TryExcept body Assign NameStore Call AttributeLoad SubscriptLoad Call AttributeLoad NameLoad attr Str Index Num attr Str Assign NameStore Dict For NameStore NameLoad body If CompareIn Str NameLoad body Assign TupleStore NameStore NameStore Call AttributeLoad NameLoad attr Str Assign SubscriptStore NameLoad Index NameLoad NameLoad Return NameLoad handlers ExceptHandler type NameLoad body Return Dict decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore Call AttributeLoad Str attr NameLoad NameLoad TryExcept body Return Call AttributeLoad AttributeLoad AttributeLoad NameLoad attr attr attr NameLoad handlers ExceptHandler type NameLoad name NameStore body If CompareIn Call AttributeLoad Str attr NameLoad AttributeLoad NameLoad attr body Raise Call NameLoad Call AttributeLoad Str attr NameLoad Raise Call NameLoad Call AttributeLoad Str attr AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore Call AttributeLoad Str attr NameLoad NameLoad TryExcept body Assign NameStore Call AttributeLoad AttributeLoad AttributeLoad NameLoad attr attr attr NameLoad handlers ExceptHandler type NameLoad name NameStore body If CompareIn Str AttributeLoad NameLoad attr body Raise Call NameLoad Call AttributeLoad Str attr NameLoad Raise Call NameLoad Call AttributeLoad Str attr AttributeLoad NameLoad attr Return NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str TryExcept body Assign NameStore Call NameLoad NameLoad Return Call AttributeLoad Call AttributeLoad NameLoad attr NameLoad attr Str handlers ExceptHandler type TupleLoad NameLoad NameLoad body Return Str decorator_list FunctionDef arguments args NameParam defaults body Expr Str TryExcept body Assign NameStore Call AttributeLoad NameLoad attr NameLoad Return Dict Str Str Str Str Str Str Str Str Str Str Str Str AttributeLoad NameLoad attr AttributeLoad NameLoad attr Call NameLoad NameLoad Call NameLoad NameLoad Call NameLoad NameLoad Call NameLoad NameLoad Call NameLoad NameLoad Call NameLoad NameLoad Call NameLoad NameLoad Str Str Str handlers ExceptHandler type NameLoad body Expr Call AttributeLoad NameLoad attr Call AttributeLoad Str attr NameLoad Return Dict Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str decorator_list FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore Call NameLoad NameLoad Str Assign NameStore Call AttributeLoad AttributeLoad AttributeLoad NameLoad attr attr attr NameLoad Assign NameStore Call NameLoad NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore Call NameLoad NameLoad Str Assign NameStore Call AttributeLoad AttributeLoad AttributeLoad NameLoad attr attr attr NameLoad Assign NameStore Call NameLoad NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore Call NameLoad NameLoad Str Return Call AttributeLoad AttributeLoad AttributeLoad NameLoad attr attr attr NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore Call NameLoad NameLoad Str Assign NameStore Call AttributeLoad AttributeLoad AttributeLoad NameLoad attr attr attr NameLoad Assign NameStore Call NameLoad NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore BinOpMult BinOpMult NameLoad Num Num Expr Call NameLoad NameLoad Call AttributeLoad Str attr NameLoad Return CompareEq Call NameLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore Call NameLoad NameLoad If CompareIn Str NameLoad body Assign NameStore SubscriptLoad NameLoad Index Str Return BinOpDiv BinOpDiv Call NameLoad NameLoad Num Num Return Num decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Expr Call NameLoad NameLoad Call AttributeLoad Str attr NameLoad Return CompareEq Call NameLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore Call NameLoad NameLoad If CompareIn Str NameLoad body Return SubscriptLoad NameLoad Index Str Return Str decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Expr Call NameLoad NameLoad Call AttributeLoad Str attr NameLoad Return CompareEq Call NameLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore Call NameLoad NameLoad If CompareIn Str NameLoad body Return SubscriptLoad NameLoad Index Str Return Str decorator_list FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore Call AttributeLoad Str attr NameLoad TryExcept body Expr Call AttributeLoad AttributeLoad AttributeLoad NameLoad attr attr attr NameLoad handlers ExceptHandler type NameLoad name NameStore body If CompareIn Str AttributeLoad NameLoad attr body Raise Call NameLoad Call AttributeLoad Str attr NameLoad Raise Call NameLoad Call AttributeLoad Str attr AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad Str attr NameLoad Expr Call AttributeLoad AttributeLoad AttributeLoad NameLoad attr attr attr NameLoad Return CompareEq SubscriptLoad Call NameLoad NameLoad Index Str Str decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore Call AttributeLoad Str attr NameLoad NameLoad TryExcept body Expr Call AttributeLoad AttributeLoad AttributeLoad NameLoad attr attr attr NameLoad handlers ExceptHandler type NameLoad name NameStore body If CompareIn Str AttributeLoad NameLoad attr body Raise Call NameLoad Call AttributeLoad Str attr NameLoad Raise Call NameLoad Call AttributeLoad Str attr AttributeLoad NameLoad attr Return NameLoad decorator_list
N/A N/A 
.. versionadded:: 2016.3.0

Manage Mac OSX local directory passwords and policies.

Note that it is usually better to apply password policies through the creation
of a configuration profile.
 __future__ absolute_import datetime datetime N/A pwd N/A salt.utils N/A logging N/A salt.utils.mac_utils salt.exceptions CommandExecutionError N/A log N/A N/A logging getLogger __name__ N/A __virtualname__ shadow __virtual__ N/A N/A N/A N/A N/A N/A N/A N/A N/A salt utils is_darwin N/A N/A N/A False Not Darwin N/A __virtualname__ N/A _get_account_policy N/A N/A name N/A N/A N/A 
    Get the entire accountPolicy and return it as a dictionary. For use by this
    module only

    :param str name: The user name

    :return: a dictionary containing all values for the accountPolicy
    :rtype: dict

    :raises: CommandExecutionError on user not found or any other unknown error
     N/A cmd N/A N/A pwpolicy -u {0} -getpolicy format name N/A N/A N/A ret N/A N/A N/A N/A salt utils mac_utils execute_return_result cmd N/A N/A N/A CommandExecutionError N/A exc N/A N/A N/A N/A N/A Error: user <{0}> not found format name N/A exc strerror N/A N/A N/A CommandExecutionError N/A N/A User not found: {0} format name N/A N/A CommandExecutionError N/A N/A Unknown error: {0} format N/A exc strerror N/A N/A N/A policy_list N/A N/A N/A N/A N/A ret split N/A 1 split N/A policy_dict N/A N/A policy policy_list N/A N/A N/A = policy N/A N/A N/A key value N/A N/A policy split = N/A N/A policy_dict N/A key value N/A policy_dict N/A N/A N/A IndexError N/A N/A N/A N/A _set_account_policy N/A N/A name policy N/A N/A N/A 
    Set a value in the user accountPolicy. For use by this module only

    :param str name: The user name
    :param str policy: The policy to apply

    :return: True if success, otherwise False
    :rtype: bool

    :raises: CommandExecutionError on user not found or any other unknown error
     N/A cmd N/A N/A pwpolicy -u {0} -setpolicy "{1}" format name policy N/A N/A N/A N/A N/A N/A N/A salt utils mac_utils execute_return_success cmd N/A N/A N/A CommandExecutionError N/A exc N/A N/A N/A N/A N/A Error: user <{0}> not found format name N/A exc strerror N/A N/A N/A CommandExecutionError N/A N/A User not found: {0} format name N/A N/A CommandExecutionError N/A N/A Unknown error: {0} format N/A exc strerror N/A _get_account_policy_data_value N/A N/A name key N/A N/A N/A 
    Return the value for a key in the accountPolicy section of the user's plist
    file. For use by this module only

    :param str name: The username
    :param str key: The accountPolicy key

    :return: the value contained within the key
    :rtype: str

    :raises: CommandExecutionError on user not found or any other unknown error
     N/A cmd N/A N/A dscl . -readpl /Users/{0} accountPolicyData {1} format name key N/A N/A N/A ret N/A N/A N/A N/A salt utils mac_utils execute_return_result cmd N/A N/A N/A CommandExecutionError N/A exc N/A N/A N/A eDSUnknownNodeName N/A exc strerror N/A N/A N/A CommandExecutionError N/A N/A User not found: {0} format name N/A N/A CommandExecutionError N/A N/A Unknown error: {0} format N/A exc strerror N/A ret N/A _convert_to_datetime N/A N/A unix_timestamp N/A N/A N/A 
    Converts a unix timestamp to a human readable date/time

    :param float unix_timestamp: A unix timestamp

    :return: A date/time in the format YYYY-mm-dd HH:MM:SS
    :rtype: str
     N/A N/A N/A unix_timestamp N/A float unix_timestamp N/A N/A N/A N/A N/A datetime fromtimestamp unix_timestamp strftime %Y-%m-%d %H:%M:%S N/A N/A N/A N/A ValueError TypeError N/A N/A Invalid Timestamp N/A info N/A N/A name N/A N/A N/A 
    Return information for the specified user

    :param str name: the username

    :return: A dictionary containing the user's shadow information
    :rtype: dict

    CLI Example:

    .. code-block:: bash

        salt '*' shadow.info admin
     N/A N/A N/A data N/A N/A pwd getpwnam name N/A N/A name passwd account_created login_failed_count login_failed_last lstchg max expire change min warn inact N/A data pw_name N/A data pw_passwd N/A get_account_created name N/A get_login_failed_count name N/A get_login_failed_last name N/A get_last_change name N/A get_maxdays name N/A get_expire name N/A get_change name Unavailable Unavailable Unavailable N/A N/A N/A KeyError N/A N/A N/A N/A log debug N/A N/A User not found: {0} format name N/A N/A name passwd account_created login_failed_count login_failed_last lstchg max expire change min warn inact N/A get_account_created N/A N/A name N/A N/A N/A 
    Get the date/time the account was created

    :param str name: the username of the account

    :return: the date/time the account was created (yyyy-mm-dd hh:mm:ss)
    :rtype: str

    :raises: CommandExecutionError on user not found or any other unknown error

    CLI Example:

    .. code-block:: bash

        salt '*' shadow.get_account_created admin
     N/A ret N/A _get_account_policy_data_value name creationTime N/A unix_timestamp N/A N/A N/A N/A salt utils mac_utils parse_return ret N/A date_text N/A _convert_to_datetime unix_timestamp N/A date_text N/A get_last_change N/A N/A name N/A N/A N/A 
    Get the date/time the account was changed

    :param str name: the username of the account

    :return: the date/time the account was modified (yyyy-mm-dd hh:mm:ss)
    :rtype: str

    :raises: CommandExecutionError on user not found or any other unknown error

    CLI Example:

    .. code-block:: bash

        salt '*' shadow.get_last_change admin
     N/A ret N/A _get_account_policy_data_value name passwordLastSetTime N/A unix_timestamp N/A N/A N/A N/A salt utils mac_utils parse_return ret N/A date_text N/A _convert_to_datetime unix_timestamp N/A date_text N/A get_login_failed_count N/A N/A name N/A N/A N/A 
    Get the the number of failed login attempts

    :param str name: the username of the account

    :return: The number of failed login attempts
    :rtype: int

    :raises: CommandExecutionError on user not found or any other unknown error

    CLI Example:

    .. code-block:: bash

        salt '*' shadow.get_login_failed_count admin
     N/A ret N/A _get_account_policy_data_value name failedLoginCount N/A N/A N/A N/A N/A salt utils mac_utils parse_return ret N/A get_login_failed_last N/A N/A name N/A N/A N/A 
    Get the date/time of the last failed login attempt

    :param str name: the username of the account

    :return: the date/time of the last failed login attempt on this account
    (yyyy-mm-dd hh:mm:ss)
    :rtype: str

    :raises: CommandExecutionError on user not found or any other unknown error

    CLI Example:

    .. code-block:: bash

        salt '*' shadow.get_login_failed_last admin
     N/A ret N/A _get_account_policy_data_value name failedLoginTimestamp N/A unix_timestamp N/A N/A N/A N/A salt utils mac_utils parse_return ret N/A date_text N/A _convert_to_datetime unix_timestamp N/A date_text N/A set_maxdays N/A N/A name days N/A N/A N/A 
    Set the maximum age of the password in days

    :param str name: the username of the account

    :param int days: the maximum age of the account in days

    :return: True if successful, False if not
    :rtype: bool

    :raises: CommandExecutionError on user not found or any other unknown error

    CLI Example:

    .. code-block:: bash

        salt '*' shadow.set_maxdays admin 90
     N/A minutes N/A N/A days 24 60 N/A N/A _set_account_policy name N/A N/A maxMinutesUntilChangePassword={0} format minutes N/A N/A N/A get_maxdays name days N/A get_maxdays N/A N/A name N/A N/A N/A 
    Get the maximum age of the password

    :param str name: the username of the account

    :return: the maximum age of the password in days
    :rtype: int

    :raises: CommandExecutionError on user not found or any other unknown error

    CLI Example:

    .. code-block:: bash

        salt '*' shadow.get_maxdays admin 90
     N/A policies N/A _get_account_policy name N/A N/A maxMinutesUntilChangePassword policies N/A N/A max_minutes N/A policies N/A maxMinutesUntilChangePassword N/A N/A N/A N/A int max_minutes 24 60 N/A 0 N/A set_mindays N/A N/A name days N/A N/A N/A 
    Set the minimum password age in days. Not available in OS X.

    :param str name: The user name

    :param int days: The number of days

    :return: Will always return False until OSX supports this feature.
    :rtype: bool

    CLI Example:

    .. code-block:: bash

        salt '*' shadow.set_mindays admin 90
     N/A False N/A set_inactdays N/A N/A name days N/A N/A N/A 
    Set the number if inactive days before the account is locked. Not available
    in OS X

    :param str name: The user name

    :param int days: The number of days

    :return: Will always return False until OSX supports this feature.
    :rtype: bool

    CLI Example:

    .. code-block:: bash

        salt '*' shadow.set_inactdays admin 90
     N/A False N/A set_warndays N/A N/A name days N/A N/A N/A 
    Set the number of days before the password expires that the user will start
    to see a warning. Not available in OS X

    :param str name: The user name

    :param int days: The number of days

    :return: Will always return False until OSX supports this feature.
    :rtype: bool

    CLI Example:

    .. code-block:: bash

        salt '*' shadow.set_warndays admin 90
     N/A False N/A set_change N/A N/A name date N/A N/A N/A 
    Sets the date on which the password expires. The user will be required to
    change their password. Format is mm/dd/yyyy

    :param str name: the name of the user account

    :param date date: the date the password will expire. Must be in mm/dd/yyyy
    format.

    :return: True if successful, otherwise False
    :rtype: bool

    :raises: CommandExecutionError on user not found or any other unknown error

    CLI Example:

    .. code-block:: bash

        salt '*' shadow.set_change username 09/21/2016
     N/A N/A _set_account_policy name N/A N/A usingExpirationDate=1 expirationDateGMT={0} format date N/A N/A N/A get_change name date N/A get_change N/A N/A name N/A N/A N/A 
    Gets the date on which the password expires

    :param str name: the name of the user account

    :return: The date the password will expire
    :rtype: str

    :raises: CommandExecutionError on user not found or any other unknown error

    CLI Example:

    .. code-block:: bash

        salt '*' shadow.get_change username
     N/A policies N/A _get_account_policy name N/A N/A expirationDateGMT policies N/A N/A N/A policies N/A expirationDateGMT N/A Value not set N/A set_expire N/A N/A name date N/A N/A N/A 
    Sets the date on which the account expires. The user will not be able to
    login after this date. Date format is mm/dd/yyyy

    :param str name: the name of the user account

    :param datetime date: the date the account will expire. Format must be
    mm/dd/yyyy

    :return: True if successful, False if not
    :rtype: bool

    :raises: CommandExecutionError on user not found or any other unknown error

    CLI Example:

    .. code-block:: bash

        salt '*' shadow.set_expire username 07/23/2015
     N/A N/A _set_account_policy name N/A N/A usingHardExpirationDate=1 hardExpireDateGMT={0} format date N/A N/A N/A get_expire name date N/A get_expire N/A N/A name N/A N/A N/A 
    Gets the date on which the account expires

    :param str name: the name of the user account

    :return: the date the account expires
    :rtype: str

    :raises: CommandExecutionError on user not found or any other unknown error

    CLI Example:

    .. code-block:: bash

        salt '*' shadow.get_expire username
     N/A policies N/A _get_account_policy name N/A N/A hardExpireDateGMT policies N/A N/A N/A policies N/A hardExpireDateGMT N/A Value not set N/A del_password N/A N/A name N/A N/A N/A 
    Deletes the account password

    :param str name: The user name of the account

    :return: True if successful, otherwise False
    :rtype: bool

    :raises: CommandExecutionError on user not found or any other unknown error

    CLI Example:

    .. code-block:: bash

        salt '*' shadow.del_password username
     N/A cmd N/A N/A dscl . -passwd /Users/{0} '' format name N/A N/A N/A N/A N/A N/A N/A salt utils mac_utils execute_return_success cmd N/A N/A N/A CommandExecutionError N/A exc N/A N/A N/A eDSUnknownNodeName N/A exc strerror N/A N/A N/A CommandExecutionError N/A N/A User not found: {0} format name N/A N/A CommandExecutionError N/A N/A Unknown error: {0} format N/A exc strerror N/A cmd N/A N/A dscl . -create /Users/{0} Password '*' format name N/A N/A N/A N/A N/A salt utils mac_utils execute_return_success cmd N/A N/A N/A N/A info name N/A passwd * N/A set_password N/A N/A name password N/A N/A N/A 
    Set the password for a named user (insecure, the password will be in the
    process list while the command is running)

    :param str name: The name of the local user, which is assumed to be in the
    local directory service

    :param str password: The plaintext password to set

    :return: True if successful, otherwise False
    :rtype: bool

    :raises: CommandExecutionError on user not found or any other unknown error

    CLI Example:

    .. code-block:: bash

        salt '*' mac_shadow.set_password macuser macpassword
     N/A cmd N/A N/A dscl . -passwd /Users/{0} '{1}' format name password N/A N/A N/A N/A N/A N/A N/A salt utils mac_utils execute_return_success cmd N/A N/A N/A CommandExecutionError N/A exc N/A N/A N/A eDSUnknownNodeName N/A exc strerror N/A N/A N/A CommandExecutionError N/A N/A User not found: {0} format name N/A N/A CommandExecutionError N/A N/A Unknown error: {0} format N/A exc strerror N/A True N/A