On Thu, 08 Nov 2007 18:22:48 +0000
Steve Long <[EMAIL PROTECTED]> wrote:
> > if [[ ${UID} -ne 0 ]]; then
> > 
> > We've always told people not to do that. Capabilities required by
> > eselect modules should be tested by attempting to perform the
> > action, not by some arbitrary query done on UIDs or groups. Being
> > UID 0 doesn't mean you're allowed to do something, and not being
> > UID 0 doesn't mean you're not allowed to do something.
> > 
> I've always used EUID for the root check, eg:

Which is just as bad.

> This won't get round capabilities (so error status should still be
> checked and the script bail with appropriate output, if it can't do
> something it's supposed to) but it's sufficient for root privilege
> check, and is better than UID which requires login as root. This
> doesn't, of course, deal with non-root users, eg where users in group
> portage are allowed to carry out a task.

Except you absolutely never should be checking for root. You should be
checking for capabilities.

> You can check for that kind of thing with a writeable test, eg:
> [[ -w $PORTDIR ]] || die 'Write access to portage dir required"

-w is not reliable.

> Wrt signalling die, the correct way for a script to terminate on
> signal is something like this code, taken from a SIG_INT handler:
>         trap INT
>         kill -INT $$
> This ensures the parent process is correctly notified. So IOW just
> kill self with the appropriate signal, ensuring any traps are cleared.

No it isn't. When it comes to die, from bad implementations to good
implementations, the order goes: the original drobbins prefix die sucks
more than the original agriffis die, which sucks more than my original
signalling eselect die, which sucks more than the current signalling
paludis die. As time goes on we're finding better and better tricks to
work around bash's lack of exceptions; eselect is currently one
generation behind the best current known solution.

-- 
Ciaran McCreesh

Attachment: signature.asc
Description: PGP signature

Reply via email to