Apache in chroot die 2.

Apache, Lighttpd, nginx, Cherokee
Post Reply
blaufrosch
Posts: 12
Joined: 2003-07-07 13:03
 

Apache in chroot die 2.

Post by blaufrosch »

Hallo
Ich habe ein Problem.
Ich möchte einen Apache-Webserver im chroot laufen lassen.
Das Prinzip ist verstanden. Verzeichnis kreieren, Benutzer kreieren, Verzeichnis dem Benutzer zuordnen und wichtige Dateien (library) in das Verzeichnis kopieren, so das Apache alles im chroot hat was er brauch.
Ich habe keine Ahnung was er nun alles brauch! Ich habe gehofft, das beim starten von Apache eine Fehlermeldung kommt aus der man erkennen kann was dem Apache fehlt.
Die Inofs zum kreieren habe ich von der schönen Seite:
http://penguin.epfl.ch/chroot.html#h3-prep
Fast haargenau bin die die Anleitung durch und konnte z.b. ldd oder ls in chroot wunderbar ausführen.
Aber mein Apache macht mir Probleme beim starten.
Folgende Systeme benutze ich: Suse 8.2, Apache_1.3.27 (http://www.apache.org).

Hier die Fehlermeldung beim start in chroot:
#######################################################
linux:/chrootweb # chroot /chrootweb /chrootweb/apache/sbin/apachectl start
chroot: cannot execute /chrootweb/apache/sbin/apachectl: Too many levels of
symbolic links
linux:/chrootweb # chroot /chrootweb /chrootweb/apache/sbin/httpd start
chroot: cannot execute /chrootweb/apache/sbin/httpd: Too many levels of
symbolic links
linux:/chrootweb #

Hier die Logs beim starten von Apache:
#######################################################
linux:/chrootweb/apache/sbin # strace ./apachectl
execve("./apachectl", ["./apachectl"], [/* 48 vars */]) = 0
uname({sys="Linux", node="linux", ...}) = 0
brk(0) = 0x80c28d0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x40013000
open("/etc/ld.so.preload", O_RDONLY) = -1 ENOENT (No such file or
directory)
open("/etc/ld.so.cache", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=19117, ...}) = 0
mmap2(NULL, 19117, PROT_READ, MAP_PRIVATE, 3, 0) = 0x40014000
close(3) = 0
open("/lib/libreadline.so.4", O_RDONLY) = 3
read(3, "177ELF111331300257"..., 1024)
= 1024
fstat64(3, {st_mode=S_IFREG|0755, st_size=173200, ...}) = 0
mmap2(NULL, 179092, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0x40019000
mprotect(0x40040000, 19348, PROT_NONE) = 0
mmap2(0x40040000, 16384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3,
0x26) = 0x40040000
mmap2(0x40044000, 2964, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x40044000
close(3) = 0
open("/lib/libhistory.so.4", O_RDONLY) = 3
read(3, "177ELF111331 3000"...,
1024) = 1024
fstat64(3, {st_mode=S_IFREG|0755, st_size=24252, ...}) = 0
mmap2(NULL, 27144, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0x40045000
mprotect(0x4004b000, 2568, PROT_NONE) = 0
mmap2(0x4004b000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x5)
= 0x4004b000
close(3) = 0
open("/lib/libncurses.so.5", O_RDONLY) = 3
read(3, "177ELF111331P357"..., 1024) =
1024
fstat64(3, {st_mode=S_IFREG|0755, st_size=307598, ...}) = 0
mmap2(NULL, 273516, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0x4004c000
mprotect(0x40083000, 48236, PROT_NONE) = 0
mmap2(0x40083000, 49152, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3,
0x36) = 0x40083000
close(3) = 0
open("/lib/libdl.so.2", O_RDONLY) = 3
read(3, "177ELF111331`3100"...,
1024) = 1024
fstat64(3, {st_mode=S_IFREG|0755, st_size=11832, ...}) = 0
mmap2(NULL, 11544, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0x4008f000
mprotect(0x40091000, 3352, PROT_NONE) = 0
mmap2(0x40091000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x1)
= 0x40091000
close(3) = 0
open("/lib/libc.so.6", O_RDONLY) = 3
read(3, "177ELF111331300205"..., 1024)
= 1024
fstat64(3, {st_mode=S_IFREG|0755, st_size=1312470, ...}) = 0
mmap2(NULL, 1169856, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0x40092000
mprotect(0x401a6000, 39360, PROT_NONE) = 0
mmap2(0x401a6000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3,
0x113) = 0x401a6000
mmap2(0x401ac000, 14784, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x401ac000
close(3) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x401b0000
munmap(0x40014000, 19117) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
open("/dev/tty", O_RDWR|O_NONBLOCK|O_LARGEFILE) = 3
close(3) = 0
brk(0) = 0x80c28d0
brk(0x80c28f8) = 0x80c28f8
brk(0x80c3000) = 0x80c3000
open("/usr/share/locale/locale.alias", O_RDONLY) = -1 ENOENT (No such file
or directory)
open("/usr/lib/locale/de_DE+euro/LC_CTYPE", O_RDONLY) = -1 ENOENT (No such
file or directory)
open("/usr/lib/locale/de_DE@euro/LC_CTYPE", O_RDONLY) = -1 ENOENT (No such
file or directory)
open("/usr/lib/locale/de@euro/LC_CTYPE", O_RDONLY) = -1 ENOENT (No such file
or directory)
open("/usr/lib/locale/de+euro/LC_CTYPE", O_RDONLY) = -1 ENOENT (No such file
or directory)
open("/usr/lib/locale/de_DE/LC_CTYPE", O_RDONLY) = -1 ENOENT (No such file
or directory)
open("/usr/lib/locale/de/LC_CTYPE", O_RDONLY) = -1 ENOENT (No such file or
directory)
getuid32() = 0
getgid32() = 0
geteuid32() = 0
getegid32() = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
time(NULL) = 1057913222
open("/etc/mtab", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=123, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x40014000
read(3, "/dev/hda2 / reiserfs rw 0 0nproc"..., 4096) = 123
close(3) = 0
munmap(0x40014000, 4096) = 0
open("/proc/meminfo", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x40014000
read(3, " total: used: free:"..., 4096) = 549
close(3) = 0
munmap(0x40014000, 4096) = 0
brk(0x80c4000) = 0x80c4000
rt_sigaction(SIGCHLD, {SIG_DFL}, {SIG_DFL}, 8) = 0
rt_sigaction(SIGCHLD, {SIG_DFL}, {SIG_DFL}, 8) = 0
rt_sigaction(SIGINT, {SIG_DFL}, {SIG_DFL}, 8) = 0
rt_sigaction(SIGINT, {SIG_DFL}, {SIG_DFL}, 8) = 0
rt_sigaction(SIGQUIT, {SIG_DFL}, {SIG_DFL}, 8) = 0
rt_sigaction(SIGQUIT, {SIG_DFL}, {SIG_DFL}, 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigaction(SIGQUIT, {SIG_IGN}, {SIG_DFL}, 8) = 0
uname({sys="Linux", node="linux", ...}) = 0
brk(0x80c5000) = 0x80c5000
brk(0x80c6000) = 0x80c6000
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
brk(0x80c7000) = 0x80c7000
stat64("/chrootweb/apache/sbin", {st_mode=S_IFDIR|0755, st_size=344, ...}) =
0
stat64(".", {st_mode=S_IFDIR|0755, st_size=344, ...}) = 0
getpid() = 19716
getppid() = 19715
getpgrp() = 19715
rt_sigaction(SIGCHLD, {0x8071100, [], 0x4000000}, {SIG_DFL}, 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
open("./apachectl", O_RDONLY|O_LARGEFILE) = 3
ioctl(3, TCGETS, 0xbffff450) = -1 ENOTTY (Inappropriate ioctl for
device)
_llseek(3, 0, [0], SEEK_CUR) = 0
read(3, "#!/bin/shn#n# Apache control scr"..., 80) = 80
_llseek(3, 0, [0], SEEK_SET) = 0
getrlimit(0x7, 0xbffff4b8) = 0
dup2(3, 255) = 255
close(3) = 0
fcntl64(255, F_SETFD, FD_CLOEXEC) = 0
fcntl64(255, F_GETFL) = 0x8000 (flags
O_RDONLY|O_LARGEFILE)
fstat64(255, {st_mode=S_IFREG|0755, st_size=7100, ...}) = 0
_llseek(255, 0, [0], SEEK_CUR) = 0
brk(0x80c9000) = 0x80c9000
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
read(255, "#!/bin/shn#n# Apache control scr"..., 7100) = 7100
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
brk(0x80ca000) = 0x80ca000
brk(0x80cb000) = 0x80cb000
brk(0x80cc000) = 0x80cc000
brk(0x80cd000) = 0x80cd000
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
stat64("/chrootweb/var/run/httpd.pid", {st_mode=S_IFREG|0644, st_size=6,
...}) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
brk(0x80ce000) = 0x80ce000
pipe([3, 4]) = 0
rt_sigprocmask(SIG_BLOCK, [INT CHLD], [], 8) = 0
_llseek(255, -2847, [4253], SEEK_CUR) = 0
fork() = 19717
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigaction(SIGCHLD, {0x8071100, [], 0x4000000}, {0x8071100, [],
0x4000000}, 8) = 0
close(4) = 0
read(3, "11305n", 128) = 6
read(3, 0xbfffefb0, 128) = ? ERESTARTSYS (To be restarted)
--- SIGCHLD (Child exited) ---
wait4(-1, [WIFEXITED(s) && WEXITSTATUS(s) == 0], WNOHANG, NULL) = 19717
wait4(-1, 0xbfffec54, WNOHANG, NULL) = -1 ECHILD (No child processes)
sigreturn() = ? (mask now [])
read(3, "", 128) = 0
close(3) = 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
rt_sigaction(SIGINT, {0x80701a0, [], 0x4000000}, {SIG_DFL}, 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigaction(SIGINT, {SIG_DFL}, {0x80701a0, [], 0x4000000}, 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
open("/dev/null", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0666) = 3
fcntl64(2, F_GETFD) = 0
fcntl64(2, F_DUPFD, 10) = 10
fcntl64(2, F_GETFD) = 0
fcntl64(10, F_SETFD, FD_CLOEXEC) = 0
dup2(3, 2) = 2
close(3) = 0
kill(11305, SIG_0) = 0
dup2(10, 2) = 2
fcntl64(10, F_GETFD) = 0x1 (flags FD_CLOEXEC)
close(10) = 0
fstat64(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 1), ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x40014000
write(1, "usage: ./apachectl (start|stop|r"..., 83usage: ./apachectl
(start|stop|restart|fullstatus|status|graceful|configtest|help)
) = 83
stat64(".", {st_mode=S_IFDIR|0755, st_size=344, ...}) = 0
stat64("/sbin/cat", 0xbffff010) = -1 ENOENT (No such file or
directory)
stat64("/usr/sbin/cat", 0xbffff010) = -1 ENOENT (No such file or
directory)
stat64("/usr/local/sbin/cat", 0xbffff010) = -1 ENOENT (No such file or
directory)
stat64("/root/bin/cat", 0xbffff010) = -1 ENOENT (No such file or
directory)
stat64("/usr/local/bin/cat", 0xbffff010) = -1 ENOENT (No such file or
directory)
stat64("/usr/bin/cat", 0xbffff010) = -1 ENOENT (No such file or
directory)
stat64("/usr/X11R6/bin/cat", 0xbffff010) = -1 ENOENT (No such file or
directory)
stat64("/bin/cat", {st_mode=S_IFREG|0755, st_size=14264, ...}) = 0
stat64("/bin/cat", {st_mode=S_IFREG|0755, st_size=14264, ...}) = 0
rt_sigprocmask(SIG_BLOCK, [INT CHLD], [], 8) = 0
fork() = 19718
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
rt_sigaction(SIGINT, {0x80701a0, [], 0x4000000}, {SIG_DFL}, 8) = 0
wait4(-1,
start - start httpd
stop - stop httpd
restart - restart httpd if running by sending a SIGHUP or start if
not running
fullstatus - dump a full status screen; requires lynx and mod_status enabled
status - dump a short status screen; requires lynx and mod_status
enabled
graceful - do a graceful restart by sending a SIGUSR1 or start if not
running
configtest - do a configuration syntax test
help - this screen

[WIFEXITED(s) && WEXITSTATUS(s) == 0], 0, NULL) = 19718
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
--- SIGCHLD (Child exited) ---
wait4(-1, 0xbfffee1c, WNOHANG, NULL) = -1 ECHILD (No child processes)
sigreturn() = ? (mask now [])
rt_sigaction(SIGINT, {SIG_DFL}, {0x80701a0, [], 0x4000000}, 8) = 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
read(255, "nexit $ERRORnn## ==============="..., 7100) = 2847
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
munmap(0x40014000, 4096) = 0
_exit(2) = ?

Wer kann mir weiterhelfen???
sascha
Posts: 1325
Joined: 2002-04-22 23:08
 

Re: Apache in chroot die 2.

Post by sascha »

Nimm dies: http://www.debian.org/doc/manuals/secur ... nv.en.html

Funzt nach einem ersten kurzen Test hervorragend.
rootmaster
Posts: 483
Joined: 2002-04-28 13:30
Location: Hannover
 

Re: Apache in chroot die 2.

Post by rootmaster »

oder raffinierter: benutz dafür mod_security (ist allerdings noch beta+++ ;))

http://www.modsecurity.org/documentatio ... hroot.html

"back to the roots"
mutombo
Posts: 184
Joined: 2003-06-19 06:10
 

Re: Apache in chroot die 2.

Post by mutombo »

rootmaster wrote:oder raffinierter: benutz dafür mod_security (ist allerdings noch beta+++ ;))

http://www.modsecurity.org/documentatio ... hroot.html

"back to the roots"
jupp funzt wirklich sehr einfach. die neueste CVS ziehen, als apache_module kompilieren. reiner apache funzt damit einwandfrei.
blaufrosch
Posts: 12
Joined: 2003-07-07 13:03
 

Re: Apache in chroot die 2.

Post by blaufrosch »

"die neueste CVS ziehen", mh...
ist damit das Modul mod_security-1.5.1.tar.gz gemeint??
Hab es nach ANleitung kompiliert.
Das Modul ist auch nun in der Config mit eingebunden.
Aber was ist mit dem CVS gemeint?
squize
Userprojekt
Userprojekt
Posts: 729
Joined: 2003-05-19 16:46
Location: Karlsruhe
Contact:
 

Re: Apache in chroot die 2.

Post by squize »

CVS ist ein Tool, mit dem man Quellcode verwaltet. So kannst du mit dem Programm cvs ( Windows gibt es mit WinCVS einen graphischen Client) kann man dann die aktuellen Versionen ziehen.

Gruss

Marc
blaufrosch
Posts: 12
Joined: 2003-07-07 13:03
 

Re: Apache in chroot die 2.

Post by blaufrosch »

Sorry, bin wohl etwas schwer von Kapische.... :roll:
CVS=Quellcode verwalten, ok, und welchen?
dann aktuelle Versionen ziehen? Welche woher? Was hat das mit dem Quellcode zu tun??
rootmaster
Posts: 483
Joined: 2002-04-28 13:30
Location: Hannover
 

Re: Apache in chroot die 2.

Post by rootmaster »

Code: Select all

wget http://www.modsecurity.org/download/mod_security-1.5.1.tar.gz
tar xzvf mod_security-1.51.tar.gz
cd mod_security-1.5.1/apache1
apxs -cia mod_security.c

dann:
httpd.conf entsprechend anpassen (s. manual zu mod_security)
apache neustarten
"back to the roots"
mutombo
Posts: 184
Joined: 2003-06-19 06:10
 

Re: Apache in chroot die 2.

Post by mutombo »

rootmaster wrote:

Code: Select all

wget http://www.modsecurity.org/download/mod_security-1.5.1.tar.gz
tar xzvf mod_security-1.51.tar.gz
damit funktioniert leider kein Chroot, das geht erst ab version 1.6.

Code: Select all

cvs -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/mod-security login 
cvs -z3 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/mod-security co mod_security
damit bekommt man die neueste version vom cvs server, die kann auch chroot.
rootmaster wrote:

Code: Select all

cd mod_security-1.5.1/apache1
apxs -cia mod_security.c
dann:
httpd.conf entsprechend anpassen (s. manual zu mod_security)
apache neustarten
"back to the roots"
soweit dasselbe.
rootmaster
Posts: 483
Joined: 2002-04-28 13:30
Location: Hannover
 

Re: Apache in chroot die 2.

Post by rootmaster »

mutombo wrote:
rootmaster wrote:

Code: Select all

wget http://www.modsecurity.org/download/mod_security-1.5.1.tar.gz
tar xzvf mod_security-1.51.tar.gz
damit funktioniert leider kein Chroot, das geht erst ab version 1.6.

Code: Select all

cvs -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/mod-security login 
cvs -z3 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/mod-security co mod_security
damit bekommt man die neueste version vom cvs server, die kann auch chroot.
hmm, interessant, bei mir funzt es ohne probs mit 1.5.1 8O

btw. der docroot im vhost muss relativ zum chroot angegeben werden, also zb /home/www/web1 -> /web1

"back to the roots"
mutombo
Posts: 184
Joined: 2003-06-19 06:10
 

Re: Apache in chroot die 2.

Post by mutombo »

ah sorry. alles klar, hab mir mod_rewrite kurz vor der 1.5.1 release gezogen, da gabs das nur im cvs, hatte ne mail an den author geschrieben, weil ichs auch erstmal mit der tgz probiert hatte.
Did you get the latest version from CVS? The chroot feature is
only available for Apache 1.x and in the CVS only. I will release
v1.5.1 shortly to fix some bugs and add certain enhancements to
the Apache 2.x code.
da ich confixx verwende hab ich das problem mit den vhosts durch einen link gelöst.
mein chroot ist /home/www dort hab ich ein dir home erstellt und darin einen link auf ../. gesetzt.

Code: Select all

 home/www -> ../. 
funzt soweit.
rootmaster
Posts: 483
Joined: 2002-04-28 13:30
Location: Hannover
 

Re: Apache in chroot die 2.

Post by rootmaster »

mutombo wrote: da ich confixx verwende hab ich das problem mit den vhosts durch einen link gelöst.
mein chroot ist /home/www dort hab ich ein dir home erstellt und darin einen link auf ../. gesetzt.

Code: Select all

 home/www -> ../. 
jep, natürlich, wenn man confixx benutzt ist das besser, da man nicht die confixx-config anpassen muss ;)

zb so:
cd /home/www
mkdir -p home/www
mount --bind home/www ./

ausserdem muss man beachten, dass der mysql-socket im chroot "hard-gelinkt" ist ;)

"back to the roots"
blaufrosch
Posts: 12
Joined: 2003-07-07 13:03
 

Re: Apache in chroot die 2.

Post by blaufrosch »

Hallöchen
Ich bin am verzweifeln, es funzt bei mir nicht.
Hier mal eine Zusammenfassung meiner Vorgehensweise:
mod_security-1.5.1.tar.gz und apache_1.3.27.tar.gz gesaugt und entpackt!
Somit 2 Verzeichnisse:
/usr/local/src/mod_security-1.5.1
/usr/local/src/apache_1.3.27
dann
linux:/usr/local/src/mod_security-1.5.1
cp apache1/mod_security.c /usr/local/src/apache_1.3.27
dann
linux:/usr/local/src/apache_1.3.27 #
Hier der Auszug der config,layout:
cat config.layout:
# SuSE 6.x layout
<Layout SuSE>
prefix: /usr
exec_prefix: $prefix
bindir: $prefix/bin
sbindir: $prefix/sbin
libexecdir: $prefix/lib/apache
mandir: $prefix/man
sysconfdir: /etc/httpd
datadir: /usr/local/httpd
iconsdir: $datadir/icons
htdocsdir: $datadir/htdocs
manualdir: $htdocsdir/manual
cgidir: $datadir/cgi-bin
includedir: $prefix/include/apache
localstatedir: /var
runtimedir: $localstatedir/run
logfiledir: $localstatedir/log/httpd
proxycachedir: $localstatedir/cache/httpd
</Layout>
also
./configure --with-layout=Apache --add-module=mod_security.c --enable-module=most --enable-module=so --disable-module=info --disable-module=status
läuft komplett durch ohne Fehlermeldung
dann:
make
make install
beide wieder ohne Probleme und Fehlermeldungen
dann
apxs -cia mod_security.c
wieder ohne Fehlermeldung (nur mit dem Hinweis wo die httpd.conf copiert/ersetzt wurde!
dann
linux:/etc/httpd # /usr/sbin/httpd -l
Compiled-in modules:
http_core.c
mod_vhost_alias.c
mod_env.c
mod_log_config.c
mod_mime_magic.c
mod_mime.c
mod_negotiation.c
mod_include.c
mod_autoindex.c
mod_dir.c
mod_cgi.c
mod_asis.c
mod_imap.c
mod_actions.c
mod_speling.c
mod_userdir.c
mod_alias.c
mod_rewrite.c
mod_access.c
mod_auth.c
mod_auth_anon.c
mod_auth_dbm.c
mod_digest.c
mod_proxy.c
mod_cern_meta.c
mod_expires.c
mod_headers.c
mod_usertrack.c
mod_unique_id.c
mod_so.c
mod_setenvif.c
mod_security.c
suexec: enabled; valid wrapper /usr/sbin/suexec
Also Modul mod_security.c ist Prima implementiert :)
dann hier ein Auszug aus der httpd.conf:
/etc/httpd/httpd.conf
# Example:
# LoadModule foo_module libexec/mod_foo.so
LoadModule security_module lib/apache/mod_security.so
Die Zeile fehlen (warum weiß ich net):
AddModule mod_security.c
AddModule ...
AddModule ...
AddModule ...
fehlen mir aber komplett, d.h. in der generierten httpd.conf ist nix mit AddModule!!!
Sonst alles Prima, somit weiter im Text :)
Wenn ich mich nicht irre, kann ich Prozesse in einer Chroot-Umgebung so testen (ist der nun in chroot oder nicht?):
Prozessnummer raus suchen:
linux:~ # /usr/sbin/apachectl start
/usr/sbin/apachectl start: httpd started
linux:~ # ps aux|grep httpd
root 735 0.0 0.5 2668 1252 ? S 14:39 0:00 /usr/sbin/httpd
nobody 736 0.0 0.5 2680 1252 ? S 14:39 0:00 /usr/sbin/httpd
nobody 737 0.0 0.5 2680 1252 ? S 14:39 0:00 /usr/sbin/httpd
nobody 738 0.0 0.5 2680 1252 ? S 14:39 0:00 /usr/sbin/httpd
nobody 739 0.0 0.5 2680 1252 ? S 14:39 0:00 /usr/sbin/httpd
nobody 740 0.0 0.5 2680 1252 ? S 14:39 0:00 /usr/sbin/httpd
Und nun schauen was der Prozess alles sehen kann:
ls -la /proc/735/root/.
drwxr-xr-x 20 root root 504 Jul 13 03:56 .
drwxr-xr-x 20 root root 504 Jul 13 03:56 ..
drwxr-xr-x 2 root root 368 Jul 4 17:27 BACKUP
lrwxrwxrwx 1 root root 11 Jul 8 09:03 apache -> /www/apache
drwxr-xr-x 2 root root 2136 Mar 27 11:57 bin
drwxr-xr-x 3 root root 416 Jul 11 17:06 boot
drwxr-xr-x 28 root root 94672 Jul 13 01:56 dev
drwxr-xr-x 40 root root 4808 Jul 14 06:48 etc
drwxr-xr-x 3 root root 128 Jul 12 11:32 home
-rw-r--r-- 1 root root 8539 Jul 13 01:06 kannweg
drwxr-xr-x 6 root root 2328 Jul 10 21:21 lib
drwxr-xr-x 4 root root 96 Sep 13 2002 media
drwxr-xr-x 3 root root 80 Feb 4 17:46 mnt
drwxr-xr-x 5 root root 120 Dec 2 2002 opt
dr-xr-xr-x 63 root root 0 Jul 13 03:55 proc
drwx------ 8 root root 1040 Jul 14 14:39 root
drwxr-xr-x 3 root root 6136 Mar 27 11:57 sbin
drwxr-xr-x 4 root root 96 Dec 2 2002 srv
drwxrwxrwt 20 root root 680 Jul 14 14:30 tmp
drwxr-xr-x 14 root root 368 Jul 14 12:22 usr
drwxr-xr-x 17 root root 432 Jul 14 06:47 var
linux:~ #
Verdammt, er sieht zuviel!

Was nun, wo ist mein Fehler, bzw. wo kann ich mein unbedeutendes Wissen erweitern??
Vielen Dank schonmal
mutombo
Posts: 184
Joined: 2003-06-19 06:10
 

Re: Apache in chroot die 2.

Post by mutombo »

is chrooting denn aktiviert ?
SecChrootDir /path/
blaufrosch
Posts: 12
Joined: 2003-07-07 13:03
 

Re: Apache in chroot die 2.

Post by blaufrosch »

Wo/wie soll das aktiviert werden???
mutombo
Posts: 184
Joined: 2003-06-19 06:10
 

Re: Apache in chroot die 2.

Post by mutombo »

sorry RTFM.
das steht alles in der docu und hier:
http://www.modsecurity.org/documentatio ... hroot.html
rootmaster
Posts: 483
Joined: 2002-04-28 13:30
Location: Hannover
 

Re: Apache in chroot die 2.

Post by rootmaster »

mutombo wrote:sorry RTFM.
das steht alles in der docu und hier:
http://www.modsecurity.org/documentatio ... hroot.html
naja, "SecChrootDir /pfad/zum/chroot_dir" muss in die httpd.conf

ausserdem muss die "AddModule"-Direktive für mod_security in die httpd.conf. diese muss vor allen anderen an 1. stelle stehen, da der chroot logischer weise als letztes ausgeführt werden soll ;)
btw. das apxs ist überflüssig, wenn man module in den apache reinkompiliert 8)

"back to the roots"
blaufrosch
Posts: 12
Joined: 2003-07-07 13:03
 

Re: Apache in chroot die 2.

Post by blaufrosch »

Arrgh,...
Das macht mich fertig. Wer weiß, wenn das so weiter geht liege ich bald sabbernd am Boden und flüster immer lächelnd: "chroot, apache, chroot, apache",lol
Ne, aber ich habe mein Problem im letzten Posting nicht richtig verdeutlichen können:
Die Zeilen:
AddModule mod_security.c
AddModule ...
AddModule ...
AddModule ...
Sind NICHT in meiner httpd.conf enthalten!!!!
Warum?????
Ich kann sie händisch nicht nachträglich einpflegen, dann beschwert sich mein Apache!!!
Ich habe gesehen, das unter meinen entpackten Verzeichnis
/usr/local/src/apache_1.3.27/conf
noch Konfig-Dateien stecken. In nur einen einzigen sind diese Addmudule-Zeilen zu finden, ausgerechnet nur für Windows-Scheiß!
mutombo
Posts: 184
Joined: 2003-06-19 06:10
 

Re: Apache in chroot die 2.

Post by mutombo »

an deiner stelle würde ich nochmal ganz in ruhe anfangen:
Anleitung lesen! Apache deinstallieren und nochmal alles von vorne.
bei den rooties genügt es im übrigen die apache header per yast nachzuinstallieren, damit erhält man apxs und muß den apache nicht komplett neu installieren.

auf meiner debianinstallation habe ich übrigens auch keine addmodule zeilen, vermute mal das hängt damit zusammen wie man das module reinkompiliert. Stört die funktionalität von mod_Security allerdings nicht.
blaufrosch
Posts: 12
Joined: 2003-07-07 13:03
 

Re: Apache in chroot die 2.

Post by blaufrosch »

Oki Danke für die vielen Tips.
Ich habe mal die Installation von Suse aus gemacht, und schon habe ich alle erforderlich Zeilen in der httpd.conf.
Danach ein apxs -cia mod_security.c und schon waren die erforderlichen Zeilen in meiner httpd.conf. Soweit, so gut.
Aber ein /urs/sbin/httpd -l wirft nicht das gewünschte Modul mod_Security aus, sondern nur zwei bei der STandart-SUSE-Installation intergrierten Module. Was nun?
Wie kann ich sehen/prüfen ob nun mein Apache in chroot läuft??
mutombo
Posts: 184
Joined: 2003-06-19 06:10
 

Re: Apache in chroot die 2.

Post by mutombo »

guck doch mit /ls /proc/(PID)/root
und wenn du dir sicher sein willst das mod_security läuft aktiviere mal den servertoken dann kannste im header nachgucken.
Post Reply