From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id 0NefOpIylWD/TwEAgWs5BA (envelope-from ) for ; Fri, 07 May 2021 14:29:06 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id oLNrNpIylWAhPAAA1q6Kng (envelope-from ) for ; Fri, 07 May 2021 12:29:06 +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 380A614045 for ; Fri, 7 May 2021 14:29:06 +0200 (CEST) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 9ADDC2716D; Fri, 7 May 2021 08:29:02 -0400 (EDT) Received: from lahtoruutu.iki.fi (lahtoruutu.iki.fi [185.185.170.37]) by mail.notmuchmail.org (Postfix) with ESMTPS id 7C19327167 for ; Fri, 7 May 2021 08:28:59 -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 54A811B00CC7; Fri, 7 May 2021 15:28:58 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1620390538; 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=2LEiEnoIaL76Qnx4PC/b0dUW0Aii4Yhvq7GGizsWvaY=; b=JcmDDmMtNYzKNfLgq99hxC6G+D+eu2knxosSXVfkZYEFLU4RU+djAbcrG3TvfB3uBwpC1E 4HO/Gsd/a3toKprhn4vHr7aX2chJVhBU8uiQDpwcI5Hk8eLObIW3rFRYrWHn0VtRHAOFQS PA+pRGeXvnKN81DQP2UnZ2n0NL2O6nrOuN8yFvl7KtXNzeVapdx8XA8Ww58Zzd9f7xujG/ ItpsE8a1+9f4H184dH/jmvdPhNBo2w+3t76MLKTtkRVQ9Tf0bch5oLpByvm0bzOYe19jWK V6GV/Y444kzef5ULsUKLV/rw+vA+sHqD6vKZweraE4qOsvpfCG9mVMhkTwjaZQ== 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: <20210507113029.2685184-3-david@tethera.net> 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=1620390538; 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=2LEiEnoIaL76Qnx4PC/b0dUW0Aii4Yhvq7GGizsWvaY=; b=AjGeHgplZAbNCLOvCp0jHBVUGgC7CAadRQeHNJI3T0IZZWjAHYKOycGDy2VAhyzDR6RW42 N5nsoM1SBt+90I7ghhZVpKqjgPD/87dGLuKGeZxknqySm8GYo3/1sxb1ZB8CQp5Ab9lcaI k3N0yfiBEBahmWXYHPZQn+6mpbZGu8hScTSBb9lDy/2pBAtFK9R1VTHVb5Ja6o2QGVkWFy IqEx8xsOO4Q0ppEWOTIQl843XNEHj/4e+ZrMXuWqFSdQGDrOJ6DP8wnWSBgdFTwHBxTXoJ FoHntX3eUKoates3ozHMj0fO1oCtRquPt1wZdqwGklkUWqZl+cghGTcwx6Ol8A== 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=1620390538; a=rsa-sha256; cv=none; b=NiumQxI3ijXonpm7xyxWmQjPebn1crxd2nY8mPUn/8EsVa68xDbBgC3IxcLFZCNmAJPj91 h+IcpT6b1tSqYBDVd+JO1/2veFjfe6lhwR7pJp0JBST8gYsoDEwnn1XeMTIlNQ5VnT72NR BAMtjSCUtQpgow4LtHCxQoh8gyoyzmL5gl3Z0pruCm/iqEsjj0sEjoKpjFjjpjISPaY47G LBXPSRd4pJmlhey874FgpEZyynlq/6ZiMYVA0kJCE2NeBvexu4YLHJCaCtLLIAn2m8fXCK Ti2E1vJIOQM06vZuYdjgLGySwhqGbWel++QycYdbJi2xL0L5v6mcXweGjUSdTg== Message-ID-Hash: ZPP4CUMXVNKRJS7SMWFWX3Q6WB6IYEA2 X-Message-ID-Hash: ZPP4CUMXVNKRJS7SMWFWX3Q6WB6IYEA2 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=1620390546; 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=QOyTSlWgyJjuSbDIY+M5AP3BRU/pOFh6BzkWWb9/qDA=; b=MD6+ULRDyiefF74B89LczsT42CePf7QRuQ9bIgX0V+gucK+lo4pbSTBeQ9YYGZU9oIf0TF HXhXmlZ2Y75m08q0U+WKSgYA5VuvzJ2sEm5NklG0UyvWQ0GU9Vgy929g9b3CY/82R1l5FH YCri4hDKQLn74ZPohRxniwnRrs7m8pSEZ4ozIXShkrV3U9AwCCR7BPpnyiOGnMMsSLImeH MjS13xGi4t14adxI8Xz+9jhlSBOPsU7YthAmTxxM40loktVvgIt8v8o9SfuR201kYsKAY+ xjvAIlKWG04l9GA75A2lpXfGGa3HMMdOXevJbcn7IH169gJI+Rnkdkt8uKwtaQ== ARC-Seal: i=2; s=key1; d=yhetil.org; t=1620390546; a=rsa-sha256; cv=fail; b=iBoYqoRIilHh6QY/C05QiEPfPaRw4ryS81IXKSNZLGyHaaQg6cA7+CgwzfMfj7LjpD/q4n rThpgNZ1eXxStaDUQofMJEG0dmRGCY9CjvG0LtqRGUHg4ap5/WgfqQuoGVPdLLMJCnSWqx alhYz71nQczR5T+U2f7X9nKrVBukM1LABM5DQyiJvf+ahvFiJMsgLU28US+y5kWdo/KP+Z w7+MspWFqNJoEGjC8MDZMCyu37mXqjrdk4IgIaDTUlfzXV/rvo6/TN+PgITzqm0v8/IQBV o0qIeN4iSqb9gFmQTBJVXlESCA2GANbJXUC+8U2ldQanPwGdm+I7NT/ZLr12pA== ARC-Authentication-Results: i=2; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=iki.fi header.s=lahtoruutu header.b=JcmDDmMt; arc=reject ("signature check failed: fail, {[1] = sig:iki.fi:reject}"); 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=JcmDDmMt; 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: 380A614045 X-Spam-Score: 3.42 X-Migadu-Scanner: scn0.migadu.com X-TUID: q2OWOWNycqWZ 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... > + 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