Opened 11 years ago

Last modified 11 years ago

#42 defect closed fixed (fixed)

Application.setUID and setEUID not portable.

Reported by: radix Owned by:
Priority: high Milestone:
Component: Keywords:
Cc: radix Branch:
Author: Launchpad Bug:

Description


Attachments (1)

patch.txt (1.2 KB) - added by rptownsend 11 years ago.

Download all attachments as: .zip

Change History (9)

comment:1 Changed 11 years ago by radix

These methods fail on HP-UX11i because os.getgid()
returns 3, not zero.

comment:2 Changed 11 years ago by glyph

returns 3 for root, I assume you mean

Changed 11 years ago by rptownsend

comment:3 Changed 11 years ago by rptownsend

Yes, I posted this to the Twisted-Python mailing list:

# id
uid=0(root) gid=3(sys)
groups=0(root),1(other),2(bin),4(adm),5(daemon),6(mail),7
(lp),20(users)

# /opt/python/bin/python          
Python 2.2.1 (#5, Jan 23 2003, 13:18:26) [C] on hp-ux11
Type "help", "copyright", "credits" or "license" for more 
information.
>>> import os
>>> os.getgid()
3

A patch was posted by Martin Armstrong.

Andrew Bennets replied:
"This looks sensible to me.  Would anyone object if I 
checked it in?"

Since then, nothing...

comment:4 Changed 11 years ago by radix

I don't understand how the attached patch is relevant; it
catches more errors, but doesn't seem to do anything about
the fact that on HP/UX root is uid 3. I probably don't
understand the problem enough, can you explain more?

comment:5 Changed 11 years ago by rptownsend

It's root's *gid* that is set to 3, not it's *uid*.

This means that 'if not os.getgid()' will always return 
False, thus setUID() and setEUID() will have no effect.

My patch doesn't call os.getgid(), it just tries to call 
the appropriate set functions and ignores any exceptions if 
the calls fail.

comment:6 Changed 11 years ago by radix

Ah, right, since the code wasn't checking against `0'
explicitly, I was confused. I'll commit your patch.

comment:7 Changed 11 years ago by radix

buildbot's green

comment:8 Changed 4 years ago by <automation>

Note: See TracTickets for help on using tickets.