]>
diplodocus.org Git - nmh/blob - docs/historical/mh-6.8.5/uip/conflict.c
1 /* conflict.c - the new conflict */
3 static char ident
[] = "@(#)$Id: conflict.c,v 2.9 1992/12/15 00:07:52 jromine Exp $";
7 #include "../h/aliasbr.h"
8 #include "../h/local.h"
10 #include "../zotnet/mts.h"
22 static struct swit switches
[] = {
27 "search directory", 0,
37 static char *mail
= NULL
;
39 static char *dirs
[NDIRS
];
41 static FILE * out
= NULL
;
44 extern struct aka
*akahead
;
45 extern struct home
*homehead
;
48 #if !defined(__STDC__) && !defined(__stdc__) /* __stdc__ for convex */
49 struct group
*getgrent (), *getgrgid();
50 #endif /* !__STDC__ */
68 setlocale(LC_ALL
, "");
70 invo_name
= r1bindex (argv
[0], '/');
76 while (cp
= *argp
++) {
78 switch (smatch (++cp
, switches
)) {
80 ambigsw (cp
, switches
);
83 adios (NULLCP
, "-%s unknown", cp
);
85 (void) sprintf (buf
, "%s [switches] [aliasfiles ...]",
91 if (!(cp
= *argp
++) || *cp
== '-')
92 adios (NULLCP
, "missing argument to %s", argp
[-2]);
94 adios (NULLCP
, "mail to one address only");
100 if (!(cp
= *argp
++) || *cp
== '-')
101 adios (NULLCP
, "missing argument to %s", argp
[-2]);
103 adios (NULLCP
, "more than %d directories", NDIRS
);
113 akv
[akp
++] = AliasFile
;
120 alias_files (akp
, akv
);
136 alias_files (akp
, akv
)
142 for (i
= 0; i
< akp
; i
++)
143 if ((err
= alias (akv
[i
])) != AK_OK
) {
145 fprintf (out
, "aliasing error in %s - %s\n", akv
[i
], akerror (err
));
149 fprintf (out
, "alias file %s is ok\n", akv
[i
]);
156 register struct home
*hm
,
159 for (hm
= homehead
; hm
; hm
= hm
-> h_next
)
160 for (lm
= hm
-> h_next
; lm
; lm
= lm
-> h_next
)
161 if (strcmp (hm
-> h_name
, lm
-> h_name
) == 0) {
163 fprintf (out
, "duplicate user %s(uid=%d)\n",
164 lm
-> h_name
, lm
-> h_uid
);
168 if (!hit
&& out
&& !mail
)
169 fprintf (out
, "no duplicate users\n");
177 register struct group
*gr
;
181 while (gr
= getgrent ()) {
182 for (gp
= 0; grps
[gp
]; gp
++)
183 if (strcmp (grps
[gp
], gr
-> gr_name
) == 0) {
185 fprintf (out
, "duplicate group %s(gid=%d)\n",
186 gr
-> gr_name
, gr
-> gr_gid
);
190 if (grps
[gp
] == NULL
)
192 grps
[gp
++] = getcpy (gr
-> gr_name
);
197 fprintf (out
, "more than %d groups (time to recompile)\n",
204 for (gp
= 0; grps
[gp
]; gp
++)
207 if (!hit
&& out
&& !mail
)
208 fprintf (out
, "no duplicate groups\n");
214 register int hit
= 0;
217 register struct group
*gr
;
218 register struct home
*hm
;
221 while (gr
= getgrent ())
222 for (cp
= gr
-> gr_mem
; *cp
; cp
++) {
223 for (hm
= homehead
; hm
; hm
= hm
-> h_next
)
224 if (!strcmp (*cp
, hm
-> h_name
))
228 fprintf (out
, "group %s(gid=%d) has unknown member %s\n",
229 gr
-> gr_name
, gr
-> gr_gid
, *cp
);
237 for (dp
= cp
+ 1; *dp
; dp
++)
238 if (strcmp (*cp
, *dp
) == 0) {
240 fprintf (out
, "group %s(gid=%d) has duplicate member %s\n",
241 gr
-> gr_name
, gr
-> gr_gid
, *cp
);
248 for (hm
= homehead
; hm
; hm
= hm
-> h_next
)
249 if (hm
-> h_ngrps
> NGROUPS
) {
251 fprintf (out
, "user %s is a member of %d groups (max %d)",
252 hm
-> h_name
, hm
-> h_ngrps
, NGROUPS
);
257 if (!hit
&& out
&& !mail
)
258 fprintf (out
, "all group members accounted for\n");
262 grp_ids () { /* -DRAND not implemented at most places */
263 register int hit
= 0;
264 register struct home
*hm
;
266 for (hm
= homehead
; hm
; hm
= hm
-> h_next
)
267 if (getgrgid (hm
-> h_gid
) == NULL
) {
269 fprintf (out
, "user %s(uid=%d) has unknown group-id %d\n",
270 hm
-> h_name
, hm
-> h_uid
, hm
-> h_gid
);
274 if (!hit
&& out
&& !mail
)
275 fprintf (out
, "all group-id users accounted for\n");
284 if (mmdfldir
&& *mmdfldir
)
286 if (uucpldir
&& *uucpldir
)
288 for (i
= 0; dirs
[i
]; i
++)
296 register int hit
= 0;
298 register struct dirent
*dp
;
300 register struct direct
*dp
;
302 register DIR *dd
= opendir (drop
);
306 fprintf (out
, "unable to open maildrop area %s\n", drop
);
310 while (dp
= readdir (dd
))
311 if (dp
-> d_name
[0] != '.' && !check (dp
->d_name
)) {
314 "there is a maildrop for the unknown user %s in %s\n",
320 if (!hit
&& out
&& !mail
)
321 fprintf (out
, "all maildrops accounted for in %s\n", drop
);
330 register struct home
*hm
;
332 for (hm
= homehead
; hm
; hm
= hm
-> h_next
)
333 if (!strcmp (s
, hm
-> h_name
))
348 if (pipe (pd
) == NOTOK
)
349 adios ("pipe", "unable to");
353 adios ("fork", "unable to");
356 (void) close (pd
[1]);
358 (void) dup2 (pd
[0], 0);
359 (void) close (pd
[0]);
361 if ((fd
= open ("/dev/null", 1)) != NOTOK
)
366 execlp (mailproc
, r1bindex (mailproc
, '/'),
367 mail
, "-subject", invo_name
, NULLCP
);
368 adios (mailproc
, "unable to exec ");
371 (void) close (pd
[0]);
372 out
= fdopen (pd
[1], "w");
373 fprintf (out
, "%s: the following is suspicious\n\n",
382 /* UCI specific stuff for conflict */
384 /* taken from <grpldr.h> */
386 #define GLDRS "/admin/etc/GroupLeaders"
393 int setglent (), endglent ();
394 struct grpldr
*getglent (), *getglnam ();
397 /* taken from the getglent() routines */
404 static FILE *glp
= NULL
;
405 static char line
[BUFSIZ
+1];
406 static struct grpldr grpldr
;
407 static char *gl_ldr
[MAXGLS
+ 1];
413 glp
= fopen (GLDRS
, "r");
417 return (glp
!= NULL
);
432 struct grpldr
*getglent () {
436 if (glp
== NULL
&& !setglent ())
438 if ((cp
= fgets (line
, BUFSIZ
, glp
)) == NULL
)
442 grpldr
.gl_ldr
= q
= gl_ldr
;
445 while (*cp
&& !isspace (*cp
))
447 while (*cp
&& isspace (*cp
))
451 if (q
< gl_ldr
+ MAXGLS
)
463 struct grpldr
*getglnam (name
)
466 register struct grpldr
*gl
= NULL
;
469 while (gl
= getglent ())
470 if (strcmp (name
, gl
-> gl_name
) == 0)
483 register struct grpldr
*gl
;
487 while (gl
= getglent ()) {
488 if (getgrnam (gl
-> gl_name
) == NULL
) {
490 fprintf (out
, "unknown group %s in group leaders file\n",
494 for (gp
= 0; gldrs
[gp
]; gp
++)
495 if (strcmp (gldrs
[gp
], gl
-> gl_name
) == 0) {
497 fprintf (out
, "duplicate group %s in group leaders file\n",
502 if (gldrs
[gp
] == NULL
)
504 gldrs
[gp
++] = getcpy (gl
-> gl_name
);
509 fprintf (out
, "more than %d groups in group leaders file%s\n",
510 " (time to recompile)", NGRPS
- 1);
516 for (gp
= 0; gldrs
[gp
]; gp
++)
519 if (!hit
&& out
&& !mail
)
520 fprintf (out
, "all groups in group leaders file accounted for\n");
525 register int hit
= 0;
528 register struct grpldr
*gl
;
531 while (gl
= getglent ())
532 for (cp
= gl
-> gl_ldr
; *cp
; cp
++) {
535 fprintf (out
, "group %s has unknown leader %s\n",
540 for (dp
= cp
+ 1; *dp
; dp
++)
541 if (strcmp (*cp
, *dp
) == 0) {
543 fprintf (out
, "group %s had duplicate leader %s\n",
550 if (!hit
&& out
&& !mail
)
551 fprintf (out
, "all group leaders accounted for\n");