wo4hlddlZddlZddlZddlmZddlmZmZdZdZ dZ dZ edd d gfd Z d Z eejd e ddZddZddZdS)N) lru_cache)retry_onrun_with_umaskcagefsrestartz/usr/sbin/cagefsctlz --wait-lockz/usr/binz/binc4td|DS)z6Return whether we can find systemctl in given *paths*.c3K|]A}tjtj|dVBdS) systemctlN)ospathisfilejoin).0ps h/opt/imunify360/venv/lib/python3.11/site-packages/defence360agent/migrations/129_fixed_cagefs_unmount.py z$systemctl_present..s@KKrw~~bgll1k::;;KKKKKK)any)pathss rsystemctl_presentr s! KKUKKK K KKrctrdttg}ndttg} tj|n#t $rYnwxYwt jddS)Nr service)r_COMMAND _SERVICE_NAME subprocess check_call Exceptiontimesleep)excicmds r_restart_cagefsr%st3Hm4-2 c""""      JqMMMMMsA AAT) max_trieson_errorsilentcHtj|dtjdS)NF)shellstderr)r check_outputSTDOUT)r$s r_execute_commandr/s%CuZ5FGGGGGGrFc |rdSttdgttdgg}t|5tjtr|D]}t |ddddS#1swxYwYdS)Nz--force-update-etcz --remount-all)_CAGEFSCTL_TOOL _WAIT_LOCKrr r existsr/)migratordatabasefakeumaskkwargscmd_listr$s rmigrater;)s  *&:; *o6H   && 7>>/ * * & & & %%%%&&&&&&&&&&&&&&&&&&s9A88A<?A<c dS)N)r5r6r7r9s rrollbackr>6sDr)Fr0)F)rr r functoolsrdefence360agent.utilsrrrrr2r3rr%CalledProcessErrorr/r;r>r=rrrBs :::::::: '   1'0LLLL    !    HH  H & & & &      r