changeset 5607:74d3236313c1 HEAD

lib-storage doesn't need the ability to return syntax errors. They should be checked before lib-storage is called.
author Timo Sirainen <tss@iki.fi>
date Sun, 13 May 2007 18:46:07 +0300
parents 01e318d8304b
children f5a126edd902
files src/deliver/deliver.c src/imap/cmd-fetch.c src/imap/commands-util.c src/imap/imap-search.c src/lib-storage/mail-storage-private.h src/lib-storage/mail-storage.c src/lib-storage/mail-storage.h src/plugins/convert/convert-storage.c src/plugins/lazy-expunge/lazy-expunge-plugin.c src/pop3/client.c
diffstat 10 files changed, 28 insertions(+), 65 deletions(-) [+]
line wrap: on
line diff
--- a/src/deliver/deliver.c	Sun May 13 18:43:36 2007 +0300
+++ b/src/deliver/deliver.c	Sun May 13 18:46:07 2007 +0300
@@ -81,7 +81,7 @@
 {
 	struct mail_namespace *ns;
 	struct mailbox *box;
-	bool syntax, temp;
+	bool temp;
 
 	ns = mail_namespace_find(namespaces, &name);
 	if (ns == NULL) {
@@ -95,8 +95,8 @@
 	if (box != NULL || no_mailbox_autocreate)
 		return box;
 
-	(void)mail_storage_get_last_error(ns->storage, &syntax, &temp);
-	if (syntax || temp)
+	(void)mail_storage_get_last_error(ns->storage, &temp);
+	if (temp)
 		return NULL;
 
 	/* probably the mailbox just doesn't exist. try creating it. */
@@ -715,11 +715,10 @@
 
 	if (ret < 0) {
 		const char *error, *msgid;
-		bool syntax, temporary_error;
+		bool temporary_error;
 		int ret;
 
-		error = mail_storage_get_last_error(storage, &syntax,
-						    &temporary_error);
+		error = mail_storage_get_last_error(storage, &temporary_error);
 		if (temporary_error)
 			return EX_TEMPFAIL;
 
--- a/src/imap/cmd-fetch.c	Sun May 13 18:43:36 2007 +0300
+++ b/src/imap/cmd-fetch.c	Sun May 13 18:46:07 2007 +0300
@@ -79,7 +79,7 @@
 	if (ctx->failed) {
 		struct mail_storage *storage;
 		const char *error;
-		bool syntax, temporary_error;
+		bool temporary_error;
 
 		if (ctx->client->output->closed) {
 			client_disconnect(cmd->client, "Disconnected");
@@ -87,16 +87,11 @@
 		}
 
                 storage = mailbox_get_storage(cmd->client->mailbox);
-		error = mail_storage_get_last_error(storage, &syntax,
-						    &temporary_error);
-		if (!syntax) {
-			/* We never want to reply NO to FETCH requests,
-			   BYE is preferrable (see imap-ml for reasons). */
-			client_disconnect_with_error(cmd->client, error);
-		} else {
-			/* user error, we'll reply with BAD */
-			client_send_storage_error(cmd, storage);
-		}
+		error = mail_storage_get_last_error(storage, &temporary_error);
+
+		/* We never want to reply NO to FETCH requests,
+		   BYE is preferrable (see imap-ml for reasons). */
+		client_disconnect_with_error(cmd->client, error);
 		return TRUE;
 	}
 
--- a/src/imap/commands-util.c	Sun May 13 18:43:36 2007 +0300
+++ b/src/imap/commands-util.c	Sun May 13 18:46:07 2007 +0300
@@ -147,7 +147,7 @@
 			       struct mail_storage *storage)
 {
 	const char *error;
-	bool syntax, temporary_error;
+	bool temporary_error;
 
 	if (cmd->client->mailbox != NULL &&
 	    mailbox_is_inconsistent(cmd->client->mailbox)) {
@@ -157,16 +157,15 @@
 		return;
 	}
 
-	error = mail_storage_get_last_error(storage, &syntax, &temporary_error);
-	client_send_tagline(cmd,
-			    t_strconcat(syntax ? "BAD " : "NO ", error, NULL));
+	error = mail_storage_get_last_error(storage, &temporary_error);
+	client_send_tagline(cmd, t_strconcat("NO ", error, NULL));
 }
 
 void client_send_untagged_storage_error(struct client *client,
 					struct mail_storage *storage)
 {
 	const char *error;
-	bool syntax, temporary_error;
+	bool temporary_error;
 
 	if (client->mailbox != NULL &&
 	    mailbox_is_inconsistent(client->mailbox)) {
@@ -176,9 +175,8 @@
 		return;
 	}
 
-	error = mail_storage_get_last_error(storage, &syntax, &temporary_error);
-	client_send_line(client,
-			 t_strconcat(syntax ? "* BAD " : "* NO ", error, NULL));
+	error = mail_storage_get_last_error(storage, &temporary_error);
+	client_send_line(client, t_strconcat("* NO ", error, NULL));
 }
 
 static bool is_valid_keyword(struct client_command_context *cmd,
--- a/src/imap/imap-search.c	Sun May 13 18:43:36 2007 +0300
+++ b/src/imap/imap-search.c	Sun May 13 18:46:07 2007 +0300
@@ -19,7 +19,7 @@
 		  struct mail_search_seqset **seqset_r, const char **error_r)
 {
 	struct mail_search_seqset *seqset, **p;
-	bool syntax, temporary, last;
+	bool temporary, last;
 
 	*seqset_r = imap_messageset_parse(pool, uidset);
 	if (*seqset_r == NULL) {
@@ -39,7 +39,6 @@
 				     &seqset->seq1, &seqset->seq2) < 0) {
 			struct mail_storage *storage = mailbox_get_storage(box);
 			*error_r = mail_storage_get_last_error(storage,
-							       &syntax,
 							       &temporary);
 			return -1;
 		}
--- a/src/lib-storage/mail-storage-private.h	Sun May 13 18:43:36 2007 +0300
+++ b/src/lib-storage/mail-storage-private.h	Sun May 13 18:46:07 2007 +0300
@@ -66,8 +66,6 @@
 	/* Module-specific contexts. See mail_storage_module_id. */
 	ARRAY_DEFINE(module_contexts, union mail_storage_module_context *);
 
-	/* IMAP: Give a BAD reply instead of NO */
-	unsigned int syntax_error:1;
 	/* Internal temporary error, as opposed to visible user errors like
 	   "permission denied" or "out of disk space" */
 	unsigned int temporary_error:1;
@@ -292,14 +290,11 @@
 void mail_storage_clear_error(struct mail_storage *storage);
 void mail_storage_set_error(struct mail_storage *storage,
 			    const char *fmt, ...) __attr_format__(2, 3);
-void mail_storage_set_syntax_error(struct mail_storage *storage,
-				   const char *fmt, ...) __attr_format__(2, 3);
 void mail_storage_set_critical(struct mail_storage *storage,
 			       const char *fmt, ...) __attr_format__(2, 3);
 void mail_storage_set_internal_error(struct mail_storage *storage);
 
-const char *mail_storage_class_get_last_error(struct mail_storage *storage,
-					      bool *syntax_error_r);
+const char *mail_storage_class_get_last_error(struct mail_storage *storage);
 
 enum mailbox_list_flags
 mail_storage_get_list_flags(enum mail_storage_flags storage_flags);
--- a/src/lib-storage/mail-storage.c	Sun May 13 18:43:36 2007 +0300
+++ b/src/lib-storage/mail-storage.c	Sun May 13 18:46:07 2007 +0300
@@ -236,7 +236,6 @@
 	i_free(storage->error);
 	storage->error = NULL;
 
-	storage->syntax_error = FALSE;
 	storage->temporary_error = FALSE;
 }
 
@@ -253,21 +252,6 @@
 	}
 }
 
-void mail_storage_set_syntax_error(struct mail_storage *storage,
-				   const char *fmt, ...)
-{
-	va_list va;
-
-	mail_storage_clear_error(storage);
-
-	if (fmt != NULL) {
-		va_start(va, fmt);
-		storage->error = i_strdup_vprintf(fmt, va);
-		storage->syntax_error = TRUE;
-		va_end(va);
-	}
-}
-
 void mail_storage_set_internal_error(struct mail_storage *storage)
 {
 	struct tm *tm;
@@ -279,7 +263,6 @@
 	storage->error =
 		strftime(str, sizeof(str), CRITICAL_MSG_STAMP, tm) > 0 ?
 		i_strdup(str) : i_strdup(CRITICAL_MSG);
-	storage->syntax_error = FALSE;
 	storage->temporary_error = TRUE;
 }
 
@@ -291,7 +274,6 @@
 	storage->error =
 		i_strdup(mailbox_list_get_last_error(storage->list, &temp));
 
-	storage->syntax_error = FALSE;
 	storage->temporary_error = temp;
 }
 
@@ -350,10 +332,8 @@
 }
 
 const char *mail_storage_get_last_error(struct mail_storage *storage,
-					bool *syntax_error_r,
 					bool *temporary_error_r)
 {
-	*syntax_error_r = storage->syntax_error;
 	*temporary_error_r = storage->temporary_error;
 
 	/* We get here only in error situations, so we have to return some
--- a/src/lib-storage/mail-storage.h	Sun May 13 18:43:36 2007 +0300
+++ b/src/lib-storage/mail-storage.h	Sun May 13 18:46:07 2007 +0300
@@ -231,7 +231,6 @@
 
 /* Returns the error message of last occurred error. */
 const char *mail_storage_get_last_error(struct mail_storage *storage,
-					bool *syntax_error_r,
 					bool *temporary_error_r);
 
 /* Returns path to the given mailbox, or NULL if mailbox doesn't exist in
--- a/src/plugins/convert/convert-storage.c	Sun May 13 18:43:36 2007 +0300
+++ b/src/plugins/convert/convert-storage.c	Sun May 13 18:46:07 2007 +0300
@@ -101,9 +101,9 @@
 
 static const char *storage_error(struct mail_storage *storage)
 {
-	bool syntax, temp;
+	bool temp;
 
-	return mail_storage_get_last_error(storage, &syntax, &temp);
+	return mail_storage_get_last_error(storage, &temp);
 }
 
 static const char *
--- a/src/plugins/lazy-expunge/lazy-expunge-plugin.c	Sun May 13 18:43:36 2007 +0300
+++ b/src/plugins/lazy-expunge/lazy-expunge-plugin.c	Sun May 13 18:46:07 2007 +0300
@@ -69,7 +69,7 @@
 mailbox_open_or_create(struct mail_storage *storage, const char *name)
 {
 	struct mailbox *box;
-	bool syntax, temp;
+	bool temp;
 
 	box = mailbox_open(storage, name, NULL, MAILBOX_OPEN_FAST |
 			   MAILBOX_OPEN_KEEP_RECENT |
@@ -77,8 +77,8 @@
 	if (box != NULL)
 		return box;
 
-	(void)mail_storage_get_last_error(storage, &syntax, &temp);
-	if (syntax || temp)
+	(void)mail_storage_get_last_error(storage, &temp);
+	if (temp)
 		return NULL;
 
 	/* probably the mailbox just doesn't exist. try creating it. */
--- a/src/pop3/client.c	Sun May 13 18:43:36 2007 +0300
+++ b/src/pop3/client.c	Sun May 13 18:46:07 2007 +0300
@@ -132,7 +132,7 @@
 	struct client *client;
         enum mailbox_open_flags flags;
 	const char *errmsg;
-	bool syntax_error, temporary_error;
+	bool temporary_error;
 
 	/* always use nonblocking I/O */
 	net_set_nonblock(fd_in, TRUE);
@@ -172,7 +172,6 @@
 	if (client->mailbox == NULL) {
 		errmsg = t_strdup_printf("Couldn't open INBOX: %s",
 				mail_storage_get_last_error(storage,
-							    &syntax_error,
 							    &temporary_error));
 		i_error("%s", errmsg);
 		client_send_line(client, "-ERR [IN-USE] %s", errmsg);
@@ -182,8 +181,7 @@
 
 	if (!init_mailbox(client)) {
 		i_error("Couldn't init INBOX: %s",
-			mail_storage_get_last_error(storage, &syntax_error,
-						    &temporary_error));
+			mail_storage_get_last_error(storage, &temporary_error));
 		client_destroy(client, "Mailbox init failed");
 		return NULL;
 	}
@@ -337,7 +335,7 @@
 void client_send_storage_error(struct client *client)
 {
 	const char *error;
-	bool syntax, temporary_error;
+	bool temporary_error;
 
 	if (mailbox_is_inconsistent(client->mailbox)) {
 		client_send_line(client, "-ERR Mailbox is in inconsistent "
@@ -346,7 +344,7 @@
 		return;
 	}
 
-	error = mail_storage_get_last_error(client->inbox_ns->storage, &syntax,
+	error = mail_storage_get_last_error(client->inbox_ns->storage,
 					    &temporary_error);
 	client_send_line(client, "-ERR %s", error != NULL ? error :
 			 "BUG: Unknown error");