DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download
Index: ┃ T a

⟦08f094258⟧ TextFile

    Length: 3317 (0xcf5)
    Types: TextFile
    Names: »account.c«

Derivation

└─⟦a0efdde77⟧ Bits:30001252 EUUGD11 Tape, 1987 Spring Conference Helsinki
    └─ ⟦this⟧ »EUUGD11/euug-87hel/sec8/mcp/src/account.c« 

TextFile

#include <stdio.h>
#include <sys/types.h>
#include <lastlog.h>
#include "sysdep.h"
#include "macros.h"
#include "mem.h"
#include "sort.h"
#include "lists.h"
#include "account.h"

extern	struct list AccountList;

static FILE *acf = NULL;
static addr_t line[LONG_BUF];
static struct account acct;

setacent()

{
	if ( !acf ) {
		acf = fopen (ACFILE, "r" );
		if (!acf) {
			perr(ACFILE);
			goodbye(1);
		}
	}
	else
		rewind( acf );
	return;
}

endacent()

{
	if ( acf ) {
		(void) fclose( acf );
		acf = NULL;
	}
}

addr
acskip(pp,c)
addr pp;
register c;
{
	flexaddr p;
	register char *cp;

	cp = (char *) pp;
	while( *cp && *cp != c && (*cp != ':' || c != ',') )
		++cp;
	if ( *cp == ':' && c != ':' ) {
		*(p.p_cp = cp) = '\0';
		return( p.p_ap );
	}
	if ( *cp ) *cp++ = '\0';
	p.p_cp = cp;
	return( p.p_ap );
}

struct account *
getacent()

{
	flexaddr p, oldp;
	register struct list *q;

	if (!acf)
		setacent();
	zerolist(&acct.ac_groups);
	zerolist(&acct.ac_classes);
	zerolist(&acct.ac_sigs);
#ifdef SENDMAIL
	zerolist(&acct.ac_aliases);
#endif
	if( !(p.p_cp = fgets( (char *)line, BUFSIZ, acf )) )
		return(NULL);
	acct.ac_name = p.p_ap;
	acct.ac_realname = p.p_ap = acskip(p.p_ap, ':');
	acct.ac_id = p.p_ap = acskip(p.p_ap, ':');
	p.p_ap = acskip(p.p_ap,':');
	acct.ac_uid = atoi(p.p_cp);
	p.p_ap = acskip(p.p_ap,':');
	acct.ac_gid = atoi(p.p_cp);
	(void) acskip(p.p_ap,'\n');
	oldp.p_ap = p.p_ap = acskip(p.p_ap,':');
	q = &acct.ac_groups;
	while( *p.p_cp && *p.p_cp != ':' ) {
		oldp.p_ap = p.p_ap;
		p.p_ap = acskip(p.p_ap,',');
		strlistadd(q, oldp.p_cp);
	}
	sort_list(q, pstrcmp);
	p.p_cp++;
	q = &acct.ac_classes;
	while( *p.p_cp && *p.p_cp != ':' ) {
		oldp.p_ap = p.p_ap;
		p.p_ap = acskip(p.p_ap,',');
		strlistadd(q, oldp.p_cp);
	}
	sort_list(q, pstrcmp);
	p.p_cp++;
	q = &acct.ac_sigs;
	while( *p.p_cp && *p.p_cp != ':' ) {
		oldp.p_ap = p.p_ap;
		p.p_ap = acskip(p.p_ap,',');
		strlistadd(q, oldp.p_cp);
	}
	sort_list(q, pstrcmp);
#ifdef SENDMAIL
	p.p_cp++;
	q = &acct.ac_aliases;
	while( *p.p_cp ) {
		oldp.p_ap = p.p_ap;
		p.p_ap = acskip(p.p_ap,',');
		strlistadd(q, oldp.p_cp);
	}
	sort_list(q, pstrcmp);
#endif
	return &acct;
}

struct account *
getacuid(uid)
int  uid;

{
	int found, index;

	index = search_list(&AccountList, (char *)&uid, iacctcmp, &found);
	if (found)
		return (struct account *) AccountList.l_list[index];
	return (struct account *) 0;
}

struct account *
getacid(id)
char *id;
{
	int indx;
	struct account *a;

	for (indx=0; indx < AccountList.l_count; indx++) {
		a = (struct account *) AccountList.l_list[indx];
		if (eq(a->ac_id, id))
			return a;
	}
	return (struct account *) 0;
}

struct account *
getacnam(name)
char *name;
{
	struct account *a;
	register int indx;

	if (!userexists(name))
		return (struct account *) 0;
	for (indx=0; indx < AccountList.l_count; indx++) {
		a = (struct account *) AccountList.l_list[indx];
		if (eq(a->ac_name, name))
			return a;
	}
	return (struct account *) 0;
}

/*
 * Do a simply format check of the accounts file.
 */
int
acck()

{
	FILE *f;
	char b[BUFSIZ];

	f = fopen(ACFILE, "r");
	if (f == NULL) {
		err1("can't open %s (read)", ACFILE);
		return 0;
	}
	while (fgets(b, BUFSIZ, f) != NULL) {
		if (coloncount(b) != 8) {
			err1("%s: badly formed line", ACFILE);
			return 0;
		}
	}
	(void) fclose(f);
	return 1;
}