For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > March 2004 > Find User Apache is running as









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Find User Apache is running as
Jupiterhost.Net

2004-03-28, 10:11 pm

Hello List!

I was trying to figure out how to see the user the script/webserver is
running as. (Like apache is 'nobody' or the owner 'foomonkey' perhaps
with SuExec enabled)

I looked in %ENV and didn't see it in there.

Any ideas?

TIA

Lee.M - JupiterHost.Net
Andrew Gaffney

2004-03-28, 10:11 pm

JupiterHost.Net wrote:
> Hello List!
>
> I was trying to figure out how to see the user the script/webserver is
> running as. (Like apache is 'nobody' or the owner 'foomonkey' perhaps
> with SuExec enabled)
>
> I looked in %ENV and didn't see it in there.
>
> Any ideas?


If you're running Linux (might work on other UNIXs too), you can run 'ps aux | grep
apache' (Apache 2.x) or 'ps aux | grep httpd' (Apache 1.x). The first column is the user
it's running as.

--
Andrew Gaffney
Network Administrator
Skyline Aeronautics, LLC.
636-357-1548

Wc -Sx- Jones

2004-03-28, 10:11 pm

JupiterHost.Net wrote:
> Hello List!
>
> I was trying to figure out how to see the user the script/webserver is
> running as. (Like apache is 'nobody' or the owner 'foomonkey' perhaps
> with SuExec enabled)
>


ps -ef |grep -i httpd

And, where ever your apache server logs are;
do -

grep -i suexec error*log

It will tell you the path to where it
thinks the SuExec program is...
Jupiterhost.Net

2004-03-29, 12:30 am

Thank you Gaffney and Jones for your input.

I may have to parse external program output I suppose. I was hoping
there would be a more built in or Modular way to get it. Part of the
problem is foo.pl can be run simultaneously by 2 different users so I'm
not sure how I'd be able to make foo.pl tell which ps it belongs to.

I suppose I can use the process Id in $$ in the parseing of ps output.

I was hoping for a builtin variable or module that would tell me :)

Any other ways besides parsing external program output?

TIA

Lee.M - JupiterHost.Net
U235sentinel

2004-03-29, 12:30 am

I'm wondering if there is a perl module to read from the apache server
status screen. Doesn't it tell you the server version running?

Also, when you connect to a web server, doesn't it pass along this
information also?

Been awhile since I've worked with web servers (I'm still a perl noob
btw). Maybe connect with a perl module to the server (localhost) then
parse that info.

Just a thought



JupiterHost.Net wrote:

> Thank you Gaffney and Jones for your input.
>
> I may have to parse external program output I suppose. I was hoping
> there would be a more built in or Modular way to get it. Part of the
> problem is foo.pl can be run simultaneously by 2 different users so
> I'm not sure how I'd be able to make foo.pl tell which ps it belongs to.
>
> I suppose I can use the process Id in $$ in the parseing of ps output.
>
> I was hoping for a builtin variable or module that would tell me :)
>
> Any other ways besides parsing external program output?
>
> TIA
>
> Lee.M - JupiterHost.Net
>


Wc -Sx- Jones

2004-03-29, 1:30 am

u235sentinel wrote:
> I'm wondering if there is a perl module to read from the apache server
> status screen. Doesn't it tell you the server version running?
>
> Also, when you connect to a web server, doesn't it pass along this
> information also?


See

Wc -Sx- Jones

2004-03-29, 1:30 am

JupiterHost.Net wrote:
> problem is foo.pl can be run simultaneously by 2 different users so I'm
> not sure how I'd be able to make foo.pl tell which ps it belongs to.


Not a problem - each will have it's own address space and PID.

The issue - and you haven't shown any code -
is mutual data access.

The script cannot access the same files as it's
"twin" IF they are both running simultaneously.

Why not post what you are really thinking
and wanting to do...

Bill :)
Jupiterhost.Net

2004-03-29, 2:33 pm



Bob Showalter wrote:

> JupiterHost.Net wrote:
>
>
>
> Are you trying to find out from a CGI script being run by the web server in
> question? If so, it's a matter of:
>
> print scalar(getpwuid($> ));


Perfect Mr Showalter! Exactly the same results as parsing ps but without
the External Program worries!!

Thanks a million!

I think you helped me with another issue I had in a former incarnation
with my previous emplyer. You rock!

Lee.M - JupiterHost.Net
Jupiterhost.Net

2004-03-29, 2:34 pm



WC -Sx- Jones wrote:
> JupiterHost.Net wrote:
>
>
>
> Not a problem - each will have it's own address space and PID.
>
> The issue - and you haven't shown any code -
> is mutual data access.
>
> The script cannot access the same files as it's
> "twin" IF they are both running simultaneously.
>
> Why not post what you are really thinking
> and wanting to do...


I can grab the user from the output of the ps command:

`ps -u --no-headers -p $$`

no problem.

Just for portability I was hoping for a built in way, if there is none
that's . I'll just have to implement a check to make sure it will
work before I do it.


>
> Bill :)
>
>
>

Bob Showalter

2004-03-29, 2:35 pm

JupiterHost.Net wrote:
> Hello List!
>
> I was trying to figure out how to see the user the script/webserver is
> running as. (Like apache is 'nobody' or the owner 'foomonkey' perhaps
> with SuExec enabled)
>
> I looked in %ENV and didn't see it in there.


Are you trying to find out from a CGI script being run by the web server in
question? If so, it's a matter of:

print scalar(getpwuid($> ));
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com