Skip to content

[BUG] selinux.port_get_policy ends in exception "AttributeError: 'NoneType' object has no attribute 'group'" #64583

Closed

Description

@dukhat2259

Description
Executing salt-call selinux.port_get_policy tcp/22 in fedora 38 ends in an exception

AttributeError: 'NoneType' object has no attribute 'group'

Works on fedora 37.

Detected while trying to use

policy-port-{{ config.port }}:
  selinux.port_policy_present:
    - sel_type: openvpn_port_t
    - protocol: udp
    - port: {{ config.port }}

Setup
(Please provide relevant configs and/or SLS files (be sure to remove sensitive info. There is no general set-up of Salt.)
Basic minion installation via dnf.

Please be as specific as possible and give set-up details.

  • on-prem machine
  • VM (Virtualbox, KVM, etc. please specify)
  • VM running on a cloud service, please be explicit and add details
  • container (Kubernetes, Docker, containerd, etc. please specify)
  • or a combination, please be explicit
  • jails if it is FreeBSD
  • classic packaging
  • onedir packaging
  • used bootstrap to install

Steps to Reproduce the behavior
Install salt-minion via dnf on fedora 38

# salt-call selinux.port_get_policy tcp/22
/usr/lib/python3.11/site-packages/salt/utils/http.py:8: DeprecationWarning: 'cgi' is deprecated and slated for removal in Python 3.13
  import cgi
/usr/lib/python3.11/site-packages/salt/utils/jinja.py:9: DeprecationWarning: 'pipes' is deprecated and slated for removal in Python 3.13
  import pipes
/usr/lib/python3.11/site-packages/salt/grains/core.py:2701: DeprecationWarning: Use setlocale(), getencoding() and getlocale() instead
  ) = locale.getdefaultlocale()
[INFO    ] Executing command 'semanage' in directory '/root'
[ERROR   ] An un-handled exception was caught by Salt's global exception handler:
AttributeError: 'NoneType' object has no attribute 'group'
Traceback (most recent call last):
  File "/usr/bin/salt-call", line 8, in <module>
    sys.exit(salt_call())
             ^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/salt/scripts.py", line 444, in salt_call
    client.run()
  File "/usr/lib/python3.11/site-packages/salt/cli/call.py", line 50, in run
    caller.run()
  File "/usr/lib/python3.11/site-packages/salt/cli/caller.py", line 95, in run
    ret = self.call()
          ^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/salt/cli/caller.py", line 202, in call
    ret["return"] = self.minion.executors[fname](
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/salt/loader/lazy.py", line 149, in __call__
    return self.loader.run(run_func, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/salt/loader/lazy.py", line 1232, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/salt/loader/lazy.py", line 1247, in _run_as
    return _func_or_method(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/salt/executors/direct_call.py", line 10, in execute
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/salt/loader/lazy.py", line 149, in __call__
    return self.loader.run(run_func, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/salt/loader/lazy.py", line 1232, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/salt/loader/lazy.py", line 1247, in _run_as
    return _func_or_method(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/salt/modules/selinux.py", line 766, in port_get_policy
    "sel_type": parts.group(1).strip(),
                ^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'group'
Traceback (most recent call last):
  File "/usr/bin/salt-call", line 8, in <module>
    sys.exit(salt_call())
             ^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/salt/scripts.py", line 444, in salt_call
    client.run()
  File "/usr/lib/python3.11/site-packages/salt/cli/call.py", line 50, in run
    caller.run()
  File "/usr/lib/python3.11/site-packages/salt/cli/caller.py", line 95, in run
    ret = self.call()
          ^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/salt/cli/caller.py", line 202, in call
    ret["return"] = self.minion.executors[fname](
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/salt/loader/lazy.py", line 149, in __call__
    return self.loader.run(run_func, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/salt/loader/lazy.py", line 1232, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/salt/loader/lazy.py", line 1247, in _run_as
    return _func_or_method(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/salt/executors/direct_call.py", line 10, in execute
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/salt/loader/lazy.py", line 149, in __call__
    return self.loader.run(run_func, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/salt/loader/lazy.py", line 1232, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/salt/loader/lazy.py", line 1247, in _run_as
    return _func_or_method(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/salt/modules/selinux.py", line 766, in port_get_policy
    "sel_type": parts.group(1).strip(),
                ^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'group'

Expected behavior

# salt-call selinux.port_get_policy tcp/22
/usr/lib/python3.11/site-packages/_distutils_hack/__init__.py:33: UserWarning: Setuptools is replacing distutils.
  warnings.warn("Setuptools is replacing distutils.")
[INFO    ] Executing command 'semanage' in directory '/root'
local:
    ----------
    port:
        22
    protocol:
        tcp
    sel_type:
        ssh_port_t

Versions Report

salt --versions-report (Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)
]# salt-call --versions-report
/usr/lib/python3.11/site-packages/salt/utils/http.py:8: DeprecationWarning: 'cgi' is deprecated and slated for removal in Python 3.13
  import cgi
/usr/lib/python3.11/site-packages/salt/utils/jinja.py:9: DeprecationWarning: 'pipes' is deprecated and slated for removal in Python 3.13
  import pipes
Salt Version:
          Salt: 3006.1

Python Version:
        Python: 3.11.3 (main, May 24 2023, 00:00:00) [GCC 13.1.1 20230511 (Red Hat 13.1.1-2)]

Dependency Versions:
          cffi: 1.15.1
      cherrypy: Not Installed
      dateutil: 2.8.2
     docker-py: Not Installed
         gitdb: Not Installed
     gitpython: Not Installed
        Jinja2: 3.0.3
       libgit2: Not Installed
  looseversion: 1.2.0
      M2Crypto: Not Installed
          Mako: Not Installed
       msgpack: 1.0.4
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     packaging: 23.0
     pycparser: 2.20
      pycrypto: Not Installed
  pycryptodome: 3.17.0
        pygit2: Not Installed
  python-gnupg: Not Installed
        PyYAML: 6.0
         PyZMQ: 24.0.1
        relenv: Not Installed
         smmap: Not Installed
       timelib: Not Installed
       Tornado: 4.5.3
           ZMQ: 4.3.4

System Versions:
          dist: fedora 38
        locale: utf-8
       machine: x86_64
       release: 6.3.8-200.fc38.x86_64
        system: Linux
       version: Fedora Linux 38

Activity

  1. added
    bug
    on Jun 30, 2023
  2. added
    fedora
    on Jun 30, 2023
  3. elias314 commented on Mar 2, 2024

    @elias314

    Just ran into this too. Can confirm this also happens on Fedora 39 with minion version 3006.7.

  4. added this to the Sulphur v3006.27 milestone on Jul 2, 2026
  5. dwoz commented on Jul 2, 2026

    @dwoz
    Contributor

    Fix merged and shipped in a supported release. Closing per bulk triage. Reopen if this reproduces on a currently supported release (3006.x, 3007.x, 3008.x, master).

  6. added 2 commits that reference this issue on Jul 3, 2026
    ef431e4
    883183b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugfedora

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions