diff options
author | Chenthill Palanisamy <pchenthill@novell.com> | 2010-01-30 03:40:36 +0800 |
---|---|---|
committer | Chenthill Palanisamy <pchenthill@novell.com> | 2010-01-30 04:04:00 +0800 |
commit | 1359e1e546de15f3df0b033f58f212414862b0a9 (patch) | |
tree | 3ee614076989d772758e271ba58f170154eb056f /shell | |
parent | 960de9e18a044ccf60f8fdcf7cc536cc7b049d33 (diff) | |
download | gsoc2013-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')
-rw-r--r-- | shell/e-shell-backend.c | 2 | ||||
-rw-r--r-- | shell/e-shell-migrate.c | 45 |
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, µ); + /* 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))) |