imapc_connection_set_state(conn, IMAPC_CONNECTION_STATE_CONNECTING);
if (conn->ips_count > 0) {
/* do nothing */
+ } else if (conn->client->set.host[0] == '\0') {
+ e_error(conn->event, "imapc host is empty");
+ imapc_connection_set_disconnected(conn);
+ return;
} else if (net_addr2ip(conn->client->set.host, &ip) == 0) {
conn->ips_count = 1;
conn->ips = i_new(struct ip_addr, conn->ips_count);
list->client->_list = list;
list->set = list->client->set;
+ if ((_list->ns->flags & NAMESPACE_FLAG_UNUSABLE) != 0) {
+ /* Avoid connecting to imapc just to access mailbox names.
+ There are no mailboxes, so the separator doesn't matter. */
+ list->root_sep = '/';
+ }
+
imapc_storage_client_register_untagged(list->client, "LIST",
imapc_untagged_list);
imapc_storage_client_register_untagged(list->client, "LSUB",
return -1;
if (list->refreshed_mailboxes)
return 0;
+ if ((list->list.ns->flags & NAMESPACE_FLAG_UNUSABLE) != 0) {
+ list->refreshed_mailboxes = TRUE;
+ list->refreshed_mailboxes_recently = TRUE;
+ return 0;
+ }
if (*list->set->imapc_list_prefix == '\0')
pattern = "*";
if (imapc_list_try_get_root_sep(src_list, &list_sep) < 0)
return -1;
- if (src_list->refreshed_subscriptions) {
+ if (src_list->refreshed_subscriptions ||
+ (src_list->list.ns->flags & NAMESPACE_FLAG_UNUSABLE) != 0) {
if (dest_list->subscriptions == NULL)
dest_list->subscriptions = mailbox_tree_init(dest_sep);
return 0;
return -1;
i_zero(&set);
- set.host = imapc_set->imapc_host;
- if (*set.host == '\0') {
- *error_r = "missing imapc_host";
- settings_free(imapc_set);
- return -1;
+ if ((ns->flags & NAMESPACE_FLAG_UNUSABLE) != 0) {
+ /* Shared namespace user doesn't actually exist. Don't try to
+ access the user via imapc, but also don't make this a
+ visible error. If any code path tries to connect to imapc,
+ it's a bug. Use an empty host to enforce this. */
+ set.host = "";
+ } else {
+ set.host = imapc_set->imapc_host;
+ if (*set.host == '\0') {
+ *error_r = "missing imapc_host";
+ settings_free(imapc_set);
+ return -1;
+ }
}
set.port = imapc_set->imapc_port;
if (imapc_set->imapc_user[0] != '\0')