NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

bin/42067: can not use stderr from cgi script



>Number:         42067
>Category:       bin
>Synopsis:       use of stderr from cgi script does not work
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Sep 15 14:55:00 +0000 2009
>Originator:     Arto Huusko
>Release:        NetBSD 5.99.16
>Organization:
>Environment:
System: NetBSD mutteri.local 5.99.16 NetBSD 5.99.16 (MUTTERI) #8: Thu Sep 10 
21:33:38 EEST 2009 
root%maailma.local@localhost:/local/scratch/build/nbsd-current/amd64/obj/sys/arch/amd64/compile/MUTTERI
 amd64
Architecture: x86_64
Machine: amd64
>Description:
    Using stderr from a cgi script called by NetBSD stock httpd started
    from inted may be flakey, because httpd closes stderr before execing
    the cgi script.
>How-To-Repeat:
    For example, run cvsweb on a repository that has files with commitid
    keywords in them. When browsing such a file, the version history for
    that particular file is not shown at all.

    This is apparently caused by the fact that cvsweb (a perl script) runs
    rlog on the file, and rlog prints to stderr:

rlog: /some/file,v:: warning: Unknown phrases like `commitid ...;' are present.

    Due to closed stderr, rlog terminates prematurely.
>Fix:
    Don't close stderr, but duplicate it to /dev/null, for example.
    I use this diff, which also includes yet another isindex fix;
    the change relevant to this pr is the last bit:

Index: cgi-bozo.c
===================================================================
RCS file: /cvsroot/src/libexec/httpd/cgi-bozo.c,v
retrieving revision 1.14
diff -r1.14 cgi-bozo.c
41a42
> #include <fcntl.h>
91c92
< process_cgi(http_req *request)
---
> process_cgi(http_req *request, int isindex)
109a111,113
>       /* strip appended index.html */
>       if (isindex)
>               file[strlen(file) - strlen(index_html)] = 0;
265c269,270
<               close(2);
---
>               /*close(2);*/
>               {int fd = open("/dev/null", O_WRONLY, 0); dup2(fd, 
> STDERR_FILENO); close(fd);}


    A better solution would be capture stderr output, and log it.



Home | Main Index | Thread Index | Old Index