%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python2.7/site-packages/salt/utils/
Upload File :
Create Path :
Current File : //usr/lib/python2.7/site-packages/salt/utils/win_lgpo_auditpol.pyc

�
���^c	@@s(dZddlmZmZmZddlZddlZddlZddlZ	ddl
Z	ddlZ	ddlm
Z
ddlmZeje�ZdZddd	d
ddd
ddg	Zidd6dd6dd6dd6Zd�Zd�Zdd�Zd�Zd�Zd�Zd�ZdS( u{
A salt util for modifying the audit policies on the machine. This util is used
by the ``win_auditpol`` and ``win_lgpo`` modules.

Though this utility does not set group policy for auditing, it displays how all
auditing configuration is applied on the machine, either set directly or via
local or domain group policy.

.. versionadded:: 2018.3.4
.. versionadded:: 2019.2.1

This util allows you to view and modify the audit settings as they are applied
on the machine. The audit settings are broken down into nine categories:

- Account Logon
- Account Management
- Detailed Tracking
- DS Access
- Logon/Logoff
- Object Access
- Policy Change
- Privilege Use
- System

The ``get_settings`` function will return the subcategories for all nine of
the above categories in one dictionary along with their auditing status.

To modify a setting you only need to specify the subcategory name and the value
you wish to set. Valid settings are:

- No Auditing
- Success
- Failure
- Success and Failure

Usage:

.. code-block:: python

    import salt.utils.win_lgpo_auditpol

    # Get current state of all audit settings
    salt.utils.win_lgpo_auditpol.get_settings()

    # Get the current state of all audit settings in the "Account Logon"
    # category
    salt.utils.win_lgpo_auditpol.get_settings(category="Account Logon")

    # Get current state of the "Credential Validation" setting
    salt.utils.win_lgpo_auditpol.get_setting(name='Credential Validation')

    # Set the state of the "Credential Validation" setting to Success and
    # Failure
    salt.utils.win_lgpo_auditpol.set_setting(name='Credential Validation',
                                             value='Success and Failure')

    # Set the state of the "Credential Validation" setting to No Auditing
    salt.utils.win_lgpo_auditpol.set_setting(name='Credential Validation',
                                             value='No Auditing')
i(tabsolute_importtunicode_literalstprint_functionN(tCommandExecutionError(tzipuauditpolu
Account LogonuAccount ManagementuDetailed Trackingu	DS AccessuLogon/Logoffu
Object Accessu
Policy Changeu
Privilege UseuSystemu!/success:disable /failure:disableuNo Auditingu /success:enable /failure:disableuSuccessu /success:disable /failure:enableuFailureu/success:enable /failure:enableuSuccess and FailurecC@s tjjj�stdfStS(u*
    Only load if on a Windows system
    u&This utility only available on Windows(tsalttutilstplatformt
is_windowstFalset__virtualname__(((s@/usr/lib/python2.7/site-packages/salt/utils/win_lgpo_auditpol.pyt__virtual__bs
cC@s{tjjjddj|�dt�}|ddkrE|dj�Sdj|�}|dj|d�7}t|��d	S(
u
    Helper function for running the auditpol command

    Args:
        cmd (str): the auditpol command to run

    Returns:
        list: A list containing each line of the return (splitlines)

    Raises:
        CommandExecutionError: If the command encounters an error
    tcmduauditpol {0}tpython_shelluretcodeiustdoutu&Error executing auditpol command: {0}
u
N(	Rtmodulestcmdmodtrun_alltformattTruet
splitlinestjoinR(Rtrettmsg((s@/usr/lib/python2.7/site-packages/salt/utils/win_lgpo_auditpol.pyt
_auditpol_cmdls
	uAllc	C@s�|j�d	krd}nC|j�gtD]}|j�^q+kr^tdj|���ndj|�}t|�}i}xe|dD]Y}d|j�kr�|jttt	t
tjd|j���gd����q�q�W|S(
u�
    Get the current configuration for all audit settings specified in the
    category

    Args:
        category (str):
            One of the nine categories to return. Can also be ``All`` to return
            the settings for all categories. Valid options are:

            - Account Logon
            - Account Management
            - Detailed Tracking
            - DS Access
            - Logon/Logoff
            - Object Access
            - Policy Change
            - Privilege Use
            - System
            - All

            Default value is ``All``

    Returns:
        dict: A dictionary containing all subcategories for the specified
            category along with their current configuration

    Raises:
        KeyError: On invalid category
        CommandExecutionError: If an error is encountered retrieving the settings

    Usage:

    .. code-block:: python

        import salt.utils.win_lgpo_auditpol

        # Get current state of all audit settings
        salt.utils.win_lgpo_auditpol.get_settings()

        # Get the current state of all audit settings in the "Account Logon"
        # category
        salt.utils.win_lgpo_auditpol.get_settings(category="Account Logon")
    uallu*uInvalid category: "{0}"u/get /category:"{0}"iu  u\s{2,}i(uallu*(
tlowert
categoriestKeyErrorRRtstriptupdatetdicttlistRtitertretsplit(tcategorytxRtresultsRtline((s@/usr/lib/python2.7/site-packages/salt/utils/win_lgpo_auditpol.pytget_settings�s-	+EcC@sYtdd�}x.|D]&}|j�|j�kr||SqWtdj|���dS(uB
    Get the current configuration for the named audit setting

    Args:
        name (str): The name of the setting to retrieve

    Returns:
        str: The current configuration for the named setting

    Raises:
        KeyError: On invalid setting name
        CommandExecutionError: If an error is encountered retrieving the settings

    Usage:

    .. code-block:: python

        import salt.utils.win_lgpo_auditpol

        # Get current state of the "Credential Validation" setting
        salt.utils.win_lgpo_auditpol.get_setting(name='Credential Validation')
    R"uAlluInvalid name: {0}N(R&RRR(tnametcurrent_settingstsetting((s@/usr/lib/python2.7/site-packages/salt/utils/win_lgpo_auditpol.pytget_setting�s

cC@sIdtkrAtdd�}g|D]}|j�^q"td<ntdS(Nuauditpol.valid_namesR"uAll(t__context__R&R(tsettingstk((s@/usr/lib/python2.7/site-packages/salt/utils/win_lgpo_auditpol.pyt_get_valid_names�s&cC@s�|j�t�kr-tdj|���nxUtD]8}|j�|j�kr4dj|t|�}Pq4q4Wtdj|���t|�tS(uG
    Set the configuration for the named audit setting

    Args:

        name (str):
            The name of the setting to configure

        value (str):
            The configuration for the named value. Valid options are:

            - No Auditing
            - Success
            - Failure
            - Success and Failure

    Returns:
        bool: True if successful

    Raises:
        KeyError: On invalid ``name`` or ``value``
        CommandExecutionError: If an error is encountered modifying the setting

    Usage:

    .. code-block:: python

        import salt.utils.win_lgpo_auditpol

        # Set the state of the "Credential Validation" setting to Success and
        # Failure
        salt.utils.win_lgpo_auditpol.set_setting(name='Credential Validation',
                                                 value='Success and Failure')

        # Set the state of the "Credential Validation" setting to No Auditing
        salt.utils.win_lgpo_auditpol.set_setting(name='Credential Validation',
                                                 value='No Auditing')
    uInvalid name: {0}u/set /subcategory:"{0}" {1}uInvalid setting value: {0}(RR.RRR,RR(R'tvalueR)R((s@/usr/lib/python2.7/site-packages/salt/utils/win_lgpo_auditpol.pytset_setting�s(

cC@sitjdd��}|j}WdQXdj|�}t|�tjjj|��}|j	�SWdQXdS(u_
    Gets the contents of an auditpol /backup. Used by the LGPO module to get
    fieldnames and GUIDs for Advanced Audit policies.

    Returns:
        list: A list of lines form the backup file

    Usage:

    .. code-block:: python

        import salt.utils.win_lgpo_auditpol

        dump = salt.utils.win_lgpo_auditpol.get_auditpol_dump()
    tsuffixu.csvNu/backup /file:{0}(
ttempfiletNamedTemporaryFileR'RRRRtfilestfopent	readlines(ttmp_filetcsv_fileRtfp((s@/usr/lib/python2.7/site-packages/salt/utils/win_lgpo_auditpol.pytget_auditpol_dumps
(t__doc__t
__future__RRRtloggingR R2tsalt.modules.cmdmodRtsalt.utils.filestsalt.utils.platformtsalt.exceptionsRtsalt.ext.six.movesRt	getLoggert__name__tlogR
RR,RRR&R*R.R0R:(((s@/usr/lib/python2.7/site-packages/salt/utils/win_lgpo_auditpol.pyt<module>=s>	

	
	=			6

Zerion Mini Shell 1.0