XylotrechusZ
�
iAh � �z � d dl Z d dlZd dlmZmZ d dlmZmZ d dlm Z m
Z
ddddd�Zd� Zd � Z
dd�Zd� Zd
efd�ZdS )� N)�Feature�is_panel_feature_supported)�
SysCtlConf�SYSCTL_CL_CONF_FILE)�grep�)proc_can_see_other_uid_and_hidepid_synced� � )�noaccess� invisible�1�2c � � d} t | dd�� � 5 }|D ]g}|� � � }|rO|� d� � s:|� � � }|r$|d dk rd|d v r d
d
d
� � dS �h d
d
d
� � n# 1 swxY w Y n=# t t
f$ r)}t
d| d
t |� � � � Y d
}~nd
}~ww xY wdS )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�utf-8)�encoding�#r �proczhidepid=� NTzError: failed to parse�:F)�open�strip�
startswith�split�IOError�
IndexError�print�str)�fstab�f�line�
splitted_line�es �py/cl_proc_hidepid.py�
hidepid_foundr% sh � �
�E� <�
�%��w�
/�
/�
/� $�1��
$�
$���z�z�|�|��� $����� 4� 4� $�$(�J�J�L�L�M�$� $��q�)9�V�)C�)C�
�Vc�de�Vf�Hf�Hf�#�
$� $� $� $� $� $� $� $��
$� $� $� $� $� $� $� $� $� $� $� $���� $� $� $� $���
�Z� � <� <� <�
�&��s�C��F�F�;�;�;�;�;�;�;�;�����<�����5sG �B �AB�3B � B�B �B�B �B�B �C�+C�Cc �t � |r#t dd� | � � � � t j | � � S )N� executing� )r �join�
subprocess�call)�cmd�verboses r$ �executer. - s4 � �� *�
�k�3�8�8�C�=�=�)�)�)��?�3���� Fc � � t � � rdS t t j � � s| rt d� � dS t t �� � }| rt d� � t � � r#| rt d� � t g d�| � � S |� d� � }|� d� � }|d k r#| rt d
� � t g d�| � � S | rt d� � t d
dd|z dg| � � S )z9
Remount /proc with hidepid=2 option when needed
Nz>environment without LVE detected - remounting /proc is skipped)�config_filezapply sysctl settingszUhidepid option is found in /etc/fstab - remounting /proc with options from /etc/fstab)�
/bin/mount�-o�remount�/proczfs.proc_can_see_other_uidzfs.proc_super_gid�0zJvirtualized procfs feature is not enabled in sysctl conf - disable hidepid)r2 r3 zremount,hidepid=0,gid=0r5 zenable hidepid for /procr2 r3 zremount,hidepid=2,gid=r5 )
r r r �LVEr r r r% r. �get)r- �sysctl�proc_can_see_other_uid� super_gids r$ �remount_procr<