Skip to content

Commit

Permalink
Explicitly set ownership of results directory (recursively)
Browse files Browse the repository at this point in the history
* Linux: Transfer ownership to current user and group.
* Windows: Transfer ownership to administrator group.

Files in this directory are never written by a different user, so we can take
ownership recursively. If the scheduler was previously executed as a different
user, it's OK for us to take over ownership, since the previous user must anyway
have elevated access.

CMK-20037
  • Loading branch information
jherbel committed Nov 7, 2024
1 parent 3a12992 commit 5701504
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/bin/scheduler/setup/directories.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![allow(dead_code)]

use super::plans_by_sessions;
use super::rcc::rcc_setup_working_directory;
use crate::internal_config::{
Expand Down Expand Up @@ -56,8 +54,8 @@ pub fn setup(
remove_dir_all(&global_config.managed_directory)?;
}
create_dir_all(&global_config.managed_directory)?;
setup_results_directories(global_config, &plans)?;

setup_results_directories(global_config, &plans, &ownership_setter)?;
let (surviving_plans, managed_dir_failures) = setup_managed_directories(plans);
let (mut surviving_plans, working_dir_failures) =
setup_working_directories(global_config, surviving_plans, &ownership_setter);
Expand Down Expand Up @@ -390,9 +388,14 @@ fn setup_with_one_directory_for_current_session(
}
}

fn setup_results_directories(global_config: &GlobalConfig, plans: &[Plan]) -> AnyhowResult<()> {
fn setup_results_directories(
global_config: &GlobalConfig,
plans: &[Plan],
ownership_setter: &OwnershipSetter,
) -> AnyhowResult<()> {
create_dir_all(&global_config.results_directory)?;
create_dir_all(plan_results_directory(&global_config.results_directory))?;
ownership_setter.transfer_directory_ownership_recursive(&global_config.results_directory)?;
clean_up_results_directory(global_config, plans).context("Failed to clean up results directory")
}

Expand Down

0 comments on commit 5701504

Please sign in to comment.