get_secontext: ignore ENODATA

This commit is contained in:
vvb2060 2025-03-03 00:24:10 +08:00 committed by John Wu
parent e8a3bf82c6
commit e8958c6b5c

View File

@ -733,10 +733,12 @@ impl FsPath {
XATTR_NAME_SELINUX.as_ptr().cast(), XATTR_NAME_SELINUX.as_ptr().cast(),
con.as_mut_ptr().cast(), con.as_mut_ptr().cast(),
con.capacity(), con.capacity(),
) );
.check_os_err()?;
if sz < 1 { if sz < 1 {
con.clear(); con.clear();
if *errno() != libc::ENODATA {
return Err(io::Error::last_os_error());
}
} else { } else {
con.set_len((sz - 1) as usize); con.set_len((sz - 1) as usize);
} }
@ -840,11 +842,16 @@ pub fn fd_get_attr(fd: RawFd) -> io::Result<FileAttr> {
XATTR_NAME_SELINUX.as_ptr().cast(), XATTR_NAME_SELINUX.as_ptr().cast(),
attr.con.as_mut_ptr().cast(), attr.con.as_mut_ptr().cast(),
attr.con.capacity(), attr.con.capacity(),
) );
.check_os_err()?; if sz < 1 {
if *errno() != libc::ENODATA {
return Err(io::Error::last_os_error());
}
} else {
attr.con.set_len((sz - 1) as usize); attr.con.set_len((sz - 1) as usize);
} }
} }
}
Ok(attr) Ok(attr)
} }