name : netbsd.cpython-39.opt-1.pyc
a

'�Dg�@s�UddlZddlZddlZddlZddlmZddlZddlmZm	Z	z0ddl
Z
e
jZej
e
j
e
�e�d�Zeed<WnHeefy�zddlmZejZWney�dd�ZYn0Yn0e�e�ZGdd	�d	ejjj�ZGd
d�de�ZdS)�N)�Any)�subp�util)�salt�
blowfish_hash)�bcryptcCstd��dS)z�Raise when called so that importing this module doesn't throw
            ImportError when this module is not used. In this case, crypt
            and passlib are not needed.
            z/crypt and passlib not found, missing dependencyN)�ImportError)�_�r
�</usr/lib/python3.9/site-packages/cloudinit/distros/netbsd.pyrs�cs�eZdZdZdZdgZgd�Z�fdd�Zdd�Ze	d	�d
d�Z
dd
d�Zdd�Zdd�Z
ddd�Zdd�Zdd�dd�Z�ZS)�NetBSDzS
    Distro subclass for NetBSD.

    (N.B. OpenBSD inherits from this class.)
    z*/usr/pkg/etc/sudoers.d/90-cloud-init-usersZgroupadd)z
^{username}::z'^{username}:\*\*\*\*\*\*\*\*\*\*\*\*\*:z1^{username}:\*LOCKED\*\*\*\*\*\*\*\*\*\*\*\*\*\*:cs\t��|||�tj�d�rFgd�|_gd�|_gd�|_gd�|_nddg|_dg|_dS)	Nz/usr/pkg/bin/pkgin)�pkgin�-y�install)r
r�remove)r
r�update)r
rzfull-upgradeZpkg_addz-UZ
pkg_delete)	�super�__init__�os�path�existsZpkg_cmd_install_prefixZpkg_cmd_remove_prefixZpkg_cmd_update_prefixZpkg_cmd_upgrade_prefix)�self�nameZcfg�paths��	__class__r
rr?s



zNetBSD.__init__cCsdd||gS)N�usermod�-Gr
)r�member_nameZ
group_namer
r
r�_get_add_member_to_group_cmdJsz#NetBSD._get_add_member_to_group_cmd)�returnc
KsLt�|�rt�d|�dSdg}dg}dddddd	�}d
ddd
�}|��D]Z\}}||vr||r|t|t�r||�|||g�qJ||vrJ|rJ|�||�|�||�qJd|vs�d|vr�|dg7}|dg7}||g7}||g7}t�d|�zt	j	||d�Wn$t
�y t�td|��Yn0|�dd�}	|	du�rH|j
||	dd�dS)z~
        Add a user to the system using standard tools

        Returns False if user already exists, otherwise True.
        z!User %s already exists, skipping.FZuseraddz-dz-cz-grz-s)�homedirZgecosZ
primary_group�groups�shellz--no-user-groupz--systemz
--no-log-init)Z
no_user_group�systemZno_log_initZno_create_homer$z-mzAdding user %s)Z	logstringzFailed to create user %s�passwdNT)�hashed)rZis_user�LOG�info�items�
isinstance�str�extend�appendr�	Exception�logexc�get�
set_passwd)
rr�kwargsZadduser_cmdZlog_adduser_cmdZadduser_optsZ
adduser_flags�key�valZ
passwd_valr
r
r�add_userMsH
��




zNetBSD.add_userFcCsZ|r
|}nt|�}zt�dd||g�Wn"tyJt�td|��Yn0|�|�dS)Nrz-pzFailed to set password for %s)rrr.rr/r'�
unlock_passwd)r�userr%r&Z	hashed_pwr
r
rr1�szNetBSD.set_passwdcCs>zt�ddd|g�Wn"ty8t�td|��Yn0dS)Nr�-CZyeszFailed to lock user %s�rr.rr/r'�rrr
r
r�lock_passwd�s
zNetBSD.lock_passwdcCs>zt�ddd|g�Wn"ty8t�td|��Yn0dS)Nrr8�nozFailed to unlock user %sr9r:r
r
rr6�s
zNetBSD.unlock_passwdNcCst�d�dS)NzCannot set the locale.)r'�debug)r�localeZout_fnr
r
r�apply_locale�szNetBSD.apply_localecCs&t��}t��}dd|�d|�d�iS)z9Return env vars used in NetBSD package_command operationsZPKG_PATHz1http://cdn.netbsd.org/pub/pkgsrc/packages/NetBSD/�/z/All)�platform�release�machine)rZ
os_releaseZos_archr
r
r�_get_pkg_cmd_environ�s���zNetBSD._get_pkg_cmd_environ)�forcecCsdS)Nr
)rrEr
r
r�update_package_sources�szNetBSD.update_package_sources)F)N)�__name__�
__module__�__qualname__�__doc__Z
ci_sudoers_fnZgroup_add_cmd_prefixZ#shadow_empty_locked_passwd_patternsrr�boolr5r1r;r6r?rDrF�
__classcell__r
r
rrr*s9


rc@seZdZdS)�DistroN)rGrHrIr
r
r
rrM�srM)�	functoolsZloggingrrA�typingrZcloudinit.distros.bsdZ	cloudinitrrZcryptZMETHOD_BLOWFISHr�partialZmksaltr�__annotations__r�AttributeErrorZpasslib.hashr�hashZ	getLoggerrGr'ZdistrosZbsdZBSDrrMr
r
r
r�<module>s.
�




© 2025 Cubjrnet7