Skip to content

Commit 0391fb4

Browse files
committed
lsm: Add some more comments
No functional changes. Signed-off-by: Colin Walters <[email protected]>
1 parent da468f5 commit 0391fb4

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/src/lsm.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,11 @@ pub(crate) fn has_security_selinux(root: &Dir, path: &Utf8Path) -> Result<SELinu
230230
}
231231
}
232232

233+
/// Directly set the `security.selinux` extended atttribute on the target
234+
/// path. Symbolic links are not followed for the target.
235+
///
236+
/// Note that this API will work even if SELinux is disabled.
233237
pub(crate) fn set_security_selinux_path(root: &Dir, path: &Utf8Path, label: &[u8]) -> Result<()> {
234-
// TODO: avoid hardcoding a max size here
235238
let fdpath = format!("/proc/self/fd/{}/", root.as_raw_fd());
236239
let fdpath = &Path::new(&fdpath).join(path);
237240
rustix::fs::lsetxattr(
@@ -243,6 +246,9 @@ pub(crate) fn set_security_selinux_path(root: &Dir, path: &Utf8Path, label: &[u8
243246
Ok(())
244247
}
245248

249+
/// Given a policy, ensure the target file path has a security.selinux label.
250+
/// If the path already is labeled, this function is a no-op, even if
251+
/// the policy would default to a different label.
246252
pub(crate) fn ensure_labeled(
247253
root: &Dir,
248254
path: &Utf8Path,

0 commit comments

Comments
 (0)