From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id Rm8/Bv6xTWEHeQEAgWs5BA (envelope-from ) for ; Fri, 24 Sep 2021 13:09:50 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id sNhcAf6xTWGgQAAAB5/wlQ (envelope-from ) for ; Fri, 24 Sep 2021 11:09:50 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 9ECDB3492E for ; Fri, 24 Sep 2021 13:09:49 +0200 (CEST) Received: from localhost ([::1]:51312 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mTj5Q-00039I-RS for larch@yhetil.org; Fri, 24 Sep 2021 07:09:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58842) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mTj1m-0006yg-Ud for guix-patches@gnu.org; Fri, 24 Sep 2021 07:06:06 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:45229) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mTj1m-00055O-Mq for guix-patches@gnu.org; Fri, 24 Sep 2021 07:06:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mTj1m-0002PJ-HR for guix-patches@gnu.org; Fri, 24 Sep 2021 07:06:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#50751] [PATCH 1/2] gnu: python-trezor-agent: Fix key generation with trezor-gpg init References: <20210923083045.10372-1-attila@lendvai.name> In-Reply-To: <20210923083045.10372-1-attila@lendvai.name> Resent-From: Attila Lendvai Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 24 Sep 2021 11:06:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 50751 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 50751@debbugs.gnu.org Cc: Attila Lendvai Received: via spool by 50751-submit@debbugs.gnu.org id=B50751.16324815379196 (code B ref 50751); Fri, 24 Sep 2021 11:06:02 +0000 Received: (at 50751) by debbugs.gnu.org; 24 Sep 2021 11:05:37 +0000 Received: from localhost ([127.0.0.1]:56771 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mTj1N-0002OF-0n for submit@debbugs.gnu.org; Fri, 24 Sep 2021 07:05:37 -0400 Received: from mail-ed1-f49.google.com ([209.85.208.49]:43955) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mTj1L-0002Ny-Td for 50751@debbugs.gnu.org; Fri, 24 Sep 2021 07:05:36 -0400 Received: by mail-ed1-f49.google.com with SMTP id v10so29999806edj.10 for <50751@debbugs.gnu.org>; Fri, 24 Sep 2021 04:05:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=8xuDM3yq4KiX7RWJDXD0Q9fgM9tNFJSAE34wqtedVNg=; b=F/B48GzJFMCAozMbRRRDejKqKKCb6yOVvmt6rdvR/z8QL8L5ZFhOT6ln2DJbqc22wm BtHONfDpIgvILTy82qFfrN5c6pMPy5Z7ssoIvAdDZ5bk3n3McfASQOciWGDIE8zN4jr5 zzCXFJ3Y5GB2WAuOcoCUOmnbGTDeUbaslfxAHgWTmc+R/1J7qUcNkF0F7C+2dZB8gPIU GwkcG1WcqRyJAKCvUDm1I2yQhAajiC8XLsGEDoYwLY9uGosM1PwqNP9Z2pkLxPABovMX ZtEmNLmj0ooJVHwDEZh7NRowRoxMcTUHUDeYI0JLcAvTQjNYvLw06OG5a5fAtJbH8f8h 4G1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; bh=8xuDM3yq4KiX7RWJDXD0Q9fgM9tNFJSAE34wqtedVNg=; b=bKvc/WbfI7D53qc/6VNFcYhR6RMOe8RezzVeJJzG+suWExrYj4GiRAPSah3diF89J/ QQQo7nkdph5DUfm+rNCtFtszT+km/YEJTIOQEWs7/64qXolOLJyyq5BnaoXXiHHZZEWg qNcuPYEjmzBG9bFZmd9/vgHF8I7Tgwn+PtY9EtyUK2uJ3x8bdSVC7F3cNnoaAqeGWwvR kR6Dpmj90O1uVRgI5KvxBP+J2YK3A9e3I7LeoDPwc27bJRwNSw1DmDqbYwQV9lFWPdmh 3YvAPvuA/VcQMwQ9oi2OA6v5ZmGgKdbz1BwesVyboXLfoqnUtpNJ+TIIkq5Ivf1HAm5j SWgg== X-Gm-Message-State: AOAM531MRq9I9QrLnebCUFZlUAfqQ3DcekKYVlCy0wyANIzxK9om2Vui gjsxhJmbe1dPTSGMwPcT2a2RAIvj0Gg= X-Google-Smtp-Source: ABdhPJx0OKg+TeEdc8A92nnCm5SU564WlJWobYdAuyJDiXqEWQVL0bd5ugk0QWh5e6skI19ys1szRw== X-Received: by 2002:a50:e0c3:: with SMTP id j3mr4316568edl.60.1632481530145; Fri, 24 Sep 2021 04:05:30 -0700 (PDT) Received: from lelap.lan (catv-213-222-131-28.catv.broadband.hu. [213.222.131.28]) by smtp.gmail.com with ESMTPSA id x7sm5495527ede.86.2021.09.24.04.05.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 04:05:28 -0700 (PDT) From: Attila Lendvai Date: Fri, 24 Sep 2021 13:05:05 +0200 Message-Id: <20210924110506.4676-1-attila@lendvai.name> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1632481789; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=8xuDM3yq4KiX7RWJDXD0Q9fgM9tNFJSAE34wqtedVNg=; b=ijN5C236Ie2Nb1CpMVgy9iaSyvA+xpBxGsL61lybPnK6aTd00ojQK0rmk0uL/lOjbHeX5l CdNnLnQBakxP7fJMaK7y1DwL0ERftRvhYywGYWV9ydepkVQg9cAZCT94FpyAmiP/oL6kai KnFUCPaZoogiKVQXAN8ljAD9uDh2zfJ1irADIUMLDfVIbLfb4PRtPai1gTuFllP0s240t5 L9CNmBLt+imrj38/zcjFH2VJwVl7UbJBeLHH+IcKsNKEQCnVpscvYlhoCVbYzsrB70Sf/s pMKjK1/sVZN6aimPw9Co5uL1z3+/B/0XamlfZ7cmnmbMbHc5k/3GsfNb5/Cvfg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1632481789; a=rsa-sha256; cv=none; b=T9xeJ1XTSskTGyyM4ih4Yad3TKKmIArLERuCJbGpLhlgPjVr7PFi0v6M24rXfctGXClGE+ lKVolRMvdNIrEnRXXwilEeUZFrTY9Q0fzNt7SPXKiGvaC5q/m1UWTzzs69D9F8ou1Tb6do FkTe5bbsWNF8bdEaXIU0qvbERJ75gnMddS2BgTIxv4OBeu59UYRiOf6jgz5ajR0hmjimHg 8kLKEzxO5n9MhZw2iVI5ENRDxeygAbz75IfIsaXxqfYtw718LBSHGDF4Q57fBE+mqEwpgq xnEbCz/tCdv9nPHr2rTEil3gCUWe3QlD1KLqKGwZN6acpPhcG2wnmJUKJjLWJQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b="F/B48GzJ"; dmarc=none; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Spam-Score: 3.21 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b="F/B48GzJ"; dmarc=none; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: 9ECDB3492E X-Spam-Score: 3.21 X-Migadu-Scanner: scn1.migadu.com X-TUID: h5pjK1UCZOE+ Someone with a better understanding of the python infrastructure may be able to fix it nicer, but it works. * gnu/packages/finance.scm (trezor-agent): Add comment on why the undoing of the wrapping is done, and also delete the irrelevant sideffect of the now undone wrapping. (python-trezor-agent): Add a patch that changes the python code to handle the argv[0] changed by the wrapping. * gnu/packages/patches/trezor-agent-fix-argv0.patch: New file. --- gnu/packages/finance.scm | 13 +++++++-- .../patches/trezor-agent-fix-argv0.patch | 27 +++++++++++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 gnu/packages/patches/trezor-agent-fix-argv0.patch diff --git a/gnu/packages/finance.scm b/gnu/packages/finance.scm index 9b073541de..a123efe207 100644 --- a/gnu/packages/finance.scm +++ b/gnu/packages/finance.scm @@ -844,7 +844,8 @@ the Monero GUI client.") (commit (string-append "v" version)))) (file-name (git-file-name name version)) (sha256 - (base32 "0q99vbfd3h85s8rnjipnmldixabqmmlk5w9karv6f0rhyi54f4zv")))) + (base32 "0q99vbfd3h85s8rnjipnmldixabqmmlk5w9karv6f0rhyi54f4zv")) + (patches (search-patches "trezor-agent-fix-argv0.patch")))) (build-system python-build-system) (arguments `(#:phases @@ -1089,7 +1090,15 @@ the KeepKey Hardware Wallet.") (add-after 'wrap 'fixup-agent-py (lambda* (#:key inputs outputs #:allow-other-keys) (let* ((out (assoc-ref outputs "out"))) - ;; overwrite the wrapper with the real thing. + ;; The wrap phase also wraps trezor_agent.py (besides the + ;; public facing executable called trezor-agent). We need to + ;; undo that wrapping. The reason this is needed is that the + ;; python easy install generates a toplevel script (?) that + ;; messes with argv[0] and then re-opens the python + ;; module. This fails when the wrapped file is actually a shell + ;; script, not a python file. + (delete-file (string-append out "/bin/.trezor_agent.py-real")) + ;; Overwrite the wrapped one with the real thing. (install-file "./trezor_agent.py" (string-append out "/bin")) #t)))))) diff --git a/gnu/packages/patches/trezor-agent-fix-argv0.patch b/gnu/packages/patches/trezor-agent-fix-argv0.patch new file mode 100644 index 0000000000..9462067cd5 --- /dev/null +++ b/gnu/packages/patches/trezor-agent-fix-argv0.patch @@ -0,0 +1,27 @@ +diff --git a/libagent/gpg/__init__.py b/libagent/gpg/__init__.py +index 3711bc8..67085de 100644 +--- a/libagent/gpg/__init__.py ++++ b/libagent/gpg/__init__.py +@@ -122,15 +122,19 @@ def run_init(device_type, args): + verify_gpg_version() + + # Prepare new GPG home directory for hardware-based identity +- device_name = os.path.basename(sys.argv[0]).rsplit('-', 1)[0] +- log.info('device name: %s', device_name) ++ exe_name = os.path.basename(sys.argv[0]) ++ # drop the Guix wrapper's dot prefix from the name ++ if exe_name[0] == '.' and exe_name.endswith('-real'): ++ exe_name = exe_name[1:-5:] ++ device_name = exe_name.rsplit('-', 1)[0] ++ log.info('exe name: %s, device name: %s', exe_name, device_name) + homedir = args.homedir + if not homedir: + homedir = os.path.expanduser('~/.gnupg/{}'.format(device_name)) + + log.info('GPG home directory: %s', homedir) + +- if os.path.exists(homedir): ++ if os.path.exists(homedir) and not args.subkey: + log.error('GPG home directory %s exists, ' + 'remove it manually if required', homedir) + sys.exit(1) -- 2.33.0