saltstack / saltstack/salt

[BUG] macOS: cmd.run env variables doesn't work when running with runas argument

Open
#66,285 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug needs-triage
Dominant language
Python
Stars
15.7k
Forks
5.6k
Avg merge
2d 44m
Merged PRs (30d)
80

Description

Description
cmd.run environment variables doesn't work with runas

Setup

  • on-prem machine

salt master runs on linux machine. minion runs on macOS 14.3.1 machine and uses minion release 3006.6. Master probably doesn't matter here.

Steps to Reproduce the behavior

/home/salt# salt 'mac' cmd.run 'echo $HELLO' env='{"HELLO": "there"}' runas='me'
mac:
/home/salt# salt 'mac' cmd.run 'echo $HELLO' env='{"HELLO": "there"}'           
mac:
    there

/home/salt# salt 'nuc' cmd.run 'echo $HELLO' env='{"HELLO": "there"}'
nuc:
    there
/home/salt# salt 'nuc' cmd.run 'echo $HELLO' env='{"HELLO": "there"}' runas='ubuntu'
nuc:
    there

same happens when running with sls file.

Expected behavior

cmd.run works same way than in linux regardless runas usage.

Versions Report

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

MINION

mac11:
    Salt Version:
              Salt: 3006.6
     
    Python Version:
            Python: 3.10.13 (main, Nov 15 2023, 04:31:50) [Clang 14.0.3 (clang-1403.0.22.14.1)]
     
    Dependency Versions:
              cffi: 1.14.6
          cherrypy: unknown
          dateutil: 2.8.0
         docker-py: Not Installed
             gitdb: 4.0.7
         gitpython: 3.1.41
            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.14.2
             smmap: 4.0.0
           timelib: 0.2.4
           Tornado: 4.5.3
               ZMQ: 4.3.4
     
    System Versions:
              dist: darwin 23.3.0 
            locale: utf-8
           machine: arm64
           release: 23.3.0
            system: Darwin
           version: 14.3.1 arm64

MASTER

# salt --versions-report
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.16.0
      cherrypy: unknown
      dateutil: 2.8.1
     docker-py: Not Installed
         gitdb: Not Installed
     gitpython: Not Installed
        Jinja2: 3.1.3
       libgit2: 1.7.2
  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: 1.14.1
  python-gnupg: 0.4.8
        PyYAML: 6.0.1
         PyZMQ: 23.2.0
        relenv: 0.15.1
         smmap: Not Installed
       timelib: 0.2.4
       Tornado: 4.5.3
           ZMQ: 4.3.4
 
System Versions:
          dist: ubuntu 22.04.3 jammy
        locale: utf-8
       machine: x86_64
       release: 6.5.0-1014-aws
        system: Linux
       version: Ubuntu 22.04.3 jammy

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the cmd.run entry point and reproduce the macOS case with env and runas, then compare it with the working Linux and no-runas cases. Check the related sls-file behavior as well; done means the HELLO variable is available on macOS when cmd.run uses runas, with regression coverage for the reported command.

Written by the indexing model from the issue text.

Assessment

Tech stack
macos, python
Domain
backend, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.