summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhillip Berndt <phillip.berndt@gmail.com>2011-02-16 22:17:32 +0100
committerCosimo Cecchi <cosimoc@gnome.org>2011-09-07 16:01:10 -0400
commit8978c6375bbe0cd26fffded25bc4606cab2c88e6 (patch)
treef8be32766d3102f33103e4669f378d7f447a5cfd
parentd1bc9311392e243aa5c9af4b80a373b6dd69d741 (diff)
downloadnautilus-8978c6375bbe0cd26fffded25bc4606cab2c88e6.tar.gz
nautilus-autorun-software: Use /bin/sh for autorun.sh execution
If the autorun file is called autorun.sh it is clearly meant for execution through a sh processor. The benefit of using /bin/sh as the executable is that autorun will also work on FAT formatted media (which does not allow autorun.sh to have +x permission set) https://bugzilla.gnome.org/show_bug.cgi?id=642511
-rw-r--r--src/nautilus-autorun-software.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/nautilus-autorun-software.c b/src/nautilus-autorun-software.c
index 0687def22..50e53561e 100644
--- a/src/nautilus-autorun-software.c
+++ b/src/nautilus-autorun-software.c
@@ -99,8 +99,10 @@ autorun (GMount *mount)
char *error_string;
GFile *root;
GFile *program_to_spawn;
+ GFile *program_parameter_file;
char *path_to_spawn;
char *cwd_for_program;
+ char *program_parameter;
root = g_mount_get_root (mount);
@@ -113,13 +115,16 @@ autorun (GMount *mount)
program_to_spawn = NULL;
path_to_spawn = NULL;
+ program_parameter_file = NULL;
+ program_parameter = NULL;
if (_check_file (root, ".autorun", TRUE)) {
program_to_spawn = g_file_get_child (root, ".autorun");
} else if (_check_file (root, "autorun", TRUE)) {
program_to_spawn = g_file_get_child (root, "autorun");
} else if (_check_file (root, "autorun.sh", TRUE)) {
- program_to_spawn = g_file_get_child (root, "autorun.sh");
+ program_to_spawn = g_file_new_for_path ("/bin/sh");
+ program_parameter_file = g_file_get_child (root, "autorun.sh");
} else if (_check_file (root, "autorun.exe", TRUE)) {
/* TODO */
} else if (_check_file (root, "AUTORUN.EXE", TRUE)) {
@@ -133,13 +138,16 @@ autorun (GMount *mount)
if (program_to_spawn != NULL) {
path_to_spawn = g_file_get_path (program_to_spawn);
}
+ if (program_parameter_file != NULL) {
+ program_parameter = g_file_get_path (program_parameter_file);
+ }
cwd_for_program = g_file_get_path (root);
error_string = NULL;
if (path_to_spawn != NULL && cwd_for_program != NULL) {
if (chdir (cwd_for_program) == 0) {
- execl (path_to_spawn, path_to_spawn, NULL);
+ execl (path_to_spawn, path_to_spawn, program_parameter, NULL);
error_string = g_strdup_printf (_("Error starting autorun program: %s"), strerror (errno));
goto out;
}
@@ -152,11 +160,15 @@ out:
if (program_to_spawn != NULL) {
g_object_unref (program_to_spawn);
}
+ if(program_parameter_file != NULL) {
+ g_object_unref (program_parameter_file);
+ }
if (root != NULL) {
g_object_unref (root);
}
g_free (path_to_spawn);
g_free (cwd_for_program);
+ g_free (program_parameter);
if (error_string != NULL) {
GtkWidget *dialog;