From 7e951a5b6a88b3482f0154282344963ac4e77f74 Mon Sep 17 00:00:00 2001 From: Ana Hobden Date: Tue, 21 Feb 2023 07:28:14 -0800 Subject: [PATCH] Set the correct permissions on the zshenv (#257) * Set the correct permissions on the zshenv * Update error to suggest chmod instead of delete * Missed a formatting option * 644, not 755 * Get a bit more specific * Mac specific permissions --- src/action/common/configure_shell_profile.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/action/common/configure_shell_profile.rs b/src/action/common/configure_shell_profile.rs index 81a88f0e5..3112f128f 100644 --- a/src/action/common/configure_shell_profile.rs +++ b/src/action/common/configure_shell_profile.rs @@ -3,6 +3,7 @@ use crate::action::{Action, ActionDescription, ActionError, StatefulAction}; use nix::unistd::User; use std::path::{Path, PathBuf}; +use target_lexicon::OperatingSystem; use tokio::task::JoinSet; use tracing::{span, Instrument, Span}; @@ -65,12 +66,22 @@ impl ConfigureShellProfile { ); continue; } + // Macs require a different mode on certain files... + let required_mode = match target_lexicon::OperatingSystem::host() { + OperatingSystem::MacOSX { + major: _, + minor: _, + patch: _, + } + | OperatingSystem::Darwin => 0o100444, + _ => 0o100644, + }; create_or_insert_files.push( CreateOrInsertIntoFile::plan( profile_target_path, None, None, - None, + required_mode, shell_buf.to_string(), create_or_insert_into_file::Position::Beginning, ) @@ -112,7 +123,7 @@ impl ConfigureShellProfile { profile_target, None, None, - 0o0755, + 0o100644, fish_buf.to_string(), create_or_insert_into_file::Position::Beginning, )