uutils/coreutils · error · SmackError::LabelRetrievalFailure

no security context set

Error message

no security context set

What it means

Error "no security context set" thrown in uutils/coreutils.

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 0b77ced485)

Solutions

  1. Set a SMACK security context (or run with one configured) before requesting it.
  2. Handle the unlabeled case gracefully when SMACK labels are absent.

When it happens

Trigger: Occurs when querying SMACK security labels on a file or process that has no security context assigned.

Common situations: Running SMACK-aware tools on files without labels or on systems where SMACK is enabled but the object is unlabeled.


AI-assisted analysis of uutils/coreutils@0b77ced485 (2026-08-19). Data as JSON: /api/errors/d21dad2f4c9d6833. Report an issue: GitHub.