{"record":{"id":"d21dad2f4c9d6833","repo":"uutils/coreutils","slug":"no-security-context-set","errorCode":null,"errorMessage":"no security context set","messagePattern":"no security context set","errorType":"exception","errorClass":"SmackError::LabelRetrievalFailure","httpStatus":null,"severity":"error","filePath":"src/uucore/src/lib/features/smack.rs","lineNumber":89,"sourceCode":"pub fn set_smack_label_for_self(label: &str) -> Result<(), SmackError> {\n    if !is_smack_enabled() {\n        return Err(SmackError::SmackNotEnabled);\n    }\n\n    fs::File::create(\"/proc/self/attr/current\")\n        .and_then(|mut f| f.write_all(label.as_bytes()))\n        .map_err(|e| SmackError::LabelSetFailure(label.to_string(), e))\n}\n\n/// Gets the SMACK label for a filesystem path via xattr.\npub fn get_smack_label_for_path(path: &Path) -> Result<String, SmackError> {\n    if !is_smack_enabled() {\n        return Err(SmackError::SmackNotEnabled);\n    }\n\n    match xattr::get(path, \"security.SMACK64\") {\n        Ok(Some(value)) => Ok(String::from_utf8_lossy(&value).trim().to_string()),\n        Ok(None) => Err(SmackError::LabelRetrievalFailure(io::Error::new(\n            io::ErrorKind::NotFound,\n            translate!(\"smack-error-no-label-set\"),\n        ))),\n        Err(e) => Err(SmackError::LabelRetrievalFailure(e)),\n    }\n}\n\n/// Sets the SMACK label for a filesystem path via xattr.\npub fn set_smack_label_for_path(path: &Path, label: &str) -> Result<(), SmackError> {\n    if !is_smack_enabled() {\n        return Err(SmackError::SmackNotEnabled);\n    }\n\n    xattr::set(path, \"security.SMACK64\", label.as_bytes())\n        .map_err(|e| SmackError::LabelSetFailure(label.to_string(), e))\n}\n\n/// Sets SMACK label for a new path, calling cleanup on failure.","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/uutils/coreutils/blob/0b77ced48502a5f80c51dfa827af7e69f3687053/src/uucore/src/lib/features/smack.rs#L71-L107","documentation":"Error \"no security context set\" thrown in uutils/coreutils.","triggerScenarios":"Occurs when querying SMACK security labels on a file or process that has no security context assigned.","commonSituations":"Running SMACK-aware tools on files without labels or on systems where SMACK is enabled but the object is unlabeled.","solutions":["Set a SMACK security context (or run with one configured) before requesting it.","Handle the unlabeled case gracefully when SMACK labels are absent."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0b77ced48502a5f80c51dfa827af7e69f3687053","analyzedAt":"2026-08-19T21:43:27.871Z","contentChangedAt":"2026-08-19T21:43:27.871Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}