Skip to content

Commit

Permalink
Properly accounts for behavior on windows systems
Browse files Browse the repository at this point in the history
Signed-off-by: Jason Heath <jh@jasonheath.com>
  • Loading branch information
jasonheath committed Sep 20, 2024
1 parent 2c7784d commit 30aa1c0
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions components/hab/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ use habitat_common::{self as common,
UIWriter,
UI},
FeatureFlag};
#[cfg(not(target_os = "windows"))]
use habitat_core::util::posix_perm;
use habitat_core::{crypto::{init,
keys::{Key,
KeyCache}},
Expand All @@ -70,7 +72,6 @@ use habitat_core::{crypto::{init,
PackageTarget},
service::ServiceGroup,
url::default_bldr_url,
util::posix_perm,
ChannelIdent};
use habitat_sup_client::{SrvClient,
SrvClientError};
Expand Down Expand Up @@ -129,20 +130,25 @@ async fn main() {
env_logger::init();
let mut ui = UI::default_with_env();
let flags = FeatureFlag::from_env(&mut ui);

#[cfg(not(target_os = "windows"))]
if let Err(e) = posix_perm::set_umask_0022() {
ui.fatal(e).unwrap();
std::process::exit(1);
}

manage_permissions(&mut ui);
if let Err(e) = start(&mut ui, flags).await {
let exit_code = e.exit_code();
ui.fatal(e).unwrap();
std::process::exit(exit_code)
}
}

#[cfg(not(target_os = "windows"))]
fn manage_permissions(ui: &mut UI) {
if let Err(e) = posix_perm::set_umask_0022() {
ui.fatal(e).unwrap();
std::process::exit(1);
}
}

#[cfg(target_os = "windows")]
fn manage_permissions(_ui: &mut UI) {}

#[allow(clippy::cognitive_complexity)]
async fn start(ui: &mut UI, feature_flags: FeatureFlag) -> Result<()> {
// We parse arguments with configopt in a separate thread to eliminate
Expand Down

0 comments on commit 30aa1c0

Please sign in to comment.