public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
From: Steve Long <slong@rathaus.eclipse.co.uk>
To: gentoo-dev@lists.gentoo.org
Subject: [gentoo-dev]  Re: eselect_zenity: alpha eselect GUI
Date: Thu, 08 Nov 2007 18:22:48 +0000	[thread overview]
Message-ID: <fgvju5$lck$1@ger.gmane.org> (raw)
In-Reply-To: 20071108124333.2a3dfdc7@blueyonder.co.uk

Ciaran McCreesh 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:
if ((EUID)); then
        echo "You must be root to run this script" >&2
        exit 1
fi

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.

You can check for that kind of thing with a writeable test, eg:
[[ -w $PORTDIR ]] || die 'Write access to portage dir required"
While none of this stops you from needing to check errors, it does make it
nicer for users, imo, if scripts check early on for broader permissions
where it's appropriate.

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.


-- 
gentoo-dev@gentoo.org mailing list



  reply	other threads:[~2007-11-08 18:22 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-08 10:48 [gentoo-dev] eselect_zenity: alpha eselect GUI Donnie Berkholz
2007-11-08 10:54 ` Ciaran McCreesh
2007-11-08 12:07   ` Donnie Berkholz
2007-11-08 12:43     ` Ciaran McCreesh
2007-11-08 18:22       ` Steve Long [this message]
2007-11-08 18:34         ` [gentoo-dev] " Ciaran McCreesh
2007-11-11  9:43           ` [gentoo-dev] " Steve Long
2007-11-11 11:58             ` [gentoo-dev] " Christian Faulhammer
2007-11-11 13:08             ` [gentoo-dev] " Ciaran McCreesh
2007-11-12  9:13               ` [gentoo-dev] " Steve Long
2007-11-12 13:30                 ` Fernando J. Pereda
2007-11-12 23:30                 ` Jan Kundrát
2007-11-13 15:41                 ` Ciaran McCreesh
2007-11-13 16:13                   ` Dan
2007-11-13 16:22                     ` Jeroen Roovers
2007-11-08 15:03 ` [gentoo-dev] " Luis Francisco Araujo
2007-11-13 19:12 ` Doug Klima
2007-11-13 19:22   ` [gentoo-dev] " Markus Ullmann
2007-11-13 22:07     ` Doug Klima
2007-11-13 22:32     ` Donnie Berkholz
2007-11-13 22:55       ` Rémi Cardona

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='fgvju5$lck$1@ger.gmane.org' \
    --to=slong@rathaus.eclipse.co.uk \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox