From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:8:6d80::]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id iNErOUcRbWBzHwEAgWs5BA (envelope-from ) for ; Wed, 07 Apr 2021 03:56:23 +0200 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 WDYCM0cRbWBsSQAAbx9fmQ (envelope-from ) for ; Wed, 07 Apr 2021 01:56:23 +0000 Received: from mail.notmuchmail.org (nmbug.tethera.net [IPv6:2607:5300:201:3100::1657]) (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 6D7A114739 for ; Wed, 7 Apr 2021 03:56:23 +0200 (CEST) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id A8F782904E; Tue, 6 Apr 2021 21:55:52 -0400 (EDT) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by mail.notmuchmail.org (Postfix) with ESMTP id 7C84B26A09 for ; Tue, 6 Apr 2021 21:55:41 -0400 (EDT) Received: by fethera.tethera.net (Postfix, from userid 1001) id 6D8E45FA96; Tue, 6 Apr 2021 21:55:41 -0400 (EDT) Received: (nullmailer pid 2964226 invoked by uid 1000); Wed, 07 Apr 2021 01:55:35 -0000 From: David Bremner To: notmuch@notmuchmail.org Cc: David Bremner Subject: [PATCH 10/28] lib/open: canonicalize relative path read from config file Date: Tue, 6 Apr 2021 22:55:12 -0300 Message-Id: <20210407015530.2964017-11-david@tethera.net> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210407015530.2964017-1-david@tethera.net> References: <20210407015530.2964017-1-david@tethera.net> MIME-Version: 1.0 Message-ID-Hash: B7UX7OIS7JCUVRR2N5M2IF6Q42YCS2PE X-Message-ID-Hash: B7UX7OIS7JCUVRR2N5M2IF6Q42YCS2PE 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; 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=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1617760583; 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; bh=ioCYEgwBQTqnr2f64aPF0xps7feBBxvMMvf5wzQL93k=; b=ClXrEzw5A95k3Gzz2n/wzD+aZK+s0oIhIqo5cIX/TtoFeaQDQlZG+IdUSbVO0BRCNvqYye KV4FE8y2X1KVfkqeO6VsxWNKeaZ2A6SrakeIz/rPThUZWCB5WHMcLRfc5LzVCEeSAlsQlB WX6YETiDN7CEeQK6ZUIt8Xej0GaGeD4lSqsMyMAko2/XSaBx8xawaCNxO3ydwMqoiARM/I 2lr41PcYtaBpLTuqmPhsOga1kPYPKF0WcJJ/6mQ+Lvze/9FDw8fibQVfa9QRfdbVbnHcZJ ojhmvj0HMcgpDoOuDuQwEBcXMYd3659jxYII6fvVtHeqAQMSwf7WyIJwrLLKxw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1617760583; a=rsa-sha256; cv=none; b=H33gvL19Z6ioJLS+qYT60Naq/nYLsp1eyGl4fxfH/V+BkGqg4v+uPBQwoW+WznbzYP6NGP zGkJN/EULnE/H3H9gEsKMSnpNKvXy+k04Zpyak4cx4IRiTBr+vXE9iaVZZ4X0xldn1/mGy ylQ4ytq0HerISGvxnLPnhhWulRy/BG/CBDsrYoTG59JPp8DytTobynu4W5hMfXMiadaIwr T0XmB+dIlWpsaMZFWFrRnG/ozDSedG/JdDexgSebUht0xP70gVAFJLMHwJ0s4CVjJNiiSU JIV6gBi9VhsfBlb0H6Ad8C3UM/YQ/Z5G75s/JWEEHaSKXuqGEJ8mDHNjBpeuxQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2607:5300:201:3100::1657 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: 0.02 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2607:5300:201:3100::1657 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: 6D7A114739 X-Spam-Score: 0.02 X-Migadu-Scanner: scn0.migadu.com X-TUID: F2V+1BbDdO3L This matches functionality in the the CLI function notmuch_config_get_database_path, which was previously used in the CLI code for all calls to open a database. --- lib/open.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/open.cc b/lib/open.cc index 6c3ef46f..d0493950 100644 --- a/lib/open.cc +++ b/lib/open.cc @@ -196,11 +196,13 @@ _choose_database_path (void *ctx, if (! *database_path && key_file) { char *path = g_key_file_get_value (key_file, "database", "path", NULL); if (path) { - *database_path = talloc_strdup (ctx, path); + if (path[0] == '/') + *database_path = talloc_strdup (ctx, path); + else + *database_path = talloc_asprintf (ctx, "%s/%s", getenv ("HOME"), path); g_free (path); } } - if (! *database_path) { *database_path = _xdg_dir (ctx, "XDG_DATA_HOME", ".local/share", profile); *split = true; -- 2.30.2