mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-27 19:17:43 +00:00
set_selinux_security_context split the ContextRetrievalFailure error in two
This commit is contained in:
parent
3bc267902c
commit
8d94add393
1 changed files with 8 additions and 5 deletions
|
@ -16,9 +16,12 @@ pub enum SeLinuxError {
|
|||
#[error("Failed to open the file")]
|
||||
FileOpenFailure,
|
||||
|
||||
#[error("Failed to retrieve or set the security context")]
|
||||
#[error("Failed to retrieve the security context")]
|
||||
ContextRetrievalFailure,
|
||||
|
||||
#[error("Failed to set the security context")]
|
||||
ContextSetFailure,
|
||||
|
||||
#[error("Invalid context string or conversion failure")]
|
||||
ContextConversionFailure,
|
||||
}
|
||||
|
@ -29,7 +32,8 @@ impl From<SeLinuxError> for i32 {
|
|||
SeLinuxError::SELinuxNotEnabled => 1,
|
||||
SeLinuxError::FileOpenFailure => 2,
|
||||
SeLinuxError::ContextRetrievalFailure => 3,
|
||||
SeLinuxError::ContextConversionFailure => 4,
|
||||
SeLinuxError::ContextSetFailure => 4,
|
||||
SeLinuxError::ContextConversionFailure => 5,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -109,11 +113,10 @@ pub fn set_selinux_security_context(
|
|||
false,
|
||||
)
|
||||
.set_for_path(path, false, false)
|
||||
.map_err(|_| SeLinuxError::ContextRetrievalFailure)
|
||||
.map_err(|_| SeLinuxError::ContextSetFailure)
|
||||
} else {
|
||||
// If no context provided, set the default SELinux context for the path
|
||||
SecurityContext::set_default_for_path(path)
|
||||
.map_err(|_| SeLinuxError::ContextRetrievalFailure)
|
||||
SecurityContext::set_default_for_path(path).map_err(|_| SeLinuxError::ContextSetFailure)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue