From: Timo Sirainen Date: Fri, 1 Oct 2010 18:09:29 +0000 (+0100) Subject: dsync: Fail if both source and destination mail location point to same directory. X-Git-Tag: 2.0.5~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3643fe9aaaf5fc11e0a08582b4f63acf39aca145;p=thirdparty%2Fdovecot%2Fcore.git dsync: Fail if both source and destination mail location point to same directory. This should prevent some accidents. --- diff --git a/src/dsync/dsync.c b/src/dsync/dsync.c index 489d3f1e20..3a6c4b2737 100644 --- a/src/dsync/dsync.c +++ b/src/dsync/dsync.c @@ -160,6 +160,7 @@ int main(int argc, char *argv[]) struct dsync_worker *worker1, *worker2, *workertmp; const char *error, *username, *cmd_name, *mailbox = NULL; const char *local_location = NULL, *const *remote_cmd_args = NULL; + const char *path1, *path2; bool dsync_server = FALSE, unexpected_changes = FALSE; bool dsync_debug = FALSE, reverse_workers = FALSE; char alt_char = '_'; @@ -277,6 +278,14 @@ int main(int argc, char *argv[]) "virtual mailbox hierarchy separator " "(specify separator for the default namespace)"); } + path1 = mailbox_list_get_path(mail_user->namespaces->list, NULL, + MAILBOX_LIST_PATH_TYPE_MAILBOX); + path2 = mailbox_list_get_path(mail_user2->namespaces->list, NULL, + MAILBOX_LIST_PATH_TYPE_MAILBOX); + if (strcmp(path1, path2) == 0) { + i_fatal("Both source and destination mail_location " + "points to same directory: %s", path1); + } worker2 = dsync_worker_init_local(mail_user2, alt_char); if (reverse_workers) {