salt icon indicating copy to clipboard operation
salt copied to clipboard

[Bug]: cmd.run doesn't handle wildcards anymore? after upgrade 3006.14 -> 3006.15

Open dudleyperkins opened this issue 1 year ago • 2 comments

What happened?

At first i thought it was a permission problem, but it's actually just the wildcard that causes a problem. I did not see anything in the 3006.15-changelog that could have caused this. Maybe someone here can explain what's happening.

execute on the master (3006.15) with a minion (3006.15):

root@master:~# salt 'host' cmd.run 'ls -l /boot/'
host:
    total 76892
    -rw-r--r-- 1 root root       83 May 22 20:32 System.map-6.1.0-37-amd64
    -rw-r--r-- 1 root root       83 Aug  2 15:13 System.map-6.1.0-38-amd64
    -rw-r--r-- 1 root root   259612 May 22 20:32 config-6.1.0-37-amd64
    -rw-r--r-- 1 root root   259557 Aug  2 15:13 config-6.1.0-38-amd64
    drwxr-xr-x 5 root root     4096 Aug 13 08:55 grub
    -rw-r--r-- 1 root root 30911784 May 30 10:29 initrd.img-6.1.0-37-amd64
    -rw-r--r-- 1 root root 30879274 Aug 13 08:53 initrd.img-6.1.0-38-amd64
    -rw-r--r-- 1 root root  8193984 May 22 20:32 vmlinuz-6.1.0-37-amd64
    -rw-r--r-- 1 root root  8206272 Aug  2 15:13 vmlinuz-6.1.0-38-amd64

root@master:~# salt 'host' cmd.run 'ls -l /boot/vmlinuz-6.1.0-37-amd64'
host:
    -rw-r--r-- 1 root root 8193984 May 22 20:32 /boot/vmlinuz-6.1.0-37-amd64

root@master:~# salt 'host' cmd.run '"ls -l /boot/vmlinuz*"'
host:
    ls: cannot access '/boot/vmlinuz*': No such file or directory

execute on the master (3006.15) with a minion (3006.14), the first two commands with the same result, but also the last one ist successful:

root@master:~# salt 'host2' cmd.run 'ls -l /boot/vmlinuz*'
host2:
    -rw-r--r-- 1 root root 8193984 May 22 20:32 /boot/vmlinuz-6.1.0-37-amd64
    -rw-r--r-- 1 root root 8206272 Aug  2 15:13 /boot/vmlinuz-6.1.0-38-amd64

I was hoping the behaviour would be the same on the newest version - bug or feature ;-)?

Type of salt install

Official deb

Major version

3006.x

What supported OS are you seeing the problem on? Can select multiple. (If bug appears on an unsupported OS, please open a GitHub Discussion instead)

debian-12

salt --versions-report output

Salt Version:
          Salt: 3006.15

Python Version:
        Python: 3.10.18 (main, Aug 27 2025, 22:35:38) [GCC 11.2.0]

Dependency Versions:
          cffi: 1.14.6
      cherrypy: 18.10.0
  cryptography: 42.0.5
      dateutil: 2.8.1
     docker-py: Not Installed
         gitdb: Not Installed
     gitpython: Not Installed
        Jinja2: 3.1.6
       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: 24.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.20.5
         smmap: Not Installed
       timelib: 0.3.0
       Tornado: 4.5.3
           ZMQ: 4.3.4

System Versions:
          dist: debian 12 bookworm
        locale: utf-8
       machine: x86_64
       release: 6.1.0-38-amd64
        system: Linux
       version: Debian GNU/Linux 12 bookworm

dudleyperkins avatar Sep 01 '25 14:09 dudleyperkins

This is related to the cmd execution module change disabling shell functionality by default. See #68156

Running cmd.shell or using the parameters python_shell/ shell when running cmd.run will work instead. This also applies if other shell features like pipes and variables are required.

xsmile avatar Sep 01 '25 20:09 xsmile

Aah thank you. Didn't look further into that PR cause it sayed "...for windows".

With cmd.shell everything tested so far is working. So i will stick to cmd.shell from now on.

And i would say this isn't a bug and close this.

dudleyperkins avatar Sep 02 '25 09:09 dudleyperkins