From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:c151::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id 2GZBG4/aQGBvbgAA0tVLHw (envelope-from ) for ; Thu, 04 Mar 2021 13:03:11 +0000 Received: from aspmx2.migadu.com ([2001:41d0:2:c151::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id mGgVF4/aQGC1GgAA1q6Kng (envelope-from ) for ; Thu, 04 Mar 2021 13:03:11 +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)) (No client certificate requested) by aspmx2.migadu.com (Postfix) with ESMTPS id F2F1625788 for ; Thu, 4 Mar 2021 14:03:10 +0100 (CET) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 339FF27573; Thu, 4 Mar 2021 08:02:13 -0500 (EST) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by mail.notmuchmail.org (Postfix) with ESMTP id 18B6C26C4A for ; Thu, 4 Mar 2021 08:01:56 -0500 (EST) Received: by fethera.tethera.net (Postfix, from userid 1001) id 0D6655FA96; Thu, 4 Mar 2021 08:01:55 -0500 (EST) Received: (nullmailer pid 4047181 invoked by uid 1000); Thu, 04 Mar 2021 13:01:45 -0000 From: David Bremner To: notmuch@notmuchmail.org Cc: David Bremner Subject: [PATCH 09/27] lib/open: canonicalize relative path read from config file Date: Thu, 4 Mar 2021 09:01:21 -0400 Message-Id: <20210304130139.4046183-10-david@tethera.net> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210304130139.4046183-1-david@tethera.net> References: <20210304130139.4046183-1-david@tethera.net> MIME-Version: 1.0 Message-ID-Hash: ADB52XINWD5CYYWASUIVKNZSMIH6KOV4 X-Message-ID-Hash: ADB52XINWD5CYYWASUIVKNZSMIH6KOV4 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=1614862991; 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=9zsVUNj+znwR8jOmVR0x1yYCowjzOyZJ9OhTi7ZTeV0=; b=mQQCccAxg82rZQU8ivOPz1csmWb740TztDaBvNAUdTa+wW7IPnkadcY9v8//Mcj57CKQE4 h3Lf8Lgq0butT79VTz1/UIizUtCrEM/2p966Bv55nC6/9K+ORanKnsV1dmx9etNa38Az46 EbQ1W6eskZ9pYZRl8CnS39GK+pgtZXrkj2h5kPUNm55MqSuHuTVX3bt8g8H8ZeL6GOEhZw NH+OQxVvmB5HKYzlqkDm73TVJc1eQeX4Q+1Y27pWOiiiDjS05PiqUhPVSf5M53GEYccVVl gtrHl4gvbWjlSEzqcui/qS1wnemVhtAV9SXu20rPNszTZI0Ri/EFS1jR4S18ig== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1614862991; a=rsa-sha256; cv=none; b=J4yF61j+zOEufgQ9sUnvAUGrcA7zdja+K5ncLc+oIwCCeATidYH+bks2I/b3PR8zx9Fm4b /e7julHxqv2xM6qtoDAEdUPAyskOn3N/kzPV+pisz2hk5l3OSGfGgqDGd06193Qkm/yr6z HBhe8/cnCJISH727nFbWbgeGZBXXhbfB2bHYlmb0IARShhar6WED//jhHQB36zjedTruHv 7vfqChdOxht3dL5igIdF4V/aQl7OjBrzI6wtCIZ383G9SQjWy1Mbw0YpX2d/bChxTb7l33 7uxzbEA25sRk6qMATA3+5In7QhEu5DMgdSopM+mC62aRDZjAyPrwyjsN8ivVgQ== ARC-Authentication-Results: i=1; aspmx2.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx2.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: -0.88 Authentication-Results: aspmx2.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx2.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: F2F1625788 X-Spam-Score: -0.88 X-Migadu-Scanner: scn1.migadu.com X-TUID: Pfn7pLr0Y53c 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 | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/open.cc b/lib/open.cc index 58385592..737e79a7 100644 --- a/lib/open.cc +++ b/lib/open.cc @@ -193,9 +193,16 @@ _choose_database_path (void * ctx, *database_path = getenv ("NOTMUCH_DATABASE"); } - if (! *database_path && key_file) - *database_path = g_key_file_get_value (key_file, "database", "path", NULL); - + if (! *database_path && key_file) { + gchar *path = g_key_file_get_value (key_file, "database", "path", NULL); + if (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.1