[Gllug] cuserid?

Peter Childs peterachilds at gmail.com
Mon Oct 17 19:23:23 UTC 2005


Ok So why can't I get the effective user id and then look it up using
the settings in nsswitch.conf using standard nss libraries I guess.
Why are things always 10 time more complex than they seam at first?

Peter Childs

On 17/10/05, Peter Grandi <pg_gllug at gllug.for.sabi.co.uk> wrote:
> >>> On Mon, 17 Oct 2005 15:21:54 +0100,
> >>> pg_gllug at gllug.for.sabi.co.UK (Peter Grandi) said:
>
> >>> On Mon, 17 Oct 2005 15:10:16 +0100, Peter Childs
> >>> <peterachilds at gmail.com> said:
>
> peterachilds> How do I find out who the current user is as
> peterachilds> returned by whoami in c [ ... ]
>
> pg_gllug> Well in the general case this is impossible; what a
> pg_gllug> process really knows is the current numeric id [ ... ]
> pg_gllug> The best bet is severalfold: check both '$USER' and
> pg_gllug> '$LOGNAME' first, then if that fails find out which
> pg_gllug> one is the current tty, and use 'wtmp'(5)
>
> Oops, that should have been 'utmp'(5), but fortunately it is the
> same 'man' page for both :-); also, in particular consider the
> prominent warning in it.
>
> pg_gllug> [ ... ] As a shortcut you can look at the output of
> pg_gllug> 'id -a' for example. [ ... ]
>
> Or even better, 'strace' or even 'ltrace' an invocation of
> 'whoami' or 'id'. That should be quite entertaining.
>
> --
> Gllug mailing list  -  Gllug at gllug.org.uk
> http://lists.gllug.org.uk/mailman/listinfo/gllug
>
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list