File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -21,9 +21,9 @@ fn get_config_file_path(app: &AppHandle) -> PathBuf {
2121 if !config_file_path. exists ( ) {
2222 create_dir_all ( & config_file_path) . expect ( "Failed to create missing app data dir" ) ;
2323 }
24- set_perms ( & config_file_path, true ) ;
24+ set_perms ( & config_file_path) ;
2525 config_file_path. push ( APP_CONFIG_FILE_NAME ) ;
26- set_perms ( & config_file_path, false ) ;
26+ set_perms ( & config_file_path) ;
2727 config_file_path
2828}
2929
Original file line number Diff line number Diff line change @@ -287,8 +287,8 @@ fn main() {
287287 . unwrap_or_else ( |_| "UNDEFINED LOG DIRECTORY" . into ( ) ) ;
288288
289289 // Ensure directories have appropriate permissions (dg25-28).
290- set_perms ( & data_dir, true ) ;
291- set_perms ( & log_dir, true ) ;
290+ set_perms ( & data_dir) ;
291+ set_perms ( & log_dir) ;
292292 info ! (
293293 "Application data (database file) will be stored in: {data_dir:?} and application logs in: {log_dir:?}. \
294294 Logs of the background Defguard service responsible for managing VPN connections at the \
Original file line number Diff line number Diff line change @@ -59,7 +59,7 @@ fn prepare_db_url() -> Result<String, Error> {
5959 app_dir. to_string_lossy( )
6060 ) ;
6161 }
62- set_perms ( & app_dir, true ) ;
62+ set_perms ( & app_dir) ;
6363 let db_path = app_dir. join ( DB_NAME ) ;
6464 if db_path. exists ( ) {
6565 debug ! (
@@ -78,7 +78,7 @@ fn prepare_db_url() -> Result<String, Error> {
7878 db_path. to_string_lossy( )
7979 ) ;
8080 }
81- set_perms ( & db_path, false ) ;
81+ set_perms ( & db_path) ;
8282 debug ! (
8383 "Application's database file is located at: {}" ,
8484 db_path. to_string_lossy( )
Original file line number Diff line number Diff line change @@ -85,10 +85,10 @@ pub fn app_data_dir() -> Option<PathBuf> {
8585/// Ensures path has appropriate permissions set (dg25-28):
8686/// - 700 for directories
8787/// - 600 for files
88- pub fn set_perms ( path : & PathBuf , is_directory : bool ) {
88+ pub fn set_perms ( path : & PathBuf ) {
8989 #[ cfg( not( windows) ) ]
9090 {
91- let perms = if is_directory { 0o700 } else { 0o600 } ;
91+ let perms = if path . is_dir ( ) { 0o700 } else { 0o600 } ;
9292 if let Err ( err) = set_permissions ( path, Permissions :: from_mode ( perms) ) {
9393 warn ! ( "Failed to set permissions on path {path:?}: {err}" ) ;
9494 }
You can’t perform that action at this time.
0 commit comments