tmpdir: Split out new file of common utilities.
[checkpath] / tmpdir.c
index 466b29c..070dee0 100644 (file)
--- a/tmpdir.c
+++ b/tmpdir.c
@@ -48,6 +48,7 @@
 #include <mLib/report.h>
 
 #include "checkpath.h"
+#include "utils.h"
 
 /*----- Static variables --------------------------------------------------*/
 
@@ -272,46 +273,6 @@ setting for that shell type.\n\
        fp);
 }
 
-/* --- @allowgroup@ --- *
- *
- * Arguments:  @const char *gname@ = trust group @gname@
- *
- * Returns:    ---
- *
- * Use:                Adds the gid corresponding to @gname@ (which may be a number)
- *             to the list of things we trust.
- */
-
-static void allowgroup(const char *gname)
-{
-  struct group *gr;
-  const char *p;
-  gid_t g;
-
-  /* --- Check for numeric group spec --- */
-
-  for (p = gname; *p; p++) {
-    if (!isdigit((unsigned char)*p))
-      goto lookup;
-  }
-  g = atoi(gname);
-  goto insert;
-
-  /* --- Look up a group by name --- */
-
-lookup:
-  if ((gr = getgrnam(gname)) == 0)
-    die(1, "group %s not found", gname);
-  g = gr->gr_gid;
-
-  /* --- Insert the group into the table --- */
-
-insert:
-  if (cp.cp_gids >= N(cp.cp_gid))
-    die(1, "too many groups");
-  cp.cp_gid[cp.cp_gids++] = g;
-}
-
 /* --- @main@ --- *
  *
  * Arguments:  @int argc@ = number of command line arguments
@@ -387,7 +348,7 @@ int main(int argc, char *argv[])
        return (!fullcheck(optarg));
        break;
       case 'g':
-       allowgroup(optarg);
+       allowgroup(&cp, optarg);
        break;
       case 'v':
        cp.cp_verbose++;