From 94cdc752d0030e828241ace821e7d303bb35ac58 Mon Sep 17 00:00:00 2001 From: rbuj Date: Mon, 23 Nov 2020 23:39:10 +0100 Subject: caja-directory-async: trust also launchers from user desktop --- libcaja-private/caja-directory-async.c | 11 ++++------- libcaja-private/caja-file-utilities.c | 25 +++++++++++++++++++++++++ libcaja-private/caja-file-utilities.h | 3 ++- 3 files changed, 31 insertions(+), 8 deletions(-) diff --git a/libcaja-private/caja-directory-async.c b/libcaja-private/caja-directory-async.c index 718f7809..cd02177c 100644 --- a/libcaja-private/caja-directory-async.c +++ b/libcaja-private/caja-directory-async.c @@ -3854,25 +3854,22 @@ static gboolean is_link_trusted (CajaFile *file, gboolean is_launcher) { - gboolean res; + gboolean res = FALSE; if (!is_launcher) { return TRUE; } - res = FALSE; - if (caja_file_can_execute (file) && caja_file_is_local (file)) { GFile *location; location = caja_file_get_location (file); - res = caja_is_in_system_dir (location); - if (!res) { - res = is_trusted_system_desktop_file (location); - } + res = caja_is_in_system_dir (location) || + is_trusted_system_desktop_file (location) || + caja_is_in_desktop_dir (location); g_object_unref (location); } diff --git a/libcaja-private/caja-file-utilities.c b/libcaja-private/caja-file-utilities.c index 424cf421..2dae9794 100644 --- a/libcaja-private/caja-file-utilities.c +++ b/libcaja-private/caja-file-utilities.c @@ -1134,6 +1134,31 @@ caja_is_in_system_dir (GFile *file) return res; } +gboolean +caja_is_in_desktop_dir (GFile *file) +{ + char *path; + char *dirname; + gboolean res = FALSE; + + if (!g_file_is_native (file)) + { + return res; + } + + path = g_file_get_path (file); + dirname = g_path_get_dirname (path); + if (g_strcmp0 (dirname, g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP)) == 0) + { + res = TRUE; + } + + g_free (path); + g_free (dirname); + + return res; +} + GHashTable * caja_trashed_files_get_original_directories (GList *files, GList **unhandled_files) diff --git a/libcaja-private/caja-file-utilities.h b/libcaja-private/caja-file-utilities.h index 2306601f..1a65fcb9 100644 --- a/libcaja-private/caja-file-utilities.h +++ b/libcaja-private/caja-file-utilities.h @@ -48,7 +48,8 @@ gboolean caja_is_home_directory (GFile *dir); gboolean caja_is_home_directory_file (GFile *dir, const char *filename); GMount * caja_get_mounted_mount_for_root (GFile *location); -gboolean caja_is_in_system_dir (GFile *location); +gboolean caja_is_in_desktop_dir (GFile *file); +gboolean caja_is_in_system_dir (GFile *file); char * caja_get_pixmap_directory (void); gboolean caja_should_use_templates_directory (void); -- cgit v1.2.1