Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!bloom-beacon!gatech!gt-cmmsr!auc!maw From: maw@auc.UUCP (Michael A. Walker) Newsgroups: comp.lang.c Subject: Re: getpwnam Message-ID: <32132@auc.UUCP> Date: Sun, 16-Aug-87 14:08:41 EDT Article-I.D.: auc.32132 Posted: Sun Aug 16 14:08:41 1987 Date-Received: Sun, 16-Aug-87 22:49:42 EDT References: <8725@brl-adm.ARPA> <32131@auc.UUCP> Organization: Atlanta University, Atlanta, GA Lines: 50 Summary: errata from the author of this article In article <32131@auc.UUCP>, maw@auc.UUCP (Michael A. Walker) writes: > In article <8725@brl-adm.ARPA>, oxy!bagpiper@csvax.caltech.EDU (Michael Paul Hunter) writes: > > > > In uudecode.c there is a function called getpwnam. (struct passwd getpwnam) > > Since I am not using a true unix (primix 2.0 yuch) I need to know what this > > function does so that I can try to rewrite it. Could anybody please either > > send me a functional speck of getpwnam, or, could somebody send me a piece > > of code that does what unix getpwname does, but on a PR1ME 9955. > > The function getpwnam() returns a pointer to the entry in the password > file for a specified login name. The following is an example of how it might > be used in a program(probably only in UN*X enviornments: > ----cut out stuff--- > > However, to mimic getpwnam(), one can very simply write a program that will > search the password file and retrieve the desired information. Here's an > example that retrieves all of the users login name: ^^^^^ ^^^^^ ^^^^ This is not true. The second program I wrote in the last message, returns the contents of the pw_comments part of the /etc/passwd file( field 5 ). To return the all of the users login names, you would have to define FIELD to be 0 instead of 4. Also, you can get other data from the password file by changing the FIELD definition to a number one less than the actual field you want. Please forgive me of the error. -----mike P. S. Both of my messages were written with the following structure of the password file in mind(delimited by :'s): struct passwd { char *pw_name; char *pw_passwd; int pw_uid; int pw_gid; char *pw_age; char *pw_comment; char *pw_gecos; char *pw_dir; char *pw_shell; }; -- <-----------------------------------------------------------------------------> < Michael A. Walker | Operator | AUC Computational Center > < gatech!gt-cmmsr!auc!maw | <<<<>>>> | "There is strength in diversity." > <----------------------------------------------------------------------------->