Skip to content

Commit 39f9f5e

Browse files
fix skip unix permissions config
1 parent 481cc78 commit 39f9f5e

File tree

3 files changed

+27
-5
lines changed

3 files changed

+27
-5
lines changed

src/config.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,11 @@ pub struct Config {
4949
)]
5050
pub token: String,
5151

52-
#[arg(env = "SKIP_GPG_PERMISSIONS", default_value = "false")]
52+
#[arg(
53+
long = "skip-permissions",
54+
env = "SKIP_GPG_PERMISSIONS",
55+
default_value_t = false
56+
)]
5357
pub skip_gpg_permissions: bool,
5458

5559
/// Configuration file path

src/gpg.rs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
#[cfg(target_family = "unix")]
23
use std::path::PathBuf;
34
use std::time::Duration;
@@ -8,6 +9,8 @@ use std::{
89
process::{Child, Command, Stdio},
910
};
1011

12+
#[cfg(target_family = "unix")]
13+
use log::error;
1114
use log::{debug, info};
1215
use serde::Serialize;
1316
use tokio::time::interval;
@@ -70,8 +73,19 @@ pub fn set_permissions(dir_path: &PathBuf) -> Result<(), WorkerError> {
7073
debug!("GPG temp folder set to {0}", dir_string);
7174
use std::os::unix::prelude::PermissionsExt;
7275
let permissions = fs::Permissions::from_mode(0o700);
73-
fs::set_permissions(dir_path, permissions)?;
74-
debug!("Permissions set");
76+
match fs::set_permissions(dir_path, permissions) {
77+
Ok(_) => {
78+
debug!("Permissions set");
79+
}
80+
Err(e) => {
81+
error!(
82+
"Failed to set permissions for GPG TEMP Home! \
83+
Location: {dir_string} \n \
84+
Error: {0}\n Program will proceed with default permissions.",
85+
e.to_string()
86+
);
87+
}
88+
}
7589
Ok(())
7690
}
7791

@@ -83,7 +97,10 @@ pub fn init_gpg(config: &Config) -> Result<(String, Child), WorkerError> {
8397

8498
#[cfg(target_family = "unix")]
8599
if !config.skip_gpg_permissions {
86-
set_permissions(&temp_path)?;
100+
// ignore permissions error, just warn the user and proceed. Default permissions still allow for provisioning to work.
101+
if let Err(e) = set_permissions(&temp_path) {
102+
error!("Failed to set permissions! \n Error: {}", e.to_string());
103+
}
87104
}
88105

89106
let temp_path_str = temp_path.to_str().ok_or(WorkerError::Gpg)?;

src/main.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ async fn main() -> Result<(), WorkerError> {
3838
let config = get_config().expect("Failed to create config");
3939
//init logging
4040
logging::init(&config.log_level, &None).expect("Failed to init logging, check logging config");
41-
debug!("config loaded");
41+
debug!("Logging initialized.");
42+
debug!("Current config: {:?}", &config);
4243
// Check required binaries
4344
let gpg_command = get_gpg_command();
4445
debug!("gpg command: {}", &gpg_command);

0 commit comments

Comments
 (0)