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

selinux.module looks for module source in the base environment, not the current environment #43679

Closed
xenophonf opened this issue Sep 21, 2017 · 3 comments
Labels
Bug broken, incorrect, or confusing behavior Core relates to code central or existential to Salt Execution-Module P3 Priority 3 severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around stale
Milestone

Comments

@xenophonf
Copy link
Contributor

xenophonf commented Sep 21, 2017

Description of Issue/Question

Other states that take source kwargs (e.g., file.managed) will look in the current environment for those files. The selinux.module state looks in the base environment instead, which breaks state execution in multi-environment setups.

Setup

https://github.com/irtnog/salt-states/tree/development/tomcat/pwm.sls
https://github.com/irtnog/salt-states/tree/development/tomcat/files/tomcat-mysql.te

Note that in my setup, I use the base environment solely for targeting.

Steps to Reproduce Issue

  1. Write an SELinux type enforcement module and corresponding SLS file that calls selinux.module (e.g., above), and save them to an environment other than base.

  2. Run the SLS file in that environment (e.g., salt-call state.apply tomcat.pwm saltenv=development).

The relevant log entries:

[DEBUG   ] LazyLoaded selinux.module
[INFO    ] Running state [pwm_tomcat] at time 11:52:09.166189
[INFO    ] Executing state selinux.module for [pwm_tomcat]
[DEBUG   ] Could not find file 'salt://tomcat/files/tomcat-mysql.te' in saltenv 'base'
[ERROR   ] Unable to cache file 'salt://tomcat/files/tomcat-mysql.te' from saltenv 'base'.
[INFO    ] Executing command 'semodule -i False' in directory '/root'
[ERROR   ] Command 'semodule -i False' failed with return code: 1
[ERROR   ] output: libsemanage.map_file: Unable to open False
 (No such file or directory).
libsemanage.semanage_direct_install_file: Unable to read file False
 (No such file or directory).
semodule:  Failed on False!
[ERROR   ] Failed to install module salt://tomcat/files/tomcat-mysql.te
[INFO    ] Completed state [pwm_tomcat] at time 11:52:09.511841 duration_in_ms=345.653

Versions Report

Salt Version:
           Salt: 2017.7.1

Dependency Versions:
           cffi: Not Installed
       cherrypy: Not Installed
       dateutil: 1.5
      docker-py: Not Installed
          gitdb: Not Installed
      gitpython: Not Installed
          ioflo: Not Installed
         Jinja2: 2.7.2
        libgit2: Not Installed
        libnacl: Not Installed
       M2Crypto: Not Installed
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.4.8
   mysql-python: 1.2.5
      pycparser: Not Installed
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: Not Installed
         Python: 2.7.5 (default, Aug  4 2017, 00:39:18)
   python-gnupg: Not Installed
         PyYAML: 3.11
          PyZMQ: 15.3.0
           RAET: Not Installed
          smmap: Not Installed
        timelib: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.1.4

System Versions:
           dist: centos 7.4.1708 Core
         locale: UTF-8
        machine: x86_64
        release: 3.10.0-693.2.2.el7.x86_64
         system: Linux
        version: CentOS Linux 7.4.1708 Core
@xenophonf
Copy link
Contributor Author

I realize now that I'm supposed to use selinux.module to deploy .pp files, not .te files. Still, it's looking in the wrong environment for the files.

@gtmanfred gtmanfred added the Bug broken, incorrect, or confusing behavior label Sep 22, 2017
@gtmanfred
Copy link
Contributor

Should be easy enough to pass __env__ to the command if no environment is passed to the state/module.

Would you mind submitting a PR for this?

Thanks,
Daniel

@gtmanfred gtmanfred added Core relates to code central or existential to Salt Execution-Module severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around P3 Priority 3 team-core labels Sep 22, 2017
@gtmanfred gtmanfred added this to the Approved milestone Sep 22, 2017
xenophonf added a commit to irtnog/salt-states that referenced this issue Oct 25, 2017
@stale
Copy link

stale bot commented Feb 7, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.

@stale stale bot added the stale label Feb 7, 2019
@stale stale bot closed this as completed Feb 14, 2019
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 Core relates to code central or existential to Salt Execution-Module P3 Priority 3 severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around stale
Projects
None yet
Development

No branches or pull requests

2 participants