View previous topic :: View next topic |
Author |
Message |
lavish Bodhisattva
Joined: 13 Sep 2004 Posts: 4296
|
Posted: Tue Sep 18, 2007 2:07 pm Post subject: Problemi con Apache e suEXEC: failed to setgid |
|
|
Sono 3 giorni che sto sbattendo la testa su un problema riguardante suEXEC:
Ho il seguente script di prova: /var/www/localhost/cgi-bin/test.rc
Code: | #!/usr/local/9/bin/rc
cat <<END
Content-Type: text/plain
prova rc
END |
Viene usata come shell rc, la shell originaria di Plan9. E' disponibile in portage via plan9port, ma io uso un pacchetto differente che installa solo l'userland.. si tratta semplicemente di un subset di plan9port.
Affinche' venisse inclusa la dir /usr/local/9/bin in $SAFE_PATH, ho modificato l'ebuild per includerla e infatti:
Code: | suexec -V
-D AP_DOC_ROOT="/var/www"
-D AP_GID_MIN=100
-D AP_HTTPD_USER="apache"
-D AP_LOG_EXEC="/var/log/apache2/suexec_log"
-D AP_SAFE_PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/9/bin"
-D AP_SUEXEC_UMASK=077
-D AP_UID_MIN=1000
-D AP_USERDIR_SUFFIX="public_html" |
Questo script tenendo suEXEC disabilitato funziona alla perfezione; lo stesso vale se commento in /etc/apache2/vhosts.d/00_default_vhost.conf Code: | # SuexecUserGroup lavish users | : funziona alla grande.
Abilitando suEXEC dal browser ho un bel errore 500. Nei log mi ritrovo le seguenti cose:
/var/log/apache2/suexec_log
Code: | [2007-09-18 15:35:52]: uid: (1000/lavish) gid: (100/100) cmd: test.rc
[2007-09-18 15:35:52]: failed to setgid (100: test.rc) |
/var/log/apache2/error_log
Code: | [Tue Sep 18 15:35:52 2007] [error] [client 127.0.0.1] suexec policy violation: see suexec log for more details
[Tue Sep 18 15:35:52 2007] [error] [client 127.0.0.1] Premature end of script headers: test.rc |
Provando a fare uno strace su apache non si ricavano molte informazioni se non:
Code: | 15358 write(3, "[2007-09-18 15:35:52]: uid: (100"..., 70) = 70
15358 setgid32(100) = -1 EPERM (Operation not permitted)
15358 write(2, "suexec policy violation: see sue"..., 57 <unfinished ...>
15352 <... epoll_wait resumed> {{EPOLLIN, {u32=136497416, u64=68855974152}}}, 2, 300000) = 1
15358 <... write resumed> ) = 57
15352 read(20, "s", 1) = 1
15352 read(20, "u", 1) = 1
15352 read(20, "e", 1) = 1
15352 read(20, "x", 1) = 1
15352 read(20, "e", 1) = 1
15352 read(20, "c", 1) = 1
15352 read(20, " ", 1) = 1
15352 read(20, "p", 1) = 1
15352 read(20, "o", 1) = 1
15352 read(20, "l", 1) = 1
15352 read(20, "i", 1) = 1
15352 read(20, "c", 1) = 1
15352 read(20, "y", 1) = 1
15352 read(20, " ", 1) = 1
15352 read(20, "v", 1) = 1
15352 read(20, "i", 1) = 1
15352 read(20, "o", 1) = 1
15352 read(20, "l", 1) = 1
15352 read(20, "a", 1) = 1
15352 read(20, "t", 1) = 1
15352 read(20, "i", 1) = 1
15352 read(20, "o", 1) = 1
15352 read(20, "n", 1) = 1
15352 read(20, ":", 1) = 1
15352 read(20, " ", 1) = 1
15352 read(20, "s", 1) = 1
15352 read(20, "e", 1) = 1
15352 read(20, "e", 1) = 1
15352 read(20, " ", 1) = 1
15352 read(20, "s", 1) = 1
15352 read(20, "u", 1) = 1
15352 read(20, "e", 1) = 1
15352 read(20, "x", 1) = 1
15352 read(20, "e", 1) = 1
15352 read(20, "c", 1) = 1
15352 read(20, " ", 1) = 1
15352 read(20, "l", 1) = 1
15352 read(20, "o", 1) = 1
15352 read(20, "g", 1) = 1
... (il log a cui rimanda ve l'ho riportato prima) |
Da notare che rc non e' un simlink o altro... Code: | /usr/local/9/bin/rc: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.6.9, statically linked, not stripped |
Io sono arrivato a un punto morto.. se qualcuno sa aiutarmi lo ringrazio _________________ minimalblue.com | secgroup.github.io/ |
|
Back to top |
|
|
Dun Apprentice
Joined: 17 Apr 2004 Posts: 172 Location: Amsterdam (NL) / Venice (IT)
|
Posted: Tue Sep 18, 2007 2:44 pm Post subject: |
|
|
..... pffffff
Note: Scusate, e' che so gia' in che server andranno a finire queste cose :p |
|
Back to top |
|
|
lavish Bodhisattva
Joined: 13 Sep 2004 Posts: 4296
|
Posted: Tue Sep 18, 2007 2:45 pm Post subject: |
|
|
Dun wrote: | Note: Scusate, e' che so gia' in che server andranno a finire queste cose :p |
_________________ minimalblue.com | secgroup.github.io/ |
|
Back to top |
|
|
lavish Bodhisattva
Joined: 13 Sep 2004 Posts: 4296
|
|
Back to top |
|
|
randomaze Bodhisattva
Joined: 21 Oct 2003 Posts: 9985
|
Posted: Fri Sep 21, 2007 3:01 pm Post subject: |
|
|
lavish wrote: | Niente di niente? Devo postare nel forum internazionale? |
Tutto quello che ti posso dire é che quella spataffiata di roba che hai postato é concorde: non riesce a settare il gruppo.
Puoi postare/spedirmi/guardare le precedenti righe di strace? Perché vedo che non sostituisce il nome del gruppo nella linea di log ma lascia il simbolico, come se non fosse riuscito a leggerlo.
Non conosco Suexec, ma se c'é un chroot di mezzo forse potrei pensare che ti sei dimenticato qualcosa tipo /etc/groups... _________________ Ciao da me! |
|
Back to top |
|
|
lavish Bodhisattva
Joined: 13 Sep 2004 Posts: 4296
|
Posted: Fri Sep 21, 2007 4:34 pm Post subject: |
|
|
randomaze wrote: | Non conosco Suexec, ma se c'é un chroot di mezzo forse potrei pensare che ti sei dimenticato qualcosa tipo /etc/groups... |
Nah, sto provando questa configurazione su una macchina di testing, non mi metto a fare le prove sul server Niente chroot quindi. Inoltre gli altri cgi che si appoggiano a python/perl/sh/c funzionano alla grande... ho provato a fare un binario in C che stampa su stdout un header html e l'ho piazzato in /usr/local/9/bin/. Funziona pure lui
randomaze wrote: | Tutto quello che ti posso dire é che quella spataffiata di roba che hai postato é concorde: non riesce a settare il gruppo.
Puoi postare/spedirmi/guardare le precedenti righe di strace? Perché vedo che non sostituisce il nome del gruppo nella linea di log ma lascia il simbolico, come se non fosse riuscito a leggerlo. |
Yessir _________________ minimalblue.com | secgroup.github.io/ |
|
Back to top |
|
|
Alakhai Apprentice
Joined: 16 Oct 2003 Posts: 151
|
Posted: Fri Sep 21, 2007 6:30 pm Post subject: |
|
|
Code: |
[2007-09-18 15:35:52]: uid: (1000/lavish) gid: (100/100) cmd: test.rc
[2007-09-18 15:35:52]: failed to setgid (100: test.rc)
|
a me da l'idea che il gid 100 non esiste O_o
dico una cazzata?
usi LDAP? _________________ Gentoo Linux 64Bit User |
|
Back to top |
|
|
lavish Bodhisattva
Joined: 13 Sep 2004 Posts: 4296
|
Posted: Fri Sep 21, 2007 6:42 pm Post subject: |
|
|
Alakhai wrote: | Code: |
[2007-09-18 15:35:52]: uid: (1000/lavish) gid: (100/100) cmd: test.rc
[2007-09-18 15:35:52]: failed to setgid (100: test.rc)
|
a me da l'idea che il gid 100 non esiste O_o
dico una cazzata? |
Code: | 0 $ id
uid=1000(lavish) gid=100(users) groups=10(wheel),11(floppy),18(audio),19(cdrom),27(video),35(games),80(cdrw),85(usb),100(users),250(portage),408(qemu) |
Nein _________________ minimalblue.com | secgroup.github.io/ |
|
Back to top |
|
|
Alakhai Apprentice
Joined: 16 Oct 2003 Posts: 151
|
Posted: Fri Sep 21, 2007 7:02 pm Post subject: |
|
|
il programma ha i priv da root o ha i suoi?
se ha i suoi, può eseguire cambiamenti di privs? _________________ Gentoo Linux 64Bit User |
|
Back to top |
|
|
lavish Bodhisattva
Joined: 13 Sep 2004 Posts: 4296
|
Posted: Fri Sep 21, 2007 7:06 pm Post subject: |
|
|
Alakhai wrote: | il programma ha i priv da root o ha i suoi?
se ha i suoi, può eseguire cambiamenti di privs? |
Non ti seguo
Lo script rc e' Code: | -rwxr-xr-x 1 lavish users 3614 2007-09-19 15:46 /var/www/localhost/cgi-bin/show.rc |
Mentre rc stessa: Code: | -rwxr-xr-x 1 root root 670854 2007-09-17 01:18 /usr/local/9/bin/rc |
Era questo che chiedevi? _________________ minimalblue.com | secgroup.github.io/ |
|
Back to top |
|
|
Alakhai Apprentice
Joined: 16 Oct 2003 Posts: 151
|
Posted: Fri Sep 21, 2007 7:40 pm Post subject: |
|
|
premetto che non sono pratico di apache, peò vediamo un po
allora il file test.rc che priv ha?
se gli setti i priv a mano?
chown lavish:users /percorsodelfile/test.rc _________________ Gentoo Linux 64Bit User |
|
Back to top |
|
|
lavish Bodhisattva
Joined: 13 Sep 2004 Posts: 4296
|
Posted: Fri Sep 21, 2007 7:44 pm Post subject: |
|
|
Alakhai wrote: | premetto che non sono pratico di apache, peò vediamo un po
allora il file test.rc che priv ha?
se gli setti i priv a mano?
chown lavish:users /percorsodelfile/test.rc |
Ma se te li ho postati 2 secondi fa?
//EDIT: ho letto meglio, tu chiedi test.rc : ha gli stessi permessi di show.rc _________________ minimalblue.com | secgroup.github.io/ |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|