관리-도구
편집 파일: netbsd.cpython-39.opt-1.pyc
a ����'�Dg����������������������@���s����U�d�dl�Z�d�dlZd�dlZd�dlZd�dlmZ�d�dlZd�dlmZm Z �z0d�dl Z e jZe�j e j e �e�d�Zeed<�W�nH�eefy����zd�dlmZ�ejZW�n�ey����dd��ZY�n0�Y�n0�e�e�ZG�dd ��d ejjj�ZG�d d��de�ZdS�)�����N)�Any)�subp�util)�salt� blowfish_hash)�bcryptc�����������������C���s���t�d��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.pyr������s�����c�����������������������s����e�Zd�ZdZdZdgZg�d�Z��fdd�Zdd��Ze d �d d�Z dd d�Zdd��Zdd��Z ddd�Zdd��Zdd�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\*\*\*\*\*\*\*\*\*\*\*\*\*\*:c��������������������s\���t����|||��tj�d�rFg�d�|�_g�d�|�_g�d�|�_g�d�|�_nddg|�_dg|�_d�S�) Nz/usr/pkg/bin/pkgin)�pkgin�-y�install)r ���r����remove)r ���r����update)r ���r���zfull-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 ���r���r���?���s���� zNetBSD.__init__c�����������������C���s���dd||gS�)N�usermod�-Gr ���)r����member_nameZ group_namer ���r ���r����_get_add_member_to_group_cmdJ���s����z#NetBSD._get_add_member_to_group_cmd)�returnc����������� ������K���sL��t��|�rt�d|��dS�dg}dg}dddddd �}d ddd �}|���D�]Z\}}||v�r||r|t|t�r||�||�|g��qJ||v�rJ|rJ|�||���|�||���qJd|vs�d|vr�|dg7�}|dg7�}||g7�}||g7�}t�d|��zt j ||d��W�n$�t �y ���t��td|����Y�n0�|�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-gr���z-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)r���Zis_user�LOG�info�items� isinstance�str�extend�appendr���� Exception�logexc�get� set_passwd) r���r����kwargsZadduser_cmdZlog_adduser_cmdZadduser_optsZ adduser_flags�key�valZ passwd_valr ���r ���r����add_userM���sH���� �� zNetBSD.add_userFc�����������������C���sZ���|r |}nt�|�}zt�dd||g��W�n"�tyJ���t�td|����Y�n0�|��|��d�S�)Nr���z-pzFailed to set password for %s)r���r���r.���r���r/���r'���� unlock_passwd)r����userr%���r&���Z hashed_pwr ���r ���r���r1�������s����zNetBSD.set_passwdc�����������������C���s>���zt���ddd|g��W�n"�ty8���t�td|����Y�n0�d�S�)Nr����-CZyeszFailed to lock user %s�r���r.���r���r/���r'����r���r���r ���r ���r����lock_passwd����s ����zNetBSD.lock_passwdc�����������������C���s>���zt���ddd|g��W�n"�ty8���t�td|����Y�n0�d�S�)Nr���r8����nozFailed to unlock user %sr9���r:���r ���r ���r���r6�������s ����zNetBSD.unlock_passwdNc�����������������C���s���t��d��d�S�)NzCannot set the locale.)r'����debug)r����localeZout_fnr ���r ���r����apply_locale����s����zNetBSD.apply_localec�����������������C���s&���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)r���Z os_releaseZos_archr ���r ���r����_get_pkg_cmd_environ����s�������zNetBSD._get_pkg_cmd_environ)�forcec����������������C���s���d�S�)Nr ���)r���rE���r ���r ���r����update_package_sources����s����zNetBSD.update_package_sources)F)N)�__name__� __module__�__qualname__�__doc__Z ci_sudoers_fnZgroup_add_cmd_prefixZ#shadow_empty_locked_passwd_patternsr���r����boolr5���r1���r;���r6���r?���rD���rF���� __classcell__r ���r ���r���r���r���*���s���9 r���c�������������������@���s���e�Zd�ZdS�)�DistroN)rG���rH���rI���r ���r ���r ���r���rM�������s���rM���)� functoolsZloggingr���rA����typingr���Zcloudinit.distros.bsdZ cloudinitr���r���ZcryptZMETHOD_BLOWFISHr����partialZmksaltr����__annotations__r����AttributeErrorZpasslib.hashr����hashZ getLoggerrG���r'���ZdistrosZbsdZBSDr���rM���r ���r ���r ���r����<module>���s.��� � �