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

[BUG] gpg modules crash/fail when GNUPGHOME does not exist #66312

Closed
lkubb opened this issue Apr 4, 2024 · 0 comments · Fixed by #66316
Closed

[BUG] gpg modules crash/fail when GNUPGHOME does not exist #66312

lkubb opened this issue Apr 4, 2024 · 0 comments · Fixed by #66316
Labels
Bug broken, incorrect, or confusing behavior
Milestone

Comments

@lkubb
Copy link
Contributor

lkubb commented Apr 4, 2024

Description
The gpg execution module crashes when GNUPGHOME does not exist (which also makes the state module fail).

Note: When invoking the gpg binary, it does work if the parent directory exists.

Setup
Irrelevant

Steps to Reproduce the behavior

  • salt-call gpg.list_keys gnupghome=/tmp/tmpgnu

Expected behavior
Returns an empty list.

Screenshots

Traceback (most recent call last):
  File "/bin/salt-call", line 11, in <module>
    sys.exit(salt_call())
  File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/scripts.py", line 443, in salt_call
    client.run()
  File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/cli/call.py", line 50, in run
    caller.run()
  File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/cli/caller.py", line 95, in run
    ret = self.call()
  File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/cli/caller.py", line 202, in call
    ret["return"] = self.minion.executors[fname](
  File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/loader/lazy.py", line 159, in __call__
    ret = self.loader.run(run_func, *args, **kwargs)
  File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/loader/lazy.py", line 1251, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/loader/lazy.py", line 1266, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/executors/direct_call.py", line 10, in execute
    return func(*args, **kwargs)
  File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/loader/lazy.py", line 159, in __call__
    ret = self.loader.run(run_func, *args, **kwargs)
  File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/loader/lazy.py", line 1251, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/loader/lazy.py", line 1266, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/gpg.py", line 284, in list_keys
    for _key in _list_keys(user, gnupghome):
  File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/gpg.py", line 196, in _list_keys
    gpg = _create_gpg(user, gnupghome)
  File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/gpg.py", line 187, in _create_gpg
    gpg = gnupg.GPG(gnupghome=gnupghome)
  File "/opt/saltstack/salt/extras-3.10/gnupg.py", line 854, in __init__
    raise ValueError('gnupghome should be a directory (it isn\'t): %s' % gnupghome)
ValueError: gnupghome should be a directory (it isn't): /tmp/tmpgnu

Versions Report

salt --versions-report (Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)
Salt Version:
          Salt: 3006.7

Python Version:
        Python: 3.10.13 (main, Feb 19 2024, 03:31:20) [GCC 11.2.0]

Dependency Versions:
          cffi: 1.14.6
      cherrypy: unknown
      dateutil: 2.8.1
     docker-py: Not Installed
         gitdb: 4.0.11
     gitpython: 3.1.42
        Jinja2: 3.1.3
       libgit2: Not Installed
  looseversion: 1.0.2
      M2Crypto: Not Installed
          Mako: Not Installed
       msgpack: 1.0.2
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     packaging: 22.0
     pycparser: 2.21
      pycrypto: Not Installed
  pycryptodome: 3.19.1
        pygit2: Not Installed
  python-gnupg: 0.4.8
        PyYAML: 6.0.1
         PyZMQ: 23.2.0
        relenv: 0.15.1
         smmap: 5.0.1
       timelib: 0.2.4
       Tornado: 4.5.3
           ZMQ: 4.3.4

System Versions:
          dist: rocky 9.3 Blue Onyx
        locale: utf-8
       machine: x86_64
       release: 5.14.0-362.13.1.el9_3.x86_64
        system: Linux
       version: Rocky Linux 9.3 Blue Onyx

Additional context
I will submit a PR

@lkubb lkubb added Bug broken, incorrect, or confusing behavior needs-triage labels Apr 4, 2024
@dwoz dwoz removed the needs-triage label Apr 10, 2024
@dwoz dwoz added this to the Argon v3008.0 milestone Apr 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug broken, incorrect, or confusing behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants