� c��jf����dZddlZddlZddlZddlZddlZgd�ZGd�de�Zd d�Z d d�Z d d�Z d d �Z d �Z ddlZejej fe Zy#eef$r ddlZe ZYy#e$re ZYYywxYwwxYw) a�Utilities to get a password and/or the current user name. getpass(prompt[, stream]) - Prompt for a password, with echo turned off. getuser() - Get the user name from the environment or password database. GetPassWarning - This UserWarning is issued when getpass() cannot prevent echoing of the password contents while reading. On Windows, the msvcrt module will be used. �N)�getpass�getuser�GetPassWarningc� �eZdZy)rN)�__name__� __module__� __qualname__��� /usr/lib64/python3.12/getpass.pyrrs�r rc���d}tj�5} tjdtjtj z�}t j|d�}|j|�t j|�}|j|�|s|}|�� t'j(|�}|dd}|dxxt&j*zcc<t&j,} t/t&d�r| t&j0z} t'j2|| |�t5|||��}t'j2|| |�|j7� |j;d�|cddd�S#t$ry|j� tjj�}n##tt f$rd}t#||�}YnwxYwtj}|stj$}Y��WwxYw#t'j2|| |�|j7�wxYw#t&j8$r'|��||ur|j�t#||�}Y��wxYw#1swYyxYw)aPrompt for a password, with echo turned off. Args: prompt: Written on stream to ask for the input. Default: 'Password: ' stream: A writable file object to display the prompt. Defaults to the tty. If no tty is available defaults to sys.stderr. Returns: The seKr3t input. Raises: EOFError: If our input tty or stdin was closed. GetPassWarning: When we were unable to turn echo off on the input. Always restores terminal settings before returning. Nz/dev/ttyzw+��TCSASOFT)�input� )� contextlib� ExitStack�os�open�O_RDWR�O_NOCTTY�io�FileIO� enter_context� TextIOWrapper�OSError�close�sys�stdin�fileno�AttributeError� ValueError�fallback_getpass�stderr�termios� tcgetattr�ECHO� TCSAFLUSH�hasattrr� tcsetattr� _raw_input�flush�error�write) �prompt�stream�passwd�stack�fd�ttyr�old�new�tcsetattr_flagss r � unix_getpassr8s���F� � � � �5� $�����R�Y�Y�r�{�{�%:�;�B��)�)�B��%�C� � � �� $��$�$�S�)�E� � � �� &���� �>� :��'�'��+���!�f���A��7�<�<�-�'��")�"3�"3���7�J�/�#�w�'7�'7�7�O�#��%�%�b�/�3�?�'���e�D�F��%�%�b�/�3�?��L�L�N� � � �T���c � ��� $� �K�K�M� :��Y�Y�%�%�'���"�J�/� :���)�&�&�9�� :���I�I�E������� $��0�%�%�b�/�3�?��L�L�N���=�=� :��%����&��K�K�M�)�&�&�9�� :��I � �s��I#�BE5�I#�"A)H&� %G:�1'H&�I#�5G7�F.�-G7�.G� G7� G�%G7�3I#�6G7�7I#�:)H#�#H&�&6I �I#�I � I#�#I,c�f�tjtjur t||�S|D]}t j |��d} t j �}|dk(s|dk(rn|dk(rt�|dk(r|dd}n||z}�;t j d�t j d�|S)z:Prompt for password with echo off, using Windows getwch().�� r��N�����)rr� __stdin__r#�msvcrt�putwch�getwch�KeyboardInterrupt)r/r0�c�pws r � win_getpassrFas��� �y�y�� � �%����/�/� ��� � �a��� �B� � �M�M�O�� ��9��T� � � ��;�#� #� ��9��C�R��B��a��B� � �M�M�$�� �M�M�$�� �Ir c��tjdtd��|stj}t d|��t ||�S)Nz%Can not control echo on the terminal.�)� stacklevelz&Warning: Password input may be echoed.)�file)�warnings�warnrrr$�printr+)r/r0s r r#r#xs:�� �M�M�9�>�� � ����� � 2��@� �f�f� %�%r c��|stj}|stj}t|�}|r" |j |�|j�|j�}|st�|ddk(r|dd}|S#t $rK|j |jd�}|j|j�}|j |�Y��wxYw)N�replacer>r) rr$r�strr.�UnicodeEncodeError�encode�encoding�decoder,�readline�EOFError)r/r0r�lines r r+r+�s��� ����� �� � �� ��[�F� � !� �L�L�� � � � �� �>�>� �D� ��� �B�x�4���C�R�y�� �K��"� !��]�]�6�?�?�I�>�F��]�]�6�?�?�3�F� �L�L�� �  !�s�A;�;AC�Cc��dD]'}tjj|�}|s�%|cSddl}|j tj ��dS)z�Get the username from the environment or password database. First try various environment variables, then the password database. This works on Windows as long as USERNAME is set. )�LOGNAME�USER�LNAME�USERNAMErN)r�environ�get�pwd�getpwuid�getuid)�name�userr_s r rr�sG��9���z�z�~�~�d�#�� ��K�9� � �<�<�� � � � $�Q� '�'r )z Password: N)r:NN)�__doc__rrrrrK�__all__� UserWarningrr8rFr#r+rr%r&r*r� ImportErrorr!r@r r r �rhs��� � � � � �� 0��(�[�'�A�H�.&��2(�$ �� ���w�(�(�(��G�� �^�$������� �#�"��#���s/�A�A8�!A)�%A8�)A4�0A8�3A4�4A8