|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T r
Length: 6824 (0x1aa8) Types: TextFile Names: »report.c«
└─⟦a0efdde77⟧ Bits:30001252 EUUGD11 Tape, 1987 Spring Conference Helsinki └─⟦this⟧ »EUUGD11/euug-87hel/sec8/mcp/src/report.c«
#include <sys/types.h> #include <sys/stat.h> #include <sys/time.h> #include <lastlog.h> #include "sysdep.h" #include "macros.h" #include "mem.h" #include "lists.h" #include "account.h" #ifdef SENDMAIL #include "alias.h" #endif #include "class.h" #include "groupmap.h" #include "range.h" #include "sig.h" #include "sort.h" #ifdef BSD4_3 time_t time(); #endif #ifdef SENDMAIL extern struct list AliasList; #endif extern struct list AccountList, ClassList, GroupMapList, RangeList, SigList; extern int root; extern char *when(); Summarize() { (void) printf("%d user%s, %d group%s, %d class%s, %d sig%s", AccountList.l_count, S(AccountList.l_count), GroupMapList.l_count, S(GroupMapList.l_count), ClassList.l_count, ES(ClassList.l_count), SigList.l_count, S(SigList.l_count)); #ifdef SENDMAIL (void) printf(", %d alias%s\n", AliasList.l_count, ES(AliasList.l_count)); #else (void) puts(""); #endif return; } int ReportGoop() { struct account *ac; struct groupmap *gm; struct class *cs; struct sig *sg; struct stat sb; struct list c, s; #ifdef SENDMAIL struct alias *al; char *cp; #endif time_t now; int goop = 0; register int indx, i; zerolist(&c); zerolist(&s); for (indx=0; indx < AccountList.l_count; indx++) { ac = (struct account *) AccountList.l_list[indx]; /* * For root and vig members, howl if no password. */ if (ac->ac_passwd[0] == '\0') { if (ac->ac_uid == 0) { (void) printf("user \"%s\" has no password!\n", ac->ac_name); continue; } gm = getgmgid(ac->ac_gid); if (gm && vigexists((char *)gm->gm_name)) (void) printf("user \"%s\" has no password\n", ac->ac_name); } /* * Report users with base gids that do not correspond * to a group in /etc/group. */ if (!gidexists(ac->ac_gid)) (void) printf("user \"%s\" has nonexistent gid of (%d)\n", ac->ac_name, ac->ac_gid); /* * Report references to non-existent classes */ for (i=0; i < ac->ac_classes.l_count; i++) { if (!classexists((char *)ac->ac_classes.l_list[i])) { (void) printf("user \"%s\" is member of nonexistent class \"%s\"\n", ac->ac_name, ac->ac_classes.l_list[i]); goop++; continue; } if (!instrlist(&c, (char *)ac->ac_classes.l_list[i])) strlistadd(&c, (char *)ac->ac_classes.l_list[i]); } /* * Report references to non-existent sigs */ for (i=0; i < ac->ac_sigs.l_count; i++) { if (!sigexists((char *)ac->ac_sigs.l_list[i])) { (void) printf("user \"%s\" is member of nonexistent sig \"%s\"\n", ac->ac_name, ac->ac_sigs.l_list[i]); goop++; continue; } if (!instrlist(&s, (char *)ac->ac_sigs.l_list[i])) strlistadd(&s, (char *)ac->ac_sigs.l_list[i]); } /* * Skip home directory and shell check if not the super-user, * since not some shells may not be accessible to non * super-users. */ if (!root) continue; if (!fileexists((char *)ac->ac_dir)) (void) printf("user \"%s\"'s home directory (%s) not found\n", ac->ac_name, ac->ac_dir); if (stat((char *)ac->ac_dir, &sb) == 0) if (sb.st_uid != ac->ac_uid) (void) printf("user \"%s\" does not own his home directory (%s)\n", ac->ac_name, ac->ac_dir); if (!fileexists((char *)ac->ac_shell)) (void) printf("user \"%s\" login shell (%s) not found\n", ac->ac_name, ac->ac_shell); } sort_list(&s, pstrcmp); sort_list(&c, pstrcmp); for (indx=0; indx < GroupMapList.l_count; indx++) { gm = (struct groupmap *) GroupMapList.l_list[indx]; for (i=0; i < gm->gm_mem.l_count; i++) { if (!userexists((char *)gm->gm_mem.l_list[i])) { (void) printf("group \"%s\" contains nonexistent user \"%s\"\n", gm->gm_name, gm->gm_mem.l_list[i]); goop++; } } } (void) time(&now); for (indx=0; indx < ClassList.l_count; indx++) { cs = (struct class *) ClassList.l_list[indx]; if (!instrlist(&c, (char *)cs->cs_name)) { (void) printf("class \"%s\" is empty\n", cs->cs_name); goop++; } if (cs->cs_exptime && (now >= cs->cs_exptime)) { (void) printf("class \"%s\" expired %s\n", cs->cs_name, when(cs->cs_exptime)); goop++; } } for (indx=0; indx < SigList.l_count; indx++) { sg = (struct sig *) SigList.l_list[indx]; if (!instrlist(&s, (char *)sg->sg_name)) { (void) printf("sig \"%s\" is empty\n", sg->sg_name); goop++; } if (sg->sg_exptime && (now >= sg->sg_exptime)) { (void) printf("sig \"%s\" expired %s\n", sg->sg_name, when(sg->sg_exptime)); goop++; } } #ifdef SENDMAIL for (indx=0; indx < AliasList.l_count; indx++) { al = (struct alias *) AliasList.l_list[indx]; for (i=0; i < al->al_groups.l_count; i++) { cp = (char *)al->al_groups.l_list[i]; if (!groupexists(cp)) { (void) printf("alias \"%s\" bound to nonexistent group \"%s\"\n", al->al_name, cp); goop++; } } for (i=0; i < al->al_classes.l_count; i++) { cp = (char *)al->al_classes.l_list[i]; if (!classexists(cp)) { (void) printf("alias \"%s\" bound to nonexistent class \"%s\"\n", al->al_name, cp); goop++; } } for (i=0; i < al->al_sigs.l_count; i++) { cp = (char *)al->al_sigs.l_list[i]; if (!sigexists(cp)) { (void) printf("alias \"%s\" bound to nonexistent sig \"%s\"\n", al->al_name, cp); goop++; } } } #endif return goop; } ListThemThangs() { struct groupmap *gm; struct class *cs; struct sig *sg; struct account *ac; register int i, j; int memcount; if (GroupMapList.l_count) puts("== Groups =="); for (i=0; i < GroupMapList.l_count; i++) { gm = (struct groupmap *) GroupMapList.l_list[i]; memcount = gm->gm_mem.l_count; for (j=0; j < AccountList.l_count; j++) { ac = (struct account *) AccountList.l_list[j]; if (ac->ac_gid == gm->gm_gid) memcount++; } printf("\"%s\", %d member%s, %d groupie%s\n", gm->gm_name, memcount - gm->gm_mem.l_count, S(memcount - gm->gm_mem.l_count), gm->gm_mem.l_count, S(gm->gm_mem.l_count)); } if (ClassList.l_count) puts("== Classes =="); for (i=0; i < ClassList.l_count; i++) { memcount = 0; cs = (struct class *) ClassList.l_list[i]; for (j=0; j < AccountList.l_count; j++) { ac = (struct account *) AccountList.l_list[j]; if (instrlist(&ac->ac_classes, cs->cs_name)) memcount++; } printf("\"%s\", %d member%s, ends %s\n", cs->cs_name, memcount, S(memcount), when(cs->cs_exptime)); } if (SigList.l_count) puts("== Sigs =="); for (i=0; i < SigList.l_count; i++) { memcount = 0; sg = (struct sig *) SigList.l_list[i]; for (j=0; j < AccountList.l_count; j++) { ac = (struct account *) AccountList.l_list[j]; if (instrlist(&ac->ac_sigs, sg->sg_name)) memcount++; } printf("\"%s\", %d member%s, ends %s\n", sg->sg_name, memcount, S(memcount), when(sg->sg_exptime)); } return; }