mirror of
https://github.com/uutils/coreutils.git
synced 2025-07-07 21:45:01 +00:00
set_selinux_security_context: match GNU's error
This commit is contained in:
parent
8d94add393
commit
595f56a9e7
3 changed files with 8 additions and 7 deletions
|
@ -19,8 +19,8 @@ pub enum SeLinuxError {
|
|||
#[error("Failed to retrieve the security context")]
|
||||
ContextRetrievalFailure,
|
||||
|
||||
#[error("Failed to set the security context")]
|
||||
ContextSetFailure,
|
||||
#[error("failed to set default file creation context to {0}")]
|
||||
ContextSetFailure(String),
|
||||
|
||||
#[error("Invalid context string or conversion failure")]
|
||||
ContextConversionFailure,
|
||||
|
@ -32,7 +32,7 @@ impl From<SeLinuxError> for i32 {
|
|||
SeLinuxError::SELinuxNotEnabled => 1,
|
||||
SeLinuxError::FileOpenFailure => 2,
|
||||
SeLinuxError::ContextRetrievalFailure => 3,
|
||||
SeLinuxError::ContextSetFailure => 4,
|
||||
SeLinuxError::ContextSetFailure(_) => 4,
|
||||
SeLinuxError::ContextConversionFailure => 5,
|
||||
}
|
||||
}
|
||||
|
@ -113,10 +113,11 @@ pub fn set_selinux_security_context(
|
|||
false,
|
||||
)
|
||||
.set_for_path(path, false, false)
|
||||
.map_err(|_| SeLinuxError::ContextSetFailure)
|
||||
.map_err(|_| SeLinuxError::ContextSetFailure(ctx_str.to_string()))
|
||||
} else {
|
||||
// If no context provided, set the default SELinux context for the path
|
||||
SecurityContext::set_default_for_path(path).map_err(|_| SeLinuxError::ContextSetFailure)
|
||||
SecurityContext::set_default_for_path(path)
|
||||
.map_err(|_| SeLinuxError::ContextSetFailure("".to_string()))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -160,7 +160,7 @@ fn test_mkfifo_selinux_invalid() {
|
|||
.arg(arg)
|
||||
.arg(dest)
|
||||
.fails()
|
||||
.stderr_contains("Failed to");
|
||||
.stderr_contains("failed to");
|
||||
if at.file_exists(dest) {
|
||||
at.remove(dest);
|
||||
}
|
||||
|
|
|
@ -187,7 +187,7 @@ fn test_mknod_selinux_invalid() {
|
|||
.arg(dest)
|
||||
.arg("p")
|
||||
.fails()
|
||||
.stderr_contains("Failed to");
|
||||
.stderr_contains("failed to");
|
||||
if at.file_exists(dest) {
|
||||
at.remove(dest);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue