NetBSD Problem Report #42067

From  Tue Sep 15 14:54:18 2009
Return-Path: <>
Received: from ( [])
	by (Postfix) with ESMTP id 4C7F363B877
	for <>; Tue, 15 Sep 2009 14:54:18 +0000 (UTC)
Message-Id: <20090915145415.07E838DA62@mutteri.local>
Date: Tue, 15 Sep 2009 17:54:14 +0300 (EEST)
Subject: can not use stderr from cgi script
X-Send-Pr-Version: 3.95

>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
System: NetBSD mutteri.local 5.99.16 NetBSD 5.99.16 (MUTTERI) #8: Thu Sep 10 21:33:38 EEST 2009 root@maailma.local:/local/scratch/build/nbsd-current/amd64/obj/sys/arch/amd64/compile/MUTTERI amd64
Architecture: x86_64
Machine: amd64
    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.
    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.
    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
> #include <fcntl.h>
< process_cgi(http_req *request)
> process_cgi(http_req *request, int isindex)
>       /* strip appended index.html */
>       if (isindex)
>               file[strlen(file) - strlen(index_html)] = 0;
<               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.

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD:,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.