dbfdg 3 nmaG@s~ddlZejdddZejZddlTddlmZddlZddlTddlZda ddZ d gZ d d Z ddlZGd d d eZ dS)Nzsetroubleshoot-pluginsT)Zfallback)*)PlugincCs.ts&ttj}|jjda|j|tkS)N )customizable_typesopenselinuxZselinux_customizable_types_pathreadsplitclose)targetfdr //usr/share/setroubleshoot/plugins/restorecon.py customizable s  rz/sys/fscCs xtD]}|j|rdSqWdS)NTF)excluded_paths startswith)Z target_pathpathr r r excluded_path,s  rc@sTeZdZedZdZedZddZedZddZ edZ d Z d d Z ddZ 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. )_)selfavcargsr r rget_problem_description?szplugin.get_problem_descriptionzGIf you want to fix the label. $TARGET_PATH default label should be %s.cCs|j|dS)Nr)if_text)rrrr r r get_if_text\szplugin.get_if_textzTyou can run restorecon. The access attempt may have been stopped due to insufficientzh permissions to access a parent directory in which case try to change the following command accordingly.z"# /sbin/restorecon -v $TARGET_PATHcCs0tj|t|jdd|_d|_td|_dS)NdZgreenTzRestore Context)r__init____name__Z set_prioritylevelZfixablerZ button_text)rr r rrds   zplugin.__init__cCs6|js dS|jjdkrdS|jjtkr*dS|jdr8dSi}t|d<t|d<t|d<t|d<t |d<|j |j r2|j dkrdS|j d krdS|j d d krdSt |j rdSt|jjrdSyLtj|j jd ||jd }|jd d}||jjkr |jd |fSWn$tk r0}zWYdd}~XnXdS)Ncifs_tnfs_tZ relabeltodirfileZlnk_fileZchr_fileZblk_file/r"r:)r!r")Zquery_environmentZtcontexttypeZ file_typesZall_accesses_are_inS_IFDIRS_IFREGS_IFLNKS_IFCHRS_IFBLKZ has_tclass_inkeysZtpathrrrZ matchpathconstripZtclassr ZreportOSError)rrZrestorecon_filesZmconZ mcon_typeer r ranalyzeksB       zplugin.analyzeNzyou 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.)r __module__ __qualname__rZsummaryZfix_cmdZfix_descriptionrrrZ then_textZdo_textrr3r r r rr2sr)gettextZ translationrZsetroubleshoot.utilZsetroubleshoot.Pluginrosstatrrrrrrr r r rs