|
|
1.1 root 1: /* /sccs/src/cmd/uucp/s.uucheck.c
2: uucheck.c 1.5 8/30/84 17:37:48
3: */
4: #define UUCHECK
5: int Uerrors = 0; /* error count */
6:
7: /* This unusual include (#include "permission.c") is done because
8: * uucheck wants to use the global static variable in permission.c
9: */
10:
11: #include "uucp.h"
12: VERSION(@(#)uucheck.c 1.5);
13: #include "permission.c"
14:
15: /* These are here because uucpdefs.c is not used, and
16: * some routines are referenced (never called within uucheck execution)
17: * and not included.
18: */
19:
20: #define USAGE "[-v] [-xNUM]"
21:
22: int Debug=0;
23: mkdirs(){}
24: canPath(){}
25: char RemSpool[] = SPOOL; /* this is a dummy for chkpth() -- never used here */
26: char *Spool = SPOOL;
27: char *Pubdir = PUBDIR;
28: char *Bnptr;
29: char Progname[NAMESIZE];
30: /* used for READANY and READSOME macros */
31: struct stat __s_;
32:
33: /* This is stuff for uucheck */
34:
35: struct tab
36: {
37: char *name;
38: char *value;
39: } tab[] =
40: {
41: #ifdef CORRUPTDIR
42: "CORRUPT", CORRUPTDIR,
43: #endif
44: "LOGUUCP", LOGUUCP,
45: "LOGUUX", LOGUUX,
46: "LOGUUXQT", LOGUUXQT,
47: "LOGCICO", LOGCICO,
48: "SEQDIR", SEQDIR,
49: "STATDIR", STATDIR,
50: "PFILE", PFILE,
51: #ifndef MANYSYS
52: "SYSFILE", SYSFILE,
53: #endif
54: "DEVFILE", DEVFILE ,
55: "DIALFILE", DIALFILE,
56: "DIALERFILE", DIALERFILE,
57: #ifdef USRSPOOLLOCKS
58: "USRSPOOLLOCKS", "/usr/spool/locks",
59: #endif
60: #ifdef NOSTRANGERS
61: "NOSTRANGERS", NOSTRANGERS,
62: #endif
63: "LMTUUXQT", LMTUUXQT, /* if not defined we'll stat NULL, it's not a bug */
64: "LMTUUSCHED", LMTUUSCHED, /* if not defined we'll stat NULL, it's not a bug */
65: "XQTDIR", XQTDIR,
66: "WORKSPACE", WORKSPACE,
67: "admin directory", ADMIN,
68: NULL,
69: };
70:
71: extern char *nextarg();
72: int verbose = 0; /* fsck-like verbosity */
73:
74: main(argc, argv)
75: char *argv[];
76: {
77: struct stat statbuf;
78: struct tab *tabptr;
79: int i;
80:
81: (void) strcpy(Progname, "uucheck");
82: while ((i = getopt(argc, argv, "vx:")) != EOF) {
83: switch(i){
84:
85: case 'v':
86: verbose++;
87: break;
88:
89: case 'x':
90: Debug = atoi(optarg);
91: if (Debug <= 0)
92: Debug = 1;
93: break;
94:
95: default:
96: (void) fprintf(stderr, "\tusage: %s %s\n",
97: Progname, USAGE);
98: exit(1);
99: }
100: }
101: if (argc != optind) {
102: (void) fprintf(stderr, "\tusage: %s %s\n", Progname, USAGE);
103: exit(1);
104: }
105:
106: if (verbose) printf("*** uucheck: Check Required Files and Directories\n");
107: for (tabptr = tab; tabptr->name != NULL; tabptr++) {
108: if (stat(tabptr->value, &statbuf) < 0) {
109: fprintf(stderr, "%s - ", tabptr->name);
110: perror(tabptr->value);
111: Uerrors++;
112: }
113: }
114: #if MANYSYS
115: if (badsys())
116: Uerrors++;
117: #endif
118:
119: if (verbose) printf("*** uucheck: Directories Check Complete\n\n");
120:
121: /* check the permissions file */
122:
123: if (verbose) printf("*** uucheck: Check %s file\n", PFILE);
124: Uerrors += checkPerm();
125: if (verbose) printf("*** uucheck: %s Check Complete\n\n", PFILE);
126:
127: exit(Uerrors);
128:
129: }
130:
131: #if MANYSYS
132:
133: badsys()
134: {
135: FILE *fp;
136: FILE *sysopen();
137: int n;
138:
139: for (n = 0; (fp = sysopen("r")) != NULL; n++)
140: fclose(fp);
141: if (n)
142: return (0);
143: fprintf(stderr, "No readable Systems files\n");
144: return (0);
145: }
146:
147: #endif
148:
149: char *Name[] = {
150: "U_LOGNAME",
151: "U_MACHINE",
152: "U_CALLBACK",
153: "U_REQUEST",
154: "U_SENDFILES",
155: "U_READPATH",
156: "U_WRITEPATH",
157: "U_NOREADPATH",
158: "U_NOWRITEPATH",
159: "U_PROTOCOL",
160: "U_COMMANDS",
161: "U_VALIDATE",
162: };
163:
164: int
165: checkPerm ()
166: {
167: int type;
168: int error=0;
169: char defaults[BUFSIZ];
170:
171: for (type=0; type<2; type++) {
172: /* type = 0 for LOGNAME, 1 for MACHINE */
173:
174: if (verbose) printf("** %s \n\n",
175: type == U_MACHINE
176: ?"MACHINE PHASE (when we call or execute their uux requests)"
177: :"LOGNAME PHASE (when they call us)" );
178:
179: Fp = fopen(PFILE, "r");
180: if (Fp == NULL) {
181: if (verbose) printf("can't open %s\n", PFILE);
182: exit(1);
183: }
184:
185: for (;;) {
186: if (parse_tokens (_Flds) != 0) {
187: fclose(Fp);
188: break;
189: }
190: if (_Flds[type] == NULL)
191: continue;
192:
193: fillFlds();
194: /* if no ReadPath set num to 1--Path already set */
195: fillList(U_READPATH, _RPaths);
196: fillList(U_WRITEPATH, _WPaths);
197: fillList(U_NOREADPATH, _NoRPaths);
198: fillList(U_NOWRITEPATH, _NoWPaths);
199: if (_Flds[U_COMMANDS] == NULL) {
200: strcpy(defaults, DEFAULTCMDS);
201: _Flds[U_COMMANDS] = defaults;
202: }
203: fillList(U_COMMANDS, _Commands);
204: error += outLine(type);
205: }
206: if (verbose) printf("\n");
207: }
208: return(error);
209: }
210:
211: int
212: outLine(type)
213: int type;
214: {
215: register int i;
216: register char *p;
217: char *arg, cmd[BUFSIZ];
218: int error = 0;
219: char myname[MAXBASENAME+1];
220:
221: if (_Flds[type][0] == 0)
222: return(0);
223:
224: if (type == U_LOGNAME) { /* for LOGNAME */
225: p = _Flds[U_LOGNAME];
226: if (verbose) printf("When a system logs in as: ");
227: while (*p != '\0') {
228: p = nextarg(p, &arg);
229: if (verbose) printf("(%s) ", arg);
230: }
231: if (verbose) printf("\n");
232:
233: if (callBack()) {
234: if (verbose) printf("\tWe will call them back.\n\n");
235: return(0);
236: }
237: }
238: else { /* MACHINE */
239: p = _Flds[U_MACHINE];
240: if (verbose) printf("When we call system(s): ");
241: while (*p != '\0') {
242: p = nextarg(p, &arg);
243: if (verbose) printf("(%s) ", arg);
244: }
245: if (verbose) printf("\n");
246:
247: }
248:
249: if (verbose) printf("\tWe %s allow them to request files.\n",
250: requestOK()? "DO" : "DO NOT");
251:
252: if (type == U_LOGNAME) {
253: if (verbose) printf("\tWe %s send files queued for them on this call.\n",
254: switchRole()? "WILL" : "WILL NOT");
255: }
256:
257: if (verbose) printf("\tThey can send files to\n");
258: if (_Flds[U_WRITEPATH] == NULL) {
259: if (verbose) printf("\t %s (DEFAULT)\n", Pubdir);
260: }
261: else {
262: for (i=0; _WPaths[i] != NULL; i++)
263: if (verbose) printf("\t %s\n", _WPaths[i]);
264: }
265:
266: if (_Flds[U_NOWRITEPATH] != NULL) {
267: if (verbose) printf("\tExcept\n");
268: for (i=0; _NoWPaths[i] != NULL; i++)
269: if (verbose) printf("\t %s\n", _NoWPaths[i]);
270: }
271:
272: if (requestOK()) {
273: if (verbose) printf("\tThey can request files from\n");
274: if (_Flds[U_READPATH] == NULL) {
275: if (verbose) printf("\t %s (DEFAULT)\n", Pubdir);
276: }
277: else {
278: for (i=0; _RPaths[i] != NULL; i++)
279: if (verbose) printf("\t %s\n", _RPaths[i]);
280: }
281:
282: if (_Flds[U_NOREADPATH] != NULL) {
283: if (verbose) printf("\tExcept\n");
284: for (i=0; _NoRPaths[i] != NULL; i++)
285: if (verbose) printf("\t %s\n", _NoRPaths[i]);
286: }
287: }
288:
289: myName(myname);
290: if (verbose) printf("\tMyname for the conversation will be %s.\n",
291: myname);
292: if (verbose) printf("\tPUBDIR for the conversation will be %s.\n",
293: Pubdir);
294:
295: if (verbose) printf("\n");
296:
297: if (type == U_MACHINE) {
298: if (verbose) printf("Machine(s): ");
299: p = _Flds[U_MACHINE];
300: while (*p != '\0') {
301: p = nextarg(p, &arg);
302: if (verbose) printf("(%s) ", arg);
303: }
304: if (verbose) printf("\nCAN execute the following commands:\n");
305: for (i=0; _Commands[i] != NULL; i++) {
306: if (cmdOK(BASENAME(_Commands[i], '/'), cmd) == FALSE) {
307: if (verbose) printf("Software Error in permission.c\n");
308: error++;
309: }
310: if (verbose) printf("command (%s), fullname (%s)\n",
311: BASENAME(_Commands[i], '/'), cmd);
312: }
313: if (verbose) printf("\n");
314: }
315:
316: return(error);
317: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.