From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id UGo5NL4dx2E/7wAAgWs5BA (envelope-from ) for ; Sat, 25 Dec 2021 14:33:50 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id IGfBL74dx2FzfAAAbx9fmQ (envelope-from ) for ; Sat, 25 Dec 2021 13:33:50 +0000 Received: from mail.notmuchmail.org (yantan.tethera.net [135.181.149.255]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 947F723D8F for ; Sat, 25 Dec 2021 14:33:50 +0100 (CET) Received: from yantan.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 5B6285F72F; Sat, 25 Dec 2021 13:33:36 +0000 (UTC) Received: from fethera.tethera.net (fethera.tethera.net [IPv6:2607:5300:60:c5::1]) by mail.notmuchmail.org (Postfix) with ESMTP id 97A8E5F722 for ; Sat, 25 Dec 2021 13:33:32 +0000 (UTC) Received: by fethera.tethera.net (Postfix, from userid 1001) id DCF995FC48; Sat, 25 Dec 2021 08:33:31 -0500 (EST) Received: (nullmailer pid 3014298 invoked by uid 1000); Sat, 25 Dec 2021 13:33:27 -0000 From: David Bremner To: David Bremner , notmuch@notmuchmail.org Subject: [PATCH 6/6] lib/open: no default mail root in split configurations Date: Sat, 25 Dec 2021 09:33:05 -0400 Message-Id: <20211225133305.3014272-4-david@tethera.net> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20211225133305.3014272-1-david@tethera.net> References: <20211211124912.1823559-2-david@tethera.net> <20211225133305.3014272-1-david@tethera.net> MIME-Version: 1.0 Message-ID-Hash: G6E6NV4Q65VH446MYOJU4KGBUVJO3GYN X-Message-ID-Hash: G6E6NV4Q65VH446MYOJU4KGBUVJO3GYN X-MailFrom: bremner@tethera.net X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.3 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_IN X-Migadu-Country: DE ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1640439230; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-owner:list-unsubscribe:list-subscribe:list-post; bh=J4oMTqlT7gca1CWoXMP92X1wuAzKRKNKmuoZRCf5e9U=; b=cRMRMVqhMt6U49ylWYdmmnxVKj3I3Qst0w+6FyxFt+1VjkkNeOdrAoZLl65XrWzEI+OsJk TwXsef0KBkzRDEdeoxMX4Gl1GUt7ZivNbyV0dWjFuD08LRISjuBSeb5m9clnsGoajsLJVt d7jSM98lLup3vktNtm1sNIKg1GQb1ROpBAxSnEjPP8YPH+zh3yfxB9ntGdk+A5g/WspzsQ aPy3OKJQG3AVfyrmgpFz6FRQ84ZmAz1VYfVUreg8kh59AUxKUQGfiGCDeb8ObtNDDYVTmA CsvCMVWRVA5kHGo526ZDXE2QX/L/dNLnGgPlX0SYWe0wgepf6Rk/DVpSnvEdww== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1640439230; a=rsa-sha256; cv=none; b=D49yaQ3rH2+Wd8E1t4vONY4SmELWdfttnMMiHmB4KLYa5xh7MYZprnlPJBjmXpcfWiO7gS E7yTqJOD+iSAdcfjgW+n0EB1T/qdRU6xjh1CLAfObHIYsEVcVL7FWCKDE/5s2MTOehhO8f zM01rf+H5WnoOFGBgQ778ie8Le+B5372fJIwGqJmmPdkaDtWPhiFVZQBf2laG+nDTHIobl 6vTRYfTkUHpHVqYUMlzM0MQTvftGxICgKYjI6Gs+/9BcdnJE0nIVUTpjhP5fXKfLannNeR enrkjtD5APsVBfHjHlOKRNuUqWKmTSQga8fGXBsnuTURJvhAKRKTFA52CbRolg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 135.181.149.255 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: -1.24 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 135.181.149.255 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: 947F723D8F X-Spam-Score: -1.24 X-Migadu-Scanner: scn0.migadu.com X-TUID: vTVKw9bKNiXO If we know the configuration is split, but there is no mail root defined, this indicates a (lack of) configuration error. Currently this can only arise in XDG configurations. --- bindings/python-cffi/notmuch2/_build.py | 1 + lib/config.cc | 6 +++++- lib/database.cc | 2 ++ lib/notmuch.h | 4 ++++ test/T590-libconfig.sh | 1 - 5 files changed, 12 insertions(+), 2 deletions(-) diff --git a/bindings/python-cffi/notmuch2/_build.py b/bindings/python-cffi/notmuch2/_build.py index 45eb20c0..a55b484f 100644 --- a/bindings/python-cffi/notmuch2/_build.py +++ b/bindings/python-cffi/notmuch2/_build.py @@ -54,6 +54,7 @@ ffibuilder.cdef( NOTMUCH_STATUS_NO_DATABASE, NOTMUCH_STATUS_DATABASE_EXISTS, NOTMUCH_STATUS_BAD_QUERY_SYNTAX, + NOTMUCH_STATUS_NO_MAIL_ROOT, NOTMUCH_STATUS_LAST_STATUS } notmuch_status_t; typedef enum { diff --git a/lib/config.cc b/lib/config.cc index 8f6ef110..f61eb636 100644 --- a/lib/config.cc +++ b/lib/config.cc @@ -657,6 +657,7 @@ notmuch_status_t _notmuch_config_load_defaults (notmuch_database_t *notmuch) { notmuch_config_key_t key; + notmuch_status_t status = NOTMUCH_STATUS_SUCCESS; if (notmuch->config == NULL) notmuch->config = _notmuch_string_map_create (notmuch); @@ -669,11 +670,14 @@ _notmuch_config_load_defaults (notmuch_database_t *notmuch) val = _notmuch_string_map_get (notmuch->config, key_string); if (! val) { + if (key == NOTMUCH_CONFIG_MAIL_ROOT && (notmuch->params & NOTMUCH_PARAM_SPLIT)) + status = NOTMUCH_STATUS_NO_MAIL_ROOT; + _notmuch_string_map_set (notmuch->config, key_string, _notmuch_config_default (notmuch, key)); } } - return NOTMUCH_STATUS_SUCCESS; + return status; } const char * diff --git a/lib/database.cc b/lib/database.cc index 6ef56d56..0effe978 100644 --- a/lib/database.cc +++ b/lib/database.cc @@ -311,6 +311,8 @@ notmuch_status_to_string (notmuch_status_t status) return "Database exists, not recreated"; case NOTMUCH_STATUS_BAD_QUERY_SYNTAX: return "Syntax error in query"; + case NOTMUCH_STATUS_NO_MAIL_ROOT: + return "No mail root found"; default: case NOTMUCH_STATUS_LAST_STATUS: return "Unknown error status value"; diff --git a/lib/notmuch.h b/lib/notmuch.h index 1b2bdf3f..fef98b4b 100644 --- a/lib/notmuch.h +++ b/lib/notmuch.h @@ -224,6 +224,10 @@ typedef enum { * Syntax error in query */ NOTMUCH_STATUS_BAD_QUERY_SYNTAX, + /** + * No mail root could be deduced from parameters and environment + */ + NOTMUCH_STATUS_NO_MAIL_ROOT, /** * Not an actual status value. Just a way to find out how many * valid status values there are. diff --git a/test/T590-libconfig.sh b/test/T590-libconfig.sh index 9cc79e8c..0b5291ab 100755 --- a/test/T590-libconfig.sh +++ b/test/T590-libconfig.sh @@ -1022,7 +1022,6 @@ notmuch_dir_sanitize < OUTPUT > OUTPUT.clean test_expect_equal_file EXPECTED.common OUTPUT.clean test_begin_subtest "open/error: config=empty with no mail root in db (xdg)" -test_subtest_known_broken old_NOTMUCH_CONFIG=${NOTMUCH_CONFIG} unset NOTMUCH_CONFIG backup_database -- 2.34.1