Ich habe den PHP exec Befehl verwendet, um lpr -P printer_name /var/www/html/somefile.pdf
auszustellen, aber nach einem RHEL-Systemupdate (7.2 bis 7.3) hat selinux entschieden, diese Anfragen zu blockieren.Drucken von PHP nach Systemupdate (mit exec über PHP)
ls -lZ /var/www/html/somefile.pdf
-rw-r-----. apache webdev system_u:object_r:httpd_sys_rw_content_t:s0 /var/www/html/somefile.pdf
Es erscheint im Überwachungsprotokoll, mit dem oben exec
Befehl entspricht, von PHP:
zeit> Do 3. November
selinux Rechte der Datei zum Drucken gesendet werden 15:07:02 2016
type = PATH msg = Audit (1478200022,446: 5151): item = 0 name = "/ etc/cups/lpoptions" inode = 134317708 dev = fd: 03 mode = 0100644 ouid = 0 ogid = 7 rdev = 00: 00 obj = system_u: object_r: cupsd_rw_etc_t: s0 objtype = NORMAL
type = CWD msg = Audit (1478200022,446: 5151): CWD = "/ var/www/html "
type = sYSCALL msg = Audit (1478200022,446: 5151): arch = c000003e syscall = 2 Erfolg = yes exit = 5 a0 = 7fff26837c70 a1 = 0 A2 = 0 a3 = 9 items = 1 PPID = 19397 pid = 46644 auid = 4294967295 uid = 48 gid = 48 euid = 48 suid = 48 fsuid = 48 egid = 48 sgid = 48 fsgid = 48 tty = (keine) ses = 4294967295 comm = "lpr" exe = "/ usr/bin/lpr.cups "subj = system_u: system_r: httpd_t: s0 Schlüssel = (null)
typ = AVC msg = audit (1478200022.446: 5151): avc: verweigerte {open} für pid = 46644 comm = "lpr" pfad = "/ etc/cups/lpoptions" dev = "dm-3" ino = 134317708 scontext = system_u: system_r: httpd_t: s0 TContext = system_u: object_r: cupsd_rw_etc_t: s0 TClass =
type = AVC msg = Audit (1478200022,446: 5151): Datei avc: verweigert {read} für pid = 46644 comm = "lpr" name = "lpoptions" dev = "dm-3" ino = 134317708 scontext = system_u: system_r: httpd_t: s0 TContext = system_u: object_r: cupsd_rw_etc_t: s0 TClass = Datei
Erste ähnlich Fehler wit h ein weiterer exec
Befehl für .
Hier ist die aktuelle selinux config:
# getsebool -a | grep httpd
httpd_anon_write --> off
httpd_builtin_scripting --> on
httpd_can_check_spam --> off
httpd_can_connect_ftp --> off
httpd_can_connect_ldap --> off
httpd_can_connect_mythtv --> off
httpd_can_connect_zabbix --> off
httpd_can_network_connect --> on
httpd_can_network_connect_cobbler --> off
httpd_can_network_connect_db --> off
httpd_can_network_memcache --> off
httpd_can_network_relay --> off
httpd_can_sendmail --> on
httpd_dbus_avahi --> off
httpd_dbus_sssd --> off
httpd_dontaudit_search_dirs --> off
httpd_enable_cgi --> on
httpd_enable_ftp_server --> off
httpd_enable_homedirs --> off
httpd_execmem --> off
httpd_graceful_shutdown --> on
httpd_manage_ipa --> off
httpd_mod_auth_ntlm_winbind --> off
httpd_mod_auth_pam --> off
httpd_read_user_content --> off
httpd_run_ipa --> off
httpd_run_preupgrade --> off
httpd_run_stickshift --> off
httpd_serve_cobbler_files --> off
httpd_setrlimit --> off
httpd_ssi_exec --> on
httpd_sys_script_anon_write --> off
httpd_tmp_exec --> off
httpd_tty_comm --> off
httpd_unified --> off
httpd_use_cifs --> off
httpd_use_fusefs --> off
httpd_use_gpg --> off
httpd_use_nfs --> on
httpd_use_openstack --> off
httpd_use_sasl --> off
httpd_verify_dns --> off
All dies unmittelbar nach yum begann RHEL mein System von der Aktualisierung 7,2-7,3.
Was verursacht die Verweigerung?
Welchen Dateityp versuchen Sie zu drucken? – cmorrissey
Ich sende ein pdf. Beispiel: 'lpr -P printer_name/var/www/html/somefile.pdf'. Wenn ich das in der Befehlszeile als root ausführe, wird die Datei gedruckt. Wenn ich es über PHP-Skript mit der 'exec'-Funktion ausführen, schlägt es mit den obigen Protokolldaten fehl. –
Ich vermute, dass Ihr Apache-Daemon den 'lpr_exec_t'-Kontext nicht angewendet hat (es gibt keinen einzigen booleschen Wert dafür, im Gegensatz zu zB sendmail). Die schnellste (am wenigsten sichere) Lösung kann 'sudo semanage permissive -a lpr_t' sein. Siehe auch [dieser Beitrag] (http://danwalsh.livejournal.com/55324.html) für blutige Details (und wie man Kontexte anwendet). – bishop