]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
dsync: Fail if both source and destination mail location point to same directory.
authorTimo Sirainen <tss@iki.fi>
Fri, 1 Oct 2010 18:09:29 +0000 (19:09 +0100)
committerTimo Sirainen <tss@iki.fi>
Fri, 1 Oct 2010 18:09:29 +0000 (19:09 +0100)
This should prevent some accidents.

src/dsync/dsync.c

index 489d3f1e20ac809e5e36b480dcd1d724f9ab6d45..3a6c4b2737bd66bdf294dc6f2867cf43e9e7a16d 100644 (file)
@@ -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) {