Skip to content

Commit

Permalink
copy file permissions when bootstrapping file content
Browse files Browse the repository at this point in the history
this is important when there are secrets in the file
  • Loading branch information
Kladki committed Nov 16, 2024
1 parent 6c426dd commit 071d9d5
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/_archive/core/bootstrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,25 @@ impl<'a> BuildContext<'a> {
"Reading from '{}' ; [{pretty_path}]",
source.display()
))?;
let permissions = fs::metadata(&source)
.await
.context(format!(
"Getting metadata of '{}' ; [{pretty_path}]",
source.display()
))?
.permissions();

let bootstrapped_contents = self.bootstrap_content(&config_contents);

fs::write(&dest, bootstrapped_contents)
.await
.context(format!("Writing to '{}' ; [{pretty_path}]", dest.display()))?;
fs::set_permissions(&dest, permissions)
.await
.context(format!(
"Setting permissions for '{}' ; [{pretty_path}]",
dest.display()
))?;
} else {
// ? idk why but read_to_string and fs::write works with 'dest' but fs::copy doesnt
fs::copy(&source, &dest).await.context(format!(
Expand Down

0 comments on commit 071d9d5

Please sign in to comment.