|
|
1.1 ! root 1: #define MAINLINE ! 2: #include "parms.h" ! 3: #include "structs.h" ! 4: ! 5: #ifdef RCSIDENT ! 6: static char rcsid[] = "$Header: nfaccess.c,v 1.7 85/01/18 15:40:27 notes Rel $"; ! 7: #endif RCSIDENT ! 8: ! 9: /* ! 10: * This program works sort of chmod by adding/deleting ! 11: * permissions to the specified access lists. ! 12: * ! 13: * Any normal user can run this program. It only allows changes ! 14: * to notesfiles the user is a director in. ! 15: * ! 16: * Ray Essick February 1984 ! 17: */ ! 18: ! 19: ! 20: ! 21: #define MAXADD 1 /* simultaneous adds */ ! 22: struct perm_f Newmodes[MAXADD]; /* inserted modes */ ! 23: static int nmodes = 0; /* active slots */ ! 24: ! 25: #include <pwd.h> ! 26: #include <grp.h> ! 27: extern struct passwd *getpwnam (); ! 28: extern struct group *getgrnam (); ! 29: ! 30: ! 31: main (argc, argv) ! 32: int argc; ! 33: char **argv; ! 34: { ! 35: struct io_f io; ! 36: int argn; ! 37: struct nflist_f *nfptr; ! 38: ! 39: startup (argc, argv); /* common init code */ ! 40: ! 41: if (parsemode (argv[1], &Newmodes[nmodes++], 1)) /* grab a mode */ ! 42: { ! 43: usage (argv[0]); /* incorrect */ ! 44: } ! 45: ! 46: for (argn = 2; argn < argc; argn++) ! 47: { ! 48: expand (argv[argn]); /* load it */ ! 49: } ! 50: ! 51: while ((nfptr = nextgroup ()) != (struct nflist_f *) NULL) ! 52: { ! 53: if (init (&io, nfptr -> nf_name) < 0) /* open */ ! 54: { ! 55: printf ("%s: couldn't open\n", nfptr -> nf_name); ! 56: continue; ! 57: } ! 58: if (!allow (&io, DRCTOK)) /* a director? */ ! 59: { ! 60: printf ("%s: Not a director\n", nfptr -> nf_name); ! 61: closenf (&io); ! 62: continue; ! 63: } ! 64: ! 65: addmodes (&io, nmodes, &Newmodes, 1); /* add permissions */ ! 66: closenf (&io); ! 67: } ! 68: exit (0); /* all done */ ! 69: } ! 70: ! 71: usage (name) /* how to invoke */ ! 72: char *name; ! 73: { ! 74: fprintf (stderr, ! 75: "Usage: %s <permission> <notesfile> [<notesfile>...]\n", ! 76: name); ! 77: exit (1); ! 78: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.