Re: Enjaular Apache2 con mod_chroot
Por si a alguien le interesa he realizado un pequeño manual de cómo instalar Apache con SSL, PHP y MySQL con apache dentro de una jaula usando mod_chroot. http://resete.sytes.net/blog/index.php/2007/03/06/apache-en-chroot-con-mod_chroot/ Aún me queda solucionar alguna cosilla como poder ejecutar algún binario con la función exec() de PHP.
Re: Enjaular Apache2 con mod_chroot
Estoy configurando PHP e instalando algunas herramientas como phpmyadmin. El problema está en que se instalan fuera del entorno chroot. Lo que estoy haciendo es mover todo dentro del chroot, por ejemplo (árbol directorios dentro del chroot): . |-- etc | `-- phpmyadmin |-- lib |-- usr | `-- share | `-- phpmyadmin `-- var |-- run | |-- apache2 | `-- mysqld `-- www `-- admin `-- phpmyadmin - ../../../usr/share/phpmyadmin/ Y fuera hago enlaces hacia el chroot, por ejemplo: /etc/phpmyadmin - /home/chroot/apache2/etc/phpmyadmin/ /usr/share/phpmyadmin - /home/chroot/apache2/var/www/admin/phpmyadmin La idea es que en caso de actualización lo haga directamente en el chroot. ¿Me podéis decir si es correcto? Un saludo.
Enjaular Apache2 con mod_chroot
Hay varios métodos para enjaular apache pero me gustaría usar mod_chroot (libapache2-mod-chroot) antes que mod_security o el chroot clásico. Creo que puede ser la forma más sencilla pero no consigo hacerlo funcionar. Estoy siguiendo este manual, más o menos: http://core.segfault.pl/~hobbit/mod_chroot/apache20.html He tenido que añadir /etc/mimes.types, copiar los sockets y también en vez de crear un enlace a /var/run/apache2.pid he creado un fichero nuevo dentro del chroot. Sino hago el enlace como indica en el manual me da el siguiente error en el log: [Tue Feb 27 10:02:01 2007] [error] (40)Too many levels of symbolic links: could not create /var/run/apache2.pid [Tue Feb 27 10:02:01 2007] [error] apache2: could not log pid to file /var/run/apache2.pid La lista de directorios y archivos en el chroot, /home/apache . |-- etc | `-- mime.types `-- var |-- log |-- run | |-- apache2 | | |-- cgisock.17690 | | |-- cgisock.19844 | | |-- cgisock.22180 | | |-- cgisock.5294 | | |-- cgisock.5308 | | |-- cgisock.5351 | | |-- cgisock.6235 | | |-- cgisock.9293 | | `-- cgisock.9305 | |-- apache2.pid | `-- mysqld `-- www `-- index.html He cargado el mod: a2enmod mod_chroot Añadido el chroot en /etc/apache2/httpd.conf : PidFile /var/run/apache2.pid ChrootDir /home/apache/ Y finalmente arranco apache2. La primera petición la sirve bien, después no vuelve a cargar. Al parar Apache2 dice lo siguiente: $ /etc/init.d/apache2 stop Stopping web server (apache2)...apache2: Could not reliably determine the server's fully qualified domain name, using 192.168.1.50 for ServerName httpd (no pid file) not running Por otra parte en /var/log/apache2/error.log libgcc_s.so.1 must be installed for pthread_cancel to work [Tue Feb 27 09:49:20 2007] [notice] mod_chroot: changed root to /home/apache/. [Tue Feb 27 09:49:20 2007] [warn] pid file /var/run/apache2.pid overwritten -- Unclean shutdown of previous Apache run? [Tue Feb 27 09:49:20 2007] [notice] Apache/2.2.3 (Debian) mod_chroot/0.5 configured -- resuming normal operations libgcc_s.so.1 must be installed for pthread_cancel to work libgcc_s.so.1 must be installed for pthread_cancel to work [Tue Feb 27 09:49:21 2007] [notice] child pid 25440 exit signal Aborted (6) [Tue Feb 27 09:49:21 2007] [notice] child pid 25442 exit signal Aborted (6) libgcc_s.so.1 must be installed for pthread_cancel to work [Tue Feb 27 09:49:23 2007] [notice] child pid 25497 exit signal Aborted (6) libgcc_s.so.1 must be installed for pthread_cancel to work [Tue Feb 27 09:49:25 2007] [notice] child pid 25525 exit signal Aborted (6) libgcc_s.so.1 must be installed for pthread_cancel to work Y se tira así todo el rato. Saludos.
Re: Enjaular Apache2 con mod_chroot
2007/2/27, Ruben Marcos [EMAIL PROTECTED]: Hay varios métodos para enjaular apache pero me gustaría usar mod_chroot (libapache2-mod-chroot) antes que mod_security o el chroot clásico. Creo que puede ser la forma más sencilla pero no consigo hacerlo funcionar. Estoy siguiendo este manual, más o menos: http://core.segfault.pl/~hobbit/mod_chroot/apache20.html He tenido que añadir /etc/mimes.types, copiar los sockets y también en vez de crear un enlace a /var/run/apache2.pid he creado un fichero nuevo dentro del chroot. Sino hago el enlace como indica en el manual me da el siguiente error en el log: [Tue Feb 27 10:02:01 2007] [error] (40)Too many levels of symbolic links: could not create /var/run/apache2.pid [Tue Feb 27 10:02:01 2007] [error] apache2: could not log pid to file /var/run/apache2.pid La lista de directorios y archivos en el chroot, /home/apache . |-- etc | `-- mime.types `-- var |-- log |-- run | |-- apache2 | | |-- cgisock.17690 | | |-- cgisock.19844 | | |-- cgisock.22180 | | |-- cgisock.5294 | | |-- cgisock.5308 | | |-- cgisock.5351 | | |-- cgisock.6235 | | |-- cgisock.9293 | | `-- cgisock.9305 | |-- apache2.pid | `-- mysqld `-- www `-- index.html He cargado el mod: a2enmod mod_chroot Añadido el chroot en /etc/apache2/httpd.conf : PidFile /var/run/apache2.pid ChrootDir /home/apache/ Y finalmente arranco apache2. La primera petición la sirve bien, después no vuelve a cargar. Al parar Apache2 dice lo siguiente: $ /etc/init.d/apache2 stop Stopping web server (apache2)...apache2: Could not reliably determine the server's fully qualified domain name, using 192.168.1.50 for ServerName httpd (no pid file) not running Por otra parte en /var/log/apache2/error.log libgcc_s.so.1 must be installed for pthread_cancel to work [Tue Feb 27 09:49:20 2007] [notice] mod_chroot: changed root to /home/apache/. [Tue Feb 27 09:49:20 2007] [warn] pid file /var/run/apache2.pid overwritten -- Unclean shutdown of previous Apache run? [Tue Feb 27 09:49:20 2007] [notice] Apache/2.2.3 (Debian) mod_chroot/0.5 configured -- resuming normal operations libgcc_s.so.1 must be installed for pthread_cancel to work libgcc_s.so.1 must be installed for pthread_cancel to work [Tue Feb 27 09:49:21 2007] [notice] child pid 25440 exit signal Aborted (6) [Tue Feb 27 09:49:21 2007] [notice] child pid 25442 exit signal Aborted (6) libgcc_s.so.1 must be installed for pthread_cancel to work [Tue Feb 27 09:49:23 2007] [notice] child pid 25497 exit signal Aborted (6) libgcc_s.so.1 must be installed for pthread_cancel to work [Tue Feb 27 09:49:25 2007] [notice] child pid 25525 exit signal Aborted (6) libgcc_s.so.1 must be installed for pthread_cancel to work Y se tira así todo el rato. Saludos. Solucionado, de momento, he tenido que añadir la librería libgcc_s.so al chroot: . |-- etc | `-- mime.types |-- lib | `-- libgcc_s.so.1 `-- var |-- log |-- run | |-- apache2 | | |-- cgisock.17690 | | |-- cgisock.19844 | | |-- cgisock.22180 | | |-- | |-- apache2.pid | `-- mysqld `-- www `-- index.html De todas formas el pidfile sigue dándome fallos, cuando paro apache: $ /etc/init.d/apache2 stop Stopping web server (apache2)...apache2: Could not reliably determine the server's fully qualified domain name, using 192.168.1.50 for ServerName httpd (no pid file) not running Obviamente los procesos siguen y tengo que matarlos a mano.
Re: Enjaular Apache2 con mod_chroot
2007/2/27, Ruben Marcos [EMAIL PROTECTED]: De todas formas el pidfile sigue dándome fallos, cuando paro apache: $ /etc/init.d/apache2 stop Stopping web server (apache2)...apache2: Could not reliably determine the server's fully qualified domain name, using 192.168.1.50 for ServerName httpd (no pid file) not running Obviamente los procesos siguen y tengo que matarlos a mano. Perdonad por el flood pero también está solucionado. El problema es que había entendido mal el enlace al pidfile, en vez de enlazar fuera del chroot al de dentro lo había hecho al revés. Con esto ya tengo apache2 con mod_chroot funcionando correctamente: ln -s /home/apache/var/run/apache2.pid /var/run/apache2.pid Ahora me queda php y mysql. Un saludo.