【发布时间】:2017-07-13 15:26:49
【问题描述】:
我正在尝试在 Apache 上下文中触发在 CentOS 7 服务器表单上运行预编译的 MATLAB 程序。系统允许用户上传一些文件。然后执行一些健全性检查。然后调用 MATLAB 程序并执行一些 MATLAB 魔术。
我安装了 MATLAB 环境:
unzip -d mcr_unzipped MCR_R2015b_glnxa64_installer.zip
sudo mcr_unzipped/install -glnx86 -tmpdir ~/tmp -mode silent -agreeToLicense yes
我在 http.conf 文件中添加了 LD_LIBRARY_PATH:
SetEnv LD_LIBRARY_PATH /usr/local/MATLAB/MATLAB_Runtime/v90/runtime/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v90/bin/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v90/sys/os/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v90/sys/opengl/lib/glnxa64
我尝试为我的 web 应用程序的文件夹指定类型 httpd_sys_rw_content_t,而 MATLAB 环境的类型为 httpd_fastcgi_script_exec_t:
chcon -R -t httpd_sys_rw_content_t /var/www/webapp
#allow exec:
setsebool -P httpd_ssi_exec 1
#context:
chcon -Rv --type=httpd_fastcgi_script_exec_t /usr/local/MATLAB/
当我用“setenforce 0”禁用 SELinux 时,设置就可以工作了。 Apache 运行 MATLAB 二进制文件,我的所有绘图和资料都可用。
我通过添加 audit.log 中的策略解决了一些问题:
audit2allow -a -M mypolicy
semodule -i mypolicy.pp
并像这样添加到 /etc/ld.so.conf.d/ 的路径:
echo "/usr/local/MATLAB/MATLAB_Runtime/v90/runtime/glnxa64" > /etc/ld.so.conf.d/matlab.runtime.conf
然后调用 ldconfig。
我的问题:
执行 SELinux 时,无法加载 MATLAB 运行时环境。这里是具体时间的/var/log/httpd/error_log:
[Thu Jul 13 15:54:28.676588 2017] [:error] [pid 1382] [client 10.0.2.2:50377] PHP Notice: ... some warning or notice
Error:Could not find version 9.0 of the MATLAB Runtime.
Attempting to load libmwmclmcrrt.so.9.0.
Please install the correct version of the MATLAB Runtime.
Contact your vendor if you do not have an installer for the MATLAB Runtime.
[Thu Jul 13 15:54:29.056179 2017] [:error] [pid 1382] [client 10.0.2.2:50377] PHP Warning: ... some warning or notice
如您所见,执行失败,就像未设置 MATLAB 环境的路径一样。
- 我尝试调用 MATLAB C 编译器生成的 run_binary.sh 脚本,而不是二进制文件,但无济于事。
- 我为 MATLAB *.so 和我的二进制文件尝试了“chcon -t textrel_shlib_t”。
- 我尝试启用 SELinux 的不同/甚至所有布尔值(虚拟机开发环境 FTW)
- 我安装了 setroubleshoot + setroubleshoot-server
- 调用 PHP 文件时,我在 /var/log/message 和 /var/log/audit/audit.log 中没有任何条目
除了禁用 SELinux 之外,有人知道我能做些什么吗?
【问题讨论】:
标签: linux apache matlab selinux