NetBSD Problem Report #42067
From arto.huusko@pp2.inet.fi Tue Sep 15 14:54:18 2009
Return-Path: <arto.huusko@pp2.inet.fi>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
by www.NetBSD.org (Postfix) with ESMTP id 4C7F363B877
for <gnats-bugs@gnats.NetBSD.org>; 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)
From: arto.huusko@pp2.inet.fi
Reply-To: arto.huusko@pp2.inet.fi
To: gnats-bugs@gnats.NetBSD.org
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
>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:/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.
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.