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 do not respect GNUPGHOME from (shell) environment config #66313

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

[BUG] gpg modules do not respect GNUPGHOME from (shell) environment config #66313

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

Comments

@lkubb
Copy link
Contributor

lkubb commented Apr 4, 2024

Description
The gpg modules do not respect a process-specific or (when user is passed) user-set GNUPGHOME env var. The former is always expected, the latter is in contrast to the cmd modules, which keep the user environment intact.

Setup
Irrelevant

Steps to Reproduce the behavior
(for bash, the user issue)

  • echo 'export GNUPGHOME=$HOME/.local/share/gnupg' >> ~/.bashrc
  • exec $SHELL -l
  • mkdir -p $GNUPGHOME && chmod 0700 $GNUPGHOME
  • gpg --receive-key 8ABE4EFCF0F4B24BFF2AAF90D570F2D34EA0793D
  • sudo salt-call gpg.list_keys user=$(whoami)

Expected behavior

local:
    |_
      ----------
      created:
          2014-07-04
      expires:
          2025-03-21
      fingerprint:
          8ABE4EFCF0F4B24BFF2AAF90D570F2D34EA0793D
      keyLength:
          4096
      keyid:
          D570F2D34EA0793D
      ownerTrust:
          Unknown
      trust:
          Unknown
      uids:
          - SaltStack Security Team <security@saltstack.com>

Screenshots
Lists ~/.gnupg (or crashes if it does not exist, see #66312)

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
@lkubb lkubb mentioned this issue Apr 4, 2024
3 tasks
@dwoz dwoz removed the needs-triage label Apr 10, 2024
@OrangeDog
Copy link
Contributor

I would not expect ~/.bashrc to have any effect on general Salt functions at all.
The only environment variables that should be used should be those of the relevant Salt process.

cmd is a messy exception, because people use it with runas expecting it to act exactly as a login shell.

@lkubb
Copy link
Contributor Author

lkubb commented Apr 12, 2024

Imho the same argument can be made for the gpg modules when specifying a user. Agree it's messy, which comes from the unusual requirement of impersonating different users in the same process. Also agree I would not expect ~/.bashrc and friends to influence Salt functions if user was not specified, need to check if my PR accounts for that.

This issue description is too specific btw, GNUPGHOME from the relevant Salt process is currently ignored as well afair. Will update after I confirm.

@lkubb lkubb changed the title [BUG] gpg modules do not respect GNUPGHOME from shell environment config [BUG] gpg modules do not respect GNUPGHOME from (shell) environment config Apr 15, 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.

3 participants