%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/cloudinit/distros/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/cloudinit/distros/__pycache__/freebsd.cpython-312.pyc

�

���f"����ddlZddlZddlZddlmZddlZddlmZmZddl	m
Z
ddlmZm
Z
eje�ZGd�dej"j$j&�Zy)�N)�StringIO)�subp�util)�FreeBSDNetworking)�
PER_ALWAYS�PER_INSTANCEc
�$�eZdZdZeZdZdZdZdZ	gd�Z
ddgZdd	gZdd
gZ
ddgZdZd
ZdZdZgd�Zed,d��Zedd�dededefd��Zd�Zdefd�Zd�Zd-d�Zd�Zd�Zd,d �Zd!�Z dd"�d#�Z!e"d$ed%ed&ed'ed(ede#fd)��Z$e"d*eddfd+��Z%y).�DistrozY
    Distro subclass for FreeBSD.

    (N.B. DragonFlyBSD inherits from this class.)
    z/usr/local/libz/etc/login.confz/etc/login.conf.origz,/usr/local/etc/sudoers.d/90-cloud-init-users)�pw�group�add�pkg�install�remove�update�upgradeTz	/usr/homez/var/dbzdhclient.leases.\w+)z
^{username}::z^{username}:\*:z^{username}:\*LOCKED\*:Nc��tjjd�}|�tj	d�ytj
dd|gd|��S)z�
        Tell rc to reload its configuration
        Note that this only works while we're still in the process of booting.
        May raise ProcessExecutionError
        �RC_PIDNz0Unable to reload rc(8): no RC_PID in Environment�killz-SIGALRMT��capture�rcs)�os�environ�get�LOG�warningr)�clsr�rc_pids   �;/usr/lib/python3/dist-packages/cloudinit/distros/freebsd.py�reload_initzDistro.reload_init7sE��������)���>��K�K�J�K���y�y�&�*�f�5�t��M�M�)r�action�service�
extra_argsc
��|j}|dg|dg|dg|dg|dg|dg|dg|dg|dg|dg|d	g|d
gd�}|||zt|�z}tj|d|�
�S)a
        Perform the requested action on a service. This handles FreeBSD's
        'service' case. The FreeBSD 'service' is closer in features to
        'systemctl' than SysV init's 'service', so we override it.
        May raise ProcessExecutionError
        �stop�start�enable�enabled�disable�onestart�onestop�restart�status�	onestatus)r'r(r)r*r+r,r-r.�reloadz
try-reloadr/r0Tr)�init_cmd�listr)rr#r$rr%r2�cmds�cmds        r �manage_servicezDistro.manage_serviceEs����<�<���f�%��w�'���)���+���+� �*�-���+���+��	�*�"�I�.���)�!�;�/�

����f��%��Z�(8�8���y�y��d��4�4r"c��ddd|d|gS)Nr�usermod�-n�-G�)�self�member_name�
group_names   r �_get_add_member_to_group_cmdz#Distro._get_add_member_to_group_cmdas���i��{�D�*�E�Er"�returnc���tj|�rtjd|�yddd|g}ddd|g}dddd	d
ddd
�}dddd�}|j	�D]q\}}||vr8|r6t|ttf�r |j||t
|�g��B||vs�G|s�J|j||�|j||��sd|vsd|vr#|jd�|jd�nk|jd|j�d|���}	|jd|	z�|jd�|jd|	z�|jd�tjd|�	tj||��|jdd�}
|
�|j||
d��y#t$rtjtd|��wxYw)z~
        Add a user to the system using standard tools

        Returns False if user already exists, otherwise True.
        z!User %s already exists, skipping.Fr�useraddr9z-d�-cz-gr:z-sz-Ez-u)�homedir�gecos�
primary_group�groups�shell�inactive�uidz--no-user-groupz--systemz
--no-log-init)�
no_user_group�system�no_log_init�no_create_homerLz-d/nonexistentrD�/z-mzAdding user %s)�	logstringzFailed to create user %s�passwdNT)�hashed)r�is_userr�info�items�
isinstance�str�int�extend�appendr�home_dirr�	Exception�logexc�
set_passwd)r<�name�kwargs�pw_useradd_cmd�log_pw_useradd_cmd�pw_useradd_opts�pw_useradd_flags�key�valrD�
passwd_vals           r �add_userzDistro.add_userds����<�<����H�H�8�$�?���	�4��6��"�I�t�T�:����!�����
��/� �*�
������	A�H�C���o�%�#�*�S�3��*�2M��%�%��s�';�S��X�&F�G��(�(�S��%�%�&6�s�&;�<�"�)�)�*:�3�*?�@�
	A��v�%��V�);��!�!�"2�3��%�%�&6�7��j�j��t�}�}�o�Q�t�f�,E�F�G��!�!�$��.�1��!�!�$�'��%�%�d�W�n�5��%�%�d�+�	���!�4�(�	��I�I�n�0B�C��Z�Z��$�/�
