Commit b980d2bf authored by Gene Z. Ragan's avatar Gene Z. Ragan Committed by Gene Ragan

reviewed by: Pavel Cisler <pavel@eazel.com>

2001-01-25  Gene Z. Ragan  <gzr@eazel.com>

	reviewed by: Pavel Cisler <pavel@eazel.com>

	Fixed bug 6002, programs run from Nautilus Link files leave zombie processes

	* libnautilus-extensions/nautilus-gnome-extensions.c:
	* libnautilus-extensions/nautilus-gnome-extensions.h:
	(nautilus_gnome_shell_execute):
	Rename function and make it available to outside callers

	(nautilus_gnome_open_terminal):
	Rename function calls to nautilus_gnome_shell_execute

	* src/file-manager/fm-directory-view.c: (activate_callback):
	Call nautilus_gnome_shell_execute instaed of calling forking
	and calling exec.  Using nautilus_gnome_shell_execute does the
	right thing and avoids creating zombie processes.
parent dcc3f043
2001-01-25 Gene Z. Ragan <gzr@eazel.com>
reviewed by: Pavel Cisler <pavel@eazel.com>
Fixed bug 6002, programs run from Nautilus Link files leave zombie processes
* libnautilus-extensions/nautilus-gnome-extensions.c:
* libnautilus-extensions/nautilus-gnome-extensions.h:
(nautilus_gnome_shell_execute):
Rename function and make it available to outside callers
(nautilus_gnome_open_terminal):
Rename function calls to nautilus_gnome_shell_execute
* src/file-manager/fm-directory-view.c: (activate_callback):
Call nautilus_gnome_shell_execute instaed of calling forking
and calling exec. Using nautilus_gnome_shell_execute does the
right thing and avoids creating zombie processes.
2001-01-25 John Harper <jsh@eazel.com> 2001-01-25 John Harper <jsh@eazel.com>
reviewed by: Pavel Cisler <pavel@eazel.com> reviewed by: Pavel Cisler <pavel@eazel.com>
......
...@@ -441,8 +441,8 @@ max_open_files (void) ...@@ -441,8 +441,8 @@ max_open_files (void)
return files; return files;
} }
static int int
nautilus_gnome_terminal_shell_execute (const char *command) nautilus_gnome_shell_execute (const char *command)
{ {
struct sigaction ignore, save_intr, save_quit, save_stop; struct sigaction ignore, save_intr, save_quit, save_stop;
int status, i; int status, i;
...@@ -562,18 +562,18 @@ nautilus_gnome_open_terminal (const char *command) ...@@ -562,18 +562,18 @@ nautilus_gnome_open_terminal (const char *command)
command_line = g_strconcat (terminal_path, " -e ", command, NULL); command_line = g_strconcat (terminal_path, " -e ", command, NULL);
} }
nautilus_gnome_terminal_shell_execute (command_line); nautilus_gnome_shell_execute (command_line);
g_free (command_line); g_free (command_line);
} else { } else {
if (using_gnome_terminal) { if (using_gnome_terminal) {
terminal_flags = " --login"; terminal_flags = " --login";
terminal_path_with_flags = g_strconcat (terminal_path, terminal_flags, NULL); terminal_path_with_flags = g_strconcat (terminal_path, terminal_flags, NULL);
nautilus_gnome_terminal_shell_execute (terminal_path_with_flags); nautilus_gnome_shell_execute (terminal_path_with_flags);
g_free (terminal_path_with_flags); g_free (terminal_path_with_flags);
} else { } else {
terminal_flags = " -ls"; terminal_flags = " -ls";
terminal_path_with_flags = g_strconcat (terminal_path, terminal_flags, NULL); terminal_path_with_flags = g_strconcat (terminal_path, terminal_flags, NULL);
nautilus_gnome_terminal_shell_execute (terminal_path_with_flags); nautilus_gnome_shell_execute (terminal_path_with_flags);
} }
} }
......
...@@ -116,4 +116,9 @@ void nautilus_gnome_open_terminal (const c ...@@ -116,4 +116,9 @@ void nautilus_gnome_open_terminal (const c
gboolean nautilus_gnome_stock_set_icon_or_register (GnomeStock *stock, gboolean nautilus_gnome_stock_set_icon_or_register (GnomeStock *stock,
const char *icon); const char *icon);
/* Execute a command. To be used in place of the exec family commands. This function
* protects against creating zombie processes.
*/
int nautilus_gnome_shell_execute (const char *command);
#endif /* NAUTILUS_GNOME_EXTENSIONS_H */ #endif /* NAUTILUS_GNOME_EXTENSIONS_H */
...@@ -441,8 +441,8 @@ max_open_files (void) ...@@ -441,8 +441,8 @@ max_open_files (void)
return files; return files;
} }
static int int
nautilus_gnome_terminal_shell_execute (const char *command) nautilus_gnome_shell_execute (const char *command)
{ {
struct sigaction ignore, save_intr, save_quit, save_stop; struct sigaction ignore, save_intr, save_quit, save_stop;
int status, i; int status, i;
...@@ -562,18 +562,18 @@ nautilus_gnome_open_terminal (const char *command) ...@@ -562,18 +562,18 @@ nautilus_gnome_open_terminal (const char *command)
command_line = g_strconcat (terminal_path, " -e ", command, NULL); command_line = g_strconcat (terminal_path, " -e ", command, NULL);
} }
nautilus_gnome_terminal_shell_execute (command_line); nautilus_gnome_shell_execute (command_line);
g_free (command_line); g_free (command_line);
} else { } else {
if (using_gnome_terminal) { if (using_gnome_terminal) {
terminal_flags = " --login"; terminal_flags = " --login";
terminal_path_with_flags = g_strconcat (terminal_path, terminal_flags, NULL); terminal_path_with_flags = g_strconcat (terminal_path, terminal_flags, NULL);
nautilus_gnome_terminal_shell_execute (terminal_path_with_flags); nautilus_gnome_shell_execute (terminal_path_with_flags);
g_free (terminal_path_with_flags); g_free (terminal_path_with_flags);
} else { } else {
terminal_flags = " -ls"; terminal_flags = " -ls";
terminal_path_with_flags = g_strconcat (terminal_path, terminal_flags, NULL); terminal_path_with_flags = g_strconcat (terminal_path, terminal_flags, NULL);
nautilus_gnome_terminal_shell_execute (terminal_path_with_flags); nautilus_gnome_shell_execute (terminal_path_with_flags);
} }
} }
......
...@@ -116,4 +116,9 @@ void nautilus_gnome_open_terminal (const c ...@@ -116,4 +116,9 @@ void nautilus_gnome_open_terminal (const c
gboolean nautilus_gnome_stock_set_icon_or_register (GnomeStock *stock, gboolean nautilus_gnome_stock_set_icon_or_register (GnomeStock *stock,
const char *icon); const char *icon);
/* Execute a command. To be used in place of the exec family commands. This function
* protects against creating zombie processes.
*/
int nautilus_gnome_shell_execute (const char *command);
#endif /* NAUTILUS_GNOME_EXTENSIONS_H */ #endif /* NAUTILUS_GNOME_EXTENSIONS_H */
...@@ -73,12 +73,15 @@ ...@@ -73,12 +73,15 @@
#include <math.h> #include <math.h>
#include <src/nautilus-application.h> #include <src/nautilus-application.h>
#define DISPLAY_TIMEOUT_INTERVAL_MSECS 500 #define DISPLAY_TIMEOUT_INTERVAL_MSECS 500
#define SILENT_WINDOW_OPEN_LIMIT 5 #define SILENT_WINDOW_OPEN_LIMIT 5
#define DUPLICATE_HORIZONTAL_ICON_OFFSET 70 #define DUPLICATE_HORIZONTAL_ICON_OFFSET 70
#define DUPLICATE_VERTICAL_ICON_OFFSET 30 #define DUPLICATE_VERTICAL_ICON_OFFSET 30
#define NAUTILUS_COMMAND_SPECIFIER "command:"
/* Paths to use when referring to bonobo menu items. */ /* Paths to use when referring to bonobo menu items. */
#define FM_DIRECTORY_VIEW_MENU_PATH_OPEN "/menu/File/Open Placeholder/Open" #define FM_DIRECTORY_VIEW_MENU_PATH_OPEN "/menu/File/Open Placeholder/Open"
#define FM_DIRECTORY_VIEW_MENU_PATH_OPEN_IN_NEW_WINDOW "/menu/File/Open Placeholder/OpenNew" #define FM_DIRECTORY_VIEW_MENU_PATH_OPEN_IN_NEW_WINDOW "/menu/File/Open Placeholder/OpenNew"
...@@ -3466,7 +3469,7 @@ activate_callback (NautilusFile *file, gpointer callback_data) ...@@ -3466,7 +3469,7 @@ activate_callback (NautilusFile *file, gpointer callback_data)
GnomeVFSMimeActionType action_type; GnomeVFSMimeActionType action_type;
GnomeVFSMimeApplication *application; GnomeVFSMimeApplication *application;
gboolean performed_special_handling; gboolean performed_special_handling;
parameters = callback_data; parameters = callback_data;
nautilus_timed_wait_stop (cancel_activate_callback, parameters); nautilus_timed_wait_stop (cancel_activate_callback, parameters);
...@@ -3484,7 +3487,7 @@ activate_callback (NautilusFile *file, gpointer callback_data) ...@@ -3484,7 +3487,7 @@ activate_callback (NautilusFile *file, gpointer callback_data)
if (nautilus_file_is_broken_symbolic_link (file)) { if (nautilus_file_is_broken_symbolic_link (file)) {
report_broken_symbolic_link (view, file); report_broken_symbolic_link (view, file);
performed_special_handling = TRUE; performed_special_handling = TRUE;
} else if (nautilus_istr_has_prefix (uri, "command:")) { } else if (nautilus_istr_has_prefix (uri, NAUTILUS_COMMAND_SPECIFIER)) {
/* don't allow command execution from remote uris to partially mitigate /* don't allow command execution from remote uris to partially mitigate
* the security risk of executing arbitrary commands. */ * the security risk of executing arbitrary commands. */
if (!nautilus_file_is_local (file)) { if (!nautilus_file_is_local (file)) {
...@@ -3495,10 +3498,9 @@ activate_callback (NautilusFile *file, gpointer callback_data) ...@@ -3495,10 +3498,9 @@ activate_callback (NautilusFile *file, gpointer callback_data)
/* as an additional security precaution, we only execute commands without /* as an additional security precaution, we only execute commands without
* any parameters, which is enforced by using fork/execlp instead of system * any parameters, which is enforced by using fork/execlp instead of system
*/ */
if (fork () == 0) { g_assert (strncmp (uri, NAUTILUS_COMMAND_SPECIFIER, sizeof (NAUTILUS_COMMAND_SPECIFIER) - 1) == 0);
command = uri + 8; command = uri + sizeof (NAUTILUS_COMMAND_SPECIFIER) - 1;
execlp (command, command, NULL); nautilus_gnome_shell_execute (command);
}
performed_special_handling = TRUE; performed_special_handling = TRUE;
} }
} else if (file_is_launchable (file)) { } else if (file_is_launchable (file)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment