Re: TODO Done. Superuser backend slot reservations - Mailing list pgsql-hackers

From Nigel J. Andrews
Subject Re: TODO Done. Superuser backend slot reservations
Date
Msg-id Pine.LNX.4.21.0208261055020.576-100000@ponder.fairway2k.co.uk
Whole thread Raw
In response to Re: TODO Done. Superuser backend slot reservations  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: TODO Done. Superuser backend slot reservations
List pgsql-hackers
On Mon, 26 Aug 2002, Tom Lane wrote:

> "Nigel J. Andrews" <nandrews@investsystems.co.uk> writes:
> > +     if (!superuser() && MyBackendId > MaxBackends - ReservedBackends)
> > +         elog(ERROR, "Normal user limit exceeded");
>
> This coding is wrong on its face: the slot number you happen to find has
> no relationship to the number of slots remaining free, except as an
> existence proof that the number of slots free was > 0 before you took
> one.

Yes.

I was taking the line that the last slots in the array are reserved. Those are
not going to be taken by non su connections. Therefore, if MyBackendId is
under the lower limit it doesn't matter if it's the only slot free since the
'safety' measure has already been used in restricting access to the last free
slots and it just so happens that those sessions are still active.

I take Neil's point about the order of the tests. That's my stupidity when
rearranging stuff after noticing in tests that the user information wasn't
available where I was [also stupidly] expecting it to be first time around.


--
Nigel J. Andrews


pgsql-hackers by date:

Previous
From: Christopher Kings-Lynne
Date:
Subject: Re: PostgreSQL 7.2.2 and docs
Next
From: Sir Mordred The Traitor
Date:
Subject: @(#)Mordred Labs advisory 0x0006: Two minor DoS conditions in PostgreSQL