PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : Apache/php will keine executables ausführen



mamue
22.10.09, 10:01
Hallo
ich finde es ja eigentlich gut, dass mein Webserver/PHP keine Programme ausführen mag, aber leider muß er das können (joomla, moodle), um Dateien indexieren zu können. Ich habe die Pfade angepasst, die Programme kopiert und links gesetzt, aber es wird jedesmal gemeldet, dass z.B. antiword oder pdftotext nicht ausgeführt werden dürfe. Die Rechte, den gesamten Pfad hoch, sind r-x für other.
Hat jemand eine Ahnung, woran das liegen könnte? Derzeit sieht ein vhost so aus:


<Directory "/srv/www/vhosts/vhostnameStandHier">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>

Apache lädt diese Module:


APACHE_MODULES="actions alias auth_basic authn_file authz_host authz_groupfile authz_default authz_user authn_dbm autoindex cgi dir env expires include log_config mime negotiation setenvif ssl suexec php5 proxy proxy_ajp"

Laut /etc/php5/apache2/php.ini ist safe_mode = Off

Weiss jemand Rat?
mamue

marce
22.10.09, 10:41
poste bitte mal die php.ini, den konkreten Aufruf der ext. Datei, die Rechte der Zieldatei, die komplette Fehlermeldung (error_log) und evtl. vorhandene php-Konfig-Änderungen in .htaccess oder httpd-confs...

mamue
22.10.09, 11:06
Ich habe versucht, die /etc/php5/apache/php.ini von Kommentaren zu befreien, sieht so aus:


[PHP]
engine = On
zend.ze1_compatibility_mode = Off
short_open_tag = Off
asp_tags = Off
precision = 14
y2k_compliance = On
output_buffering = 4096
zlib.output_compression = Off
implicit_flush = Off
unserialize_callback_func=
serialize_precision = 100
allow_call_time_pass_reference = Off
safe_mode = Off
safe_mode_gid = Off
safe_mode_include_dir =
safe_mode_exec_dir =
safe_mode_allowed_env_vars = PHP_
safe_mode_protected_env_vars = GCONV_PATH,GETCONF_DIR,HOSTALIASES,LD_AUDIT,LD_DE
BUG,LD_DEBUG_OUTPUT,LD_DYNAMIC_WEAK,LD_LIBRARY_PAT H,LD_ORIGIN_PATH,LD_PRELOAD,LD
_PROFILE,LD_SHOW_AUXV,LD_USE_LOAD_BIAS,LOCALDOMAIN ,LOCPATH,MALLOC_TRACE,NLSPATH,
RESOLV_HOST_CONF,RES_OPTIONS,TMPDIR,TZDIR
disable_functions =
disable_classes =
expose_php = On
max_execution_time = 600 ; Maximum execution time of each script, in seconds
max_input_time = 60 ; Maximum amount of time each script may spend parsing r
equest data
memory_limit = 256M ; Maximum amount of memory a script may consume (128MB)
error_reporting = E_ALL
display_errors = Off
display_startup_errors = Off
log_errors = On
log_errors_max_len = 1024
ignore_repeated_errors = Off
ignore_repeated_source = Off
report_memleaks = On
track_errors = Off
html_errors = Off
variables_order = "GPCS"
register_globals = Off
register_long_arrays = Off
register_argc_argv = Off
auto_globals_jit = On
post_max_size = 64M
magic_quotes_gpc = Off
magic_quotes_runtime = Off
magic_quotes_sybase = Off
auto_prepend_file =
auto_append_file =
default_mimetype = "text/html"
include_path = ".:/usr/share/php5:/usr/share/php5/PEAR"
doc_root =
user_dir =
extension_dir = /usr/lib64/php5/extensions
enable_dl = Off
file_uploads = On
upload_tmp_dir = "/tmp"
upload_max_filesize = 64M
allow_url_fopen = On
allow_url_include = Off
default_socket_timeout = 60
[Date]
[filter]
[iconv]
[sqlite]
[Pcre]
[Syslog]
define_syslog_variables = Off
[mail function]
[SQL]
sql.safe_mode = Off
[ODBC]
odbc.allow_persistent = Off
odbc.check_persistent = On
odbc.max_persistent = -1
odbc.max_links = -1
odbc.defaultlrl = 4096
odbc.defaultbinmode = 1
[MySQL]
mysql.allow_persistent = Off
mysql.max_persistent = -1
mysql.max_links = -1
mysql.default_port =
mysql.default_socket =
mysql.default_host =
mysql.default_user =
mysql.default_password =
mysql.connect_timeout = 60
mysql.trace_mode = Off
[MySQLi]
mysqli.max_links = -1
mysqli.default_port = 3306
mysqli.default_socket =
mysqli.default_host =
mysqli.default_user =
mysqli.default_pw =
mysqli.reconnect = Off
[PostgresSQL]
pgsql.allow_persistent = Off
pgsql.auto_reset_persistent = Off
pgsql.max_persistent = -1
pgsql.max_links = -1
pgsql.ignore_notice = 0
pgsql.log_notice = 0
[bcmath]
bcmath.scale = 0
[browscap]
[Session]
session.save_handler = files
session.save_path = "/var/lib/php5"
session.use_cookies = 1
session.use_only_cookies = 1
session.name = PHPSESSID
session.auto_start = 0
session.cookie_lifetime = 0
session.cookie_path = /
session.cookie_domain =
session.cookie_httponly = 1
session.serialize_handler = php
session.gc_probability = 1
session.gc_divisor = 1000
session.gc_maxlifetime = 1440
session.bug_compat_42 = 0
session.bug_compat_warn = 1
session.referer_check =
session.entropy_length = 16
session.entropy_file = /dev/urandom
session.cache_limiter = nocache
session.cache_expire = 180
session.use_trans_sid = 0
session.hash_function = 1
session.hash_bits_per_character = 5
url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentr y"
[Assertion]
[mbstring]
mbstring.func_overload = 7
[gd]
[exif]
[Tidy]
tidy.clean_output = Off
[soap]
soap.wsdl_cache_enabled=1
soap.wsdl_cache_dir="/tmp"
soap.wsdl_cache_ttl=86400

(grep ^[a-zA-Z\[] /etc/php5/apache2/php.ini)
Die Zahl der conf Dateien des Webserver ist recht groß. Ich habe eigentlich nichts zu php finden können (httpd.conf, default-server.conf, mod_info.conf). Der vhost ist im Prinzip komplett aufgelistet von mir, der Rest sind nur die Angaben zu log, VirtualName, Directory etc. Mehr ist da nicht.
Die Rechte der Datei (antiword)
/opt/: drwxr-xr-x
/opt/antiword/: drwxr-xr-x
/opt/antiword/antiword: -rwxr-xr-x

Der vhost ist in /srv/www/vhosts/vhostnameStandHier
Apache läuft chroot, daher versucht:
ln -s /opt /srv/www/vhosts/vhostnameStandHier/opt => nee
mkdir /srv/www/vhosts/vhostnameStandHier/bin
cp /opt/antiword/antiword /srv/www/vhosts/vhostnameStandHier/bin
/srv/www/vhosts/vhostnameStandHier/bin: drwxrwx--x wwwrun.root
/srv/www/vhosts/vhostnameStandHier/bin/antiword: -rwxr-xr-x wwwrun.root
Ich bin leider nicht moodle-Admin, adminrechte reichen da nicht, man muß _der_ admin sein. Ich versuche mal, eine PHP Datei zu bauen, die antiword/pdftotext aufruft. Das wird etwas dauern, ich komme eher aus der Java-Ecke ;-)

Danke
mamue

marce
22.10.09, 11:11
wenn der Apache in einem chroot läuft musst Du darin die komplette Umgebung, die AbiWord braucht bereitstellen - da reicht es nicht, nur das binary zu kopieren, da müssen noch einige Libs und andere Dinge dazu...

mamue
22.10.09, 11:19
Glaube ich eher nicht. Die glibc dürfte dem Apache wohl bekannt sein und antiword besteht nur aus dem binary antiword. Keine libs. antiword wurde von mir übersetzt und mit --prefix=/opt/antiword konfiguriert.


ldd /opt/antiword/antiword
linux-vdso.so.1 => (0x00007fffd4287000)
libc.so.6 => /lib64/libc.so.6 (0x00007fb676dc2000)
/lib64/ld-linux-x86-64.so.2 (0x00007fb67711b000)

Ich versuche gerade folgendes PHP-script:


<?php
#exec('/opt/antiword/antiword test123.doc', $output);
exec('antiword test123.doc', $output);
var_dump($output);
?>

Ausgabe auf der Webseite ist:
array(0) { }
Was sagt einem das?
Oh, ich fand gerade folgenden Tipp:


$out = shell_exec('ls -al');
echo "<pre>$out</pre>";

Das funktioniert und gibt


-rw-r--r-- 1 root root 12288 Oct 22 11:32 .test.php.swp
-rwxr-xr-x 1 root root 258650 Oct 22 11:28 antiword
-rw-r--r-- 1 root root 175 Oct 22 11:32 test.php
-rw-r--r-- 1 root root 19968 Oct 22 11:27 test123.doc

Also liegt es nicht am Apache, sondern an antiword oder doch an fehlenden libs.

Danke

mamue
22.10.09, 11:50
OK, mein script kann antiword ausführen.
1.: antiword reicht nicht, die map-Dateien (Resources) werden benötigt. Die müssen per Hand nach /usr/share/antiword kopiert werden.
2.: Die Rechte anpassen, denn standardmäßig haben die maps 640.
3.: Der einzige Pfad, der funktionierte, war exec('/opt/antiword/antiword...');

Ich nehme an, mit pdftotext wird es etwas ähnliches sein.

Merci marce
mamue