dovecot-2.0: Verify that service type string is known. Removed a...

dovecot at dovecot.org dovecot at dovecot.org
Wed May 6 04:28:41 EEST 2009


details:   http://hg.dovecot.org/dovecot-2.0/rev/d83bfe8c38c2
changeset: 9230:d83bfe8c38c2
user:      Timo Sirainen <tss at iki.fi>
date:      Tue May 05 18:46:44 2009 -0400
description:
Verify that service type string is known. Removed auth-destination type.

diffstat:

2 files changed, 27 insertions(+), 2 deletions(-)
src/master/main.c            |   20 ++++++++++++++++++--
src/master/master-settings.c |    9 +++++++++

diffs (56 lines):

diff -r e5303fd61b5c -r d83bfe8c38c2 src/master/main.c
--- a/src/master/main.c	Tue May 05 15:33:44 2009 -0400
+++ b/src/master/main.c	Tue May 05 18:46:44 2009 -0400
@@ -163,15 +163,31 @@ static void fatal_log_check(const struct
 		i_error("unlink(%s) failed: %m", path);
 }
 
-static bool services_have_auth_destinations(const struct master_settings *set)
+static bool
+services_has_name(const struct master_settings *set, const char *name)
 {
 	struct service_settings *const *services;
 	unsigned int i, count;
 
 	services = array_get(&set->services, &count);
 	for (i = 0; i < count; i++) {
-		if (strcmp(services[i]->type, "auth-destination") == 0)
+		if (strcmp(services[i]->name, name) == 0)
 			return TRUE;
+	}
+	return FALSE;
+}
+
+static bool services_have_auth_destinations(const struct master_settings *set)
+{
+	struct service_settings *const *services;
+	unsigned int i, count;
+
+	services = array_get(&set->services, &count);
+	for (i = 0; i < count; i++) {
+		if (strcmp(services[i]->type, "auth-source") == 0) {
+			if (services_has_name(set, services[i]->auth_dest_service))
+				return TRUE;
+		}
 	}
 	return FALSE;
 }
diff -r e5303fd61b5c -r d83bfe8c38c2 src/master/master-settings.c
--- a/src/master/master-settings.c	Tue May 05 15:33:44 2009 -0400
+++ b/src/master/master-settings.c	Tue May 05 18:46:44 2009 -0400
@@ -278,6 +278,15 @@ master_settings_verify(void *_set, pool_
 		if (*services[i]->name == '\0') {
 			*error_r = t_strdup_printf(
 				"Service #%d is missing name", i);
+			return FALSE;
+		}
+		if (*services[i]->type != '\0' &&
+		    strcmp(services[i]->type, "log") != 0 &&
+		    strcmp(services[i]->type, "config") != 0 &&
+		    strcmp(services[i]->type, "auth") != 0 &&
+		    strcmp(services[i]->type, "auth-source") != 0) {
+			*error_r = t_strconcat("Unknown service type: ",
+					       services[i]->type, NULL);
 			return FALSE;
 		}
 		for (j = 0; j < i; j++) {


More information about the dovecot-cvs mailing list