nautilus-07-lockdown.diff revision 12128
9802N/A--- /usr/tmp/clean/nautilus-2.21.1/libnautilus-private/Makefile.am 2007-12-10 13:22:01.000000000 +0000
9802N/A+++ nautilus-2.21.1/libnautilus-private/Makefile.am 2008-01-04 10:06:52.296379000 +0000
9802N/A@@ -125,6 +125,8 @@
9802N/A nautilus-lib-self-check-functions.h \
9802N/A nautilus-link.c \
9802N/A nautilus-link.h \
9802N/A+ nautilus-lockdown.c \
9802N/A+ nautilus-lockdown.h \
9802N/A nautilus-marshal.c \
9802N/A nautilus-marshal.h \
9802N/A nautilus-merged-directory.c \
9802N/A--- /usr/tmp/clean/nautilus-2.21.1/libnautilus-private/nautilus-directory-async.c 2007-12-20 13:22:58.000000000 +0000
9802N/A+++ nautilus-2.21.1/libnautilus-private/nautilus-directory-async.c 2008-01-04 10:14:16.919383000 +0000
9802N/A@@ -33,6 +33,7 @@
9802N/A #include "nautilus-signaller.h"
9802N/A #include "nautilus-global-preferences.h"
9802N/A #include "nautilus-link.h"
9802N/A+#include "nautilus-lockdown.h"
9802N/A #include "nautilus-marshal.h"
9802N/A #include "nautilus-metafile.h"
9802N/A #include <eel/eel-glib-extensions.h>
9802N/A@@ -781,6 +782,10 @@
9802N/A return TRUE;
9802N/A }
9802N/A
9802N/A+ if (nautilus_lockdown_is_forbidden_file(directory, info)) {
9802N/A+ return TRUE;
9802N/A+ }
9802N/A+
9802N/A return FALSE;
9802N/A }
9802N/A
9802N/Adiff -urN -x '*~' naut.orig/libnautilus-private/nautilus-directory.c naut.new/libnautilus-private/nautilus-directory.c
9802N/A--- naut.orig/libnautilus-private/nautilus-directory.c 2007-01-23 12:14:22.112062000 +0000
9802N/A+++ naut.new/libnautilus-private/nautilus-directory.c 2007-01-23 12:15:48.504527000 +0000
9802N/A@@ -310,6 +310,7 @@
9802N/A eel_preferences_add_callback (NAUTILUS_PREFERENCES_SHOW_BACKUP_FILES,
9802N/A filtering_changed_callback,
9802N/A NULL);
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 NULL);
9802N/Adiff -urN -x '*~' naut.orig/libnautilus-private/nautilus-file.c naut.new/libnautilus-private/nautilus-file.c
9802N/A--- naut.orig/libnautilus-private/nautilus-file.c 2007-01-23 12:14:22.111021000 +0000
9802N/A+++ naut.new/libnautilus-private/nautilus-file.c 2007-01-23 12:15:48.511205000 +0000
9802N/A@@ -48,6 +48,7 @@
9802N/A #include "nautilus-users-groups-cache.h"
9802N/A #include "nautilus-vfs-file.h"
9802N/A #include "nautilus-saved-search-file.h"
9802N/A+#include "nautilus-lockdown.h"
9802N/A #include <eel/eel-debug.h>
9802N/A #include <eel/eel-glib-extensions.h>
9802N/A #include <eel/eel-gtk-extensions.h>
9802N/A@@ -2348,7 +2349,8 @@
9802N/A gboolean show_backup)
9802N/A {
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
9802N/A }
9802N/A
9802N/Adiff -urN -x '*~' naut.orig/libnautilus-private/nautilus-global-preferences.c naut.new/libnautilus-private/nautilus-global-preferences.c
9802N/A--- naut.orig/libnautilus-private/nautilus-global-preferences.c 2007-01-23 12:14:21.403884000 +0000
9802N/A+++ naut.new/libnautilus-private/nautilus-global-preferences.c 2007-01-23 12:15:48.513608000 +0000
9802N/A@@ -46,6 +46,7 @@
9802N/A /* Path for gnome-vfs preferences */
9802N/A static const char *EXTRA_MONITOR_PATHS[] = { "/system/gnome_vfs",
9802N/A "/desktop/gnome/file_views",
9802N/A+ "/desktop/gnome/lockdown",
9802N/A NULL };
9802N/A
9802N/A /* Forward declarations */
9802N/Adiff -urN -x '*~' naut.orig/libnautilus-private/nautilus-global-preferences.h naut.new/libnautilus-private/nautilus-global-preferences.h
9802N/A--- naut.orig/libnautilus-private/nautilus-global-preferences.h 2007-01-23 12:14:22.123798000 +0000
9802N/A+++ naut.new/libnautilus-private/nautilus-global-preferences.h 2007-01-23 12:15:48.514623000 +0000
9802N/A@@ -190,6 +190,10 @@
9802N/A #define NAUTILUS_PREFERENCES_DESKTOP_NETWORK_NAME "desktop/network_icon_name"
9802N/A #define NAUTILUS_PREFERENCES_DESKTOP_PRIMARY_SCREEN "desktop/primary_screen"
9802N/A
9802N/A+#define NAUTILUS_PREFERENCES_DISABLE_COMMANDLINE "/desktop/gnome/lockdown/disable_command_line"
9802N/A+#define NAUTILUS_PREFERENCES_RESTRICT_APP_LAUNCHING "/desktop/gnome/lockdown/restrict_application_launching"
9802N/A+#define NAUTILUS_PREFERENCES_ALLOWED_APPLICATIONS "/desktop/gnome/lockdown/allowed_applications"
9802N/A+
9802N/A void nautilus_global_preferences_init (void);
9802N/A char *nautilus_global_preferences_get_default_folder_viewer_preference_as_iid (void);
9802N/A G_END_DECLS
9802N/A--- /tmp/null 1970-01-01 01:00:00.000000000 +0100
9802N/A+++ nautilus-2.21.1/libnautilus-private/nautilus-lockdown.c 2008-01-04 12:53:48.884023000 +0000
9802N/A@@ -0,0 +1,332 @@
9802N/A+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
9802N/A+/*
9802N/A+ * Copyright (C) 2004 Sun Microsystems, Inc.
9802N/A+ *
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+ *
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+ *
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+ * 02111-1307, USA.
9802N/A+ *
9802N/A+ * Authors:
9802N/A+ * Matt Keenan <matt.keenan@sun.com>
9802N/A+ * Mark McLoughlin <mark@skynet.ie>
9802N/A+ */
9802N/A+
9802N/A+#include <config.h>
9802N/A+
9802N/A+#include "nautilus-lockdown.h"
9802N/A+#include "nautilus-global-preferences.h"
9802N/A+#include "nautilus-program-choosing.h"
9802N/A+#include <eel/eel-preferences.h>
9802N/A+#include <eel/eel-string.h>
9802N/A+#include <libgnome/gnome-desktop-item.h>
9802N/A+
9802N/A+#include <string.h>
9802N/A+
9802N/A+#define N_LISTENERS 3
9802N/A+
9802N/A+typedef struct {
9802N/A+ guint initialized : 1;
9802N/A+ guint disable_command_line : 1;
9802N/A+ guint restrict_application_launching : 1;
9802N/A+
9802N/A+ char** allowed_applications;
9802N/A+
9802N/A+ guint listeners [N_LISTENERS];
9802N/A+
9802N/A+ GSList *closures;
9802N/A+} NautilusLockdown ;
9802N/A+
9802N/A+const gchar *command_line_execs[] = {
9802N/A+ "/usr/bin/gnome-terminal",
9802N/A+ "/usr/bin/xterm",
9802N/A+};
9802N/A+#define NUMBER_COMMAND_LINE_EXECS 2
9802N/A+
9802N/A+static NautilusLockdown nautilus_lockdown = { 0, };
9802N/A+
9802N/A+
9802N/A+static inline void
9802N/A+nautilus_lockdown_invoke_closures (NautilusLockdown *lockdown)
9802N/A+{
9802N/A+ GSList *l;
9802N/A+
9802N/A+ for (l = lockdown->closures; l; l = l->next)
9802N/A+ g_closure_invoke (l->data, NULL, 0, NULL, NULL);
9802N/A+}
9802N/A+
9802N/A+static void
9802N/A+disable_command_line_notify (NautilusLockdown *lockdown)
9802N/A+{
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+}
9802N/A+
9802N/A+static void
9802N/A+restrict_application_launching_notify (NautilusLockdown *lockdown)
9802N/A+{
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+}
9802N/A+
9802N/A+static void
9802N/A+allowed_applications_notify (NautilusLockdown *lockdown)
9802N/A+{
9802N/A+ g_strfreev(lockdown->allowed_applications) ;
9802N/A+ lockdown->allowed_applications =
9802N/A+ eel_preferences_get_string_array(
9802N/A+ NAUTILUS_PREFERENCES_ALLOWED_APPLICATIONS) ;
9802N/A+ nautilus_lockdown_invoke_closures (lockdown);
9802N/A+}
9802N/A+
9802N/A+static gboolean
9802N/A+nautilus_lockdown_load_bool (NautilusLockdown *lockdown,
9802N/A+ const char *key,
9802N/A+ EelPreferencesCallback notify_func)
9802N/A+{
9802N/A+ gboolean retval = eel_preferences_get_boolean (key);
9802N/A+
9802N/A+ eel_preferences_add_callback(key, notify_func, lockdown) ;
9802N/A+ return retval;
9802N/A+}
9802N/A+
9802N/A+static char**
9802N/A+nautilus_lockdown_load_allowed_applications (NautilusLockdown *lockdown)
9802N/A+{
9802N/A+ char **retval;
9802N/A+
9802N/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+ return retval;
9802N/A+}
9802N/A+
9802N/A+void
9802N/A+nautilus_lockdown_init (void)
9802N/A+{
9802N/A+ nautilus_lockdown.disable_command_line =
9802N/A+ nautilus_lockdown_load_bool (
9802N/A+ &nautilus_lockdown,
9802N/A+ NAUTILUS_PREFERENCES_DISABLE_COMMANDLINE,
9802N/A+ disable_command_line_notify);
9802N/A+ nautilus_lockdown.restrict_application_launching =
9802N/A+ nautilus_lockdown_load_bool (
9802N/A+ &nautilus_lockdown,
9802N/A+ NAUTILUS_PREFERENCES_RESTRICT_APP_LAUNCHING,
9802N/A+ restrict_application_launching_notify) ;
9802N/A+ nautilus_lockdown.allowed_applications =
9802N/A+ nautilus_lockdown_load_allowed_applications (
9802N/A+ &nautilus_lockdown) ;
9802N/A+ nautilus_lockdown.initialized = TRUE;
9802N/A+}
9802N/A+
9802N/A+void
9802N/A+nautilus_lockdown_finalize (void)
9802N/A+{
9802N/A+ GSList *l = NULL ;
9802N/A+
9802N/A+ g_assert (nautilus_lockdown.initialized == TRUE);
9802N/A+ eel_preferences_remove_callback(
9802N/A+ NAUTILUS_PREFERENCES_DISABLE_COMMANDLINE,
9802N/A+ disable_command_line_notify,
9802N/A+ &nautilus_lockdown) ;
9802N/A+ eel_preferences_remove_callback(
9802N/A+ NAUTILUS_PREFERENCES_RESTRICT_APP_LAUNCHING,
9802N/A+ restrict_application_launching_notify,
9802N/A+ &nautilus_lockdown) ;
9802N/A+ eel_preferences_remove_callback(
9802N/A+ NAUTILUS_PREFERENCES_ALLOWED_APPLICATIONS,
9802N/A+ allowed_applications_notify,
9802N/A+ &nautilus_lockdown) ;
9802N/A+ g_strfreev(nautilus_lockdown.allowed_applications) ;
9802N/A+ for (l = nautilus_lockdown.closures; l; l = l->next) {
9802N/A+ g_closure_unref (l->data);
9802N/A+ }
9802N/A+ g_slist_free (nautilus_lockdown.closures);
9802N/A+ nautilus_lockdown.closures = NULL;
9802N/A+ nautilus_lockdown.initialized = FALSE;
9802N/A+}
9802N/A+
9802N/A+gboolean
9802N/A+nautilus_lockdown_is_command_line_disabled (void)
9802N/A+{
9802N/A+ g_assert (nautilus_lockdown.initialized == TRUE);
9802N/A+ return nautilus_lockdown.disable_command_line;
9802N/A+}
9802N/A+
9802N/A+gboolean
9802N/A+nautilus_lockdown_is_app_launching_restricted (void)
9802N/A+{
9802N/A+ g_assert (nautilus_lockdown.initialized == TRUE);
9802N/A+ return nautilus_lockdown.restrict_application_launching;
9802N/A+}
9802N/A+
9802N/A+char**
9802N/A+nautilus_lockdown_get_allowed_apps (void)
9802N/A+{
9802N/A+ g_assert (nautilus_lockdown.initialized == TRUE);
9802N/A+ return nautilus_lockdown.allowed_applications;
9802N/A+}
9802N/A+
9802N/A+static GClosure *
9802N/A+nautilus_lockdown_notify_find (GSList *closures,
9802N/A+ GCallback callback_func,
9802N/A+ gpointer user_data)
9802N/A+{
9802N/A+ GSList *l;
9802N/A+
9802N/A+ for (l = closures; l; l = l->next) {
9802N/A+ GCClosure *cclosure = l->data;
9802N/A+ GClosure *closure = l->data;
9802N/A+
9802N/A+ if (closure->data == user_data &&
9802N/A+ cclosure->callback == callback_func)
9802N/A+ return closure;
9802N/A+ }
9802N/A+
9802N/A+ return NULL;
9802N/A+}
9802N/A+
9802N/A+static void
9802N/A+marshal_user_data (GClosure *closure,
9802N/A+ GValue *return_value,
9802N/A+ guint n_param_values,
9802N/A+ const GValue *param_values,
9802N/A+ gpointer invocation_hint,
9802N/A+ gpointer marshal_data)
9802N/A+{
9802N/A+ GCClosure *cclosure = (GCClosure*) closure;
9802N/A+
9802N/A+ g_return_if_fail (cclosure->callback != NULL);
9802N/A+ g_return_if_fail (n_param_values == 0);
9802N/A+
9802N/A+ ((void (*) (gpointer *))cclosure->callback) (closure->data);
9802N/A+}
9802N/A+
9802N/A+void
9802N/A+nautilus_lockdown_notify_add (GCallback callback_func,
9802N/A+ gpointer user_data)
9802N/A+{
9802N/A+ GClosure *closure;
9802N/A+
9802N/A+ g_assert (nautilus_lockdown_notify_find (nautilus_lockdown.closures,
9802N/A+ callback_func,
9802N/A+ user_data) == NULL);
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.closures = g_slist_append (nautilus_lockdown.closures,
9802N/A+ closure);
9802N/A+}
9802N/A+
9802N/A+void
9802N/A+nautilus_lockdown_notify_remove (GCallback callback_func,
9802N/A+ gpointer user_data)
9802N/A+{
9802N/A+ GClosure *closure;
9802N/A+
9802N/A+ closure = nautilus_lockdown_notify_find (nautilus_lockdown.closures,
9802N/A+ callback_func,
9802N/A+ user_data);
9802N/A+ g_assert (closure != NULL);
9802N/A+ nautilus_lockdown.closures = g_slist_remove (nautilus_lockdown.closures,
9802N/A+ closure);
9802N/A+ g_closure_unref (closure);
9802N/A+}
9802N/A+
9802N/A+static gboolean nautilus_lockdown_is_forbidden_uri(const char *uri)
9802N/A+{
9802N/A+ GnomeDesktopItem *item = NULL ;
9802N/A+ GError *error = NULL ;
9802N/A+ const char *command = NULL ;
9802N/A+ gboolean ret_code = FALSE ;
9802N/A+
9802N/A+ if (eel_str_has_prefix(uri, NAUTILUS_DESKTOP_COMMAND_SPECIFIER)) {
9802N/A+ uri += strlen(NAUTILUS_DESKTOP_COMMAND_SPECIFIER) ;
9802N/A+ }
9802N/A+ item = gnome_desktop_item_new_from_uri(uri, 0, &error) ;
9802N/A+ if (error != NULL) {
9802N/A+ g_error_free(error) ;
9802N/A+ return ret_code ;
9802N/A+ }
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+}
9802N/A+
9802N/A+static const char *GNOME_APP_MIME = "application/x-gnome-app-info" ;
9802N/A+static const char *DESKTOP_MIME = "application/x-desktop" ;
9802N/A+
9802N/A+gboolean nautilus_lockdown_is_forbidden_file(NautilusDirectory *directory,
9802N/A+ GnomeVFSFileInfo *file)
9802N/A+{
9802N/A+ const char *mime_type = gnome_vfs_file_info_get_mime_type(file) ;
9802N/A+
9802N/A+ if (nautilus_lockdown.restrict_application_launching &&
9802N/A+ mime_type != NULL &&
9802N/A+ (strcmp(mime_type, GNOME_APP_MIME) == 0 ||
9802N/A+ strcmp(mime_type, DESKTOP_MIME) == 0)) {
9802N/A+ return nautilus_lockdown_is_forbidden_uri(
9802N/A+ nautilus_directory_get_file_uri(directory, file->name)) ;
9802N/A+ }
9802N/A+ return FALSE ;
9802N/A+}
9802N/A+
9802N/A+gboolean nautilus_lockdown_is_forbidden_nautilus_file(NautilusFile *file)
9802N/A+{
9802N/A+ if (nautilus_lockdown.restrict_application_launching &&
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+ }
9802N/A+ return FALSE ;
9802N/A+}
9802N/A+
9802N/A+gboolean nautilus_lockdown_is_forbidden_command(const char *command)
9802N/A+{
9802N/A+ char *commandCopy = NULL ;
9802N/A+ char *program = NULL ;
9802N/A+ char *allowed_app;
9802N/A+ gboolean retCode = TRUE ;
9802N/A+
9802N/A+ if (!nautilus_lockdown.restrict_application_launching) { return retCode ; }
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+ program = commandCopy ;
9802N/A+ }
9802N/A+ else {
9802N/A+ char *stripped = g_path_get_basename(commandCopy) ;
9802N/A+
9802N/A+ program = g_find_program_in_path(stripped) ;
9802N/A+ g_free(stripped) ;
9802N/A+ g_free(commandCopy) ;
9802N/A+ }
9802N/A+ if (program != NULL) {
9802N/A+ allowed_app = *nautilus_lockdown.allowed_applications;
9802N/A+ while (allowed_app != NULL) {
9802N/A+ if (strcmp(allowed_app, program)) {
9802N/A+ retCode = FALSE;
9802N/A+ break;
9802N/A+ }
9802N/A+ }
9802N/A+ g_free(program) ;
9802N/A+ }
9802N/A+ return retCode ;
9802N/A+}
9802N/A+
9802N/A--- /tmp/null 1970-01-01 01:00:00.000000000 +0100
9802N/A+++ nautilus-2.21.1/libnautilus-private/nautilus-lockdown.h 2008-01-04 11:52:09.767908000 +0000
9802N/A@@ -0,0 +1,54 @@
9802N/A+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
9802N/A+/*
9802N/A+ * Copyright (C) 2004 Sun Microsystems, Inc.
9802N/A+ *
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+ *
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+ *
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+ * 02111-1307, USA.
9802N/A+ *
9802N/A+ * Authors:
9802N/A+ * Matt Keenan <matt.keenan@sun.com>
9802N/A+ * Mark McLoughlin <mark@skynet.ie>
9802N/A+ */
9802N/A+
9802N/A+#ifndef __NAUTILUS_LOCKDOWN_H__
9802N/A+#define __NAUTILUS_LOCKDOWN_H__
9802N/A+
9802N/A+#include <libgnomevfs/gnome-vfs.h>
9802N/A+#include <glib.h>
9802N/A+#include <glib-object.h>
9802N/A+#include "nautilus-directory.h"
9802N/A+
9802N/A+G_BEGIN_DECLS
9802N/A+
9802N/A+void nautilus_lockdown_init (void);
9802N/A+void nautilus_lockdown_finalize (void);
9802N/A+
9802N/A+void nautilus_lockdown_notify_add (GCallback callback_func,
9802N/A+ gpointer user_data);
9802N/A+void nautilus_lockdown_notify_remove (GCallback callback_func,
9802N/A+ gpointer user_data);
9802N/A+
9802N/A+gboolean nautilus_lockdown_is_command_line_disabled(void) ;
9802N/A+gboolean nautilus_lockdown_is_app_launching_restricted(void) ;
9802N/A+char** nautilus_lockdown_get_allowed_apps(void) ;
9802N/A+
9802N/A+gboolean nautilus_lockdown_is_forbidden_file(NautilusDirectory *directory,
9802N/A+ GnomeVFSFileInfo *file) ;
9802N/A+gboolean nautilus_lockdown_is_forbidden_nautilus_file(NautilusFile *file) ;
9802N/A+gboolean nautilus_lockdown_is_forbidden_command(const char *command) ;
9802N/A+
9802N/A+G_END_DECLS
10017N/A+
9802N/A+#endif /* __NAUTILUS_LOCKDOWN_H__ */
9802N/A--- /usr/tmp/clean/nautilus-2.21.1/libnautilus-private/nautilus-program-choosing.c 2007-12-14 10:24:07.000000000 +0000
9802N/A+++ nautilus-2.21.1/libnautilus-private/nautilus-program-choosing.c 2008-01-04 10:39:03.297183000 +0000
9802N/A@@ -324,6 +324,22 @@
9802N/A eel_g_object_list_free (locations);
9802N/A }
9802N/A
9802N/A+static gboolean
9802N/A+command_is_allowed (const char *full_command)
9802N/A+{
9802N/A+ gboolean allowed = !nautilus_lockdown_is_forbidden_command(full_command);
10017N/A+ if (!allowed) {
9802N/A+ eel_show_error_dialog
10017N/A+ /* SUN_BRANDING */
10017N/A+ (_("Sorry, This is a restricted application which "
10017N/A+ "you may not run."),
9802N/A+ /* SUN_BRANDING */
9802N/A+ _("Restricted Application"),
9802N/A+ NULL);
9802N/A+ }
9802N/A+ return allowed;
9802N/A+}
9802N/A+
9802N/A /**
9802N/A * nautilus_launch_application_from_command:
10017N/A *
9802N/A@@ -352,8 +368,22 @@
9802N/A full_command = g_strdup (command_string);
9802N/A }
9802N/A
9802N/A+ if (!command_is_allowed (command_string)) {
9802N/A+ g_free (full_command);
9802N/A+ return;
9802N/A+ }
9802N/A+
9802N/A if (use_terminal) {
10017N/A- eel_gnome_open_terminal_on_screen (full_command, screen);
9802N/A+ if (!nautilus_lockdown_is_command_line_disabled ()) {
9802N/A+ eel_gnome_open_terminal_on_screen (full_command, screen);
9802N/A+ } else {
9802N/A+ eel_show_error_dialog
9802N/A+ /* SUN_BRANDING */
9802N/A+ (_("Sorry, this command requires a terminal "),
9802N/A+ /* SUN_BRANDING */
9802N/A+ _("Terminal access is restricted."),
9802N/A+ NULL);
9802N/A+ }
9802N/A } else {
9802N/A gdk_spawn_command_line_on_screen (screen, full_command, NULL);
9802N/A }
9802N/A@@ -429,6 +459,11 @@
10017N/A
9802N/A /* check if this app only supports local files */
10017N/A command_string = gnome_desktop_item_get_string (ditem, GNOME_DESKTOP_ITEM_EXEC);
9802N/A+
9802N/A+ if (!command_is_allowed (command_string)) {
9802N/A+ return;
9802N/A+ }
9802N/A+
9802N/A if (command_string != NULL && (strstr (command_string, "%F") || strstr (command_string, "%f"))
9802N/A && !(strstr (command_string, "%U") || strstr (command_string, "%u"))
10017N/A && parameter_uris != NULL) {
9802N/Adiff -urN -x '*~' naut.orig/src/file-manager/fm-directory-view.c naut.new/src/file-manager/fm-directory-view.c
9802N/A--- naut.orig/src/file-manager/fm-directory-view.c 2007-01-23 12:14:22.597209000 +0000
9802N/A+++ naut.new/src/file-manager/fm-directory-view.c 2007-01-23 12:15:48.534029000 +0000
9802N/A@@ -366,6 +366,7 @@
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 gpointer callback_data);
9802N/A static void metadata_for_files_in_directory_ready_callback (NautilusDirectory *directory,
9802N/A@@ -1982,6 +1983,7 @@
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 }
9802N/A
9802N/A static void
9802N/A@@ -9499,6 +9501,7 @@
9802N/A return;
9802N/A }
9802N/A
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 view);
9802N/A@@ -9992,6 +9995,15 @@
9802N/A g_free (container_uri);
9802N/A }
9802N/A
9802N/A+static void lockdown_changed_callback(gpointer context)
9802N/A+{
9802N/A+ FMDirectoryView *directory_view = FM_DIRECTORY_VIEW(context) ;
9802N/A+
9802N/A+ if (directory_view != NULL && directory_view->details->model != NULL) {
9802N/A+ load_directory(directory_view, directory_view->details->model) ;
9802N/A+ }
9802N/A+}
9802N/A+
9802N/A void
9802N/A fm_directory_view_handle_text_drop (FMDirectoryView *view,
9802N/A const char *text,
9802N/Adiff -urN -x '*~' naut.orig/src/file-manager/fm-tree-model.c naut.new/src/file-manager/fm-tree-model.c
9802N/A--- naut.orig/src/file-manager/fm-tree-model.c 2007-01-23 12:14:22.594599000 +0000
9802N/A+++ naut.new/src/file-manager/fm-tree-model.c 2007-01-23 12:15:48.536375000 +0000
9802N/A@@ -38,6 +38,8 @@
9802N/A #include <gtk/gtkenums.h>
9802N/A #include <string.h>
9802N/A
9802N/A+#include <libnautilus-private/nautilus-lockdown.h>
9802N/A+
9802N/A enum {
9802N/A ROW_LOADED,
9802N/A LAST_SIGNAL
9802N/A@@ -1725,6 +1727,14 @@
9802N/A schedule_monitoring_update (model);
9802N/A }
9802N/A
9802N/A+void fm_tree_model_refresh_permissions(FMTreeModel *model)
9802N/A+{
9802N/A+ g_return_if_fail(FM_IS_TREE_MODEL(model)) ;
9802N/A+ stop_monitoring(model) ;
9802N/A+ destroy_by_function(model, nautilus_lockdown_is_forbidden_nautilus_file) ;
9802N/A+ schedule_monitoring_update(model) ;
9802N/A+}
9802N/A+
9802N/A static gboolean
9802N/A file_is_not_directory (NautilusFile *file)
9802N/A {
9802N/Adiff -urN -x '*~' naut.orig/src/file-manager/fm-tree-view.c naut.new/src/file-manager/fm-tree-view.c
9802N/A--- naut.orig/src/file-manager/fm-tree-view.c 2007-01-23 12:14:22.602086000 +0000
9802N/A+++ naut.new/src/file-manager/fm-tree-view.c 2007-01-23 12:15:48.538554000 +0000
9802N/A@@ -1499,6 +1499,7 @@
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 }
9802N/A
9802N/A static void
9802N/A@@ -1554,6 +1555,7 @@
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
9802N/A@@ -1600,6 +1602,7 @@
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
9802N/A--- /usr/tmp/clean/nautilus-2.21.1/src/nautilus-main.c 2007-12-17 11:14:03.000000000 +0000
9802N/A+++ nautilus-2.21.1/src/nautilus-main.c 2008-01-04 11:23:35.463968000 +0000
9802N/A@@ -53,6 +53,7 @@
9802N/A #include <libnautilus-private/nautilus-debug-log.h>
9802N/A #include <libnautilus-private/nautilus-directory-metafile.h>
9802N/A #include <libnautilus-private/nautilus-global-preferences.h>
9802N/A+#include <libnautilus-private/nautilus-lockdown.h>
9802N/A #include <libnautilus-private/nautilus-lib-self-check-functions.h>
9802N/A #include <libxml/parser.h>
9802N/A #ifdef HAVE_LOCALE_H
9802N/A@@ -526,6 +527,7 @@
9802N/A (NAUTILUS_PREFERENCES_DESKTOP_IS_HOME_DIR, TRUE);
9802N/A }
9802N/A
9802N/A+ nautilus_lockdown_init() ;
9802N/A bonobo_activate (); /* do now since we need it before main loop */
9802N/A
9802N/A application = NULL;
9802N/A@@ -564,6 +566,8 @@
9802N/A gtk_main ();
9802N/A }
9802N/A
9802N/A+ nautilus_lockdown_finalize ();
9802N/A+
9802N/A eel_debug_shut_down ();
9802N/A
9802N/A if (application != NULL) {
9802N/A--- /usr/tmp/clean/nautilus-2.21.1/src/nautilus-window-menus.c 2007-12-14 10:23:00.000000000 +0000
9802N/A+++ nautilus-2.21.1/src/nautilus-window-menus.c 2008-01-04 11:29:00.728638000 +0000
9802N/A@@ -51,6 +51,7 @@
9897N/A #include <libnautilus-extension/nautilus-menu-provider.h>
9897N/A #include <libnautilus-private/nautilus-file-utilities.h>
9897N/A #include <libnautilus-private/nautilus-ui-utilities.h>
9802N/A+#include <libnautilus-private/nautilus-lockdown.h>
9897N/A #include <libnautilus-private/nautilus-module.h>
9897N/A #include <libnautilus-private/nautilus-undo-manager.h>
9802N/A #include <libnautilus-private/nautilus-search-directory.h>
9802N/A@@ -779,6 +780,22 @@
9802N/A return items;
}
+static gboolean
+load_extension_menus_idle(gpointer context)
+{
+ NautilusWindow *window = NAUTILUS_WINDOW(context);
+
+ nautilus_window_load_extension_menus(window);
+ return FALSE;
+}
+
+static void
+lockdown_changed_callback(gpointer context)
+{
+ NautilusWindow *window = NAUTILUS_WINDOW(context);
+ g_idle_add(load_extension_menus_idle, window);
+}
+
void
nautilus_window_load_extension_menus (NautilusWindow *window)
{
@@ -794,6 +811,8 @@
gtk_ui_manager_remove_ui (window->details->ui_manager,
window->details->extensions_menu_merge_id);
window->details->extensions_menu_merge_id = 0;
+ } else {
+ nautilus_lockdown_notify_add(lockdown_changed_callback, window);
}
if (window->details->extensions_menu_action_group != NULL) {