HEX
Server: Apache
System: Linux insrv.serversdaddy.com 5.14.0-362.24.2.el9_3.x86_64 #1 SMP PREEMPT_DYNAMIC Sat Mar 30 14:11:54 EDT 2024 x86_64
User: jsaha (1066)
PHP: 8.3.6
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/alt/python37/lib/python3.7/site-packages/__pycache__/cl_proc_hidepid.cpython-37.pyc
B

�G�F<��@s�ddlmZddlmZddlZddlZddlmZmZddlm	Z	m
Z
ddlmZm
Z
ddddd	�Zd
d�Zdd
�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
Cs�d}yft|d��R}xJ|D]B}|��}|r|�d�s|��}|r|ddkrd|dkrdSqWWd	QRXWn8ttfk
r�}ztd
|dt|��Wd	d	}~XYnXdS)
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_founds
$r cCs|rtdd�|��t�|�S)NZ	executing� )r�join�
subprocessZcall)�cmd�verboserrr�execute/sr&FcCs�t�r
dSttj�s$|r td�dSttd�}|r:td�t�r^|rLtd�tdddd	g|�S|�	d
�}|�	d�}|dkr�|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	rrZLVErrrr r&�get)r%ZsysctlZproc_can_see_other_uidZ	super_gidrrr�remount_proc5s,



r)c
Cs�tdd�}d}y�x�|D]�}|��}||kr,q|�|�}|dkr@q|d7}||d�}|�d�}|dkrt|d|�}n$|�d�}|dkr�|d|�}ndSt|�SWWntttfk
r�YnXdS)	zN
    Retrieve hidepid gid from /proc/mounts
    :return: gid, 0 if absent
    z	,hidepid=z/proc/mountsz,gid=����N�,r!)rr�find�intrr�
ValueError)Z	lines_genZ
gid_prefixr�posrrr�get_gid_from_mountsUs.




r1)�returncCs�d}d}ydt|dd��N}xF|D]>}t�d|�}|���d�s@qq|rt�t|�d��d�}PqWWdQRXWnt	t
ttfk
r�YnX|S)	zT
    Retrieve hidepid value from /proc/mounts
    :return: hidepid, 0 if absent
    z/proc/mountsrr)�modezhidepid=(\d|\w+)z
proc /procr
N)
r�re�searchrr�HidepidValuesDictr(r�group�OSErrorrrr/)Zmounts_pathZres�filer�mrrr�get_hidepid_typing_from_mountsxs
r;)F)Z
__future__rrr#r4Zclcommon.cpapirrZclcommon.sysctlrrZclcommon.utilsrr	r6r r&r)r1r.r;rrrr�<module>
s
 #