@@ -19,8 +19,8 @@ pub enum SeLinuxError {
1919 #[ error( "Failed to retrieve the security context" ) ]
2020 ContextRetrievalFailure ,
2121
22- #[ error( "Failed to set the security context" ) ]
23- ContextSetFailure ,
22+ #[ error( "failed to set default file creation context to {0} " ) ]
23+ ContextSetFailure ( String ) ,
2424
2525 #[ error( "Invalid context string or conversion failure" ) ]
2626 ContextConversionFailure ,
@@ -32,7 +32,7 @@ impl From<SeLinuxError> for i32 {
3232 SeLinuxError :: SELinuxNotEnabled => 1 ,
3333 SeLinuxError :: FileOpenFailure => 2 ,
3434 SeLinuxError :: ContextRetrievalFailure => 3 ,
35- SeLinuxError :: ContextSetFailure => 4 ,
35+ SeLinuxError :: ContextSetFailure ( _ ) => 4 ,
3636 SeLinuxError :: ContextConversionFailure => 5 ,
3737 }
3838 }
@@ -113,10 +113,11 @@ pub fn set_selinux_security_context(
113113 false ,
114114 )
115115 . set_for_path ( path, false , false )
116- . map_err ( |_| SeLinuxError :: ContextSetFailure )
116+ . map_err ( |_| SeLinuxError :: ContextSetFailure ( ctx_str . to_string ( ) ) )
117117 } else {
118118 // If no context provided, set the default SELinux context for the path
119- SecurityContext :: set_default_for_path ( path) . map_err ( |_| SeLinuxError :: ContextSetFailure )
119+ SecurityContext :: set_default_for_path ( path)
120+ . map_err ( |_| SeLinuxError :: ContextSetFailure ( "" . to_string ( ) ) )
120121 }
121122}
122123
0 commit comments