Return-Path: Delivered-To: apmail-apr-dev-archive@www.apache.org Received: (qmail 74744 invoked from network); 20 Apr 2009 23:40:43 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 20 Apr 2009 23:40:43 -0000 Received: (qmail 17330 invoked by uid 500); 20 Apr 2009 23:40:42 -0000 Delivered-To: apmail-apr-dev-archive@apr.apache.org Received: (qmail 17237 invoked by uid 500); 20 Apr 2009 23:40:41 -0000 Mailing-List: contact dev-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Id: Delivered-To: mailing list dev@apr.apache.org Received: (qmail 17229 invoked by uid 99); 20 Apr 2009 23:40:41 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 20 Apr 2009 23:40:41 +0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of trawick@gmail.com designates 72.14.220.159 as permitted sender) Received: from [72.14.220.159] (HELO fg-out-1718.google.com) (72.14.220.159) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 20 Apr 2009 23:40:35 +0000 Received: by fg-out-1718.google.com with SMTP id e21so841893fga.22 for ; Mon, 20 Apr 2009 16:40:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type; bh=l7vvPa8A0hLG+3/lswAeGvsGZ+gXsS96DYNxwJzzea4=; b=i/oBZ7gAGAcqEJmjduNT8PXFGSqBy9jfNR5UbemUBARi5Kz0aR1gyShAe2NfT6WiBb 7d49XFNH4kT/4X77GtOg5nQKGeQGCtqHvDCWzgjg55eTZbhRmZzD8EkWtLaEgAv38m2b nzlS6XuvZp11Ma7sFxR+SwFZvaGXzvuGGurIM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=IsgbOOgDwFb2vAK9tEko9askfNKaxFwsoO8zgQWLIf2i84nhFd2BzoBmIYHoLdxcPP mfvh40ISIeE9Zu/+tE8gC+7RZqHEtCcoiaYwPFeyAMt3GzjzGaOdf2QmdYJV9mBIa5OZ QzLTeWiQGeEspTFEN6zNZxNY0Mgy1pEUa/TEE= MIME-Version: 1.0 Received: by 10.86.92.9 with SMTP id p9mr4240230fgb.15.1240270813497; Mon, 20 Apr 2009 16:40:13 -0700 (PDT) In-Reply-To: <49ECF4B5.4060502@marchex.com> References: <49ECF4B5.4060502@marchex.com> Date: Mon, 20 Apr 2009 19:40:13 -0400 Message-ID: Subject: Re: apr_file_open() flag issue From: Jeff Trawick To: dev@apr.apache.org, dev@perl.apache.org, madkins@marchex.com Content-Type: multipart/alternative; boundary=000e0cd28d14438acc0468050dd5 X-Virus-Checked: Checked by ClamAV on apache.org --000e0cd28d14438acc0468050dd5 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit (I'm not subscribed to dev@perl...) On Mon, Apr 20, 2009 at 6:18 PM, Marc Adkins wrote: > I found this in mod_perl but the issue can be demonstrated without Perl. > > Attempting to open a file for append using the following flags: > > APR_BUFFERED | APR_BINARY | APR_CREATE | APR_APPEND > > > will not work. The apr_file_open() function returns APR_EACCES. If the > following flags are used: > > APR_BUFFERED | APR_BINARY | APR_CREATE | APR_WRITE | APR_APPEND > > > it works fine. In a vacuum this behavior is debatable. On the one hand, > APR_APPEND could be seen to imply APR_WRITE. On the other hand, it might > be argued that the first case is incomplete flag-wise. > > In the context of Perl, however, particularly when using the APR PerlIO > filter, this becomes problematic. Perl uses special character sequences > which are converted to the proper flags down underneath the covers. So in > Perl '>' (write to a new file) converts properly but '>>' (append to an > existing file or create a new one if necessary) does not. There is no > message either, AFAIK, it just fails silently. > The Perl code that builds the apr_file_open() flags needs to turn on APR_WRITE. I think that this patch to mod_perl is what you need: --- modperl_apr_perlio.c.orig 2007-12-31 02:39:50.000000000 -0500 +++ modperl_apr_perlio.c 2009-04-20 19:37:25.954107404 -0400 @@ -85,7 +85,7 @@ switch (*mode) { case 'a': - apr_flag = APR_APPEND | APR_CREATE; + apr_flag = APR_WRITE | APR_CREATE | APR_APPEND; break; case 'w': apr_flag = APR_WRITE | APR_CREATE | APR_TRUNCATE; --000e0cd28d14438acc0468050dd5 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
(I'm not subscribed to dev@perl...)

O= n Mon, Apr 20, 2009 at 6:18 PM, Marc Adkins <madkins@marchex.com> wrote:
I found this in mod_perl but the issue can be demonstrated without Perl.
Attempting to open a file for append using the following flags:

APR_BUFFERED | APR_BINARY | APR_CREATE | APR_APPEND

will not work.=A0 The apr_fi= le_open() function returns APR_EACCES<= /font>.=A0 If the following flags are used:

APR_BUFFERED | APR_BINARY | APR_CREATE | APR_WRITE | APR_APPEND

it works fine.=A0 In a vacuum this behavior is debatable.=A0 On the one hand, APR_APPEND could be seen to imply APR_W= RITE.=A0 On the other hand, it might be argued that the first case is incomplete flag-wise.

In the context of Perl, however, particularly when using the APR PerlIO filter, this becomes problematic.=A0 Perl uses special character sequences which are converted to the proper flags down underneath the covers.=A0 So in Perl '&= gt;' (write to a new file) converts properly but '>>' (append to an existing file or create a new one if necessary) does not.=A0 There is no message either, AFAIK, it just fails silently.

T= he Perl code that builds the apr_file_open() flags needs to turn on APR_WRI= TE.

I think that this patch to mod_perl is what you need:

--- modperl_apr_perlio.c.orig=A0=A0=A0 2007-12-31 02:39:50.000000000 -0500<= br>+++ modperl_apr_perlio.c=A0=A0=A0 2009-04-20 19:37:25.954107404 -0400@@ -85,7 +85,7 @@
=A0
=A0=A0=A0=A0 switch (*mode) {
=A0=A0=A0=A0= =A0=A0 case 'a':
-=A0=A0=A0=A0=A0=A0=A0 apr_flag =3D APR_APPEND = | APR_CREATE;
+=A0=A0=A0=A0=A0=A0=A0 apr_flag =3D APR_WRITE | APR_CREATE | APR_APPEND;=A0=A0=A0=A0=A0=A0=A0=A0 break;
=A0=A0=A0=A0=A0=A0 case 'w':=A0=A0=A0=A0=A0=A0=A0=A0 apr_flag =3D APR_WRITE | APR_CREATE | APR_TRUNCAT= E;

--000e0cd28d14438acc0468050dd5--