HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/states/__pycache__/win_wua.cpython-310.pyc
o

�N�gA�@sjdZddlZddlZddlZddlZe�e�ZdZ	dd�Z
ddd�Zddd	�Z	
				
		ddd
�Z
dS)a�
Installation of Windows Updates using the Windows Update Agent

.. versionadded:: 2017.7.0

Salt can manage Windows updates via the "wua" state module. Updates can be
installed and removed. Update management declarations are as follows:

For installation:

.. code-block:: yaml

    # Install a single update using the KB
    KB3194343:
      wua.installed

    # Install a single update using the name parameter
    install_update:
      wua.installed:
        - name: KB3194343

    # Install multiple updates using the updates parameter and a combination of
    # KB number and GUID
    install_updates:
      wua.installed:
       - updates:
         - KB3194343
         - bb1dbb26-3fb6-45fd-bb05-e3c8e379195c

For removal:

.. code-block:: yaml

    # Remove a single update using the KB
    KB3194343:
      wua.removed

    # Remove a single update using the name parameter
    remove_update:
      wua.removed:
        - name: KB3194343

    # Remove multiple updates using the updates parameter and a combination of
    # KB number and GUID
    remove_updates:
      wua.removed:
       - updates:
         - KB3194343
         - bb1dbb26-3fb6-45fd-bb05-e3c8e379195c
�N�wuacCs"tjj��sdStjjjsdStS)z(
    Only valid on Windows machines
    )Fz%WUA: Only available on Window systems)FzWUA: Requires PyWin32 libraries)�salt�utils�platformZ
is_windows�
win_updateZHAS_PYWIN32�__virtualname__�rr�G/opt/saltstack/salt/lib/python3.10/site-packages/salt/states/win_wua.py�__virtual__?s

r
cCs�t|t�r|g}|s|}|iddd�}tjj��}|�|�}|��dkr*d|d<|Stjj��}|j	D]}tjj
�|j�sC|j	�
|�q3tjj��}g}|j	D]}tjj
�|j�s`|j	�
|�qO|�dd�|jD��qO|��dkr�d	|d<|dd
�|�7<|Stdr�d|d
<d|d<|j	D]}	|dd7<|dd�|	jj|	jg�7<q�|S|�|�|�|�|��|�	���}
i}i}i}|��}
|
D]F}||
vr�|
|d|
|dd�||<q�tjj
�|
|d��s|
|d|
|dd�||<q�|
|d|
|d|
|dd�||<q�g}|�r&|�d�||dd<|�r8|�d�||dd<d|d
<|�rF|�d�||dd<d�|�|d<|S)a�
    Ensure Microsoft Updates are installed. Updates will be downloaded if
    needed.

    Args:

        name (str):
            The identifier of a single update to install.

        updates (list):
            A list of identifiers for updates to be installed. Overrides
            ``name``. Default is None.

    .. note:: Identifiers can be the GUID, the KB number, or any part of the
       Title of the Microsoft update. GUIDs and KBs are the preferred method
       to ensure you're installing the correct update.

    .. warning:: Using a partial KB number or a partial Title could result in
       more than one update being installed.

    Returns:
        dict: A dictionary containing the results of the update. There are three
              keys under changes. `installed` is a list of updates that were
              successfully installed. `failed` is a list of updates that failed
              to install. `superseded` is a list of updates that were not
              installed because they were superseded by another update.

    CLI Example:

    .. code-block:: yaml

        # using a GUID
        install_update:
          wua.installed:
            - name: 28cf1b09-2b1a-458c-9bd1-971d1b26b211

        # using a KB
        install_update:
          wua.installed:
            - name: KB3194343

        # using the full Title
        install_update:
          wua.installed:
            - name: Security Update for Adobe Flash Player for Windows 10 Version 1607 (for x64-based Systems) (KB3194343)

        # Install multiple updates
        install_updates:
          wua.installed:
            - updates:
              - KB3194343
              - 28cf1b09-2b1a-458c-9bd1-971d1b26b211
    T���name�changes�result�commentr�No updates foundrcs��|]}d|VqdS�ZKBNr��.0Zkbrrr	�	<genexpr>���zinstalled.<locals>.<genexpr>zUpdates already installed: �
 - �testNr�Updates will be installed:�
�: �Title�KBs�rr�	Installed�NeedsReboot�rr!r�Updates installed successfullyr�	installed�Some updates failed to install�failedF�Some updates were superseded�
superseded)�
isinstance�strrrr�WindowsUpdateAgent�search�count�Updates�updates�data�is_true�IsDownloaded�Add�IsInstalled�extend�KBArticleIDs�join�__opts__�Identity�UpdateIDr�download�install�refresh�list�append)r
r/�retr�install_listr;�itemr<�installed_updates�update�	post_info�superseded_updates�failed_updates�installed_items�commentsrrr	r$Ls�
6

�

"



�

�


�


r$c
Cs�t|t�r|g}|s|}|iddd�}tjj��}|�|�}|��dkr*d|d<|Stjj��}g}|j	D]}tjj
�|j�rF|j	�
|�q5|�dd�|jD��q5|��dkrid	|d<|dd
�|�7<|Stdr�d|d
<d|d<|j	D]}|dd7<|dd�|jj|jg�7<qx|S|�|�|��|�	���}i}	i}|��D]1}tjj
�||d�r�||d||dd�|	|<q�||d||d||dd�||<q�|r�d|d<||dd<|	r�d|d<|	|dd<d|d
<|S)a
    Ensure Microsoft Updates are uninstalled.

    Args:

        name (str):
            The identifier of a single update to uninstall.

        updates (list):
            A list of identifiers for updates to be removed. Overrides ``name``.
            Default is None.

    .. note:: Identifiers can be the GUID, the KB number, or any part of the
       Title of the Microsoft update. GUIDs and KBs are the preferred method
       to ensure you're uninstalling the correct update.

    .. warning:: Using a partial KB number or a partial Title could result in
       more than one update being removed.

    Returns:
        dict: A dictionary containing the results of the removal. There are
              three keys under changes. `removed` is a list of updates that
              were successfully removed. `failed` is a list of updates that
              failed to be removed.

    CLI Example:

    .. code-block:: yaml

        # using a GUID
        uninstall_update:
          wua.removed:
            - name: 28cf1b09-2b1a-458c-9bd1-971d1b26b211

        # using a KB
        uninstall_update:
          wua.removed:
            - name: KB3194343

        # using the full Title
        uninstall_update:
          wua.removed:
            - name: Security Update for Adobe Flash Player for Windows 10 Version 1607 (for x64-based Systems) (KB3194343)

        # Install multiple updates
        uninstall_updates:
          wua.removed:
            - updates:
              - KB3194343
              - 28cf1b09-2b1a-458c-9bd1-971d1b26b211
    Trrrrrcsrrrrrrr	r9rzremoved.<locals>.<genexpr>zUpdates already removed: rrNrzUpdates will be removed:rrr rrrr!r"zUpdates removed successfullyr�removedz Some updates failed to uninstallr&F)r)r*rrrr+r,r-r.r/r0r1r4r3r5r6r7r8r9r:r�	uninstallr=r>)
r
r/r@rrKZremoved_updatesrBrDrErGrrr	rJ�sb
4


"


�


�rJTFc
Csd|iddd�}tjj��}	|	j|d||||||d�}
|
��dkr&d|d<|St|
�����}|	�|�}tjj�	�}
|j
D]}tjj�|j
�sL|
j
�|�q<tjj�	�}|j
D]}tjj�|j�sf|j
�|�qVtdr�d	|d
<d|d<|j
D]}|dd7<|dd
�|jj|jg�7<qv|S|	�|
�|	�|�|	��|	�
���}i}i}i}|��}|D]E}||vr�||d||dd�||<q�tjj�||d�s�||d||dd�||<q�||d||d||dd�||<q�g}|�r	|�d�||dd<|�r|�d�||dd<d|d
<|�r)|�d�||dd<d�|�|d<|S)a�	
    Ensure Microsoft Updates that match the passed criteria are installed.
    Updates will be downloaded if needed.

    This state allows you to update a system without specifying a specific
    update to apply. All matching updates will be installed.

    Args:

        name (str):
            The name has no functional value and is only used as a tracking
            reference

        software (bool):
            Include software updates in the results (default is True)

        drivers (bool):
            Include driver updates in the results (default is False)

        skip_hidden (bool):
            Skip updates that have been hidden. Default is False.

        skip_mandatory (bool):
            Skip mandatory updates. Default is False.

        skip_reboot (bool):
            Skip updates that require a reboot. Default is True.

        categories (list):
            Specify the categories to list. Must be passed as a list. All
            categories returned by default.

            Categories include the following:

            * Critical Updates
            * Definition Updates
            * Drivers (make sure you set drivers=True)
            * Feature Packs
            * Security Updates
            * Update Rollups
            * Updates
            * Update Rollups
            * Windows 7
            * Windows 8.1
            * Windows 8.1 drivers
            * Windows 8.1 and later drivers
            * Windows Defender

        severities (list):
            Specify the severities to include. Must be passed as a list. All
            severities returned by default.

            Severities include the following:

            * Critical
            * Important


    Returns:
        dict: A dictionary containing the results of the update. There are three
              keys under changes. `installed` is a list of updates that were
              successfully installed. `failed` is a list of updates that failed
              to install. `superseded` is a list of updates that were not
              installed because they were superseded by another update.

    CLI Example:

    .. code-block:: yaml

        # Update the system using the state defaults
        update_system:
          wua.uptodate

        # Update the drivers
        update_drivers:
          wua.uptodate:
            - software: False
            - drivers: True
            - skip_reboot: False

        # Apply all critical updates
        update_critical:
          wua.uptodate:
            - severities:
              - Critical
    Trr)�skip_hiddenZskip_installed�skip_mandatory�skip_reboot�software�drivers�
categories�
severitiesrrrrNrrrrrrrr r!r"r#rr$r%r&Fr'r()rrrr+Z	availabler-r>�keysr,r.r/r0r1r2r3r4r8r7r9r:rr;r<r=r?)r
rOrPrLrMrNrQrRr@rZavailable_updatesr/rAr;rBr<rDrErFrGrCrHrIrrr	�uptodatems�`�

�
�
"



�

�


�


rT)N)TFFFTNN)�__doc__�loggingZsalt.utils.datarZsalt.utils.platformZsalt.utils.win_update�	getLogger�__name__�logrr
r$rJrTrrrr	�<module>s(3



!