From patchwork Sat Jan 1 19:49:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Huntwork X-Patchwork-Id: 2003 Return-Path: Delivered-To: patchwork@archlinux.org Received: from mail.archlinux.org [2a01:4f9:c010:3052::1] by patchwork.archlinux.org with IMAP (fetchmail-6.4.25) for (single-drop); Sat, 01 Jan 2022 19:50:08 +0000 (UTC) Received: from mail.archlinux.org by mail.archlinux.org with LMTP id mPjSMm+w0GHmqgcAK+/4rw (envelope-from ) for ; Sat, 01 Jan 2022 19:50:07 +0000 Received: from lists.archlinux.org (lists.archlinux.org [IPv6:2a01:4f9:c010:9eb4::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.archlinux.org (Postfix) with ESMTPS id 038CCBD5DB2; Sat, 1 Jan 2022 19:50:07 +0000 (UTC) Received: from lists.archlinux.org (localhost [IPv6:::1]) by lists.archlinux.org (Postfix) with ESMTP id B25F2B5DEE6; Sat, 1 Jan 2022 19:50:03 +0000 (UTC) X-Original-To: pacman-dev@lists.archlinux.org Delivered-To: pacman-dev@lists.archlinux.org Received: from mail-qv1-xf2c.google.com (mail-qv1-xf2c.google.com [IPv6:2607:f8b0:4864:20::f2c]) by lists.archlinux.org (Postfix) with ESMTPS id F3A1CB5DECB for ; Sat, 1 Jan 2022 19:50:01 +0000 (UTC) Received: by mail-qv1-xf2c.google.com with SMTP id fo11so27424942qvb.4 for ; Sat, 01 Jan 2022 11:50:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=merelinux-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=MN9gaagFS9pj08te14LcibIWQ+TywSJd8d85ZwzHOIs=; b=ietK6z1dTOklScPxzFUUT2I3VgLAcVHklYliqiRDwvn8w04gpwGzpWgfAL38whKyBy FPOaow2G0jMKAMVDwJqbQ9nx4XFf9F/FdHhchVN5MeEPvI2Y3lhYVQXiZ/XCNkLXU2KA F7X+ofN0RghSKjuWnTJnI/XusAvXGG81YIf9wYv5tiwQzf+I0F822AWG+6d2+O27LJA6 u7whTjsTXOkeIuGmcX2EKCsVbzdofx9OLq3oylktMkEsCHT80nH9+0jAA+iA97F8iUrG DrxGGN3f+RW+v6CbKXlybcszmb/5UrQBWNLNQ8jZzwNVyEJzVQNqWN9HOFBlCao7vAjE R0KA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MN9gaagFS9pj08te14LcibIWQ+TywSJd8d85ZwzHOIs=; b=AM66yu42Q2GPW6A7XGDjjbPmWgu7DfkUuy4DzKB1BAs8No6roYpPCN2kaARRTGssJF IyUOP7D1QH97gxG/cOL4mrgbgcxlICRq4alNJFibwqOnxpuPSd29a8qlG1AxbHRg9yHo rcm3Gtzftaw+nQtnA+pqCAc9fQp43eqF29H/5KbOKZ5DIH1nPHsx3BpkmcIwLZt83xNs i2VcssLFnVJZK2Gtg2Jg8aaGwPuX7f45l/6O2jw5SYk/evD8I2fZt2pIc6EiPS3hofO8 j7ud+PdE5fneeoy73BxyUjaot8wF0L6BZNTr/jADcJD86oqYBTQeTAZmD+o/lrl+Kz5j yNlA== X-Gm-Message-State: AOAM532ZMgqDpTQxd28pJo9/NduuC+0up3mF0gAhp5zGG8rZ/dQbfHeC fQNJD1p7L5k+W7JC9lYU/UTWa5Ny9hEFqVt5 X-Google-Smtp-Source: ABdhPJyyjiKJicC1s18Rw23ZBpfgRlLLFgsoaGFKHzusWvLv07GLNqmnXcupqZGt792qyctw+KYvoA== X-Received: by 2002:ad4:596b:: with SMTP id eq11mr13330395qvb.16.1641066600334; Sat, 01 Jan 2022 11:50:00 -0800 (PST) Received: from localhost.localdomain ([208.74.141.240]) by smtp.gmail.com with ESMTPSA id s3sm24743353qkp.93.2022.01.01.11.49.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Jan 2022 11:49:59 -0800 (PST) From: Jeremy Huntwork To: pacman-dev@lists.archlinux.org Cc: Jeremy Huntwork Subject: [PATCH 2/4] Add a configuration option for asignify's key dir Date: Sat, 1 Jan 2022 14:49:32 -0500 Message-Id: <20220101194934.8229-3-jeremy@merelinux.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220101194934.8229-1-jeremy@merelinux.org> References: <20220101194934.8229-1-jeremy@merelinux.org> MIME-Version: 1.0 X-BeenThere: pacman-dev@lists.archlinux.org X-Mailman-Version: 2.1.39 Precedence: list List-Id: Discussion list for pacman development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: pacman-dev-bounces@lists.archlinux.org Sender: "pacman-dev" Authentication-Results: mail.archlinux.org; dkim=pass header.d=merelinux-org.20210112.gappssmtp.com header.s=20210112 header.b=ietK6z1d; dmarc=none; spf=pass (mail.archlinux.org: domain of pacman-dev-bounces@lists.archlinux.org designates 2a01:4f9:c010:9eb4::1 as permitted sender) smtp.mailfrom=pacman-dev-bounces@lists.archlinux.org X-Rspamd-Queue-Id: 038CCBD5DB2 X-Spamd-Result: default: False [-3.91 / 15.00]; REPLY(-4.00)[]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; RCVD_DKIM_ARC_DNSWL_MED(-0.50)[]; MAILLIST(-0.20)[mailman]; R_DKIM_ALLOW(-0.20)[merelinux-org.20210112.gappssmtp.com:s=20210112]; RCVD_IN_DNSWL_MED(-0.20)[2a01:4f9:c010:9eb4::1:from]; R_SPF_ALLOW(-0.20)[+ip6:2a01:4f9:c010:9eb4::1:c]; MIME_GOOD(-0.10)[text/plain]; HAS_LIST_UNSUB(-0.01)[]; DMARC_NA(0.00)[merelinux.org]; FROM_HAS_DN(0.00)[]; RCVD_COUNT_FIVE(0.00)[5]; RCVD_IN_DNSWL_NONE(0.00)[2607:f8b0:4864:20::f2c:received]; PREVIOUSLY_DELIVERED(0.00)[pacman-dev@lists.archlinux.org]; RCVD_VIA_SMTP_AUTH(0.00)[]; ASN(0.00)[asn:24940, ipnet:2a01:4f9::/32, country:DE]; FROM_NEQ_ENVFROM(0.00)[jeremy@merelinux.org,pacman-dev-bounces@lists.archlinux.org]; RCPT_COUNT_TWO(0.00)[2]; DKIM_TRACE(0.00)[merelinux-org.20210112.gappssmtp.com:+]; TO_DN_SOME(0.00)[]; ARC_NA(0.00)[]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; RCVD_TLS_LAST(0.00)[]; MIME_TRACE(0.00)[0:+]; NEURAL_HAM(-0.00)[-1.000]; FORGED_SENDER_MAILLIST(0.00)[] X-Rspamd-Server: mail.archlinux.org Following the pattern used by gpgdir, set asignifydir to the location where libasignify will look for and load public keys. Since the intent is to only support one signature method at a time, wrap the `--gpgdir` and `--asignifydir` flags in ifdef blocks. Signed-off-by: Jeremy Huntwork --- src/pacman/conf.c | 16 ++++++++++++++++ src/pacman/conf.h | 2 ++ src/pacman/pacman.c | 40 ++++++++++++++++++++++++++++++++-------- 3 files changed, 50 insertions(+), 8 deletions(-) diff --git a/src/pacman/conf.c b/src/pacman/conf.c index 7d0bc2f8..7fe9107b 100644 --- a/src/pacman/conf.c +++ b/src/pacman/conf.c @@ -155,6 +155,7 @@ int config_free(config_t *oldconfig) free(oldconfig->dbpath); free(oldconfig->logfile); free(oldconfig->gpgdir); + free(oldconfig->asignifydir); FREELIST(oldconfig->hookdirs); FREELIST(oldconfig->cachedirs); free(oldconfig->xfercommand); @@ -663,6 +664,11 @@ static int _parse_options(const char *key, char *value, config->gpgdir = strdup(value); pm_printf(ALPM_LOG_DEBUG, "config: gpgdir: %s\n", value); } + } else if(strcmp(key, "AsignifyDir") == 0) { + if(!config->asignifydir) { + config->asignifydir = strdup(value); + pm_printf(ALPM_LOG_DEBUG, "config: asignifydir: %s\n", value); + } } else if(strcmp(key, "LogFile") == 0) { if(!config->logfile) { config->logfile = strdup(value); @@ -871,6 +877,15 @@ static int setup_libalpm(void) return ret; } + /* Set asignify's trusted keys directory. This is not relative to rootdir, even if + * rootdir is defined. Reasoning: asignifydir contains configuration data. */ + ret = alpm_option_set_asignifydir(handle, config->asignifydir); + if(ret != 0) { + pm_printf(ALPM_LOG_ERROR, _("problem setting asignifydir '%s' (%s)\n"), + config->asignifydir, alpm_strerror(alpm_errno(handle))); + return ret; + } + /* Set user hook directory. This is not relative to rootdir, even if * rootdir is defined. Reasoning: hookdir contains configuration data. */ /* add hook directories 1-by-1 to avoid overwriting the system directory */ @@ -1152,6 +1167,7 @@ int setdefaults(config_t *c) SETDEFAULT(c->logfile, strdup(LOGFILE)); SETDEFAULT(c->gpgdir, strdup(GPGDIR)); + SETDEFAULT(c->asignifydir, strdup(ASIGNIFYDIR)); SETDEFAULT(c->cachedirs, alpm_list_add(NULL, strdup(CACHEDIR))); SETDEFAULT(c->hookdirs, alpm_list_add(NULL, strdup(HOOKDIR))); SETDEFAULT(c->cleanmethod, PM_CLEAN_KEEPINST); diff --git a/src/pacman/conf.h b/src/pacman/conf.h index a7162983..fb919b76 100644 --- a/src/pacman/conf.h +++ b/src/pacman/conf.h @@ -66,6 +66,7 @@ typedef struct __config_t { char *dbpath; char *logfile; char *gpgdir; + char *asignifydir; char *sysroot; alpm_list_t *hookdirs; alpm_list_t *cachedirs; @@ -173,6 +174,7 @@ enum { OP_ARCH, OP_PRINTFORMAT, OP_GPGDIR, + OP_ASIGNIFYDIR, OP_DBONLY, OP_FORCE, OP_OVERWRITE_FILES, diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index e7f4a10d..a3a2e2f6 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -220,7 +220,13 @@ static void usage(int op, const char * const myname) addlist(_(" --color colorize the output\n")); addlist(_(" --config set an alternate configuration file\n")); addlist(_(" --debug display debug messages\n")); +#ifdef HAVE_LIBGPGME addlist(_(" --gpgdir set an alternate home directory for GnuPG\n")); +#endif +#ifdef HAVE_LIBASIGNIFY + addlist(_(" --asignifydir \n" + " set an alternate directory for asignify's trusted public keys\n")); +#endif addlist(_(" --logfile set an alternate log file\n")); addlist(_(" --noconfirm do not ask for any confirmation\n")); addlist(_(" --confirm always ask for confirmation\n")); @@ -428,10 +434,18 @@ static int parsearg_global(int opt) /* progress bars get wonky with debug on, shut them off */ config->noprogressbar = 1; break; +#ifdef HAVE_LIBGPGME case OP_GPGDIR: free(config->gpgdir); config->gpgdir = strdup(optarg); break; +#endif +#ifdef HAVE_LIBASIGNIFY + case OP_ASIGNIFYDIR: + free(config->asignifydir); + config->asignifydir = strdup(optarg); + break; +#endif case OP_HOOKDIR: config->hookdirs = alpm_list_add(config->hookdirs, strdup(optarg)); break; @@ -944,7 +958,12 @@ static int parseargs(int argc, char *argv[]) {"asexplicit", no_argument, 0, OP_ASEXPLICIT}, {"arch", required_argument, 0, OP_ARCH}, {"print-format", required_argument, 0, OP_PRINTFORMAT}, +#ifdef HAVE_LIBGPGME {"gpgdir", required_argument, 0, OP_GPGDIR}, +#endif +#ifdef HAVE_LIBASIGNIFY + {"asignifydir", required_argument, 0, OP_ASIGNIFYDIR}, +#endif {"dbonly", no_argument, 0, OP_DBONLY}, {"color", required_argument, 0, OP_COLOR}, {"disable-download-timeout", no_argument, 0, OP_DISABLEDLTIMEOUT}, @@ -1217,22 +1236,27 @@ int main(int argc, char *argv[]) if(config->verbose > 0) { alpm_list_t *j; - printf("Root : %s\n", alpm_option_get_root(config->handle)); - printf("Conf File : %s\n", config->configfile); - printf("DB Path : %s\n", alpm_option_get_dbpath(config->handle)); - printf("Cache Dirs: "); + printf("Root : %s\n", alpm_option_get_root(config->handle)); + printf("Conf File : %s\n", config->configfile); + printf("DB Path : %s\n", alpm_option_get_dbpath(config->handle)); + printf("Cache Dirs : "); for(j = alpm_option_get_cachedirs(config->handle); j; j = alpm_list_next(j)) { printf("%s ", (const char *)j->data); } printf("\n"); - printf("Hook Dirs : "); + printf("Hook Dirs : "); for(j = alpm_option_get_hookdirs(config->handle); j; j = alpm_list_next(j)) { printf("%s ", (const char *)j->data); } printf("\n"); - printf("Lock File : %s\n", alpm_option_get_lockfile(config->handle)); - printf("Log File : %s\n", alpm_option_get_logfile(config->handle)); - printf("GPG Dir : %s\n", alpm_option_get_gpgdir(config->handle)); + printf("Lock File : %s\n", alpm_option_get_lockfile(config->handle)); + printf("Log File : %s\n", alpm_option_get_logfile(config->handle)); +#ifdef HAVE_LIBGPGME + printf("GPG Dir : %s\n", alpm_option_get_gpgdir(config->handle)); +#endif +#ifdef HAVE_LIBASIGNIFY + printf("Asignify Dir: %s\n", alpm_option_get_asignifydir(config->handle)); +#endif list_display("Targets :", pm_targets, 0); }