PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : Fedora, PHP: keine DB-Verbindung



crazynet24
03.01.06, 15:24
Moinsen,
ich kann unter Fedora (2.6.11-1.1369 FC4) keine Datenbank-Verbindung zu einem andere Rechner herstellen, wenn httpd (Apache 1.3....) automatisch unter /etc/rc.d/rc3.d gestartet wird.

Beende ich den Apache auf einer root-konsole und starte ihn dann von dort aus neu, funktioniert der Datenbankzugriff wie gewohnt...

Das dürfte wohl irgend ein Sicherheitsmechanismus von SELinux sein, aber ich find verdammt nochmal keine Doku oder Hinweise zu genau diesem Problem...

kann mir jemand helfen?

viele Gruesse
Stefan

tschloss
03.01.06, 15:36
Gibt es vielleicht verschiedene conf´s bzw. setzt der rc3-Starter z.B. die zu lauschenden Interfaces anders?

Greetz
Thomas

crazynet24
03.01.06, 18:55
Verschiedene Conf's wird es wohl nicht geben, sonst müsste ja jemand dem Apache sagen, lade das eine und nicht das andere. Ich denke eher dass die Prozesse in einem anderen Kontext gestartet werden, aber wie ?

Gruss

marce
03.01.06, 20:12
... wie startest Du ihn den manuell?

SpeedyX
04.01.06, 07:08
mach mal ein!


cat /etc/init.d/apache

Dann kannst du sehen wie er im Runlevel 3 gestartet wird und kannst es gegebenenfalls anpassen.

crazynet24
04.01.06, 08:12
@marce:
mit ./httpd -k start (in /etc/init.d)


ansonsten:
cat zeigt folgendes:
------------------------------------------------
# Source function library.
. /etc/rc.d/init.d/functions

if [ -f /etc/sysconfig/httpd ]; then
. /etc/sysconfig/httpd
fi

# Start httpd in the C locale by default.
HTTPD_LANG=${HTTPD_LANG-"C"}

# This will prevent initlog from swallowing up a pass-phrase prompt if
# mod_ssl needs a pass-phrase from the user.
INITLOG_ARGS=""

# Set HTTPD=/usr/sbin/httpd.worker in /etc/sysconfig/httpd to use a server
# with the thread-based "worker" MPM; BE WARNED that some modules may not
# work correctly with a thread-based MPM; notably PHP will refuse to start.

# Path to the apachectl script, server binary, and short-form for messages.
apachectl=/usr/sbin/apachectl
httpd=${HTTPD-/usr/sbin/httpd}
prog=httpd
pidfile=${PIDFILE-/var/run/httpd.pid}
lockfile=${LOCKFILE-/var/lock/subsys/httpd}
RETVAL=0

# check for 1.3 configuration
check13 () {
CONFFILE=/etc/httpd/conf/httpd.conf
GONE="(ServerType|BindAddress|Port|AddModule|ClearModule List|"
GONE="${GONE}AgentLog|RefererLog|RefererIgnore|FancyInde xing|"
GONE="${GONE}AccessConfig|ResourceConfig)"
if LANG=C grep -Eiq "^[[:space:]]*($GONE)" $CONFFILE; then
echo
echo 1>&2 " Apache 1.3 configuration directives found"
echo 1>&2 " please read /usr/share/doc/httpd-2.0.54/migration.ht ml"
failure "Apache 1.3 config directives test"
echo
exit 1
fi
}

# The semantics of these two functions differ from the way apachectl does
# things -- attempting to start while running is a failure, and shutdown
# when not running is also a failure. So we just do it the way init scripts
# are expected to behave here.
start() {
echo -n $"Starting $prog: "
check13 || exit 1
LANG=$HTTPD_LANG daemon $httpd $OPTIONS
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch ${lockfile}
return $RETVAL
}
stop() {
echo -n $"Stopping $prog: "
killproc $httpd
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
}
reload() {
echo -n $"Reloading $prog: "
if ! LANG=$HTTPD_LANG $httpd $OPTIONS -t >&/dev/null; then
RETVAL=$?
echo $"not reloading due to configuration syntax error"
failure $"not reloading $httpd due to configuration syntax error"
else
killproc $httpd -HUP
RETVAL=$?
fi
echo
}

# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status $httpd
RETVAL=$?
;;
restart)
stop
start
;;
condrestart)
if [ -f ${pidfile} ] ; then
stop
start
fi
;;
reload)
reload
;;
graceful|help|configtest|fullstatus)
$apachectl $@
RETVAL=$?
;;
*)
echo $"Usage: $prog {start|stop|restart|condrestart|reload|status|full st atus|graceful|help|configtest}"
exit 1
esac

exit $RETVAL
---------------------------------------------------

Da steht zwar was von dieser httpd.worker, die ist allerdings auskommentiert in /etc/sysconfig/httpd , PHP selbst läuft ja auch, nur der DB-Zugriff nicht.

Sonst kann ich leider nichts erkennen, was damit zusammen hängen könnte

Dragoran
04.01.06, 13:24
du musst entweder selinux für httpd und mysqld ein oder auschalten (beide das selbe)

crazynet24
04.01.06, 14:21
danke für die Antwort, leider bin ich jetzt nicht wirklich schlauer.

Die Datenbank liegt wie bereits erwähnt aus Sicherheitsgründen auf einem anderen Rechner. Macht es dann noch Sinn SELinux für mysqld einzuschalten? (vermute nein?).
Weiterhin muss ich noch herausfinden, wie ich Prozesse aus dem SELinux ausschalten kann. Besser wäre natürlich, ein Schlupfloch zu schaffen, das aus der gesicherten SE-Umgebung einen Datenbankverbindung zum DB-Rechner zulässt.

Jemand Ahnung davon ?

viele Gruesse

Dragoran
04.01.06, 18:38
befor wie hier dumm herumraten gibt selinux irgendwelche meldungen aus?
audit2allow < /var/log/audit.log (wenn auditd läuft) oder dmesg
versuch mal httpd_can_network_connect auf true zu setzten.

crazynet24
05.01.06, 08:44
DANKE Dragoran
!
Problem dokumentiert unter (nicht trivial):
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=164700

dazu folgendes für die Nachwelt:
Der Netzwerkzugriff funktioniert per default nicht und muss mit:
/usr/sbin/setsebool httpd_can_network_connect=1
zugelassen werden.

Die Einstellung kann mit der -P Option persistiert werden, also:

/usr/sbin/setsebool -P httpd_can_network_connect=1

Danke an alle!

----------------------------------------------
Suchmaschinen Keywords:
SELinux Fedora Redhat PHP Apache Datenbankzugriff fopen mysql connection Datenbankverbindung kein Zugriff Datenbank Database mysql_connect