mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-18 17:41:01 +00:00
PVF: fix detection of unshare-and-change-root security capability (#2304)
This commit is contained in:
@@ -27,14 +27,19 @@ const SECURE_MODE_ANNOUNCEMENT: &'static str =
|
||||
\nMore information: https://wiki.polkadot.network/docs/maintain-guides-secure-validator#secure-validator-mode";
|
||||
|
||||
/// Run checks for supported security features.
|
||||
///
|
||||
/// # Return
|
||||
///
|
||||
/// Returns the set of security features that we were able to enable. If an error occurs while
|
||||
/// enabling a security feature we set the corresponding status to `false`.
|
||||
pub async fn check_security_status(config: &Config) -> SecurityStatus {
|
||||
let Config { prepare_worker_program_path, .. } = config;
|
||||
let Config { prepare_worker_program_path, cache_path, .. } = config;
|
||||
|
||||
// TODO: add check that syslog is available and that seccomp violations are logged?
|
||||
let (landlock, seccomp, change_root) = join!(
|
||||
check_landlock(prepare_worker_program_path),
|
||||
check_seccomp(prepare_worker_program_path),
|
||||
check_can_unshare_user_namespace_and_change_root(prepare_worker_program_path)
|
||||
check_can_unshare_user_namespace_and_change_root(prepare_worker_program_path, cache_path)
|
||||
);
|
||||
|
||||
let security_status = SecurityStatus {
|
||||
@@ -149,11 +154,22 @@ fn print_secure_mode_message(errs: Vec<SecureModeError>) -> bool {
|
||||
async fn check_can_unshare_user_namespace_and_change_root(
|
||||
#[cfg_attr(not(target_os = "linux"), allow(unused_variables))]
|
||||
prepare_worker_program_path: &Path,
|
||||
#[cfg_attr(not(target_os = "linux"), allow(unused_variables))] cache_path: &Path,
|
||||
) -> SecureModeResult {
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(target_os = "linux")] {
|
||||
let cache_dir_tempdir =
|
||||
crate::worker_intf::tmppath_in("check-can-unshare", cache_path)
|
||||
.await
|
||||
.map_err(
|
||||
|err|
|
||||
SecureModeError::CannotUnshareUserNamespaceAndChangeRoot(
|
||||
format!("could not create a temporary directory in {:?}: {}", cache_path, err)
|
||||
)
|
||||
)?;
|
||||
match tokio::process::Command::new(prepare_worker_program_path)
|
||||
.arg("--check-can-unshare-user-namespace-and-change-root")
|
||||
.arg(cache_dir_tempdir)
|
||||
.output()
|
||||
.await
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user