Re: setuid(geteuid());?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, PostgreSQL Development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: setuid(geteuid());?
Date: 2001-04-21 20:42:03
Message-ID: 11098.987885723@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Peter Eisentraut <peter_e(at)gmx(dot)net> writes:
> Bruce Momjian writes:
>> so why does your test work? Does your manual say something different?
>> If setuid() sets user/effective/saved to postgres, how can you get back
>> root?

> : setuid sets the effective user ID of the current process. If the
> : effective userid of the caller is root, the real and saved user ID's
> : are also set.

HPUX has an even more bizarre definition:

setuid() sets the real-user-ID (ruid),effective-user-ID (euid), and/or
saved-user-ID (suid) of the calling process. The super-user's euid is
zero. The following conditions govern setuid's behavior:

o If the euid is zero, setuid() sets the ruid, euid, and suid to
uid.

o If the euid is not zero, but the argument uid is equal to the
ruid or the suid, setuid() sets the euid to uid; the ruid and
suid remain unchanged. (If a set-user-ID program is not
running as super-user, it can change its euid to match its
ruid and reset itself to the previous euid value.)

o If euid is not zero, but the argument uid is equal to the
euid, and the calling process is a member of a group that has
the PRIV_SETRUGID privilege (see privgrp(4)), setuid() sets
the ruid to uid; the euid and suid remain unchanged.

Rule #2 is what creates the security hole. Rule #3 would allow us to
plug the hole, but only if we have PRIV_SETRUGID...

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2001-04-21 20:43:26 Re: setuid(geteuid());?
Previous Message Bruce Momjian 2001-04-21 20:03:10 Re: setuid(geteuid());?