Don't do any saving on configuration files which are not writable
If you have a restricted setup where user configuration is not meant to be saved, Midori will not even monitor changes if the files are not writable. This does *not* prevent any changes at runtime, but nothing will be saved to disk.
This commit is contained in:
parent
d810faf933
commit
f1f27c9322
1 changed files with 81 additions and 49 deletions
|
@ -30,6 +30,12 @@
|
|||
|
||||
#include "sokoke.h"
|
||||
|
||||
#if HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#define is_writable(_cfg_filename) !g_access (_cfg_filename, W_OK)
|
||||
#else
|
||||
#define is_writable(_cfg_filename) 1
|
||||
#endif
|
||||
#include <string.h>
|
||||
#include <glib/gi18n.h>
|
||||
#include <glib/gstdio.h>
|
||||
|
@ -1911,6 +1917,7 @@ midori_load_session (gpointer data)
|
|||
KatzeArray* _session = KATZE_ARRAY (data);
|
||||
MidoriBrowser* browser;
|
||||
MidoriApp* app = katze_item_get_parent (KATZE_ITEM (_session));
|
||||
gchar* config_file;
|
||||
KatzeArray* session;
|
||||
KatzeItem* item;
|
||||
guint n, i;
|
||||
|
@ -1919,6 +1926,8 @@ midori_load_session (gpointer data)
|
|||
midori_app_add_browser (app, browser);
|
||||
gtk_widget_show (GTK_WIDGET (browser));
|
||||
|
||||
config_file = build_config_filename ("accels");
|
||||
if (is_writable (config_file))
|
||||
g_signal_connect_after (gtk_accel_map_get (), "changed",
|
||||
G_CALLBACK (accel_map_changed_cb), NULL);
|
||||
|
||||
|
@ -1954,6 +1963,9 @@ midori_load_session (gpointer data)
|
|||
midori_browser_activate_action (browser, "Location");
|
||||
g_object_unref (_session);
|
||||
|
||||
katze_assign (config_file, build_config_filename ("session.xbel"));
|
||||
if (is_writable (config_file))
|
||||
{
|
||||
g_signal_connect_after (browser, "notify::uri",
|
||||
G_CALLBACK (midori_browser_session_cb), session);
|
||||
g_signal_connect_after (browser, "add-tab",
|
||||
|
@ -1962,6 +1974,7 @@ midori_load_session (gpointer data)
|
|||
G_CALLBACK (midori_browser_session_cb), session);
|
||||
g_object_weak_ref (G_OBJECT (session),
|
||||
(GWeakNotify)(midori_browser_weak_notify_cb), browser);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -2347,8 +2360,14 @@ main (int argc,
|
|||
i++;
|
||||
}
|
||||
|
||||
katze_assign (config_file, build_config_filename ("config"));
|
||||
if (is_writable (config_file))
|
||||
g_signal_connect_after (settings, "notify",
|
||||
G_CALLBACK (settings_notify_cb), NULL);
|
||||
|
||||
katze_assign (config_file, build_config_filename ("search"));
|
||||
if (is_writable (config_file))
|
||||
{
|
||||
g_signal_connect_after (search_engines, "add-item",
|
||||
G_CALLBACK (midori_search_engines_modify_cb), search_engines);
|
||||
g_signal_connect_after (search_engines, "remove-item",
|
||||
|
@ -2363,6 +2382,10 @@ main (int argc,
|
|||
G_CALLBACK (midori_search_engines_modify_cb), search_engines);
|
||||
}
|
||||
}
|
||||
}
|
||||
katze_assign (config_file, build_config_filename ("bookmarks.xbel"));
|
||||
if (is_writable (config_file))
|
||||
{
|
||||
g_signal_connect_after (bookmarks, "add-item",
|
||||
G_CALLBACK (midori_bookmarks_add_item_cb), bookmarks);
|
||||
g_signal_connect_after (bookmarks, "remove-item",
|
||||
|
@ -2384,15 +2407,24 @@ main (int argc,
|
|||
G_CALLBACK (midori_bookmarks_notify_item_cb), bookmarks);
|
||||
}
|
||||
}
|
||||
}
|
||||
katze_assign (config_file, build_config_filename ("tabtrash.xbel"));
|
||||
if (is_writable (config_file))
|
||||
{
|
||||
g_signal_connect_after (trash, "add-item",
|
||||
G_CALLBACK (midori_trash_add_item_cb), NULL);
|
||||
g_signal_connect_after (trash, "remove-item",
|
||||
G_CALLBACK (midori_trash_remove_item_cb), NULL);
|
||||
}
|
||||
#ifdef HAVE_SQLITE
|
||||
katze_assign (config_file, build_config_filename ("history.db"));
|
||||
if (is_writable (config_file))
|
||||
{
|
||||
g_signal_connect_after (history, "add-item",
|
||||
G_CALLBACK (midori_history_add_item_cb), db);
|
||||
g_signal_connect_after (history, "clear",
|
||||
G_CALLBACK (midori_history_clear_cb), db);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* We test for the presence of a dummy file which is created once
|
||||
|
|
Loading…
Reference in a new issue