Skip to content
Advertisement

Apache executes MATLAB binary on CentOS 7 with SELinux

I am trying to trigger the run of a pre compiled MATLAB program on a CentOS 7 server form within an Apache context. The system allowes the user to upload some files. Then some sanity checks are performed. Then the MATLAB program is called and it performes some MATLAB magic.

I installed the MATLAB environment with:

JavaScript

I added LD_LIBRARY_PATH to the http.conf file:

JavaScript

I tried giving the folder of my webapplication the type httpd_sys_rw_content_t and the MATLAB environment got the type httpd_fastcgi_script_exec_t:

JavaScript

When I disable SELinux with “setenforce 0” then the setup works. Apache runs the MATLAB binary, and all my plots and stuff are available.

I fixed some issues by adding a policy from the audit.log:

JavaScript

And adding the paths to the /etc/ld.so.conf.d/ like this:

JavaScript

and calling ldconfig afterwards.

My problem:

When SELinux is enforcing, the MATLAB runtime environment can not be loaded. Here is /var/log/httpd/error_log for the specific time:

JavaScript

As you can see the execution fails as if the path to the MATLAB environment is not set.

  • I tried calling the run_binary.sh script that the MATLAB C compiler generated, instead of the binary, but to no avail.
  • I tried “chcon -t textrel_shlib_t” for the MATLAB *.so’s and my binary.
  • I tried enabeling different/even all bools of SELinux (virtual machine dev environment FTW)
  • I installed setroubleshoot + setroubleshoot-server
  • I do not have any entries in /var/log/message and /var/log/audit/audit.log when the PHP file is called

Has anybody an idea what I could do about that, except disabeling SELinux?

Advertisement

Answer

The solution was a combination of more things:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement