Skip to content

Commit 7129e8c

Browse files
codexmxcl
authored andcommitted
Tighten run workspace temp paths
Signed-off-by: Max Howell <mxcl@me.com>
1 parent 38d821e commit 7129e8c

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/lib.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ const HOMEBREW_NEEDLES: [&[u8]; 6] = [
102102
b"@@HOMEBREW_JAVA@@",
103103
];
104104
const TMP_X_ROOT: &str = "/tmp/x";
105-
const TMP_TOOL_ROOT: &str = "/tmp/pkgtool";
105+
const TMP_TOOL_ROOT: &str = "/tmp/substrate";
106106
const OPT_PKG_ROOT: &str = "/opt";
107107
const OPT_NPM_ROOT: &str = "/opt/npm";
108108
const OPT_PIP_ROOT: &str = "/opt/pip";
@@ -658,8 +658,8 @@ fn prepare_x_install_plan(plan: &InstallPlan) -> Result<(InstallPlan, TempDir),
658658
fs::create_dir_all(&plan.tmp_root)
659659
.map_err(|err| format!("failed to create {}: {err}", plan.tmp_root.display()))?;
660660
let workspace = Builder::new()
661-
.prefix(".")
662-
.rand_bytes(6)
661+
.prefix("")
662+
.rand_bytes(12)
663663
.tempdir_in(run_root)
664664
.map_err(|err| {
665665
format!(
@@ -8621,6 +8621,9 @@ info: requested `imagemagick`; `brew:imagemagick-full` is recommended instead\n"
86218621
assert_eq!(first_plan.stable_root, first_plan.install_root);
86228622
assert!(first_plan.install_root.starts_with(temp.path().join("x")));
86238623
assert_ne!(first_plan.install_root, second_plan.install_root);
8624+
let workspace_name = first_plan.install_root.file_name().unwrap().to_string_lossy();
8625+
assert_eq!(workspace_name.len(), 12);
8626+
assert!(!workspace_name.starts_with('.'));
86248627
}
86258628

86268629
#[test]
@@ -8653,7 +8656,7 @@ info: requested `imagemagick`; `brew:imagemagick-full` is recommended instead\n"
86538656
let temp = TempDir::new().unwrap();
86548657
let target_root = temp.path().join("opt");
86558658
let system_tmp_root = temp.path().join("tmp");
8656-
let shared_tmp_root = temp.path().join("pkgtool");
8659+
let shared_tmp_root = temp.path().join("substrate");
86578660

86588661
assert_eq!(
86598662
temp_root_for_target_root(&target_root, &system_tmp_root, &shared_tmp_root),
@@ -8666,7 +8669,7 @@ info: requested `imagemagick`; `brew:imagemagick-full` is recommended instead\n"
86668669
let temp = TempDir::new().unwrap();
86678670
let target_root = temp.path().join("opt");
86688671
let system_tmp_root = temp.path().join("tmp");
8669-
let shared_tmp_root = temp.path().join("pkgtool");
8672+
let shared_tmp_root = temp.path().join("substrate");
86708673
fs::create_dir_all(&shared_tmp_root).unwrap();
86718674
let mut permissions = fs::metadata(&shared_tmp_root).unwrap().permissions();
86728675
permissions.set_mode(0o555);
@@ -8683,7 +8686,7 @@ info: requested `imagemagick`; `brew:imagemagick-full` is recommended instead\n"
86838686
let temp = TempDir::new().unwrap();
86848687
let target_root = PathBuf::from("relative/opt");
86858688
let system_tmp_root = temp.path().join("tmp");
8686-
let shared_tmp_root = temp.path().join("pkgtool");
8689+
let shared_tmp_root = temp.path().join("substrate");
86878690

86888691
assert_eq!(
86898692
temp_root_for_target_root(&target_root, &system_tmp_root, &shared_tmp_root),

0 commit comments

Comments
 (0)