Return-Path: Delivered-To: apmail-httpd-modules-dev-archive@locus.apache.org Received: (qmail 94641 invoked from network); 28 Apr 2008 20:58:39 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 28 Apr 2008 20:58:39 -0000 Received: (qmail 38384 invoked by uid 500); 28 Apr 2008 20:58:40 -0000 Delivered-To: apmail-httpd-modules-dev-archive@httpd.apache.org Received: (qmail 38371 invoked by uid 500); 28 Apr 2008 20:58:40 -0000 Mailing-List: contact modules-dev-help@httpd.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: modules-dev@httpd.apache.org Delivered-To: mailing list modules-dev@httpd.apache.org Received: (qmail 38360 invoked by uid 99); 28 Apr 2008 20:58:40 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 28 Apr 2008 13:58:40 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of graham.dumpleton@gmail.com designates 209.85.198.225 as permitted sender) Received: from [209.85.198.225] (HELO rv-out-0506.google.com) (209.85.198.225) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 28 Apr 2008 20:57:55 +0000 Received: by rv-out-0506.google.com with SMTP id g37so2604715rvb.24 for ; Mon, 28 Apr 2008 13:58:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=7vqune0ggU0VhWKpKD4KyxcgVw86qIofS1x4yE7JTGs=; b=VbFcbr8bLOaJ3h3S36vyjUQeD8BZ8BBaylH+aihzWDmIfLNyQ3t1HlYQly0+I4TJ8KilVuWekl+j01xDoWoG3tP3/8b2bq944h9QBs2i+4aRdwUD0Etsq4nrM5Nm8E3DbhaClAYAe0LL766S46Y+pWMEjXqZsP7+FhaxWFOjEvg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=uV54om955uqAgqyN4+NvyH1DP84QK7OkH1He/Tuf5Gway1aux6qsk0BLHZv9MaAt4lDoc2bTWMvqNX4Fn7r6n7AeOfIIbNdOIfyYvziedjN/2FWc47oX+E9nlLYLH3WrN4UREbkW5YgtVkw3uwssvNL3+S/Mxrn8jT1gXKYdOcs= Received: by 10.141.203.7 with SMTP id f7mr3348769rvq.7.1209416245939; Mon, 28 Apr 2008 13:57:25 -0700 (PDT) Received: by 10.141.1.14 with HTTP; Mon, 28 Apr 2008 13:57:25 -0700 (PDT) Message-ID: <88e286470804281357u5f4b803bh3855a4fce681929e@mail.gmail.com> Date: Tue, 29 Apr 2008 06:57:25 +1000 From: "Graham Dumpleton" To: modules-dev@httpd.apache.org Subject: Re: need some help with module that does not work on linux In-Reply-To: <4816253B.8090403@sequoiagroup.com> MIME-Version: 1.0 Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <1209404494l.13383l.0l@raydesk1.bettercgi.com> <4816253B.8090403@sequoiagroup.com> X-Virus-Checked: Checked by ClamAV on apache.org 2008/4/29 Chris Kukuchka : > Aivars =8Aterns wrote: > > > Yes, but this is not how apache could handle this, we need argv[], but > there > > is no way to get this from apache right? > > > > > > In server/main.c, argv gets linked to the process_rec structure during t= he > process startup. Further, according to include/httpd.h, the process_rec > structure can be reached through the request_rec structure > (r->connection->server->process). As such, argv[] should be available fo= r > reading most anywhere in Apache. > > As far as the safety of making changes to those values is concerned, I h= ave > no advise beyond, "proceed with caution." Especially if you intend on > placing raw request data there. Although you can get access to argv[], you can only change the value of argv[0], at least for the purposes of effecting the output from 'ps'. This is because that argv[] is not the original argv[] and thus modules could have substituted the program arguments, ie., argv[1] and beyond. This means that any value you substitute must fit into the original length of argv[0] and cannot flow over into the additional arguments. Some code form mod_wsgi: static void wsgi_setup_daemon_name(WSGIDaemonProcess *daemon, apr_pool_t *p= ) { const char *display_name =3D NULL; int slen =3D 0; int dlen =3D 0; char *argv0 =3D NULL; display_name =3D daemon->group->display_name; if (!display_name) return; if (!strcmp(display_name, "%{GROUP}")) { display_name =3D apr_pstrcat(p, "(wsgi:", daemon->group->name, ")", NULL); } /* * Only argv[0] is guaranteed to be the real things as MPM * modules may make modifications to subsequent arguments. * Thus can only replace the argv[0] value. Because length * is restricted, need to truncate display name if too long. */ argv0 =3D (char*)wsgi_server->process->argv[0]; dlen =3D strlen(argv0); slen =3D strlen(display_name); memset(argv0, ' ', dlen); if (slen < dlen) memcpy(argv0, display_name, slen); else memcpy(argv0, display_name, dlen); } The wsgi_server variable is a cached reference to server_rec structure. Graham