[BUG] match.glob ignores minion_id parameter
Description A signing policy for x509.sign_remote_certificate can be restricted to specific minions by glob. When a minion tries to use that signing policy, the given glob is checked against the CA's minion id instead of the requestin minions'.
A simple workaround for the problem is to use compound matches instead.
Steps to Reproduce the behavior
# cat /etc/salt/minion_id
salt1
# salt-call --local match.glob "foo*" minion_id="foo-minion"
local:
False
# salt-call --local match.glob "salt*" minion_id="foo-minion"
local:
True
Expected behavior The result of match.glob checks given glob against minion_id parameter if present.
Versions Report The relevant code seems to be unchanged in later version.
Salt Version:
Salt: 2019.2.2
Dependency Versions:
cffi: Not Installed
cherrypy: Not Installed
dateutil: Not Installed
docker-py: Not Installed
gitdb: Not Installed
gitpython: Not Installed
ioflo: Not Installed
Jinja2: 2.8.1
libgit2: Not Installed
libnacl: Not Installed
M2Crypto: 0.33.0
Mako: Not Installed
msgpack-pure: Not Installed
msgpack-python: 0.5.6
mysql-python: Not Installed
pycparser: Not Installed
pycrypto: 2.6.1
pycryptodome: Not Installed
pygit2: Not Installed
Python: 3.6.8 (default, Aug 7 2019, 08:02:28)
python-gnupg: 0.4.4
PyYAML: 3.12
PyZMQ: 15.3.0
RAET: Not Installed
smmap: Not Installed
timelib: Not Installed
Tornado: 4.4.2
ZMQ: 4.1.4
System Versions:
dist: oracle 7.7
locale: UTF-8
machine: x86_64
release: 4.1.12-124.33.4.el7uek.x86_64
system: Linux
version: Oracle Linux Server 7.7
Additional context At first glance, the error is in modules/match.py (only relevant lines copied):
if minion_id is not None:
opts = copy.copy(__opts__)
opts['id'] = minion_id
return matchers['glob_match.match'](tgt, opts=__opts__)
But I have not checked if a change here leads to unwanted behaviour elsewhere.
I can verify this bug. No matter what I put in minion_id it always grabs the ID from config.
root@salt:/home/salt/conf/# salt-call --local match.glob gluster-1 gluster-1
local:
False
Has regressed since 2018.3.5.
This was fixed here: bf3110a0b5e86233c89c607a2fbecc4447c3d753 from this PR https://github.com/saltstack/salt/pull/57441
which was included in v3001