|
|
BSD 4.3
#include "parms.h"
#include "structs.h"
#ifdef RCSIDENT
static char rcsid[] = "$Header: /var/lib/cvsd/repos/CSRG/43BSD/contrib/notes/src/gname.c,v 1.1.1.1 2018/04/24 16:12:54 root Exp $";
#endif RCSIDENT
/*
* get the user id ( and his name from th password file )
* the easy way - with system calls.
*/
getname (who_me, anon) /* anon=true for anonymous */
struct auth_f *who_me;
{
static char name[PASSWDLEN]; /* must contain the /etc/passwd entry */
register count;
register char *s,
*d;
static int gotname = 0; /* whether we have done a getpw */
static int gotstat = 0; /* status getpw returned */
if (gotname == 0 && anon == 0) /* grab name if we will require it */
{
gotstat = getpw (globuid, name); /* grab it */
gotname = 1; /* set flag saying we have it */
}
if (gotstat || anon)
{
s = "Anonymous:";
who_me -> aid = Anonuid;
}
else
{
s = name;
who_me -> aid = globuid;
}
d = who_me -> aname; /* copy his name */
count = NAMESZ;
while (((*d++ = *s++) != ':') && --count);
*--d = '\0';
s = Authsystem; /* copy his system */
d = who_me -> asystem;
count = HOMESYSSZ;
while (((*d++ = *s++)) != '\0' && --count); /* move system */
*--d = '\0';
}
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.