Unix Programming - Get login name differences in this case...

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > July 2007 > Get login name differences in this case...





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Get login name differences in this case...
K-mart Cashier

2007-07-11, 1:21 am

What's the difference between using

struct passwd *getpwuid(uid_t uid);

vs

reading utmp to get name of the person currently logged on?


Thanks in advance
Chad

Kurt M. Weber

2007-07-11, 1:21 am

K-mart Cashier wrote:

> What's the difference between using
>
> struct passwd *getpwuid(uid_t uid);
>
> vs
>
> reading utmp to get name of the person currently logged on?



utmp is unreliable (see utmp(5) for an explanation).

--
Kurt M. Weber
<kmw@armory.com>
K-mart Cashier

2007-07-11, 1:21 am

On Jul 10, 8:19 pm, "Kurt M. Weber" <k...@armory.com> wrote:
> K-mart Cashier wrote:
>
>
>
>
> utmp is unreliable (see utmp(5) for an explanation).
>
> --
> Kurt M. Weber
> <k...@armory.com>



On the Linux utmp(5), I don't see anyting that would say utmp is
unreliable. Maybe I'm not looking at utmp(5) close enough.

Chad

Barry Margolin

2007-07-11, 1:21 am

In article <1398j2g7224co6c@corp.supernews.com>,
"Kurt M. Weber" <kmw@armory.com> wrote:

> K-mart Cashier wrote:
>
>
>
> utmp is unreliable (see utmp(5) for an explanation).


If there are multiple usernames that map to the same UID, which of the
two methods will give the one that was actually used at login time?

--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
Barry Margolin

2007-07-11, 1:21 am

In article <1184129411.938641.215930@x35g2000prf.googlegroups.com>,
K-mart Cashier <cdalten@gmail.com> wrote:

> On Jul 10, 8:19 pm, "Kurt M. Weber" <k...@armory.com> wrote:
>
> On the Linux utmp(5), I don't see anyting that would say utmp is
> unreliable. Maybe I'm not looking at utmp(5) close enough.


I don't see it in the OS X man page, either.

--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
Kurt M. Weber

2007-07-11, 1:22 pm

K-mart Cashier wrote:

>
> On the Linux utmp(5), I don't see anyting that would say utmp is
> unreliable. Maybe I'm not looking at utmp(5) close enough.
>
> Chad


*DESCRIPTION*
The utmp file allows one to discover information about who is
currently using the system. There may be more users currently using the
system, because not all programs use utmp logging.

It also doesn't include logins done via xdm, since XDM login sessions aren't
assigned to a particular terminal.

Furthermore, the format for utmp varies from platform to platform. Chances
are your code won't be portable.

--
Kurt M. Weber
<kmw@armory.com>
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com