aboutsummaryrefslogtreecommitdiffstats
path: root/shell/e-shell-migrate.c
diff options
context:
space:
mode:
authorChenthill Palanisamy <pchenthill@novell.com>2010-01-30 03:40:36 +0800
committerChenthill Palanisamy <pchenthill@novell.com>2010-01-30 04:04:00 +0800
commit1359e1e546de15f3df0b033f58f212414862b0a9 (patch)
tree3ee614076989d772758e271ba58f170154eb056f /shell/e-shell-migrate.c
parent960de9e18a044ccf60f8fdcf7cc536cc7b049d33 (diff)
downloadgsoc2013-evolution-1359e1e546de15f3df0b033f58f212414862b0a9.tar
gsoc2013-evolution-1359e1e546de15f3df0b033f58f212414862b0a9.tar.gz
gsoc2013-evolution-1359e1e546de15f3df0b033f58f212414862b0a9.tar.bz2
gsoc2013-evolution-1359e1e546de15f3df0b033f58f212414862b0a9.tar.lz
gsoc2013-evolution-1359e1e546de15f3df0b033f58f212414862b0a9.tar.xz
gsoc2013-evolution-1359e1e546de15f3df0b033f58f212414862b0a9.tar.zst
gsoc2013-evolution-1359e1e546de15f3df0b033f58f212414862b0a9.zip
Bug 581604 - Permissions on mail/local folders are too open
Diffstat (limited to 'shell/e-shell-migrate.c')
-rw-r--r--shell/e-shell-migrate.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/shell/e-shell-migrate.c b/shell/e-shell-migrate.c
index 1186b7934f..6ed7bccc08 100644
--- a/shell/e-shell-migrate.c
+++ b/shell/e-shell-migrate.c
@@ -194,6 +194,47 @@ fail:
return result;
}
+static void
+change_dir_modes (const gchar *path)
+{
+ GDir *dir;
+ GError *err = NULL;
+ const char *file = NULL;
+
+ dir = g_dir_open (path, 0, &err);
+ if (err) {
+ g_warning ("Error opening directory %s: %s \n", path, err->message);
+ g_clear_error (&err);
+ return;
+ }
+
+ while ((file = g_dir_read_name (dir))) {
+ gchar *full_path = g_build_filename (path, file, NULL);
+
+ if (g_file_test (full_path, G_FILE_TEST_IS_DIR))
+ change_dir_modes (full_path);
+
+ g_free (full_path);
+ }
+
+ g_chmod (path, 0700);
+ g_dir_close (dir);
+}
+
+static void
+fix_folder_permissions (const char *data_dir)
+{
+ struct stat sb;
+
+ if (g_stat (data_dir, &sb) == -1) {
+ g_warning ("error stat: %s \n", data_dir);
+ return;
+ }
+
+ if (((guint32) sb.st_mode & 0777) != 0700)
+ change_dir_modes (data_dir);
+}
+
gboolean
e_shell_migrate_attempt (EShell *shell)
{
@@ -221,6 +262,10 @@ e_shell_migrate_attempt (EShell *shell)
shell_migrate_get_version (shell, &major, &minor, &micro);
+ /* This sets the folder permissions to S_IRWXU if needed */
+ if (curr_major <= 2 && curr_minor <= 30)
+ fix_folder_permissions (e_get_user_data_dir ());
+
if (!(curr_major > major ||
(curr_major == major && curr_minor > minor) ||
(curr_major == major && curr_minor == minor && curr_micro > micro)))