You are viewing a plain text version of this content. The canonical link for it is here.
Posted to test-dev@httpd.apache.org by William McKee <wi...@knowmad.com> on 2003/12/12 13:55:43 UTC

Getting User and Group from custom httpd.conf

Hi,

This is my first posting to the list so please forgive my ignorance of
any customs. I am in the process of getting a test environment setup
using the Apache::Test package. While originally installing the package
a few months ago, I ran into a couple of problems which I posted to
rt.cpan.org. Stas kindly replied to both my tickets:
	#3860- a comment about problems with custom httpd in
		/usr/local/apache/bin
	#3861- problems with the generation of the httpd.conf file

Over the course of our conversation about the latter bug, Stas explained
that User and Group directives get set to 'nobody' if TEST is run as
root, otherwise these values get set to the current user. My web
environment is setup with 'www' as the owner of the Apache processes so
I needed to pass in the -User and -Group parameters to TEST to get the
proper settings for my environment.

Stas suggested that I look into a way of reading these values from the
system-installed httpd.conf file. I began to work on that task last
evening (yeah, I got a bit derailed for a few months). While doing so, I
sent the message at the end of this email to Stas. He suggested that I
join the mailing list and post my findings here.

As I contemplate this matter after a night's rest, I'm wondering if it's
such a good idea to get the values of User and Group from the
httpd.conf. It was rather easy to add the ability to pull these entries
from the original http.conf (save some extra logic that needs to be
written to only retrieve the first set from the global options) which
makes me wonder if there was a reason these have been purposely left out
of the TestConfigParse.pm module.

Thanks for any advice and pointers.

William


----- Forwarded message from Stas Bekman <st...@stason.org> -----

