Новости | Документация | Download | Webboard | FAQ | Поиск | Контакты

Apache.RU - Webboard



Вернуться
CGI + CHROOT = Premature end of script header (hades) 02/12 - 09:22:52



From: hades - 02/12 - 09:22:52
Subject:CGI + CHROOT = Premature end of script header
-----------------
Не могу понять от куда растут грабли :(

вот код

#include <stdio.h>

int main ()
{
printf ("Content-type: text/html\n\n");
printf ("TEst\n");

return 0;
}

компилю gcc -static -o s.cgi index.c

соответственно

file /var/www/local.lan/cgi-bin/s.cgi
/var/www/local.lan/cgi-bin/s.cgi: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.2.0, statically linked, not stripped

ldd /var/www/local.lan/cgi-bin/s.cgi
not a dynamic executable


Фрагмент httpd.conf

<Directory "/cgi-bin">
Options ExecCGI
SetHandler cgi-script
AllowOverride None
Order allow,deny
Allow from all
</Directory>
AddHandler cgi-script .cgi
ScriptAlias /my/cgi-bin/ /cgi-bin/

итого 112
drwxr-xr-x 2 root root 4096 2006-12-01 20:44 bin
drwxr-xr-x 2 apache apache 4096 2006-12-01 21:17 cgi-bin
drwxr-xr-x 2 root root 4096 2006-06-01 01:21 dev
drwxr-xr-x 2 root root 4096 2006-12-01 21:27 etc
drwxr-xr-x 3 root root 4096 2006-12-02 07:44 lib
drwxr-xr-x 2 root root 4096 2006-06-03 01:56 libexec
drwxr-xr-x 2 root root 4096 2006-12-02 07:50 logs
drwxr-xr-x 2 root root 4096 2006-09-11 12:45 mrtg
drwxr-xr-x 4 root root 4096 2006-12-01 16:51 opt
drwxrwxrwx 2 root root 20480 2006-12-02 08:00 tmp
drwxr-xr-x 5 root root 4096 2006-12-02 07:48 usr
drwxr-xr-x 6 root root 4096 2006-10-25 18:17 var
drwxr-xr-x 3 root root 4096 2006-10-21 13:00 www

/cgi-bin/

-rwxr-xr-x 1 apache apache 471085 2006-12-01 21:16 s.cgi


strace chroot /var/www/local.lan/ /cgi-bin/s.cgi


execve("/usr/sbin/chroot", ["chroot", "/var/www/local.lan/", "/cgi-bin/s.cgi"], [/* 20 vars */]) = 0
uname({sys="Linux", node="local.lan", ...}) = 0
brk(0) = 0x804b2ec
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40017000
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.preload", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY) = 4
fstat64(4, {st_mode=S_IFREG|0644, st_size=31968, ...}) = 0
old_mmap(NULL, 31968, PROT_READ, MAP_PRIVATE, 4, 0) = 0x40018000
close(4) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/libc.so.6", O_RDONLY) = 4
read(4, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\360^\1"..., 512) = 512
fstat64(4, {st_mode=S_IFREG|0755, st_size=1244752, ...}) = 0
old_mmap(NULL, 1254916, PROT_READ|PROT_EXEC, MAP_PRIVATE, 4, 0) = 0x40020000
old_mmap(0x40148000, 32768, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 4, 0x127000) = 0x40148000
old_mmap(0x40150000, 9732, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x40150000
close(4) = 0
munmap(0x40018000, 31968) = 0
brk(0) = 0x804b2ec
brk(0x806c2ec) = 0x806c2ec
brk(0) = 0x806c2ec
brk(0x806d000) = 0x806d000
open("/usr/lib/locale/locale-archive", O_RDONLY|O_LARGEFILE) = 4
fstat64(4, {st_mode=S_IFREG|0644, st_size=291696, ...}) = 0
mmap2(NULL, 291696, PROT_READ, MAP_PRIVATE, 4, 0) = 0x40153000
close(4) = 0
open("/usr/lib/locale/locale-archive", O_RDONLY|O_LARGEFILE) = 4
fstat64(4, {st_mode=S_IFREG|0644, st_size=291696, ...}) = 0
mmap2(NULL, 4096, PROT_READ, MAP_PRIVATE, 4, 0x47) = 0x40018000
close(4) = 0
chroot("/var/www/local.lan/") = 0
chdir("/") = 0
execve("/cgi-bin/s.cgi", ["/cgi-bin/s.cgi"], [/* 20 vars */]) = 0
uname({sys="Linux", node="alchevsk.net", ...}) = 0
brk(0) = 0x80aea20
brk(0x80cfa20) = 0x80cfa20
brk(0x80d0000) = 0x80d0000
fstat64(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 5), ...}) = 0
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40000000
write(1, "Content-type: text/html\r\n", 25Content-type: text/html
) = 25
write(1, "\r\n", 2
) = 2
write(1, "TEst\n", 5TEst
) = 5
munmap(0x40000000, 4096) = 0
exit_group(0) = ?


[Это сообщение - спам!]

Последние сообщения из форума

 Имя:
 E-mail:
 Тема:
 Текст:
Код подтверждения отправки: Code
28797




  Copyright Apache.ru © 1999-2017, All Rights Reserved Разработка сайта: Inside.ru  
  РЕКЛАМА НА САЙТЕ: |