Edit File: cl_proc_hidepid.cpython-37.pyc
B ����5/9eG������������������@���s����d�dl�mZ�d�dl�mZ�d�dlZd�dlZd�dlmZmZ�d�dlm Z m Z �d�dlmZm Z �ddddd �Zd d��Zdd ��Zddd�Zdd��Zed�dd�ZdS�)�����)�print_function)�absolute_importN)�Feature�is_panel_feature_supported)� SysCtlConf�SYSCTL_CL_CONF_FILE)�grep�)proc_can_see_other_uid_and_hidepid_synced��������)ZnoaccessZ invisible�1�2c����������� ���C���s����d}�yft�|�d��R}xJ|D�]B}|���}|r|�d�s|���}|r|d�dkrd|d�krdS�qW�W�d Q�R�X�W�n8�ttfk r��}�ztd |�dt|���W�d d }~X�Y�nX�dS�) z� Search for line like "proc /proc proc defaults,hidepid=2,gid=clsupergid 0 0" in /etc/fstab Return True if /proc is mounted with hidepid option in /etc/fstab z /etc/fstab�r�#r����proczhidepid=����TNzError: failed to parse�:F)�open�strip� startswith�split�IOError� IndexError�print�str)Zfstab�f�lineZ splitted_line�e��r����cl_proc_hidepid.py� hidepid_found���s���� $r ���c�������������C���s���|rt�dd�|����t�|��S�)NZ executing� )r����join� subprocessZcall)�cmd�verboser���r���r����execute/���s����r&���Fc�������������C���s����t���r dS�ttj�s$|�r td��dS�ttd�}|�r:td��t��r^|�rLtd��tdddd g|��S�|� d �}|� d�}|dkr�|�r�td ��tdddd g|��S�|�r�td��tddd|�d g|��S�)z9 Remount /proc with hidepid=2 option when needed Nz>environment without LVE detected - remounting /proc is skipped)Zconfig_filezapply sysctl settingszUhidepid option is found in /etc/fstab - remounting /proc with options from /etc/fstabz /bin/mountz-oZremountz/proczfs.proc_can_see_other_uidzfs.proc_super_gid�0zJvirtualized procfs feature is not enabled in sysctl conf - disable hidepidzremount,hidepid=0,gid=0zenable hidepid for /proczremount,hidepid=2,gid=) r ���r���r���ZLVEr���r���r���r ���r&����get)r%���ZsysctlZproc_can_see_other_uidZ super_gidr���r���r����remount_proc5���s,���� r)���c����������� ���C���s����t�dd�}�d}y�x�|�D�]�}|���}||kr,q|�|�}|dkr@q|d7�}||d��}|�d�}|dkrt|d|��}n$|�d�}|dkr�|d|��}ndS�t|�S�W�W�n�tttfk r����Y�nX�dS�) zN Retrieve hidepid gid from /proc/mounts :return: gid, 0 if absent z ,hidepid=z/proc/mountsz,gid=�������N�,r!���)r���r����find�intr���r���� ValueError)Z lines_genZ gid_prefixr����posr���r���r����get_gid_from_mountsU���s.���� r1���)�returnc��������������C���s����d}�d}ydt�|�dd��N}xF|D�]>}t�d|�}|����d�s@qq|rt�t|�d��d�}P�qW�W�dQ�R�X�W�n�t t ttfk r����Y�nX�|S�) zT Retrieve hidepid value from /proc/mounts :return: hidepid, 0 if absent z/proc/mountsr���r���)�modezhidepid=(\d|\w+)z proc /procr ���N) r����re�searchr���r����HidepidValuesDictr(���r����group�OSErrorr���r���r/���)Zmounts_pathZres�filer����mr���r���r����get_hidepid_typing_from_mountsx���s���� r;���)F)Z __future__r���r���r#���r4���Zclcommon.cpapir���r���Zclcommon.sysctlr���r���Zclcommon.utilsr���r ���r6���r ���r&���r)���r1���r.���r;���r���r���r���r����<module> ���s��� #