diff options
author | António Fernandes <antoniof@gnome.org> | 2022-12-24 18:59:16 +0000 |
---|---|---|
committer | António Fernandes <antoniof@gnome.org> | 2022-12-24 18:59:16 +0000 |
commit | a895fda83495c94a49f05ba9c37b7ca00fad0813 (patch) | |
tree | 219ff610aab418c3de5bea6c5b18ec41ec29981f | |
parent | 6885fb0163ca8f232e3230b39e5bbeabb3d2d5db (diff) | |
download | nautilus-a895fda83495c94a49f05ba9c37b7ca00fad0813.tar.gz |
autorun-software: Add error message for not executable
We currently state the program was not found, when in fact it was, but
could not be accepted as it was not executable.
So, provide an tailored error for that case.
Resolves https://gitlab.gnome.org/GNOME/nautilus/-/issues/2675
-rw-r--r-- | src/nautilus-autorun-software.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/nautilus-autorun-software.c b/src/nautilus-autorun-software.c index 6d8553f1d..61e012d9d 100644 --- a/src/nautilus-autorun-software.c +++ b/src/nautilus-autorun-software.c @@ -63,7 +63,7 @@ autorun_software_dialog_mount_unmounted (GMount *mount, static gboolean _check_file (GFile *mount_root, const char *file_path, - gboolean must_be_executable) + gboolean *executable) { g_autoptr (GFile) file = NULL; g_autoptr (GFileInfo) file_info = NULL; @@ -80,10 +80,9 @@ _check_file (GFile *mount_root, return FALSE; } - if (must_be_executable && - !g_file_info_get_attribute_boolean (file_info, G_FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE)) + if (executable != NULL) { - return FALSE; + *executable = g_file_info_get_attribute_boolean (file_info, G_FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE); } return TRUE; @@ -99,6 +98,7 @@ autorun (GMount *mount) g_autofree char *path_to_spawn = NULL; g_autofree char *cwd_for_program = NULL; g_autofree char *program_parameter = NULL; + gboolean executable = TRUE; root = g_mount_get_root (mount); @@ -109,15 +109,15 @@ autorun (GMount *mount) * the ordering does matter. */ - if (_check_file (root, ".autorun", TRUE)) + if (_check_file (root, ".autorun", &executable) && executable) { program_to_spawn = g_file_get_child (root, ".autorun"); } - else if (_check_file (root, "autorun", TRUE)) + else if (_check_file (root, "autorun", &executable) && executable) { program_to_spawn = g_file_get_child (root, "autorun"); } - else if (_check_file (root, "autorun.sh", FALSE)) + else if (_check_file (root, "autorun.sh", NULL)) { program_to_spawn = g_file_new_for_path ("/bin/sh"); program_parameter_file = g_file_get_child (root, "autorun.sh"); @@ -145,6 +145,11 @@ autorun (GMount *mount) error_string = g_strdup_printf (_("Unable to start the program:\n%s"), strerror (errno)); goto out; } + else if (!executable) + { + error_string = g_strdup (_("The program is not marked as executable.")); + goto out; + } error_string = g_strdup_printf (_("Unable to locate the program")); out: |