��!��O�O�D�*�T�O�:����	��K�K��7��>��	�s�:F:�:&G c��	tjdd|ddg�y#t$rtjtd|��wxYw)Nrr8�-pz01-Jan-1970z"Failed to set pw expiration for %s�rr\rr]r)r<�users  r �
expire_passwdzDistro.expire_passwd�sA��	��I�I�t�Y��d�M�B�C���	��K�K��A�4�H��	��	��&AFc��|rd}nd}	tjdd||dg|d|z��y#t$rtjtd|��wxYw)	Nz-Hz-hrr8�0zchpasswd for %s)�datarPzFailed to set password for %srk)r<rlrQrR�hash_opts     r r^zDistro.set_passwd�s^����H��H�	��I�I��y�$��#�6��+�d�2�
��
�	��K�K��<�d�C��	�s	� *�&Ac��	tjdd|ddg�y#t$rtjtd|��wxYw)Nrr8z-w�noz)Failed to lock password login for user %srk�r<r_s  r �lock_passwdzDistro.lock_passwd�sA��	��I�I�t�Y��d�D�9�:���	��K�K��H�$�O��	�rnc�0�tjd|�y)NzRDragonfly BSD/FreeBSD password lock is not reversible, ignoring unlock for user %s)r�debugrus  r �
unlock_passwdzDistro.unlock_passwd�s���	�	�
*��	
r"c�8�t�}tj|j�j	�D]<}|jt
jdd|z|��|jd��>tj|j|j�tj|j|j��	tjd|�tjd|jg�y#tj$r~tj td|�	tj|j|j�Yy#t"$r)tj td|j�YYywxYwwxYw)Nz	^default:zdefault:lang=%s:�
zRunning cap_mkdb for %s�cap_mkdbzFailed to apply locale %szFailed to restore %s backup)rr�load_text_file�
login_conf_fn�
splitlines�write�re�sub�copy�login_conf_fn_bak�
write_file�getvaluerrxr�ProcessExecutionErrorr]�IOError)r<�locale�out_fn�newconf�lines     r �apply_localezDistro.apply_locale�s6���*���'�'��(:�(:�;�F�F�H�	 �D��M�M����|�%8�6�%A�4�H�
�
�M�M�$��		 �	
�	�	�$�$�$�d�&<�&<�=�	
����*�*�G�,<�,<�,>�?�	��I�I�/��8��I�I�z�4�#5�#5�6�7���)�)�	��K�K��8�&�A�
��	�	�$�0�0�$�2D�2D�E���
�����6��8J�8J��
��	�s*�7D�.F�7*E#�#.F�F�F�Fc�
�ddiS)zJReturn environment vars used in FreeBSD package_command
        operations�ASSUME_ALWAYS_YES�YESr;)r<s r �_get_pkg_cmd_environzDistro._get_pkg_cmd_environ�s��$�U�+�+r")�forcec�|�|jjd|jdg|rt��yt��y)Nzupdate-sourcesr)�freq)�_runner�run�package_commandrr)r<r�s  r �update_package_sourceszDistro.update_package_sources�s>��������� � �
�J�$��		�	
�+7�		�	
r"�path�
lease_file�pid_file�	interface�config_filec�*�|d|d|g|rd||gzS|gzS)Nz-lrjrCr;)r�r�r�r�r�s     r �build_dhclient_cmdzDistro.build_dhclient_cmd�s7���d�J��h�7�.9�T�;�	�*�
�	
�@I�{�
�	
r"�devicec�4�tjdd|g�y)N�
camcontrol�eject)r)r�s r �eject_mediazDistro.eject_media�s���	�	�<��&�1�2r")N)F)&�__name__�
__module__�__qualname__�__doc__r�networking_cls�usr_lib_execr~r��
ci_sudoers_fn�group_add_cmd_prefix�pkg_cmd_install_prefix�pkg_cmd_remove_prefix�pkg_cmd_update_prefix�pkg_cmd_upgrade_prefix�prefer_fqdnr[�dhclient_lease_directory�dhclient_lease_file_regex�#shadow_empty_locked_passwd_patterns�classmethodr!rWr6r?�boolrhrmr^rvryr�r�r��staticmethodr3r�r�r;r"r r
r
sc���'�N�#�L�%�M�.��B�M�1��#�Y�/��"�H�-��"�H�-��#�Y�/���K��H� )�� 6��+�'��N��N��>B�5��5�#&�5�58�5��5�6F�<�$�<�|�� �
��8,�
/4�
��	
��	
��	
��	
��		
�
�	
�
�
	
��	
��3�C�3�D�3��3r"r
)�loggingrr��ior�cloudinit.distros.bsd�	cloudinitrr�cloudinit.distros.networkingr�cloudinit.settingsrr�	getLoggerr�r�distros�bsd�BSDr
r;r"r �<module>r�sQ���	�	��� �:�7��g����!��j3�Y�
�
�
"�
"�
&�
&�j3r"

Zerion Mini Shell 1.0