File manager - Edit - /opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/pw_user.cpython-310.pyc
Back
o ;j�1 � @ sF d Z ddlZddlZddlZddlZddlZddlmZ zddl Z dZ W n ey/ dZ Y nw e�e �ZdZdd� Zd d � Zdd� Zd d� Z d4dd�Zd5dd�Zd6dd�Zdd� Zdd� Zdd� Zd6dd�Zd6dd�Zd d!� Zd"d#� Zd$d%� Zd&d'� Zd7d(d)�Z d*d+� Z!d,d-� Z"d.d/� Z#d0d1� Z$d2d3� Z%dS )8a Manage users with the pw command .. important:: If you feel that Salt should be using this module to manage users on a minion, and it is using a different module (or gives an error similar to *'user.info' is not available*), see :ref:`here <module-provider-override>`. � N)�CommandExecutionErrorTF�userc C s t r td dv r tS dS )zC Set the user module if the kernel is FreeBSD or DragonFly Zkernel)ZFreeBSDZ DragonFly)FzsThe pw_user execution module cannot be loaded: the pwd python module is not available or the system is not FreeBSD.)�HAS_PWDZ __grains__�__virtualname__� r r �H/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/pw_user.py�__virtual__: s r c C s� zt �| �j�dd�}W n ty td| � d���w |s i S t|�dk r1|�d� t|�dk s&tj j �|d �tj j �|d �tj j �|d �tj j �|d �d �S )zD Retrieve GECOS field info and return it in dictionary form �,� �User '�' does not exist� � r � � ��fullname� roomnumber� workphone� homephone)�pwd�getpwnam�pw_gecos�split�KeyErrorr �len�append�salt�utils�data�decode)�name�gecos_fieldr r r � _get_gecosG s � ��r# c C s0 d� | �dd�| �dd�| �dd�| �dd��S )z� Accepts a dictionary entry containing GECOS field names and their values, and returns a full GECOS comment string, to be used with pw usermod. z{},{},{},{}r r r r r )�format�get)Z gecos_dictr r r �_build_gecos] s �r&