X-Git-Url: https://git.distorted.org.uk/~mdw/checkpath/blobdiff_plain/60538794f1efdac9d84632579e36b61ca58c925c..e0d83cefbc0d0fec6a9e59a97a2191da6d8e61b4:/tmpdir.c diff --git a/tmpdir.c b/tmpdir.c index f0fcb5f..5d19e3a 100644 --- a/tmpdir.c +++ b/tmpdir.c @@ -48,6 +48,7 @@ #include #include "checkpath.h" +#include "utils.h" /*----- Static variables --------------------------------------------------*/ @@ -233,7 +234,7 @@ static void report(unsigned what, int verbose, /* --- @usage@ --- */ static void usage(FILE *fp) - { fprintf(fp, "Usage: %s [-bc] [-v PATH]\n", QUIS); } + { fprintf(fp, "Usage: %s [-bcv] [-g NAME] [-C PATH]\n", QUIS); } /* --- @version@ --- */ @@ -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 @@ -337,12 +298,11 @@ int main(int argc, char *argv[]) /* --- Initialize variables --- */ ego(argv[0]); - me = geteuid(); + me = cp.cp_uid = geteuid(); cp.cp_what = (CP_WRWORLD | CP_WROTHGRP | CP_WROTHUSR | CP_STICKYOK | CP_REPORT); cp.cp_verbose = 0; cp.cp_report = report; - checkpath_setids(&cp); cp.cp_gids = 0; /* ignore group membership */ pw = getpwuid(me); if (!pw) @@ -388,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++;