aboutsummaryrefslogtreecommitdiffstats
path: root/shell
diff options
context:
space:
mode:
Diffstat (limited to 'shell')
-rw-r--r--shell/e-shell-backend.c2
-rw-r--r--shell/e-shell-migrate.c45
2 files changed, 46 insertions, 1 deletions
diff --git a/shell/e-shell-backend.c b/shell/e-shell-backend.c
index 79acf60fa9..18ebe0f8d8 100644
--- a/shell/e-shell-backend.c
+++ b/shell/e-shell-backend.c
@@ -162,7 +162,7 @@ shell_backend_get_config_dir (EShellBackend *shell_backend)
/* Create the user configuration directory for this backend,
* which should also create the user data directory. */
- if (g_mkdir_with_parents (config_dir, 0777) != 0)
+ if (g_mkdir_with_parents (config_dir, 0700) != 0)
g_critical (
"Cannot create directory %s: %s",
config_dir, g_strerror (errno));
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)))