From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id cBuHGuBnlWCdNgAAgWs5BA (envelope-from ) for ; Fri, 07 May 2021 18:16:32 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id kIgIFuBnlWD0WAAAbx9fmQ (envelope-from ) for ; Fri, 07 May 2021 16:16:32 +0000 Received: from mail.notmuchmail.org (nmbug.tethera.net [144.217.243.247]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id A398318371 for ; Fri, 7 May 2021 18:16:31 +0200 (CEST) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 8FFC92717A; Fri, 7 May 2021 12:16:27 -0400 (EDT) Received: from lahtoruutu.iki.fi (lahtoruutu.iki.fi [185.185.170.37]) by mail.notmuchmail.org (Postfix) with ESMTPS id AF4042716D for ; Fri, 7 May 2021 12:16:24 -0400 (EDT) Received: from guru.guru-group.fi (unknown [IPv6:2a02:2380:1:9:5054:ff:feb7:a4bc]) (using TLSv1.2 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: too) by lahtoruutu.iki.fi (Postfix) with ESMTPSA id 6CAA41B00C5F; Fri, 7 May 2021 19:16:19 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1620404179; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=hT5S5BJ8Y3sdvGYFMVkPiNktGs7xw1izUoc5oRwDcDI=; b=SXTdNz5fjbIRMZdJsCu1jkE4n0Fslo6nRyvipnpsuUWHnHk7iqcPah1cT0R4BoCVbo/jLo baGm+8c7Xl9JdRzE96dYq5jxjOQJhquezXA1yQIGNwgUZ2YPutHg7oSleIqywjB8MgvaDf V6MoWhOen7dvLk54sX+WttIwMloB7C3PuGO/4pg6vX2fK1tanWdEIzQ8KCTkv02EyiU0oq KcpQn4VkYZ4JYSyuaPjhEkKc+hPDWhJU2+y+3svRuSbiXnbe4yBRM/QS6s2qVt45i9FfGt WYq61zjGv2giGRIf/pmfp2GxoREEFIzgJHdFO8d9hxrL0t/nKw6lYL8+3ThkHA== From: Tomi Ollila To: David Bremner , notmuch@notmuchmail.org Cc: David Bremner Subject: Re: [PATCH 2/9] lib/config: canonicalize paths relative to $HOME. In-Reply-To: References: <20210507113029.2685184-1-david@tethera.net> <20210507113029.2685184-3-david@tethera.net> User-Agent: Notmuch/0.32+21~gfdddd4c (https://notmuchmail.org) Emacs/27.1 X-Face: HhBM'cA~ MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1620404179; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=hT5S5BJ8Y3sdvGYFMVkPiNktGs7xw1izUoc5oRwDcDI=; b=AvpE1ePbHwy926Tdq3w5Uw7ux/QVxM5RWvlc86yZ4NT53y0FXbKbggra8YEqlGgFEqwVyt ejCEyV95CpebWMcQS1IfNTaLalafhBOFaHLMYP7fiKBtJ2ep+54RhcV4NFk5E1nCSy7cio Eeu51NH6cS1zgqoINoodiPUYciZiIdq/cWtRzUdE0n3pzLESiF76G1uCAKOCgYeLMU4U2V +XeNTYvpLQMrLSWORI54wmQuvK0ChiEbkq3mBs0VLuynea7GdSd7eVR7mJF0r+o398zefX OWYHhKk7RUhNxJCtQUJQPFwp9W28Fdbq6NFyzVjAPC+gcONjdjbR+SMo6/WCGA== ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=too smtp.mailfrom=tomi.ollila@iki.fi ARC-Seal: i=1; s=lahtoruutu; d=iki.fi; t=1620404179; a=rsa-sha256; cv=none; b=pbptOf6jtzUbKyp4rKEdBkjKWJUGGbOW7gZbwbPSIslKDdES0yKR3CBwScCKK1i1exlGFK awztBqLorhjadsXVHC1gMz4VEsgVPl+p3Rovb//tFsEh0nkhiI4bal9ZLbueXvCwZiIFCv prxWtzRTxwbZdTvr02lmJ2QrO+qOzavkipGNc38cdo90x9YxvgtAiDYJ4lzni2bh0g1KZL dQpf2BsxlsgjeWjcfUF4f0th4mrpXrddanw9Xmow7Bk05TwI/of62P1RPcWkmDehY349n1 YUuYeK6emqRjM33JoPFIJPEaYKv5kr4f7UHr9mgmK5CLxSM5DYLR7Kt2szqc0w== Message-ID-Hash: J2P7KV6W4ADKSOZDTN2YN3TUFQRJFTUY X-Message-ID-Hash: J2P7KV6W4ADKSOZDTN2YN3TUFQRJFTUY X-MailFrom: tomi.ollila@iki.fi 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; suspicious-header X-Mailman-Version: 3.2.1 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1620404191; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc: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-unsubscribe:list-subscribe:list-post:dkim-signature; bh=RTLPit5/K7+2j4a1NllkYKIVMnOp0v7Fks4l5nUh7jU=; b=o34FKOG5KmaAjqyn35BMR0/ya/DaVWKcQ3xdn0BvvtHFw7qls4lObmD4hNhD9lm19YneKf AO7MPvGyzeXPsq9LI9ENq+GvhyMRlvPV1JCaC1J4H0Zxl1W6CTy6g81x7nmUKxb4chTeUI zeBjMYgd16CsXyCHDD8bnuMSQufghm35QjwcjzXJZ8ACM/7MiV02M5H0tunNEOwAx0dG7S 99FCpXSZF+eQaAJpGva6NQOaBQ3q8C/UkmVkSTSZRUTElPoz6ftiEwwLGCqiFZWdn0QUgy 5BJUSucdqtFIVYw4UBOzs+/YI9GchVYYLt5BiKbxTYXaNhXEJL7tInEP0dgRrQ== ARC-Seal: i=2; s=key1; d=yhetil.org; t=1620404191; a=rsa-sha256; cv=fail; b=MhS2cBDwjt2xEL0lBqiKoMQs4utwFPEhCJt9EbFS4DfVhgKn0JHRB+/BO1NT1BkOLIVrb0 k2IX3nzSMxjAGSDwBdSuXNMm0ojrSOSSmhiYW7HiTqacyntMqNwXrnDhlJddhQPVCBgsLx 38P0C4YdT/Bw707hH3qAvKqOjPIHKFZumow/dIZxAvrN/IcF0gqmJKRehGSdVPq1hYWowC bKV6BPr8Rg+dYDTiYQof1Zk3QKvGiMoIBoq13ppxHzQcn5ag9K5DoscXk2xWWDc+UMlHjB IrmjNndnDCXiH5MXPI5cveEJ7SousZBB5L8MH67gNyWPPzsWz/m0Kus6/yixEw== ARC-Authentication-Results: i=2; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=iki.fi header.s=lahtoruutu header.b=SXTdNz5f; arc=reject ("signature check failed: fail, {[1] = sig:iki.fi:reject}"); dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 144.217.243.247 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: 3.42 Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=iki.fi header.s=lahtoruutu header.b=SXTdNz5f; arc=reject ("signature check failed: fail, {[1] = sig:iki.fi:reject}"); dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 144.217.243.247 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: A398318371 X-Spam-Score: 3.42 X-Migadu-Scanner: scn0.migadu.com X-TUID: CCnSYZxB38AJ On Fri, May 07 2021, Tomi Ollila wrote: > On Fri, May 07 2021, David Bremner wrote: > >> Prior to 0.32, notmuch had the (undocumented) behaviour that it >> expanded a relative value of database.path with respect to $HOME. In >> 0.32 this was special cased for database.path but broken for >> database.mail_root, which causes problems for at least notmuch-new >> when database.path is set to a relative path. >> >> The change in T030-config.sh reflects a user visible, but hopefully >> harmless behaviour change; the expanded form of the paths will now be >> printed by notmuch config. >> --- >> lib/config.cc | 22 +++++++++++++++++++++- >> test/T030-config.sh | 6 +++--- >> test/T050-new.sh | 1 - >> 3 files changed, 24 insertions(+), 5 deletions(-) >> >> diff --git a/lib/config.cc b/lib/config.cc >> index 50bcf6a2..e08c6bf7 100644 >> --- a/lib/config.cc >> +++ b/lib/config.cc >> @@ -387,6 +387,23 @@ notmuch_config_pairs_destroy (notmuch_config_pairs_t *pairs) >> talloc_free (pairs); >> } >> >> +static char * >> +_expand_path (void *ctx, const char *key, const char *val) >> +{ >> + char *expanded_val; >> + >> + if ((strcmp (key, "database.path") == 0 || >> + strcmp (key, "database.mail_root") == 0 || >> + strcmp (key, "database.hook_dir") == 0 || >> + strcmp (key, "database.backup_path") == 0 ) && >> + val[0] != '/') > > check val[0] first then one does not need to waste time scanning > through all the other possible values for 'key'. that is trivial > "optimization", other possible but not worth the effort... Forget this suggestion; changing order makes things worse -- probably in values of other keys than these checked don't start with '/' so there would be one extra check in most of the cases... Tomi > >> + expanded_val = talloc_asprintf (ctx, "%s/%s", getenv("HOME"), val); >> + else >> + expanded_val = talloc_strdup (ctx, val); >> + >> + return expanded_val; >> +} >> + >> notmuch_status_t >> _notmuch_config_load_from_file (notmuch_database_t *notmuch, >> GKeyFile *file) >> @@ -407,14 +424,17 @@ _notmuch_config_load_from_file (notmuch_database_t *notmuch, >> keys = g_key_file_get_keys (file, *grp, NULL, NULL); >> for (gchar **keys_p = keys; *keys_p; keys_p++) { >> char *absolute_key = talloc_asprintf (notmuch, "%s.%s", *grp, *keys_p); >> + char *normalized_val; >> val = g_key_file_get_value (file, *grp, *keys_p, NULL); >> if (! val) { >> status = NOTMUCH_STATUS_FILE_ERROR; >> goto DONE; >> } >> - _notmuch_string_map_set (notmuch->config, absolute_key, val); >> + normalized_val = _expand_path (notmuch, absolute_key, val); >> + _notmuch_string_map_set (notmuch->config, absolute_key, normalized_val); >> g_free (val); >> talloc_free (absolute_key); >> + talloc_free (normalized_val); >> if (status) >> goto DONE; >> } >> diff --git a/test/T030-config.sh b/test/T030-config.sh >> index b22d8f29..7a1660e9 100755 >> --- a/test/T030-config.sh >> +++ b/test/T030-config.sh >> @@ -117,12 +117,12 @@ test_expect_equal "$(notmuch config get database.path)" \ >> >> ln -s `pwd`/mail home/Maildir >> add_email_corpus >> -test_begin_subtest "Relative database path expanded in open" >> +test_begin_subtest "Relative database path expanded" >> notmuch config set database.path Maildir >> -path=$(notmuch config get database.path) >> +path=$(notmuch config get database.path | notmuch_dir_sanitize) >> count=$(notmuch count '*') >> test_expect_equal "${path} ${count}" \ >> - "Maildir 52" >> + "CWD/home/Maildir 52" >> >> test_begin_subtest "Add config to database" >> notmuch new >> diff --git a/test/T050-new.sh b/test/T050-new.sh >> index 5faf6839..33ad7f5a 100755 >> --- a/test/T050-new.sh >> +++ b/test/T050-new.sh >> @@ -395,7 +395,6 @@ EOF >> test_expect_equal_file EXPECTED OUTPUT >> >> test_begin_subtest "Relative database path expanded in new" >> -test_subtest_known_broken >> ln -s `pwd`/mail home/Maildir >> notmuch config set database.path Maildir >> generate_message >> -- >> 2.30.2 >> _______________________________________________ >> notmuch mailing list -- notmuch@notmuchmail.org >> To unsubscribe send an email to notmuch-leave@notmuchmail.org