h!&j<BdZddlZddlZddlZddlZdZdZdddZdZdS) zHelpers for CageFS interaction from lvectl / lvdctl. Kept in python_lve to avoid a hard dependency on securelve: lve-utils is installed on systems without CageFS, so anything we call here must degrade to a no-op when CageFS is absent. Nz/usr/sbin/cagefsctlz/etc/cagefs/proxy.commandsz(/usr/share/lve-utils/lvd-registry-helperz&/usr/share/lve-utils/lvd-limits-helper)LVD_REGISTRY_HELPERLVD_LIMITS_HELPERcntjtsdS t t dd5}|}dddn #1swxYwYn#t$rd}YnwxYw|}t D]Q\}}||vr tj|s*|r| ds|dz }||d|dz }R||krdStj dt tj t }tj|d tj|d \}} tj|d d5}||dddn #1swxYwYtj|t nB#t($r5tj|rtj|wxYwt-jtdgt,jt,jddS)a5Register LVD helper proxyexec entries in /etc/cagefs/proxy.commands. No-op when CageFS is not installed (cagefsctl binary absent) or when the entries are already present. When entries are added, runs ``cagefsctl --update-wrappers`` so the in-CageFS proxyexec wrappers appear immediately. Nrzutf-8)encoding =zRegistering LVD helpers in %sT)exist_okz.proxy.commands.)dirprefixwz--update-wrappersF)stdoutstderrcheck)ospathexistsCAGEFSCTL_TOOLopenPROXY_COMMANDS_PATHreadFileNotFoundErrorLVD_PROXY_ENTRIESitemsendswithlogginginfodirnamemakedirstempfilemkstempfdopenwritereplace BaseExceptionunlink subprocessrunDEVNULL)fcontent new_contentkeybinary proxy_dirfdtmp_paths py/lve_utils/cagefs.pyensure_lvd_proxy_commandsr4!s 7>>. ) ) %sW = = = ffhhG                K(..00++ V +   w~~f%%    {33D99 4 K#****** g L02EFFF 344IK D))))# :LMMMLB Yr3 1 1 1 !Q GGK  ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! 801111  7>>( # # Ih     N ,-!! sdA,A  A, A$$A,'A$(A,, A;:A;!G8F GFG!F"G?G?) __doc__rrr(r!rrrr4r3r8st '2 FA 11111r7