busybox httpd cgi cgi-bin

Denys Vlasenko vda.linux at googlemail.com
Wed May 7 12:13:43 UTC 2008


On Wednesday 07 May 2008 11:33, cheesiong wrote:
> hi Denys,
>  thank you.
>  i hardly understand what is in the httpd.log. please have a look on the
> httpd.log generated from the method you guide me when you are free.

Please send non-linewrapped file next time.
If needed, attach it instead of pasting it inline.
Thanks.

The log actually is very useful. You found a bug!

We chdir to "home dir" (given by -h DIR):

2772  chdir("www")                      = 0

We got a request for /form-post.html:

2775  write(2, "10.104.9.53:1268: connected\n", 28) = 28
2775  rt_sigaction(SIGALRM, {0x80ba0da, [], 0}, NULL, 8) = 0
2775  alarm(60)                         = 0
2775  read(0, "GET /form-post.html HTTP/1.1\r\nUs"..., 8193) = 367
2775  stat64("form-post.html", {st_mode=S_IFREG|0777, st_size=747, ...}) = 0
2775  write(2, "10.104.9.53:1268: url:/form-post"..., 38) = 38

We successfully handle it:

2775  write(1, "HTTP/1.0 200 OK\r\nContent-type: t"..., 167) = 167
2775  read(3, "<html>\r\n<head>\r\n<title>CGI Test<"..., 8192) = 747
2775  write(1, "<html>\r\n<head>\r\n<title>CGI Test<"..., 747) = 747
2775  read(3, "", 8192)                 = 0
2775  shutdown(1, 1 /* send */)         = 0
2775  fcntl64(0, F_GETFL)               = 0x2 (flags O_RDWR)
2775  fcntl64(0, F_SETFL, O_RDWR|O_NONBLOCK) = 0
2775  read(0, "", 8192)                 = 0
2775  write(2, "10.104.9.53:1268: closed\n", 25) = 25
2775  exit_group(0)    

We got a request for /cgi-bin/test-post:

2776  write(2, "10.104.9.53:1269: connected\n", 28) = 28
2776  rt_sigaction(SIGALRM, {0x80ba0da, [], 0}, NULL, 8) = 0
2776  alarm(60)                         = 0
2776  read(0, "POST /cgi-bin/test-post HTTP/1.1"..., 8193) = 588
2776  stat64("cgi-bin/test-post",  <unfinished ...>
2776  <... stat64 resumed> {st_mode=S_IFREG|0777, st_size=591, ...}) = 0
2776  write(2, "10.104.9.53:1269: url:/cgi-bin/t"..., 41) = 41
2776  stat64("cgi-bin", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0

And here's the bug:

2776  vfork()                           = 2777
2777  close(6)                          = 0
2777  close(3)                          = 0
2777  dup2(5, 0)                        = 0
2777  close(5)                          = 0
2777  dup2(4, 1)                        = 1
2777  close(4)                          = 0
2777  chdir("www/cgi-bin")              = -1 ENOENT (No such file or directory)

httpd incorrectly prepended "www" to CGI's path!

Can you replace httpd.c with attached file, rerun the test,
and send strace log again (even if test is successful)?
--
vda
-------------- next part --------------
A non-text attachment was scrubbed...
Name: httpd.c.bz2
Type: application/x-bzip2
Size: 19486 bytes
Desc: not available
Url : http://lists.busybox.net/pipermail/busybox/attachments/20080507/aab80fbf/attachment-0002.bin 


More information about the busybox mailing list