Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

securesystemslib.gpg cannot handle absolute paths on Windows #517

Open
lukpueh opened this issue Feb 20, 2023 · 0 comments
Open

securesystemslib.gpg cannot handle absolute paths on Windows #517

lukpueh opened this issue Feb 20, 2023 · 0 comments

Comments

@lukpueh
Copy link
Member

lukpueh commented Feb 20, 2023

When passing an absolute path as homedir argument to create_signature or export_pubkey in securesystemslib.gpg.functions on Windows, gpg seems to treat it as relative path and prepends it with cwd:

Python 3.11.2 (tags/v3.11.2:878ead1, Feb  7 2023, 16:38:35) [MSC v.1934 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> import securesystemslib.gpg.functions as gpg
>>> gnupg_home = os.path.realpath("rsa")
>>> gnupg_home
'D:\\a\\securesystemslib\\securesystemslib\\tests\\gpg_keyrings\\rsa'
>>> gpg.create_signature(b"data", homedir=gnupg_home)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\a\securesystemslib\securesystemslib\securesystemslib\gpg\functions.py", line 141, in create_signature
    raise CommandError(
securesystemslib.gpg.exceptions.CommandError: Command '['gpg', '--detach-sign', '--digest-algo', 'SHA256', '--homedir', 'D:/a/securesystemslib/securesystemslib/tests/gpg_keyrings/rsa']' returned non-zero exit status '2', stderr was:
gpg: keyblock resource '/d/a/securesystemslib/securesystemslib/tests/gpg_keyrings/D:/a/securesystemslib/securesystemslib/tests/gpg_keyrings/rsa/pubring.kbx': No such file or directory
gpg: failed to create temporary file '/d/a/securesystemslib/securesystemslib/tests/gpg_keyrings/D:/a/securesystemslib/securesystemslib/tests/gpg_keyrings/rsa/.#lk0x0000000a0000b3a0.fv-az89-415.1589': No such file or directory
gpg: can't connect to the agent: No such file or directory
gpg: no default secret key: No secret key
gpg: signing failed: No secret key
.

It works as expected, when passing a relative path:

# ... continued from above
>>> gpg.create_signature(b"data", homedir="rsa")
{'keyid': 'c5a0abe6ec19d0d65f85e2c39be9df5131d924e9', 'other_headers': '040001...', 'signature': 'b2c4f4...'}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant