9 date 92.12.15.00.07.52; author jromine; state Exp;
14 date 92.11.13.16.56.02; author jromine; state Exp;
19 date 92.11.04.00.40.56; author jromine; state Exp;
24 date 92.10.30.05.53.28; author jromine; state Exp;
29 date 92.05.19.21.06.30; author jromine; state Exp;
34 date 92.02.03.16.35.26; author jromine; state Exp;
39 date 92.01.31.22.07.50; author jromine; state Exp;
44 date 90.04.05.14.57.02; author sources; state Exp;
49 date 90.01.30.11.11.41; author sources; state Exp;
54 date 89.11.17.15.57.52; author sources; state Exp;
59 date 89.06.26.14.36.38; author sources; state Exp;
73 @/* conflict.c - the new conflict */
75 static char ident[] = "@@(#)$Id: conflict.c,v 2.8 1992/11/13 16:56:02 jromine Exp jromine $";
79 #include "../h/aliasbr.h"
80 #include "../h/local.h"
82 #include "../zotnet/mts.h"
94 static struct swit switches[] = {
99 "search directory", 0,
109 static char *mail = NULL;
111 static char *dirs[NDIRS];
113 static FILE * out = NULL;
116 extern struct aka *akahead;
117 extern struct home *homehead;
120 #if !defined(__STDC__) && !defined(__stdc__) /* __stdc__ for convex */
121 struct group *getgrent (), *getgrgid();
122 #endif /* !__STDC__ */
140 setlocale(LC_ALL, "");
142 invo_name = r1bindex (argv[0], '/');
144 mts_init (invo_name);
148 while (cp = *argp++) {
150 switch (smatch (++cp, switches)) {
152 ambigsw (cp, switches);
155 adios (NULLCP, "-%s unknown", cp);
157 (void) sprintf (buf, "%s [switches] [aliasfiles ...]",
159 help (buf, switches);
163 if (!(cp = *argp++) || *cp == '-')
164 adios (NULLCP, "missing argument to %s", argp[-2]);
166 adios (NULLCP, "mail to one address only");
172 if (!(cp = *argp++) || *cp == '-')
173 adios (NULLCP, "missing argument to %s", argp[-2]);
175 adios (NULLCP, "more than %d directories", NDIRS);
185 akv[akp++] = AliasFile;
192 alias_files (akp, akv);
208 alias_files (akp, akv)
214 for (i = 0; i < akp; i++)
215 if ((err = alias (akv[i])) != AK_OK) {
217 fprintf (out, "aliasing error in %s - %s\n", akv[i], akerror (err));
221 fprintf (out, "alias file %s is ok\n", akv[i]);
228 register struct home *hm,
231 for (hm = homehead; hm; hm = hm -> h_next)
232 for (lm = hm -> h_next; lm; lm = lm -> h_next)
233 if (strcmp (hm -> h_name, lm -> h_name) == 0) {
235 fprintf (out, "duplicate user %s(uid=%d)\n",
236 lm -> h_name, lm -> h_uid);
240 if (!hit && out && !mail)
241 fprintf (out, "no duplicate users\n");
249 register struct group *gr;
253 while (gr = getgrent ()) {
254 for (gp = 0; grps[gp]; gp++)
255 if (strcmp (grps[gp], gr -> gr_name) == 0) {
257 fprintf (out, "duplicate group %s(gid=%d)\n",
258 gr -> gr_name, gr -> gr_gid);
262 if (grps[gp] == NULL)
264 grps[gp++] = getcpy (gr -> gr_name);
269 fprintf (out, "more than %d groups (time to recompile)\n",
276 for (gp = 0; grps[gp]; gp++)
279 if (!hit && out && !mail)
280 fprintf (out, "no duplicate groups\n");
286 register int hit = 0;
289 register struct group *gr;
290 register struct home *hm;
293 while (gr = getgrent ())
294 for (cp = gr -> gr_mem; *cp; cp++) {
295 for (hm = homehead; hm; hm = hm -> h_next)
296 if (!strcmp (*cp, hm -> h_name))
300 fprintf (out, "group %s(gid=%d) has unknown member %s\n",
301 gr -> gr_name, gr -> gr_gid, *cp);
309 for (dp = cp + 1; *dp; dp++)
310 if (strcmp (*cp, *dp) == 0) {
312 fprintf (out, "group %s(gid=%d) has duplicate member %s\n",
313 gr -> gr_name, gr -> gr_gid, *cp);
320 for (hm = homehead; hm; hm = hm -> h_next)
321 if (hm -> h_ngrps > NGROUPS) {
323 fprintf (out, "user %s is a member of %d groups (max %d)",
324 hm -> h_name, hm -> h_ngrps, NGROUPS);
329 if (!hit && out && !mail)
330 fprintf (out, "all group members accounted for\n");
334 grp_ids () { /* -DRAND not implemented at most places */
335 register int hit = 0;
336 register struct home *hm;
338 for (hm = homehead; hm; hm = hm -> h_next)
339 if (getgrgid (hm -> h_gid) == NULL) {
341 fprintf (out, "user %s(uid=%d) has unknown group-id %d\n",
342 hm -> h_name, hm -> h_uid, hm -> h_gid);
346 if (!hit && out && !mail)
347 fprintf (out, "all group-id users accounted for\n");
356 if (mmdfldir && *mmdfldir)
358 if (uucpldir && *uucpldir)
360 for (i = 0; dirs[i]; i++)
368 register int hit = 0;
370 register struct dirent *dp;
372 register struct direct *dp;
374 register DIR *dd = opendir (drop);
378 fprintf (out, "unable to open maildrop area %s\n", drop);
382 while (dp = readdir (dd))
383 if (dp -> d_name[0] != '.' && !check (dp ->d_name)) {
386 "there is a maildrop for the unknown user %s in %s\n",
392 if (!hit && out && !mail)
393 fprintf (out, "all maildrops accounted for in %s\n", drop);
402 register struct home *hm;
404 for (hm = homehead; hm; hm = hm -> h_next)
405 if (!strcmp (s, hm -> h_name))
420 if (pipe (pd) == NOTOK)
421 adios ("pipe", "unable to");
425 adios ("fork", "unable to");
428 (void) close (pd[1]);
430 (void) dup2 (pd[0], 0);
431 (void) close (pd[0]);
433 if ((fd = open ("/dev/null", 1)) != NOTOK)
438 execlp (mailproc, r1bindex (mailproc, '/'),
439 mail, "-subject", invo_name, NULLCP);
440 adios (mailproc, "unable to exec ");
443 (void) close (pd[0]);
444 out = fdopen (pd[1], "w");
445 fprintf (out, "%s: the following is suspicious\n\n",
454 /* UCI specific stuff for conflict */
456 /* taken from <grpldr.h> */
458 #define GLDRS "/admin/etc/GroupLeaders"
465 int setglent (), endglent ();
466 struct grpldr *getglent (), *getglnam ();
469 /* taken from the getglent() routines */
476 static FILE *glp = NULL;
477 static char line[BUFSIZ+1];
478 static struct grpldr grpldr;
479 static char *gl_ldr[MAXGLS + 1];
485 glp = fopen (GLDRS, "r");
489 return (glp != NULL);
504 struct grpldr *getglent () {
508 if (glp == NULL && !setglent ())
510 if ((cp = fgets (line, BUFSIZ, glp)) == NULL)
514 grpldr.gl_ldr = q = gl_ldr;
517 while (*cp && !isspace (*cp))
519 while (*cp && isspace (*cp))
523 if (q < gl_ldr + MAXGLS)
535 struct grpldr *getglnam (name)
538 register struct grpldr *gl = NULL;
541 while (gl = getglent ())
542 if (strcmp (name, gl -> gl_name) == 0)
555 register struct grpldr *gl;
559 while (gl = getglent ()) {
560 if (getgrnam (gl -> gl_name) == NULL) {
562 fprintf (out, "unknown group %s in group leaders file\n",
566 for (gp = 0; gldrs[gp]; gp++)
567 if (strcmp (gldrs[gp], gl -> gl_name) == 0) {
569 fprintf (out, "duplicate group %s in group leaders file\n",
574 if (gldrs[gp] == NULL)
576 gldrs[gp++] = getcpy (gl -> gl_name);
581 fprintf (out, "more than %d groups in group leaders file%s\n",
582 " (time to recompile)", NGRPS - 1);
588 for (gp = 0; gldrs[gp]; gp++)
591 if (!hit && out && !mail)
592 fprintf (out, "all groups in group leaders file accounted for\n");
597 register int hit = 0;
600 register struct grpldr *gl;
603 while (gl = getglent ())
604 for (cp = gl -> gl_ldr; *cp; cp++) {
607 fprintf (out, "group %s has unknown leader %s\n",
612 for (dp = cp + 1; *dp; dp++)
613 if (strcmp (*cp, *dp) == 0) {
615 fprintf (out, "group %s had duplicate leader %s\n",
622 if (!hit && out && !mail)
623 fprintf (out, "all group leaders accounted for\n");
631 @don't include stdlib, it's included by strings.h (via mh.h)
636 static char ident[] = "@@(#)$Id: conflict.c,v 2.7 1992/11/04 00:40:56 jromine Exp jromine $";
641 struct group *getgrent (),*getgrgid();
671 static char ident[] = "@@(#)$Id: conflict.c,v 2.6 1992/10/30 05:53:28 jromine Exp jromine $";
673 #ifdef _AIX /* Need declaration of free() */
682 @#ifdef around putenv decl in <stdlib.h>
687 static char ident[] = "@@(#)$Id: conflict.c,v 2.5 1992/05/19 21:06:30 jromine Exp jromine $";
690 #define putenv _putenv
704 static char ident[] = "@@(#)$Id: conflict.c,v 2.4 1992/02/03 16:35:26 jromine Exp jromine $";
717 static char ident[] = "@@(#)$Id: conflict.c,v 2.3 1992/01/31 22:07:50 jromine Exp jromine $";
735 static char ident[] = "@@(#)$Id: conflict.c,v 2.2 1990/04/05 14:57:02 sources Exp jromine $";
748 static char ident[] = "@@(#)$Id:$";
764 @changes for SUN40 shared libraries and NNTP under bbc
772 if ((i = alias (akv[i])) != AK_OK) {
775 fprintf (out, "aliasing error in %s - %s\n", akv[i], akerror (i));