Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > CGI Python user/group permission weirdness

Reply
Thread Tools

CGI Python user/group permission weirdness

 
 
Aienthiwan
Guest
Posts: n/a
 
      01-18-2004
Ok - this one's a baffling one.

I have a Python script run in cgi, it accesses a directory...
/var/foo.

The permissions on /var/foo are 770 with an ownership of mark:dbtest.
The permissions on /var are 755.

In my /etc/group file, www-data is part of the www-data, dbtest,
fusion and cvs groups.

I get an exception thrown with a permission denied on /var/foo.

I have confirmed that it's the www-data user by calling a
os.system('whoami') in my script for debugging.

When I su www-data at the terminal, I can access /var/foo just fine.

What's even weirder, if I switch the ownership of /var/foo to any of
the other groups (except the cvs and the dbtest one), the script
works!

The only inconsistancy is in dbtest and cvs.

I have attempted to rename them, adjust their ids, pretty much
everything I thought of.

I'm out of ideas.

HELP!

~ Aienthiwan.
 
Reply With Quote
 
 
 
 
Samuel Walters
Guest
Posts: n/a
 
      01-18-2004
| Aienthiwan said |

> Ok - this one's a baffling one.

<chop>
> I have confirmed that it's the www-data user by calling a
> os.system('whoami') in my script for debugging.

<chop>
> The only inconsistancy is in dbtest and cvs.


Have you tried os.system('groups') to verify that the user is in groups
dbtest and cvs? Though I can't think of a reason why, maybe the script
or the calling process is dropping it's privileges to these groups.

Have you tried making all the directories leading up to the path of the
file executable by dbtest and cvs? Some oddball code may be walking to
the path, rather than jumping to the file. How about world executable?

If you're just testing, you might also try making the files 777 for a
minute and testing to see if the problem persists. (Don't leave this in
production, only use it to isolate the error.)

Try making a link from the file you want into another directory. Can you
access it with the same permissions as the original, or perhaps with
different permission?

What www-daemon is this running on? Some www-daemons can be configured to
lock down certain directories and var is a likely candidate for that. Can
you access other files withing the var directory? If you fail this test,
and succeed with the previous two tests, consider that it might be the
daemon with an out-of-box configuration to keep web-processes out of
sensitive system areas.

HTH

I'll post if I think of anything else.

Sam Walters.

--
Never forget the halloween documents.
http://www.opensource.org/halloween/
""" Where will Microsoft try to drag you today?
Do you really want to go there?"""

 
Reply With Quote
 
 
 
 
Aienthiwan
Guest
Posts: n/a
 
      01-19-2004
Hi Sam,

Thanks for your prompt reply, and for all your suggestions.

The process is a cgi python script being called from apache, so it's
the www-data user that apache generated by default.

That idea of making a link is a good one - I'll remember that for next
time.

I tried pretty much all of what you suggested, to know avail. The last
thing I tried shortly after writing this e-mail was going into apache
and switching the Group directive from www-data to dbtest in
httpd.conf to see if that made a difference; and it did.

So it seems to be dropping groups somehow - I did some research on
this and all the evidence in apache documentation let to the contrary.

I didn't want to leave my www-data user by default as dbtest group, so
I tinkered around with it some more, and eventually put it back the
way that it was.

And then everything started working properly.

I wish I had an idea of what I did exactly - serves me right for
attempting this stuff at 5 in the morning I guess.

Well, problem's solved although I don't know exactly why - thx again
for all your help and suggestions!

Regards,
Aienthiwan


Samuel Walters <> wrote in message news:<>...
> | Aienthiwan said |
>
> > Ok - this one's a baffling one.

> <chop>
> > I have confirmed that it's the www-data user by calling a
> > os.system('whoami') in my script for debugging.

> <chop>
> > The only inconsistancy is in dbtest and cvs.

>
> Have you tried os.system('groups') to verify that the user is in groups
> dbtest and cvs? Though I can't think of a reason why, maybe the script
> or the calling process is dropping it's privileges to these groups.


> Have you tried making all the directories leading up to the path of the
> file executable by dbtest and cvs? Some oddball code may be walking to
> the path, rather than jumping to the file. How about world executable?
>
> If you're just testing, you might also try making the files 777 for a
> minute and testing to see if the problem persists. (Don't leave this in
> production, only use it to isolate the error.)
>
> Try making a link from the file you want into another directory. Can you
> access it with the same permissions as the original, or perhaps with
> different permission?
>
> What www-daemon is this running on? Some www-daemons can be configured to
> lock down certain directories and var is a likely candidate for that. Can
> you access other files withing the var directory? If you fail this test,
> and succeed with the previous two tests, consider that it might be the
> daemon with an out-of-box configuration to keep web-processes out of
> sensitive system areas.
>
> HTH
>
> I'll post if I think of anything else.
>
> Sam Walters.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Fixed: The machine-default permission settings do not grant Local Activation permission for the COM Server application with CLSID {555F3418-D99E-4E51-800A-6E89CFD8B1D7} to the user NT AUTHORITY\LOCAL SERVICE SID (S-1-5-19). Skybuck Flying Windows 64bit 1 06-29-2009 06:17 PM
cgi relay for python cgi script Amir Michail Python 7 10-04-2005 07:11 PM
Python-cgi or Perl-cgi script doubt praba kar Python 1 07-30-2005 08:25 AM
Tkinter WEIRDNESS or Python WEIRDNESS? steve Python 4 03-13-2005 12:34 AM
Python CGI - Accepting Input, Invoking Another Process, Ending CGI LarsenMTL Python 4 11-04-2004 05:59 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57