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] some arguments to salt.states.smtp.send_msg are ignored #66961

Open
jcpearson opened this issue Oct 11, 2024 · 0 comments
Open

[BUG] some arguments to salt.states.smtp.send_msg are ignored #66961

jcpearson opened this issue Oct 11, 2024 · 0 comments
Labels
Bug broken, incorrect, or confusing behavior needs-triage

Comments

@jcpearson
Copy link

Description

The documentation for salt.states.smtp.send_msg gives the usage as:

salt.states.smtp.send_msg(name, recipient, subject, sender=None, profile=None, use_ssl='True', attachments=None)

However, to be able to send an SMTP email a server is required, but there is no server argument to salt.states.smtp.send_msg

The only way to specify a server is via the profile argument - something like:

my-smtp-login:
    smtp.server: smtp.domain.com
    smtp.tls: True
    smtp.sender: [email protected]
    smtp.username: myuser
    smtp.password: verybadpass

The smtp.send_msg state calls the smtp.send_msg module, by passing its arguments to the module - however, the module code does:

    if profile:
        creds = __salt__["config.option"](profile)
        server = creds.get("smtp.server")
        use_ssl = creds.get("smtp.tls")
        sender = creds.get("smtp.sender")
        username = creds.get("smtp.username")
        password = creds.get("smtp.password")

i.e. as a profile has to be used with the smtp.send_msg state, the values of the sender and use_ssl arguments are replaced by the values given in the profile - which means any values of use_ssl and sender given to state are ignored ...

Also, the smtp.send_msg state code does:

    if profile is None and sender is None:
        ret["result"] = False
        ret["comment"] = "Missing parameter sender or profile for state smtp.send_msg"
        return ret

as the sender argument is never used, and the profile must be set, then there is no point testing if the sender is set ...

One simple fix to this is to add a server argument to the smtp.send_msg state - this would then allow a server and sender (plus use_ssl) arguments to be used without using a profile - i.e. use server/sender/use_ssl or profile arguments

Setup

Using 3006.9 on master and minion

  • on-prem machine
  • VM (Nutanix)
  • onedir packaging

Versions Report

salt --versions-report
Salt Version:
          Salt: 3006.9
 
Python Version:
        Python: 3.10.14 (main, Jun 26 2024, 11:44:37) [GCC 11.2.0]
 
Dependency Versions:
          cffi: 1.14.6
      cherrypy: 18.6.1
  cryptography: 42.0.5
      dateutil: 2.8.1
     docker-py: Not Installed
         gitdb: 4.0.11
     gitpython: 3.1.43
        Jinja2: 3.1.4
       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.17.0
         smmap: 5.0.1
       timelib: 0.2.4
       Tornado: 4.5.3
           ZMQ: 4.3.4
 
System Versions:
          dist: rocky 9.4 Blue Onyx
        locale: utf-8
       machine: x86_64
       release: 5.14.0-427.24.1.el9_4.x86_64
        system: Linux
       version: Rocky Linux 9.4 Blue Onyx
@jcpearson jcpearson added Bug broken, incorrect, or confusing behavior needs-triage labels Oct 11, 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 needs-triage
Projects
None yet
Development

No branches or pull requests

1 participant