Ejemplo n.º 1
0
static bool mdbox_storage_autodetect(const struct mail_namespace *ns,
                                     struct mailbox_list_settings *set)
{
    bool debug = ns->mail_set->mail_debug;
    struct stat st;
    const char *path, *root_dir;

    if (set->root_dir != NULL)
        root_dir = set->root_dir;
    else {
        root_dir = mdbox_storage_find_root_dir(ns);
        if (root_dir == NULL) {
            if (debug)
                i_debug("mdbox: couldn't find root dir");
            return FALSE;
        }
    }

    path = t_strconcat(root_dir, "/"MDBOX_GLOBAL_DIR_NAME, NULL);
    if (stat(path, &st) < 0) {
        if (debug)
            i_debug("mdbox autodetect: stat(%s) failed: %m", path);
        return FALSE;
    }

    if (!S_ISDIR(st.st_mode)) {
        if (debug)
            i_debug("mdbox autodetect: %s not a directory", path);
        return FALSE;
    }

    set->root_dir = root_dir;
    dbox_storage_get_list_settings(ns, set);
    return TRUE;
}
Ejemplo n.º 2
0
static bool sdbox_storage_autodetect(const struct mail_namespace *ns,
				     struct mailbox_list_settings *set)
{
	bool debug = ns->mail_set->mail_debug;
	struct stat st;
	const char *path, *root_dir;

	if (set->root_dir != NULL)
		root_dir = set->root_dir;
	else {
		root_dir = sdbox_storage_find_root_dir(ns);
		if (root_dir == NULL) {
			if (debug)
				i_debug("sdbox: couldn't find root dir");
			return FALSE;
		}
	}

	/* NOTE: this check works for mdbox as well. we'll rely on the
	   autodetect ordering to catch mdbox before we get here. */
	path = t_strconcat(root_dir, "/"DBOX_MAILBOX_DIR_NAME, NULL);
	if (stat(path, &st) < 0) {
		if (debug)
			i_debug("sdbox autodetect: stat(%s) failed: %m", path);
		return FALSE;
	}

	if (!S_ISDIR(st.st_mode)) {
		if (debug)
			i_debug("sdbox autodetect: %s not a directory", path);
		return FALSE;
	}

	set->root_dir = root_dir;
	dbox_storage_get_list_settings(ns, set);
	return TRUE;
}