[dovecot-cvs] dovecot/src/lib module-dir.c,1.19.2.2,1.19.2.3
tss at dovecot.org
tss at dovecot.org
Thu Dec 21 11:29:25 UTC 2006
Update of /var/lib/cvs/dovecot/src/lib
In directory talvi:/tmp/cvs-serv21207
Modified Files:
Tag: branch_1_0
module-dir.c
Log Message:
Give an error if there are duplicate files for a single module. Also if the
module directory can't be opened, die immediately.
Index: module-dir.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib/module-dir.c,v
retrieving revision 1.19.2.2
retrieving revision 1.19.2.3
diff -u -d -r1.19.2.2 -r1.19.2.3
--- module-dir.c 4 Nov 2006 19:49:13 -0000 1.19.2.2
+++ module-dir.c 21 Dec 2006 11:29:23 -0000 1.19.2.3
@@ -155,6 +155,25 @@
return FALSE;
}
+static void check_duplicates(array_t *names, const char *name, const char *dir)
+{
+ ARRAY_SET_TYPE(names, const char *);
+ const char *const *names_p, *base_name, *tmp;
+ unsigned int i, count;
+
+ t_push();
+ base_name = module_file_get_name(name);
+ names_p = array_get(names, &count);
+ for (i = 0; i < count; i++) {
+ tmp = module_file_get_name(names_p[i]);
+
+ if (strcmp(tmp, base_name) == 0)
+ i_fatal("Multiple files for module %s: %s/%s, %s/%s",
+ base_name, dir, name, dir, names_p[i]);
+ }
+ t_pop();
+}
+
struct module *module_dir_load(const char *dir, const char *module_names,
bool require_init_funcs)
{
@@ -171,11 +190,8 @@
i_info("Loading modules from directory: %s", dir);
dirp = opendir(dir);
- if (dirp == NULL) {
- if (errno != ENOENT)
- i_error("opendir(%s) failed: %m", dir);
- return NULL;
- }
+ if (dirp == NULL)
+ i_fatal("opendir(%s) failed: %m", dir);
pool = pool_alloconly_create("module loader", 1024);
ARRAY_CREATE(&names, pool, const char *, 32);
@@ -191,6 +207,8 @@
if (p == NULL || strlen(p) != 3)
continue;
+ check_duplicates(&names, name, dir);
+
name = p_strdup(pool, d->d_name);
array_append(&names, &name, 1);
}
@@ -205,7 +223,7 @@
else {
module_names_arr = t_strsplit_spaces(module_names, ", ");
/* allow giving the module names also in non-base form.
- conver them in here. */
+ convert them in here. */
for (i = 0; module_names_arr[i] != NULL; i++) {
module_names_arr[i] =
module_file_get_name(module_names_arr[i]);
More information about the dovecot-cvs
mailing list