> To: william@knowmad.com
> From: Stas Bekman <st...@stason.org>
> Date: Thu, 11 Dec 2003 20:52:12 -0800
> Subject: [Fwd: [cpan #3861] Custom t/conf/httpd.conf.in is ignored]
> Organization: Hope, Humanized
> 
> Hi William,
> 
> this shouldn't be a private discussion. There is a team of developers that 
> handle that module. So if you'd be so kind to repost this to
> test-dev@httpd.apache.org and may be giving some more background on what 
> you are trying to overcome, that would be very helpful. (You may want to 
> subscribe to the list first - test-dev-subscribe@httpd.apache.org, 
> otherwise it may take some time for your message to get approved). I'm 
> about to leave shortly and won't be able to look at it untill I'm back a 
> few days later. So may be Geoff will be able to work with you to resolve 
> the issue while I'm away. Thank you.
> 
> -------- Original Message --------
> Subject: [cpan #3861] Custom t/conf/httpd.conf.in is ignored
> Date: Thu, 11 Dec 2003 21:26:54 -0500 (EST)
> From: Guest via RT <bu...@rt.cpan.org>
> Reply-To: bug-Apache-Test@rt.cpan.org
> To: AdminCc of cpan Ticket #3861: ;
> 
> 
> This message about Apache-Test was sent to you by guest <> via rt.cpan.org
> 
> Full context and any attached attachments can be found at:
> <URL: https://rt.cpan.org/Ticket/Display.html?id=3861 >
> 
> [STAS - Fri Oct  3 18:25:27 2003]:
> 
> >You should be able to grep for this kind of tokens. It's coming from
> >TestConfigParse.pm.
> 
> Hi Stas,
> 
> I've finally had a chance to take another look at parsing the httpd.conf
> file for the Group and User settings. I looked in the TestConfigParse.pm
> file; there's some nice, but complex, code in that module.
> 
> >From what I could figure out, the %wanted_config contains a hash of
> hashes which is used to parse the config file. The TAKE1 group appears
> to be made for retrieving a single key, so I added User and Group to
> that list.
> 
> Now, however, I'm stuck. If I dump the vars hashref after running
> inherit_config, the values of User and Group are my user id 'william'
> (despite the fact that I'm running the script as root). I also looked at
> the value of User when it was being parsed inside of the
> inheret_config_file_or_directory sub. The script had the right values.
> 
> I tried debugging but this part of the code is wrapped inside of an eval
> which sets ulimit before calling the script again. Is there a way to
> debug under this situation?
> 
> So, I'm not sure what needs to happen to get the correct User and Group
> values into the vars hash. Sorry it's been so long but hopefully you can
> pick up the thread by reviewing the messages at rt.cpan.org.
> 
> Now that I think about it, it could be that the parsing routine is
> getting the last User and Group values. Looking at my httpd.conf, this
> appears to be the case. However, those are settings for a VirtualHost
> which probably isn't what we want. We want the global User and Group
> settings which is typically(?) going to be the first value. So, how to
> skip further user and group lines in the parsing? Any suggestions?
> 
> Thanks,
> William
> 
> -- 
> 
> 
> __________________________________________________________________
> Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
> http://stason.org/     mod_perl Guide ---> http://perl.apache.org
> mailto:stas@stason.org http://use.perl.org http://apacheweek.com
> http://modperlbook.org http://apache.org   http://ticketmaster.com

----- End forwarded message -----

-- 
Knowmad Services Inc.
http://www.knowmad.com

Re: Getting User and Group from custom httpd.conf

Posted by Stas Bekman <st...@stason.org>.
William McKee wrote:
[...]
>>Suggestion #2:
>>
>>Don't build/test as root. This is a bad practice. Build/test as a normal 
>>user and only 'su'/'sudo' when running 'make install'.
> 
> 
> Yeah I agree with the sentiment and usu. do this when installing
> software manually, but how does one install via CPAN shell? It seems
> that interface was made to be run as root. Am I missing something that
> would allow me to set it up to build/test as normal user and install as
> root?

All you need to do is to setup CPAN.pm to have its build dir under non-root 
directory, e.g. /tmp/.cpan. And the issue is solved.

> The other idea I've had is to gather this information via the processes
> already in place as well as perhaps Suggestion #1 and then present this
> information to the user in an interactive format such as done by
> HTTP::ApacheCookie. This allows users to specify alternate values if the
> system guesses incorrectly.

Yes, yes, this is all planned to do. Hopefully next month. This won't solve 
the problem of running from under /root. Apache doesn't run under root and it 
won't be able to read files under /root, ever. So you have no choice but to 
build the project under some directory that user 'nobody' (or the one set via 
APACHE_USER/APACHE_GROUP) can read/write/execute.

> I'd be willing to implement these changes if someone on the list can
> point me to the module and subroutine where I should be making them.
> Would the best place for these questions be in the TEST script? That
> would get tedious though when doing testing during development.

The plan is to adopt CPAN/FirstTime.pm to do the same for A-T. I'm planning to 
work on this somewhere next month.

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


Re: Getting User and Group from custom httpd.conf

Posted by William McKee <wi...@knowmad.com>.
On Tue, Dec 16, 2003 at 02:43:20PM -0800, Stas Bekman wrote:
> I think that whatever logic we adopt for inheriting User and Group 
> directives, someone will get bitten by it not doing the right thing, as 
> they may not have their global httpd.conf set right.

I agree.


> Suggestion #1:
> 
> set APACHE_GROUP and APACHE_USER environment variables in your shell 
> startup script, so it'll affect any Apache-Test runs

I like this idea.


> Suggestion #2:
> 
> Don't build/test as root. This is a bad practice. Build/test as a normal 
> user and only 'su'/'sudo' when running 'make install'.

Yeah I agree with the sentiment and usu. do this when installing
software manually, but how does one install via CPAN shell? It seems
that interface was made to be run as root. Am I missing something that
would allow me to set it up to build/test as normal user and install as
root?

The other idea I've had is to gather this information via the processes
already in place as well as perhaps Suggestion #1 and then present this
information to the user in an interactive format such as done by
HTTP::ApacheCookie. This allows users to specify alternate values if the
system guesses incorrectly.

I'd be willing to implement these changes if someone on the list can
point me to the module and subroutine where I should be making them.
Would the best place for these questions be in the TEST script? That
would get tedious though when doing testing during development.

William

-- 
Knowmad Services Inc.
http://www.knowmad.com

Re: Getting User and Group from custom httpd.conf

Posted by Stas Bekman <st...@stason.org>.
I think that whatever logic we adopt for inheriting User and Group directives, 
someone will get bitten by it not doing the right thing, as they may not have 
their global httpd.conf set right.

Suggestion #1:

set APACHE_GROUP and APACHE_USER environment variables in your shell startup 
script, so it'll affect any Apache-Test runs

Suggestion #2:

Don't build/test as root. This is a bad practice. Build/test as a normal user 
and only 'su'/'sudo' when running 'make install'.

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com