[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Q



On Thu, 29 Jan 1998, Erez Doron wrote:

> Hi
> 
> does anybody knows of a unix command that
> checks if a there is such a user on the system ?
> 
> i meen that I'll ask if there is a username 'yossi' or 'moshe'
> on this host, and I'll get an answer
> 
> ( do not tell me 'finger', this requires a daemon )

It depends whether you want to do local lookups or remote.

Remote:

You cannot find out if a user is on the remote system without it having
some daemon running, like sendmail for example. If the remote system is
part of a NIS domain, and the host you are on can hear broadcasts from the
network the NIS master server or slave servers sits on, then you can do:

ypbind -ypset
ypset the.master/slaver.nis.server

Then, do ypmatch username passwd. This is not full proof though, since
through netgroups one can restrict access on a computer to a certain
netgroup. You can see a user's netgroups by issuing: 

ypmatch username.\* netgroup.byuser 

for example. (assuming that the site is using netgroup.byname and 
netgroup.byuid NIS maps for the netgroups, which is the default I think).

You mileage may vary.

Local:

There are quite a few ways to find a local user, starting with the "id
username", through using shell/awk one liners, Perl, Tcl, C, C++ :))  etc
etc etc. All these solutions will be accessing /etc/passwd and look fo a
string you ask them for.

For NIS, you can also use ypmatch username passwd. and as I said in the
Remote paragraph, you need to check if there aren't any netgroup
restrictions, but the difference here is that you can find out for sure if
a NIS user can or cannot access the machine, since you can look it
/etc/passwd and see what netgroups are allowed access, and compare it with
the list of available netgroups for the user.

Regards,

--Ariel


> 
> regards
> Erez.
> 
> 
> 

   +---------------------------------------------------------------+
   | Ariel Biener                                                  |
   | e-mail: ariel@post.tau.ac.il        Work ph: 03-6406086       |
   | fingerprint = 07 D1 E5 3E EF 6D E5 82 0B E9 21 D4 3C 7D 8B BC |
   +---------------------------------------------------------------+