gzddlZddlZddlmZmZddlmZmZddlm Z m Z dddddZ dZ d Z dd Zd Zd efdZdS)N)Featureis_panel_feature_supported) SysCtlConfSYSCTL_CL_CONF_FILE)grep)proc_can_see_other_uid_and_hidepid_synced)noaccess invisible12c d} t|dd5}|D]g}|}|rO|ds:|}|r$|ddkrd|d vrd d d d Sh d d d n #1swxYwYn=#tt f$r)}t d |d t|Yd }~nd }~wwxYwdS)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/fstabrutf-8)encoding#rproczhidepid=NTzError: failed to parse:F)openstrip startswithsplitIOError IndexErrorprintstr)fstabfline splitted_linees py/cl_proc_hidepid.py hidepid_foundr%sh E < %w / / / $1 $ $zz||$ 4 4$$(JJLLM$$q)9V)C)C VcdeVfHfHf#  $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ Z <<< &sCFF;;;;;;;;< 5sGBAB3 BB BBBBBC+CCct|r#tdd|tj|S)N executing )rjoin subprocesscall)cmdverboses r$executer.-s4* k388C==))) ?3  FctrdSttjs|rt ddSt t }|rt dtr#|rt dtgd|S| d}| d}|d kr#|rt d tgd |S|rt d td dd|zdg|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-oremount/proczfs.proc_can_see_other_uidzfs.proc_super_gid0zJvirtualized procfs feature is not enabled in sysctl conf - disable hidepid)r2r3zremount,hidepid=0,gid=0r5zenable hidepid for /procr2r3zremount,hidepid=2,gid=r5) rrrLVErrrr%r.get)r-sysctlproc_can_see_other_uid super_gids r$ remount_procr<3sA122 %gk 2 2  T R S S S $7 8 8 8F' %&&&J  k i j j j???III#ZZ(CDD .//I$$  ` ^ _ _ _OOOQXYYY* ())) L$(@9(LgVX_ ` ``r/ctdd}d} |D]}|}||vr||}|dkr7|dz }||d}|d}|dkr |d|}n)|d}|dkr |d|}ndSt|cSn#tt t f$rYnwxYwdS) zN Retrieve hidepid gid from /proc/mounts :return: gid, 0 if absent z ,hidepid= /proc/mountsz,gid=N,r()rrfindintrr ValueError) lines_gen gid_prefixr!poss r$get_gid_from_mountsrHSs [.11IJ   D::<rrr)moderzhidepid=(\d|\w+)z proc /procr N) rresearchrrHidepidValuesDictr8rgroupOSErrorrrrD) mounts_pathresfiler!ms r$get_hidepid_typing_from_mountsrUvs& !K C  +C' : : : d  I1488zz||..|<<+//AGGAJJCCCE                 Wj* 5      Js5B2BB& B2&B**B2-B*.B22CC)F)r*rLclcommon.cpapirrclcommon.sysctlrrclcommon.utilsrrrNr%r.r<rHrCrUr/r$rZs >>>>>>>>;;;;;;;;JJJJJJJJ &   aaaa@   Fr/