12128N/A+ if (nautilus_lockdown_is_forbidden_file(directory, info)) {
9802N/A eel_preferences_add_callback (NAUTILUS_PREFERENCES_SHOW_BACKUP_FILES,
9802N/A filtering_changed_callback,
9802N/A+ nautilus_lockdown_notify_add(filtering_changed_callback, NULL) ;
9802N/A eel_preferences_add_callback (NAUTILUS_PREFERENCES_SHOW_TEXT_IN_ICONS,
9802N/A async_data_preference_changed_callback,
9802N/A return (show_hidden || (!nautilus_file_is_hidden_file (file) && !is_file_hidden (file))) &&
9802N/A- (show_backup || !nautilus_file_is_backup_file (file));
9802N/A+ (show_backup || !nautilus_file_is_backup_file (file) &&
9802N/A+ !nautilus_lockdown_is_forbidden_nautilus_file(file));
9802N/A /* Path for gnome-vfs preferences */
9802N/A void nautilus_global_preferences_init (void);
9802N/A char *nautilus_global_preferences_get_default_folder_viewer_preference_as_iid (void);
12337N/A+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
12337N/A+ * Copyright (C) 2004 Sun Microsystems, Inc.
12337N/A+ * This program is free software; you can redistribute it
and/or 12337N/A+ * modify it under the terms of the GNU General Public License as
12337N/A+ * published by the Free Software Foundation; either version 2 of the
12337N/A+ * License, or (at your option) any later version.
12337N/A+ * This program is distributed in the hope that it will be useful, but
12337N/A+ * WITHOUT ANY WARRANTY; without even the implied warranty of
12337N/A+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12337N/A+ * General Public License for more details.
12337N/A+ * You should have received a copy of the GNU General Public License
12337N/A+ * along with this program; if not, write to the Free Software
12337N/A+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
12337N/A+ * Matt Keenan <matt.keenan@sun.com>
12337N/A+ * Mark McLoughlin <mark@skynet.ie>
12337N/A+#ifndef __NAUTILUS_LOCKDOWN_H__
12337N/A+#define __NAUTILUS_LOCKDOWN_H__
12337N/A+void nautilus_lockdown_init (void);
12337N/A+void nautilus_lockdown_finalize (void);
12337N/A+void nautilus_lockdown_notify_add (GCallback callback_func,
12337N/A+void nautilus_lockdown_notify_remove (GCallback callback_func,
12337N/A+gboolean nautilus_lockdown_is_command_line_disabled(void) ;
12337N/A+gboolean nautilus_lockdown_is_app_launching_restricted(void) ;
12337N/A+char** nautilus_lockdown_get_allowed_apps(void) ;
12337N/A+gboolean nautilus_lockdown_is_forbidden_file(NautilusDirectory *directory,
12337N/A+gboolean nautilus_lockdown_is_forbidden_nautilus_file(NautilusFile *file) ;
12337N/A+gboolean nautilus_lockdown_is_forbidden_command(const char *command) ;
12337N/A+#endif /* __NAUTILUS_LOCKDOWN_H__ */
9802N/A+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
9802N/A+ * Copyright (C) 2004 Sun Microsystems, Inc.
9802N/A+ * This program is free software; you can redistribute it
and/or 9802N/A+ * modify it under the terms of the GNU General Public License as
9802N/A+ * published by the Free Software Foundation; either version 2 of the
9802N/A+ * License, or (at your option) any later version.
9802N/A+ * This program is distributed in the hope that it will be useful, but
9802N/A+ * WITHOUT ANY WARRANTY; without even the implied warranty of
9802N/A+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9802N/A+ * General Public License for more details.
9802N/A+ * You should have received a copy of the GNU General Public License
9802N/A+ * along with this program; if not, write to the Free Software
9802N/A+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
9802N/A+ * Matt Keenan <matt.keenan@sun.com>
9802N/A+ * Mark McLoughlin <mark@skynet.ie>
9802N/A+ guint disable_command_line : 1;
9802N/A+ guint restrict_application_launching : 1;
9802N/A+ guint listeners [N_LISTENERS];
9802N/A+const gchar *command_line_execs[] = {
9802N/A+#define NUMBER_COMMAND_LINE_EXECS 2
9802N/A+static NautilusLockdown nautilus_lockdown = { 0, };
9802N/A+nautilus_lockdown_invoke_closures (NautilusLockdown *lockdown)
9802N/A+ for (l = lockdown->closures; l; l = l->next)
9802N/A+ g_closure_invoke (l->data, NULL, 0, NULL, NULL);
9802N/A+disable_command_line_notify (NautilusLockdown *lockdown)
9802N/A+ lockdown->disable_command_line =
9802N/A+ eel_preferences_get_boolean(
9802N/A+ NAUTILUS_PREFERENCES_DISABLE_COMMANDLINE) ;
9802N/A+ nautilus_lockdown_invoke_closures (lockdown);
9802N/A+restrict_application_launching_notify (NautilusLockdown *lockdown)
9802N/A+ lockdown->restrict_application_launching =
9802N/A+ eel_preferences_get_boolean (
9802N/A+ NAUTILUS_PREFERENCES_RESTRICT_APP_LAUNCHING);
9802N/A+ nautilus_lockdown_invoke_closures (lockdown);
9802N/A+allowed_applications_notify (NautilusLockdown *lockdown)
12128N/A+ g_strfreev(lockdown->allowed_applications) ;
9802N/A+ lockdown->allowed_applications =
12128N/A+ eel_preferences_get_string_array(
9802N/A+ NAUTILUS_PREFERENCES_ALLOWED_APPLICATIONS) ;
9802N/A+ nautilus_lockdown_invoke_closures (lockdown);
9802N/A+nautilus_lockdown_load_bool (NautilusLockdown *lockdown,
9802N/A+ EelPreferencesCallback notify_func)
9802N/A+ gboolean retval = eel_preferences_get_boolean (key);
9802N/A+ eel_preferences_add_callback(key, notify_func, lockdown) ;
9802N/A+nautilus_lockdown_load_allowed_applications (NautilusLockdown *lockdown)
12128N/A+ retval = eel_preferences_get_string_array(
9802N/A+ NAUTILUS_PREFERENCES_ALLOWED_APPLICATIONS) ;
9802N/A+ eel_preferences_add_callback(NAUTILUS_PREFERENCES_ALLOWED_APPLICATIONS,
9802N/A+ allowed_applications_notify, lockdown) ;
9802N/A+nautilus_lockdown_init (void)
9802N/A+ nautilus_lockdown_load_bool (
9802N/A+ NAUTILUS_PREFERENCES_DISABLE_COMMANDLINE,
9802N/A+ disable_command_line_notify);
9802N/A+ nautilus_lockdown_load_bool (
9802N/A+ NAUTILUS_PREFERENCES_RESTRICT_APP_LAUNCHING,
9802N/A+ restrict_application_launching_notify) ;
9802N/A+ nautilus_lockdown_load_allowed_applications (
9802N/A+nautilus_lockdown_finalize (void)
9802N/A+ eel_preferences_remove_callback(
9802N/A+ NAUTILUS_PREFERENCES_DISABLE_COMMANDLINE,
9802N/A+ disable_command_line_notify,
9802N/A+ eel_preferences_remove_callback(
9802N/A+ NAUTILUS_PREFERENCES_RESTRICT_APP_LAUNCHING,
9802N/A+ restrict_application_launching_notify,
9802N/A+ eel_preferences_remove_callback(
9802N/A+ NAUTILUS_PREFERENCES_ALLOWED_APPLICATIONS,
9802N/A+ allowed_applications_notify,
9802N/A+ g_closure_unref (l->data);
9802N/A+nautilus_lockdown_is_command_line_disabled (void)
9802N/A+nautilus_lockdown_is_app_launching_restricted (void)
9802N/A+nautilus_lockdown_get_allowed_apps (void)
9802N/A+nautilus_lockdown_notify_find (GSList *closures,
9802N/A+ for (l = closures; l; l = l->next) {
9802N/A+ GCClosure *cclosure = l->data;
9802N/A+ GClosure *closure = l->data;
9802N/A+ if (closure->data == user_data &&
9802N/A+ cclosure->callback == callback_func)
9802N/A+marshal_user_data (GClosure *closure,
9802N/A+ const GValue *param_values,
9802N/A+ GCClosure *cclosure = (GCClosure*) closure;
9802N/A+ g_return_if_fail (cclosure->callback != NULL);
9802N/A+ g_return_if_fail (n_param_values == 0);
9802N/A+ ((void (*) (gpointer *))cclosure->callback) (closure->data);
9802N/A+nautilus_lockdown_notify_add (GCallback callback_func,
9802N/A+ closure = g_cclosure_new (callback_func, user_data, NULL);
9802N/A+ g_closure_set_marshal (closure, marshal_user_data);
9802N/A+nautilus_lockdown_notify_remove (GCallback callback_func,
9802N/A+ g_assert (closure != NULL);
9802N/A+ g_closure_unref (closure);
9802N/A+static gboolean nautilus_lockdown_is_forbidden_uri(const char *uri)
9802N/A+ GnomeDesktopItem *item = NULL ;
9802N/A+ const char *command = NULL ;
9802N/A+ gboolean ret_code = FALSE ;
9802N/A+ item = gnome_desktop_item_new_from_uri(uri, 0, &error) ;
9802N/A+ command = gnome_desktop_item_get_string(item, GNOME_DESKTOP_ITEM_EXEC) ;
9802N/A+ if (command == NULL) { return ret_code ; }
9802N/A+ return nautilus_lockdown_is_forbidden_command(command) ;
9802N/A+gboolean nautilus_lockdown_is_forbidden_file(NautilusDirectory *directory,
12337N/A+ const char *mime_type = g_file_info_get_content_type(file) ;
9802N/A+ (strcmp(mime_type, GNOME_APP_MIME) == 0 ||
9802N/A+ strcmp(mime_type, DESKTOP_MIME) == 0)) {
12337N/A+ return nautilus_lockdown_is_forbidden_command(
12337N/A+ nautilus_directory_get_file_uri(directory, g_file_info_get_name(file)));
9802N/A+gboolean nautilus_lockdown_is_forbidden_nautilus_file(NautilusFile *file)
9802N/A+ (nautilus_file_is_mime_type(file, GNOME_APP_MIME) ||
9802N/A+ nautilus_file_is_mime_type(file, DESKTOP_MIME))) {
9802N/A+ return nautilus_lockdown_is_forbidden_uri(nautilus_file_get_uri(file)) ;
9802N/A+gboolean nautilus_lockdown_is_forbidden_command(const char *command)
9802N/A+ char *commandCopy = NULL ;
9802N/A+ commandCopy = g_shell_unquote(command, NULL) ;
9802N/A+ if (commandCopy == NULL) { commandCopy = g_strdup(command) ; }
9802N/A+ strtok(commandCopy, " ") ;
9802N/A+ if (g_path_is_absolute(commandCopy)) {
9802N/A+ char *stripped = g_path_get_basename(commandCopy) ;
9802N/A+ program = g_find_program_in_path(stripped) ;
12337N/A+ if (!strcmp(allowed_app, program)) {
12128N/A eel_g_object_list_free (locations);
9802N/A+command_is_allowed (const char *full_command)
12128N/A+ gboolean allowed = !nautilus_lockdown_is_forbidden_command(full_command);
12128N/A+ (_("Sorry, This is a restricted application which "
12128N/A * nautilus_launch_application_from_command:
9802N/A full_command = g_strdup (command_string);
11869N/A+ if (!command_is_allowed (command_string)) {
9802N/A- eel_gnome_open_terminal_on_screen (full_command, screen);
11869N/A+ if (!nautilus_lockdown_is_command_line_disabled ()) {
11869N/A+ eel_gnome_open_terminal_on_screen (full_command, screen);
11869N/A+ (_("Sorry, this command requires a terminal "),
11869N/A+ _("Terminal access is restricted."),
12128N/A gdk_spawn_command_line_on_screen (screen, full_command, NULL);
9802N/A /* check if this app only supports local files */
9802N/A command_string = gnome_desktop_item_get_string (ditem, GNOME_DESKTOP_ITEM_EXEC);
10921N/A+ if (!command_is_allowed (command_string)) {
10921N/A if (command_string != NULL && (strstr (command_string, "%F") || strstr (command_string, "%f"))
9802N/A && !(strstr (command_string, "%U") || strstr (command_string, "%u"))
9802N/A && parameter_uris != NULL) {
9802N/A static void unschedule_display_of_pending_files (FMDirectoryView *view);
9802N/A static void disconnect_model_handlers (FMDirectoryView *view);
9802N/A static void filtering_changed_callback (gpointer callback_data);
9802N/A+static void lockdown_changed_callback(gpointer context) ;
9802N/A static void metadata_for_directory_as_file_ready_callback (NautilusFile *file,
9802N/A static void metadata_for_files_in_directory_ready_callback (NautilusDirectory *directory,
9802N/A filtering_changed_callback, view);
9802N/A eel_preferences_add_callback (NAUTILUS_PREFERENCES_SHOW_BACKUP_FILES,
9802N/A filtering_changed_callback, view);
9802N/A+ nautilus_lockdown_notify_add(lockdown_changed_callback, view) ;
9802N/A+ nautilus_lockdown_notify_remove(lockdown_changed_callback, view) ;
9802N/A eel_preferences_remove_callback (NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES,
9802N/A filtering_changed_callback,
9802N/A+static void lockdown_changed_callback(gpointer context)
9802N/A+ FMDirectoryView *directory_view = FM_DIRECTORY_VIEW(context) ;
9802N/A+ if (directory_view != NULL && directory_view->details->model != NULL) {
9802N/A+ load_directory(directory_view, directory_view->details->model) ;
9802N/A fm_directory_view_handle_text_drop (FMDirectoryView *view,
9802N/A schedule_monitoring_update (model);
9802N/A+void fm_tree_model_refresh_permissions(FMTreeModel *model)
9802N/A+ g_return_if_fail(FM_IS_TREE_MODEL(model)) ;
9802N/A+ destroy_by_function(model, nautilus_lockdown_is_forbidden_nautilus_file) ;
9802N/A+ schedule_monitoring_update(model) ;
9802N/A file_is_not_directory (NautilusFile *file)
9802N/A fm_tree_model_set_show_only_directories
9802N/A (view->details->child_model,
9802N/A eel_preferences_get_boolean (NAUTILUS_PREFERENCES_TREE_SHOW_ONLY_DIRECTORIES));
9802N/A+ fm_tree_model_refresh_permissions(view->details->child_model) ;
9802N/A filtering_changed_callback, view);
9802N/A eel_preferences_add_callback (NAUTILUS_PREFERENCES_SHOW_BACKUP_FILES,
9802N/A filtering_changed_callback, view);
9802N/A+ nautilus_lockdown_notify_add(filtering_changed_callback, view) ;
9802N/A eel_preferences_add_callback (NAUTILUS_PREFERENCES_TREE_SHOW_ONLY_DIRECTORIES,
9802N/A filtering_changed_callback, view);
9802N/A filtering_changed_callback, view);
9802N/A eel_preferences_remove_callback (NAUTILUS_PREFERENCES_SHOW_BACKUP_FILES,
9802N/A filtering_changed_callback, view);
9802N/A+ nautilus_lockdown_notify_remove(filtering_changed_callback, view) ;
9802N/A eel_preferences_remove_callback (NAUTILUS_PREFERENCES_TREE_SHOW_ONLY_DIRECTORIES,
9802N/A filtering_changed_callback, view);
9802N/A (NAUTILUS_PREFERENCES_DESKTOP_IS_HOME_DIR, TRUE);
9802N/A+ nautilus_lockdown_init() ;
9802N/A bonobo_activate (); /* do now since we need it before main loop */
12467N/A bonobo_object_unref (application);
12467N/A+ nautilus_lockdown_finalize ();
12467N/A /* If told to restart, exec() myself again. This is used when
11976N/A+load_extension_menus_idle(gpointer context)
11976N/A+ NautilusWindow *window = NAUTILUS_WINDOW(context);
11976N/A+ nautilus_window_load_extension_menus(window);
11976N/A+lockdown_changed_callback(gpointer context)
11976N/A+ NautilusWindow *window = NAUTILUS_WINDOW(context);
11976N/A+ g_idle_add(load_extension_menus_idle, window);
11976N/A nautilus_window_load_extension_menus (NautilusWindow *window)
11976N/A gtk_ui_manager_remove_ui (window->details->ui_manager,
11976N/A window->details->extensions_menu_merge_id);
11976N/A window->details->extensions_menu_merge_id = 0;
11976N/A+ nautilus_lockdown_notify_add(lockdown_changed_callback, window);
11976N/A if (window->details->extensions_menu_action_group != NULL) {