
    Vh.                    n    d dl mZ dZdZd dlmZ d dlmZ d dl	m
Z
  e e
d            Z G d d	e      Zy
)    )annotationsu  
name: run0
short_description: Systemd's run0
description:
  - This become plugins allows your remote/login user to execute commands as another user using the C(run0) utility.
author:
  - Thomas Sjögren (@konstruktoid)
version_added: '9.0.0'
options:
  become_user:
    description: User you 'become' to execute the task.
    default: root
    ini:
      - section: privilege_escalation
        key: become_user
      - section: run0_become_plugin
        key: user
    vars:
      - name: ansible_become_user
      - name: ansible_run0_user
    env:
      - name: ANSIBLE_BECOME_USER
      - name: ANSIBLE_RUN0_USER
    type: string
  become_exe:
    description: C(run0) executable.
    default: run0
    ini:
      - section: privilege_escalation
        key: become_exe
      - section: run0_become_plugin
        key: executable
    vars:
      - name: ansible_become_exe
      - name: ansible_run0_exe
    env:
      - name: ANSIBLE_BECOME_EXE
      - name: ANSIBLE_RUN0_EXE
    type: string
  become_flags:
    description: Options to pass to C(run0).
    default: ''
    ini:
      - section: privilege_escalation
        key: become_flags
      - section: run0_become_plugin
        key: flags
    vars:
      - name: ansible_become_flags
      - name: ansible_run0_flags
    env:
      - name: ANSIBLE_BECOME_FLAGS
      - name: ANSIBLE_RUN0_FLAGS
    type: string
notes:
  - This plugin will only work when a C(polkit) rule is in place.
a  
# An example polkit rule that allows the user 'ansible' in the 'wheel' group
# to execute commands using run0 without authentication.
/etc/polkit-1/rules.d/60-run0-fast-user-auth.rules: |-
  polkit.addRule(function(action, subject) {
    if(action.id == "org.freedesktop.systemd1.manage-units" &&
      subject.isInGroup("wheel") &&
      subject.user == "ansible") {
        return polkit.Result.YES;
    }
  });
)compile)
BecomeBase)to_bytesz\x1B\[[0-9;]+mc                  `     e Zd ZdZdZdZdZdZed        Z	 fdZ
 fdZ fd	Z fd
Z xZS )BecomeModulezcommunity.general.run0z
Password: )z==== AUTHENTICATION FAILED ====)z!==== AUTHENTICATION COMPLETE ====Tc                .    t         j                  d|       S )N    )ansi_color_codessub)lines    i/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/community/general/plugins/become/run0.pyremove_ansi_codeszBecomeModule.remove_ansi_codesc   s    ##C..r
   c           
         t         |   ||       |s|S | j                  d      }| j                  d      }| j                  d      }| d| d| d| j                  ||       S )N
become_exebecome_flagsbecome_userz --user= )superbuild_become_command
get_option_build_success_command)selfcmdshellbecomeflagsuser	__class__s         r   r   z!BecomeModule.build_become_commandg   ss    $S%0J./}- hhtfAeWAd.I.I#u.U-VW	
r
   c                D    | j                  |      }t        | 	  |      S N)r   r   check_successr   b_outputr   s     r   r"   zBecomeModule.check_successu   s#    ))(3w$X..r
   c                D    | j                  |      }t        | 	  |      S r!   )r   r   check_incorrect_passwordr#   s     r   r&   z%BecomeModule.check_incorrect_passwordy   s#    ))(3w/99r
   c                D    | j                  |      }t        | 	  |      S r!   )r   r   check_missing_passwordr#   s     r   r(   z#BecomeModule.check_missing_password}   s#    ))(3w-h77r
   )__name__
__module____qualname__namepromptfailsuccessrequire_ttystaticmethodr   r   r"   r&   r(   __classcell__)r   s   @r   r   r   X   sL    #DF/D4G  / /
/:8 8r
   r   N)
__future__r   DOCUMENTATIONEXAMPLESrer   
re_compileansible.plugins.becomer   ansible.module_utils._textr   r   r    r
   r   <module>r;      sA    #8t % - /h'89: '8: '8r
   