uutils/coreutils · warning · SmackError::LabelRetrievalFailure
smack-error-no-label-set
Error message
smack-error-no-label-set
What it means
get_smack_label_for_path reads the security.SMACK64 extended attribute on Smack-enabled systems. If the attribute exists but is unset (xattr returns Some with... Ok(None) meaning no value), it wraps a NotFound io error carrying 'smack-error-no-label-set' in SmackError::LabelRetrievalFailure.
Solutions
- Set a label with `chsmack -a <label> <path>` before reading
- Fall back to a default label in your code when LabelRetrievalFailure(NotFound) is returned
- Verify the filesystem supports Smack labeling
Example fix
// before let label = get_smack_label_for_path(path)?; // after let label = get_smack_label_for_path(path).unwrap_or_else(|_| "_".to_string());
Defensive patterns
Strategy: fallback
Validate before calling
// xattr presence check (Linux)
fn has_smack64(path: &Path) -> bool {
std::path::Path::new("/sys/fs/smackfs").exists() &&
std::fs::read(path).is_ok() // filesystem reachable; label check via xattr crate
} Try / catch
match get_smack_label_for_path(path) {
Err(SmackError::LabelRetrievalFailure(e)) if e.kind() == std::io::ErrorKind::NotFound => default_label(),
Ok(label) => label,
Err(e) => return Err(e.into()),
} Prevention
- Label new files with `chsmack -a` on Smack-enabled systems
- Check is_smack_enabled() before querying labels
- Don't assume xattrs survive archive extraction or tmpfs
When it happens
Trigger: Calling get_smack_label_for_path on a file that has the SMACK64 xattr slot empty or no label assigned — i.e. the file was never labeled by smack.-label or inherited no label.
Common situations: Files created on non-Smack filesystems mounted on a Smack system; freshly extracted archives lacking xattrs; tmpfs volumes without Smack labeling.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
AI-assisted analysis of uutils/coreutils@92995feca2 (2026-09-20).
Data as JSON: /api/errors/5e41cf42eadda8d9.
Report an issue: GitHub.
Appendix: source
Thrown at src/uucore/src/lib/features/smack.rs:89
pub fn set_smack_label_for_self(label: &str) -> Result<(), SmackError> {
if !is_smack_enabled() {
return Err(SmackError::SmackNotEnabled);
}
fs::File::create("/proc/self/attr/current")
.and_then(|mut f| f.write_all(label.as_bytes()))
.map_err(|e| SmackError::LabelSetFailure(label.to_string(), e))
}
/// Gets the SMACK label for a filesystem path via xattr.
pub fn get_smack_label_for_path(path: &Path) -> Result<String, SmackError> {
if !is_smack_enabled() {
return Err(SmackError::SmackNotEnabled);
}
match xattr::get(path, "security.SMACK64") {
Ok(Some(value)) => Ok(String::from_utf8_lossy(&value).trim().to_string()),
Ok(None) => Err(SmackError::LabelRetrievalFailure(io::Error::new(
io::ErrorKind::NotFound,
translate!("smack-error-no-label-set"),
))),
Err(e) => Err(SmackError::LabelRetrievalFailure(e)),
}
}
/// Sets the SMACK label for a filesystem path via xattr.
pub fn set_smack_label_for_path(path: &Path, label: &str) -> Result<(), SmackError> {
if !is_smack_enabled() {
return Err(SmackError::SmackNotEnabled);
}
xattr::set(path, "security.SMACK64", label.as_bytes())
.map_err(|e| SmackError::LabelSetFailure(label.to_string(), e))
}
/// Sets SMACK label for a new path, calling cleanup on failure.View on GitHub (pinned to 92995feca2)