- invo_name = r1bindex (argv[0], '/');
-
- /* foil search of user profile/context */
- if (context_foil (NULL) == -1)
- done (1);
-
- mts_init (invo_name);
- arguments = getarguments (invo_name, argc, argv, 0);
- argp = arguments;
-
- while ((cp = *argp++)) {
- if (*cp == '-') {
- switch (smatch (++cp, switches)) {
- case AMBIGSW:
- ambigsw (cp, switches);
- done (1);
- case UNKWNSW:
- adios (NULL, "-%s unknown", cp);
-
- case HELPSW:
- snprintf (buf, sizeof(buf), "%s [switches] [aliasfiles ...]",
- invo_name);
- print_help (buf, switches, 0);
- done (1);
- case VERSIONSW:
- print_version(invo_name);
- done (1);
-
- case MAILSW:
- if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
- if (mail)
- adios (NULL, "mail to one address only");
- else
- mail = cp;
- continue;
-
- case SERCHSW:
- if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
- if (dp >= NDIRS)
- adios (NULL, "more than %d directories", NDIRS);
- dirs[dp++] = cp;
- continue;
- }
+ invo_name = r1bindex (argv[0], '/');
+
+ /* foil search of user profile/context */
+ if (context_foil (NULL) == -1)
+ done (1);
+
+ mts_init (invo_name);
+ arguments = getarguments (invo_name, argc, argv, 0);
+ argp = arguments;
+
+ while ((cp = *argp++)) {
+ if (*cp == '-') {
+ switch (smatch (++cp, switches)) {
+ case AMBIGSW:
+ ambigsw (cp, switches);
+ done (1);
+ case UNKWNSW:
+ adios (NULL, "-%s unknown", cp);
+
+ case HELPSW:
+ snprintf (buf, sizeof(buf), "%s [switches] [aliasfiles ...]",
+ invo_name);
+ print_help (buf, switches, 0);
+ done (1);
+ case VERSIONSW:
+ print_version(invo_name);
+ done (1);
+
+ case MAILSW:
+ if (!(cp = *argp++) || *cp == '-')
+ adios (NULL, "missing argument to %s", argp[-2]);
+ if (mail)
+ adios (NULL, "mail to one address only");
+ else
+ mail = cp;
+ continue;
+
+ case SERCHSW:
+ if (!(cp = *argp++) || *cp == '-')
+ adios (NULL, "missing argument to %s", argp[-2]);
+ if (dp >= NDIRS)
+ adios (NULL, "more than %d directories", NDIRS);
+ dirs[dp++] = cp;
+ continue;
+ }
+ }
+ akv[akp++] = cp;
- for (i = 0; i < akp; i++)
- if ((err = alias (akv[i])) != AK_OK) {
- setup ();
- fprintf (out, "aliasing error in %s - %s\n", akv[i], akerror (err));
- }
- else
- if (out && !mail)
- fprintf (out, "alias file %s is ok\n", akv[i]);
+ for (i = 0; i < akp; i++)
+ if ((err = alias (akv[i])) != AK_OK) {
+ setup ();
+ fprintf (out, "aliasing error in %s - %s\n", akv[i], akerror (err));
+ }
+ else
+ if (out && !mail)
+ fprintf (out, "alias file %s is ok\n", akv[i]);
- int hit = 0;
- register struct home *hm, *lm;
-
- for (hm = homehead; hm; hm = hm->h_next)
- for (lm = hm->h_next; lm; lm = lm->h_next)
- if (strcmp (hm->h_name, lm->h_name) == 0) {
- setup ();
- fprintf (out, "duplicate user %s(uid=%d)\n",
- lm->h_name, (int) lm->h_uid);
- hit++;
- }
-
- if (!hit && out && !mail)
- fprintf (out, "no duplicate users\n");
+ int hit = 0;
+ register struct home *hm, *lm;
+
+ for (hm = homehead; hm; hm = hm->h_next)
+ for (lm = hm->h_next; lm; lm = lm->h_next)
+ if (strcmp (hm->h_name, lm->h_name) == 0) {
+ setup ();
+ fprintf (out, "duplicate user %s(uid=%d)\n",
+ lm->h_name, (int) lm->h_uid);
+ hit++;
+ }
+
+ if (!hit && out && !mail)
+ fprintf (out, "no duplicate users\n");
- int numgroups, maxgroups;
- int i, hit = 0;
- char **grps;
- struct group *gr;
-
- /* allocate space NGRPS at a time */
- numgroups = 0;
- maxgroups = NGRPS;
- if (!(grps = (char **) malloc((size_t) (maxgroups * sizeof(*grps)))))
- adios (NULL, "unable to allocate group name storage");
-
- setgrent ();
- while ((gr = getgrent ())) {
- for (i = 0; i < numgroups; i++)
- if (!strcmp (grps[i], gr->gr_name)) {
- setup ();
- fprintf (out, "duplicate group %s(gid=%d)\n",
- gr->gr_name, (int) gr->gr_gid);
- hit++;
- break;
- }
- if (i >= numgroups) {
- if (numgroups >= maxgroups) {
- maxgroups += NGRPS;
- if (!(grps = (char **) realloc(grps,
- (size_t) (maxgroups * sizeof(*grps)))))
- adios (NULL, "unable to reallocate group name storage");
- }
- grps[numgroups++] = getcpy (gr->gr_name);
+ int numgroups, maxgroups;
+ int i, hit = 0;
+ char **grps;
+ struct group *gr;
+
+ /* allocate space NGRPS at a time */
+ numgroups = 0;
+ maxgroups = NGRPS;
+ grps = (char **) mh_xmalloc((size_t) (maxgroups * sizeof(*grps)));
+
+ setgrent ();
+ while ((gr = getgrent ())) {
+ for (i = 0; i < numgroups; i++)
+ if (!strcmp (grps[i], gr->gr_name)) {
+ setup ();
+ fprintf (out, "duplicate group %s(gid=%d)\n",
+ gr->gr_name, (int) gr->gr_gid);
+ hit++;
+ break;
+ }
+ if (i >= numgroups) {
+ if (numgroups >= maxgroups) {
+ maxgroups += NGRPS;
+ grps = (char **) mh_xrealloc(grps,
+ (size_t) (maxgroups * sizeof(*grps)));
+ }
+ grps[numgroups++] = getcpy (gr->gr_name);
+ }
- register int hit = 0;
- register char **cp, **dp;
- register struct group *gr;
- register struct home *hm;
-
- setgrent ();
- while ((gr = getgrent ())) {
- for (cp = gr->gr_mem; *cp; cp++) {
- for (hm = homehead; hm; hm = hm->h_next)
- if (!strcmp (*cp, hm->h_name))
- break;
- if (hm == NULL) {
- setup ();
- fprintf (out, "group %s(gid=%d) has unknown member %s\n",
- gr->gr_name, (int) gr->gr_gid, *cp);
- hit++;
- } else {
- hm->h_ngrps++;
- }
-
- for (dp = cp + 1; *dp; dp++)
- if (strcmp (*cp, *dp) == 0) {
- setup ();
- fprintf (out, "group %s(gid=%d) has duplicate member %s\n",
- gr->gr_name, (int) gr->gr_gid, *cp);
- hit++;
+ register int hit = 0;
+ register char **cp, **dp;
+ register struct group *gr;
+ register struct home *hm;
+
+ setgrent ();
+ while ((gr = getgrent ())) {
+ for (cp = gr->gr_mem; *cp; cp++) {
+ for (hm = homehead; hm; hm = hm->h_next)
+ if (!strcmp (*cp, hm->h_name))
+ break;
+ if (hm == NULL) {
+ setup ();
+ fprintf (out, "group %s(gid=%d) has unknown member %s\n",
+ gr->gr_name, (int) gr->gr_gid, *cp);
+ hit++;
+ } else {
+ hm->h_ngrps++;
+ }
+
+ for (dp = cp + 1; *dp; dp++)
+ if (strcmp (*cp, *dp) == 0) {
+ setup ();
+ fprintf (out, "group %s(gid=%d) has duplicate member %s\n",
+ gr->gr_name, (int) gr->gr_gid, *cp);
+ hit++;
+ }
- }
- endgrent ();
-
- for (hm = homehead; hm; hm = hm->h_next)
- if (hm->h_ngrps > NGROUPS_MAX) {
- setup ();
- fprintf (out, "user %s is a member of %d groups (max %d)\n",
- hm->h_name, hm->h_ngrps, NGROUPS_MAX);
- hit++;
- }
+ endgrent ();
+
+ for (hm = homehead; hm; hm = hm->h_next)
+ if (hm->h_ngrps > NGROUPS_MAX) {
+ setup ();
+ fprintf (out, "user %s is a member of %d groups (max %d)\n",
+ hm->h_name, hm->h_ngrps, NGROUPS_MAX);
+ hit++;
+ }
-{ /* -DRAND not implemented at most places */
- register int hit = 0;
- register struct home *hm;
-
- for (hm = homehead; hm; hm = hm->h_next)
- if (getgrgid (hm->h_gid) == NULL) {
- setup ();
- fprintf (out, "user %s(uid=%d) has unknown group-id %d\n",
- hm->h_name, (int) hm->h_uid, (int) hm->h_gid);
- hit++;
- }
+{ /* -DRAND not implemented at most places */
+ register int hit = 0;
+ register struct home *hm;
+
+ for (hm = homehead; hm; hm = hm->h_next)
+ if (getgrgid (hm->h_gid) == NULL) {
+ setup ();
+ fprintf (out, "user %s(uid=%d) has unknown group-id %d\n",
+ hm->h_name, (int) hm->h_uid, (int) hm->h_gid);
+ hit++;
+ }
- register int hit = 0;
- register struct dirent *dp;
- register DIR *dd = opendir (drop);
-
- if (!dd) {
- setup ();
- fprintf (out, "unable to open maildrop area %s\n", drop);
- return;
- }
-
- while ((dp = readdir (dd)))
- if (dp->d_name[0] != '.' && !check (dp->d_name)) {
- setup ();
- fprintf (out,
- "there is a maildrop for the unknown user %s in %s\n",
- dp->d_name, drop);
- hit++;
+ register int hit = 0;
+ register struct dirent *dp;
+ register DIR *dd = opendir (drop);
+
+ if (!dd) {
+ setup ();
+ fprintf (out, "unable to open maildrop area %s\n", drop);
+ return;
- closedir (dd);
- if (!hit && out && !mail)
- fprintf (out, "all maildrops accounted for in %s\n", drop);
+ while ((dp = readdir (dd)))
+ if (dp->d_name[0] != '.' && !check (dp->d_name)) {
+ setup ();
+ fprintf (out,
+ "there is a maildrop for the unknown user %s in %s\n",
+ dp->d_name, drop);
+ hit++;
+ }
+
+ closedir (dd);
+ if (!hit && out && !mail)
+ fprintf (out, "all maildrops accounted for in %s\n", drop);
- int fd, pd[2];
-
- if (out)
- return;
-
- if (mail) {
- if (pipe (pd) == NOTOK)
- adios ("pipe", "unable to");
-
- switch (fork ()) {
- case NOTOK:
- adios ("fork", "unable to");
-
- case OK:
- close (pd[1]);
- if (pd[0] != 0) {
- dup2 (pd[0], 0);
- close (pd[0]);
+ int fd, pd[2];
+
+ if (out)
+ return;
+
+ if (mail) {
+ if (pipe (pd) == NOTOK)
+ adios ("pipe", "unable to");
+
+ switch (fork ()) {
+ case NOTOK:
+ adios ("fork", "unable to");
+
+ case OK:
+ close (pd[1]);
+ if (pd[0] != 0) {
+ dup2 (pd[0], 0);
+ close (pd[0]);
+ }
+ if ((fd = open ("/dev/null", O_WRONLY)) != NOTOK)
+ if (fd != 1) {
+ dup2 (fd, 1);
+ close (fd);
+ }
+ execlp (mailproc, r1bindex (mailproc, '/'),
+ mail, "-subject", invo_name, NULL);
+ adios (mailproc, "unable to exec ");
+
+ default:
+ close (pd[0]);
+ out = fdopen (pd[1], "w");
+ fprintf (out, "%s: the following is suspicious\n\n",
+ invo_name);
- if ((fd = open ("/dev/null", O_WRONLY)) != NOTOK)
- if (fd != 1) {
- dup2 (fd, 1);
- close (fd);
- }
- execlp (mailproc, r1bindex (mailproc, '/'),
- mail, "-subject", invo_name, NULL);
- adios (mailproc, "unable to exec ");
-
- default:
- close (pd[0]);
- out = fdopen (pd[1], "w");
- fprintf (out, "%s: the following is suspicious\n\n",
- invo_name);
- register char *cp,
- **q;
-
- if (glp == NULL && !setglent ())
- return NULL;
- if ((cp = fgets (line, BUFSIZ, glp)) == NULL)
- return NULL;
-
- grpldr.gl_name = cp;
- grpldr.gl_ldr = q = gl_ldr;
-
- while (*cp) {
- while (*cp && !isspace (*cp))
- cp++;
- while (*cp && isspace (*cp))
- *cp++ = '\0';
- if (*cp == '\0')
- break;
- if (q < gl_ldr + MAXGLS)
- *q++ = cp;
- else
- break;
- }
- *q = NULL;
+ register char *cp,
+ **q;
+
+ if (glp == NULL && !setglent ())
+ return NULL;
+ if ((cp = fgets (line, BUFSIZ, glp)) == NULL)
+ return NULL;
+
+ grpldr.gl_name = cp;
+ grpldr.gl_ldr = q = gl_ldr;
+
+ while (*cp) {
+ while (*cp && !isspace (*cp))
+ cp++;
+ while (*cp && isspace (*cp))
+ *cp++ = '\0';
+ if (*cp == '\0')
+ break;
+ if (q < gl_ldr + MAXGLS)
+ *q++ = cp;
+ else
+ break;
+ }
+ *q = NULL;
- register int gp,
- hit = 0;
- char *gldrs[NGRPS];
- register struct grpldr *gl;
-
- gldrs[0] = NULL;
- setglent ();
- while (gl = getglent ()) {
- if (getgrnam (gl->gl_name) == NULL) {
- setup ();
- fprintf (out, "unknown group %s in group leaders file\n",
- gl->gl_name);
- hit++;
+ register int gp, hit = 0;
+ char *gldrs[NGRPS];
+ register struct grpldr *gl;
+
+ gldrs[0] = NULL;
+ setglent ();
+ while (gl = getglent ()) {
+ if (getgrnam (gl->gl_name) == NULL) {
+ setup ();
+ fprintf (out, "unknown group %s in group leaders file\n",
+ gl->gl_name);
+ hit++;
+ }
+ for (gp = 0; gldrs[gp]; gp++)
+ if (strcmp (gldrs[gp], gl->gl_name) == 0) {
+ setup ();
+ fprintf (out, "duplicate group %s in group leaders file\n",
+ gl->gl_name);
+ hit++;
+ break;
+ }
+ if (gldrs[gp] == NULL)
+ if (gp < NGRPS) {
+ gldrs[gp++] = getcpy (gl->gl_name);
+ gldrs[gp] = NULL;
+ }
+ else {
+ setup ();
+ fprintf (out, "more than %d groups in group leaders file%s\n",
+ " (time to recompile)", NGRPS - 1);
+ hit++;
+ }
- if (strcmp (gldrs[gp], gl->gl_name) == 0) {
- setup ();
- fprintf (out, "duplicate group %s in group leaders file\n",
- gl->gl_name);
- hit++;
- break;
- }
- if (gldrs[gp] == NULL)
- if (gp < NGRPS) {
- gldrs[gp++] = getcpy (gl->gl_name);
- gldrs[gp] = NULL;
- }
- else {
- setup ();
- fprintf (out, "more than %d groups in group leaders file%s\n",
- " (time to recompile)", NGRPS - 1);
- hit++;
- }
- }
- endglent ();
-
- for (gp = 0; gldrs[gp]; gp++)
- free (gldrs[gp]);
-
- if (!hit && out && !mail)
- fprintf (out, "all groups in group leaders file accounted for\n");
+ free (gldrs[gp]);
+
+ if (!hit && out && !mail)
+ fprintf (out, "all groups in group leaders file accounted for\n");
- register int hit = 0;
- register char **cp,
- **dp;
- register struct grpldr *gl;
-
- setglent ();
- while (gl = getglent ())
- for (cp = gl->gl_ldr; *cp; cp++) {
- if (!check (*cp)) {
- setup ();
- fprintf (out, "group %s has unknown leader %s\n",
- gl->gl_name, *cp);
- hit++;
- }
-
- for (dp = cp + 1; *dp; dp++)
- if (strcmp (*cp, *dp) == 0) {
- setup ();
- fprintf (out, "group %s had duplicate leader %s\n",
- gl->gl_name, *cp);
- hit++;
+ register int hit = 0;
+ register char **cp, **dp;
+ register struct grpldr *gl;
+
+ setglent ();
+ while (gl = getglent ())
+ for (cp = gl->gl_ldr; *cp; cp++) {
+ if (!check (*cp)) {
+ setup ();
+ fprintf (out, "group %s has unknown leader %s\n",
+ gl->gl_name, *cp);
+ hit++;
+ }
+
+ for (dp = cp + 1; *dp; dp++)
+ if (strcmp (*cp, *dp) == 0) {
+ setup ();
+ fprintf (out, "group %s had duplicate leader %s\n",
+ gl->gl_name, *cp);
+ hit++;
+ }