
    Vh                    J    d dl mZ dZd dlZd dlmZ d dlmZ  G d de      Zy)    )annotationsa  
name: doas
short_description: Do As user
description:
  - This become plugins allows your remote/login user to execute commands as another user using the C(doas) utility.
author: Ansible Core Team
options:
  become_user:
    description: User you 'become' to execute the task.
    type: string
    ini:
      - section: privilege_escalation
        key: become_user
      - section: doas_become_plugin
        key: user
    vars:
      - name: ansible_become_user
      - name: ansible_doas_user
    env:
      - name: ANSIBLE_BECOME_USER
      - name: ANSIBLE_DOAS_USER
  become_exe:
    description: C(doas) executable.
    type: string
    default: doas
    ini:
      - section: privilege_escalation
        key: become_exe
      - section: doas_become_plugin
        key: executable
    vars:
      - name: ansible_become_exe
      - name: ansible_doas_exe
    env:
      - name: ANSIBLE_BECOME_EXE
      - name: ANSIBLE_DOAS_EXE
  become_flags:
    description: Options to pass to C(doas).
    type: string
    default: ''
    ini:
      - section: privilege_escalation
        key: become_flags
      - section: doas_become_plugin
        key: flags
    vars:
      - name: ansible_become_flags
      - name: ansible_doas_flags
    env:
      - name: ANSIBLE_BECOME_FLAGS
      - name: ANSIBLE_DOAS_FLAGS
  become_pass:
    description: Password for C(doas) prompt.
    type: string
    required: false
    vars:
      - name: ansible_become_password
      - name: ansible_become_pass
      - name: ansible_doas_pass
    env:
      - name: ANSIBLE_BECOME_PASS
      - name: ANSIBLE_DOAS_PASS
    ini:
      - section: doas_become_plugin
        key: password
  prompt_l10n:
    description:
      - List of localized strings to match for prompt detection.
      - If empty we will use the built in one.
    type: list
    elements: string
    default: []
    ini:
      - section: doas_become_plugin
        key: localized_prompts
    vars:
      - name: ansible_doas_prompt_l10n
    env:
      - name: ANSIBLE_DOAS_PROMPT_L10N
N)to_bytes)
BecomeBasec                  0     e Zd ZdZdZdZd Z fdZ xZS )BecomeModulezcommunity.general.doas)zPermission denied)zAuthorization requiredc                    | j                  d      D cg c]  }t        |       c}xs ddg}dj                  |      }t        t	        j
                  ||            S c c}w )z; checks if the expected password prompt exists in b_output prompt_l10ns   doas \(s	   Password:   |)
get_optionr   joinboolrematch)selfb_outputp	b_promptsb_prompts        i/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/community/general/plugins/become/doas.pycheck_password_promptz"BecomeModule.check_password_promptf   sV    
 +///-*HIQXa[Iik[hMi	99Y'BHHXx011 Js   Ac           	     d   t         t        |   ||       |s|S d| _        | j	                  d      }| j	                  d      }| j	                  d      s	d|vr|dz  }| j	                  d      }|rd| nd	}| j                  ||d
      }t        |d|j                        }| d| d| d| d| 	S )NT
become_exebecome_flagsbecome_passz-nz -nbecome_userz-u  )noexe
executable z -c )superr   build_become_commandpromptr   _build_success_commandgetattrSHELL_FAMILY)
r   cmdshellr   flagsr   usersuccess_cmdr   	__class__s
            r   r!   z!BecomeModule.build_become_commandp   s    lD6sEBJ__\2
/}-$e2CUNEoom4&1[M"r11#uD1IUL%2D2DE
QugQtfAj\k]KK    )	__name__
__module____qualname__namefailmissingr   r!   __classcell__)r+   s   @r   r   r   ^   s%    #D "D)G2L Lr,   r   )	
__future__r   DOCUMENTATIONr   +ansible.module_utils.common.text.convertersr   ansible.plugins.becomer   r    r,   r   <module>r9      s,   
 #Ob 
 @ -&L: &Lr,   