From d092d1de1d44e31d52fa941a408c6bcc3b206c94 Mon Sep 17 00:00:00 2001 From: Simon Lin Date: Sat, 8 Feb 2025 03:10:45 +1100 Subject: [PATCH] c --- crates/polars-io/src/path_utils/mod.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/crates/polars-io/src/path_utils/mod.rs b/crates/polars-io/src/path_utils/mod.rs index f6a193a319ac..b3c5b7bbc73d 100644 --- a/crates/polars-io/src/path_utils/mod.rs +++ b/crates/polars-io/src/path_utils/mod.rs @@ -80,7 +80,7 @@ pub static POLARS_TEMP_DIR_BASE_PATH: Lazy> = Lazy::new(|| { { use std::os::unix::fs::PermissionsExt; - (|| { + let result = (|| { std::fs::set_permissions(path.as_ref(), std::fs::Permissions::from_mode(0o700))?; let perms = std::fs::metadata(path.as_ref())?.permissions(); @@ -102,7 +102,11 @@ pub static POLARS_TEMP_DIR_BASE_PATH: Lazy> = Lazy::new(|| { path.as_ref() ), ) - })? + }); + + if std::env::var("POLARS_ALLOW_UNSECURED_TEMP_DIR").as_deref() != Ok("1") { + result?; + } } std::io::Result::Ok(path) @@ -112,7 +116,7 @@ pub static POLARS_TEMP_DIR_BASE_PATH: Lazy> = Lazy::new(|| { e.kind(), format!( "error initializing temporary directory: {} \ - consider explicitly setting POLARS_TEMP_DIR ", + consider explicitly setting POLARS_TEMP_DIR", e ), )