|
3 | 3 | // Prevents additional console window on Windows in release, DO NOT REMOVE!! |
4 | 4 | #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] |
5 | 5 |
|
6 | | -use std::{env, str::FromStr, sync::LazyLock}; |
| 6 | +use std::{ |
| 7 | + env, |
| 8 | + fs::{set_permissions, Permissions}, |
| 9 | + os::unix::fs::PermissionsExt, |
| 10 | + str::FromStr, |
| 11 | + sync::LazyLock, |
| 12 | +}; |
7 | 13 |
|
8 | 14 | #[cfg(target_os = "windows")] |
9 | 15 | use defguard_client::utils::sync_connections; |
@@ -277,15 +283,22 @@ fn main() { |
277 | 283 | app.run(|app_handle, event| match event { |
278 | 284 | // Startup tasks |
279 | 285 | RunEvent::Ready => { |
| 286 | + // Ensure data directory has appropriate permissions (dg25-28) |
| 287 | + let data_dir = app_handle |
| 288 | + .path() |
| 289 | + .app_data_dir() |
| 290 | + .unwrap_or_else(|_| "UNDEFINED DATA DIRECTORY".into()); |
| 291 | + if let Err(err) = set_permissions(&data_dir, Permissions::from_mode(0o700)) { |
| 292 | + warn!( |
| 293 | + "Failed to set permissions on data directory {}: {err}", |
| 294 | + data_dir.display() |
| 295 | + ); |
| 296 | + } |
280 | 297 | info!( |
281 | 298 | "Application data (database file) will be stored in: {} and application logs in: {}. \ |
282 | 299 | Logs of the background Defguard service responsible for managing VPN connections at the \ |
283 | 300 | network level will be stored in: {}.", |
284 | | - // display the path to the app data directory, convert option<pathbuf> to option<&str> |
285 | | - app_handle |
286 | | - .path() |
287 | | - .app_data_dir() |
288 | | - .unwrap_or_else(|_| "UNDEFINED DATA DIRECTORY".into()).display(), |
| 301 | + data_dir.display(), |
289 | 302 | app_handle |
290 | 303 | .path() |
291 | 304 | .app_log_dir() |
|
0 commit comments