`h F d dl Z d dlZd dlmZ dZdZdZd Zd Zd Z d Z
dS )
N)Optionalz/usr/sbin/cagefsctlzNot initializedz
Not installedc t j t r t j t dgt j t j d 5 } | \ }}ddd n# 1 swxY w Y | d d S # t $ r Y dS w xY w# t t f$ r Y dS w xY wdS )zp
Get Cagefs user mode, execute cagefsctl --display-user-mode cmd
:return string -> cagefs user mode
z--display-user-modeTstdoutstderrtextN: )
ospathexistsBIN_EXEC
subprocessPopenPIPEcommunicatesplitstrip
IndexErrorOSErrorIOErrorprocout_s 'py/clconfig/cagefs_statistics_config.pyget_cagefs_user_moder s0
w~~h
!01!!
,
))++Q
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
yy~~a(..000
tt
! 44 sS 3C A=1C =BC BC ,B6 6
C C CC CCc t j t st S t st S t j t dgt j t j d 5 } |
\ }}ddd n# 1 swxY w Y | S # t t f$ r Y dS w xY w)zk
Get Cagefs user status, execute cagefsctl --cagefs-status cmd
:return string -> cagefs status
z--cagefs-statusTr N)r r r
r CAGEFS_STATUS_NOT_INSTALLEDcheck_cagefs_initializedCAGEFS_STATUS_NOT_INITIALIZEDr r r r r r r r s r get_cagefs_statusr" * s 7>>(## +**#%% -,,
()??
(
%%''FC
( ( ( ( ( ( ( ( ( ( ( ( ( ( ( yy{{W tts6 3B8 5B
B8 BB8 B!B8 8C
C
c 8 t j t r | rd}nd}t j t |gt j t j d 5 }| \ }}ddd n# 1 swxY w Y t | d }|d sdS t |d d d S # t t f$ r Y dS w xY w# t t f$ r Y dS w xY wdS ) a
Get Cagefs quantity if enabled/disabled users, execute
cagefsctl --list-enabled cmd for enabled users
execute cagefsctl --list-disabled cmd for disabled users
:param enabled: true/false flag for quantity enabled/disabled users
:return int -> quantity of users
z--list-enabledz--list-disabledTr N
r )r r r
r r r r r listr intr
ValueErrorr r )enabledcmdr r r stats r get_quantityr, B sq
w~~h
(&'!3!!
,
))++Q
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
CIIdOO,,Aw 147==--a0111
+
tt
! 44 + sY :D B8D BD BD *C* <-C* *C?;D >C??D DDc t j t dgt j d dS # t j t
f$ r Y dS w xY w)z
Check if cagefs is initialized with help of --check-cagefs-skeleton command
--check-cagefs-skeleton returns rc 0 only if it is initialized
z--check-cagefs-initializedF)r shellT)r check_outputr STDOUTCalledProcessErrorr r r r e sd
+G H'1'8 G G G Gt)73 uus (, AA)r r typingr r r! r r r" r, r r2 r3 r