a yÊbZã@s€ddlZejdddZejZddlTddlmZddlZddlTddlZda dd„Z gd ¢Z d d „Z ddlZGd d „d eƒZ dS)éNzsetroubleshoot-pluginsT)Zfallback)Ú*)ÚPlugincCs.ts&tt ¡ƒ}| ¡ d¡a| ¡|tvS)NÚ )Úcustomizable_typesÚopenÚselinuxZselinux_customizable_types_pathÚreadÚsplitÚclose)ÚtargetÚfd©r ú//usr/share/setroubleshoot/plugins/restorecon.pyÚ customizable s  r)z/sys/z/proc/z/memfd:cCstD]}| |¡rdSqdS)NTF)Úexcluded_pathsÚ startswith)Z target_pathÚpathr r rÚ excluded_path,src@sTeZdZedƒZdZedƒZdd„ZedƒZdd„Z ed ƒZ d Z d d „Z d d„Z dS)ÚpluginzN SELinux is preventing $SOURCE_PATH "$ACCESS" access to $TARGET_PATH. z/sbin/restorecon $TARGET_PATHzç You can restore the default system context to this file by executing the restorecon command. restorecon '$TARGET_PATH', if this file is a directory, you can recursively restore using restorecon -R '$TARGET_PATH'. cCstdƒ|dS)NaÖ SELinux denied access requested by $SOURCE. $TARGET_PATH may be mislabeled. $TARGET_PATH default SELinux type is %s, but its current type is $TARGET_TYPE. Changing this file back to the default type may fix your problem.

File contexts can be assigned to a file in the following ways.

This file could have been mislabeled either by user error, or if an normally confined application was run under the wrong domain.

However, this might also indicate a bug in SELinux because the file should not have been labeled with this type.

If you believe this is a bug, please file a bug report against this package. é)Ú_©ÚselfÚavcÚargsr r rÚget_problem_description?sèzplugin.get_problem_descriptionzGIf you want to fix the label. $TARGET_PATH default label should be %s.cCs|j|dS)Nr)Úif_textrr r rÚ get_if_text\szplugin.get_if_textz¼you can run restorecon. The access attempt may have been stopped due to insufficient permissions to access a parent directory in which case try to change the following command accordingly.z"# /sbin/restorecon -v $TARGET_PATHcCs0t |t¡| d¡d|_d|_tdƒ|_dS)NédZgreenTzRestore Context)rÚ__init__Ú__name__Z set_priorityÚlevelZfixablerZ button_text)rr r rrds   zplugin.__init__c Cs:|js dS|jjdvrdS|jjtvr*dS| d¡r8dSi}t|d<t|d<t|d<t|d<t |d<|  |  ¡¡r6|j dur‚dS|j dkrdS|j d dkr¢dSt |j ƒr°dSt|jjƒrÀdSzNt |j  d ¡||j¡d }| d ¡d }||jjkr | d |f¡WSWn&ty4}z WYd}~n d}~00dS)N)Zcifs_tZnfs_tZ relabeltoÚdirÚfileZlnk_fileZchr_fileZblk_fileú/rú"rú:é)Zquery_environmentZtcontextÚtypeZ file_typesZall_accesses_are_inÚS_IFDIRÚS_IFREGÚS_IFLNKÚS_IFCHRÚS_IFBLKZ has_tclass_inÚkeysZtpathrrrZ matchpathconÚstripZtclassr ZreportÚOSError)rrZrestorecon_filesZmconZ mcon_typeÚer r rÚanalyzeks2  zplugin.analyzeN)r Ú __module__Ú __qualname__rZsummaryZfix_cmdZfix_descriptionrrrZ then_textZdo_textrr2r r r rr2sr)ÚgettextZ translationrZsetroubleshoot.utilZsetroubleshoot.PluginrÚosÚstatrrrrrrr r r rÚs