|
|
1.1 root 1: /* %W%
2: */
3: #ifndef lint
4: static char h_uucp[] = "%W%";
5: #endif lint
6:
7: #include "parms.h"
8:
9: #ifdef BSD4_2
10: #define V7
11: #undef NONAP
12: #undef FASTTIMER
13: #endif BSD4_2
14:
15: #ifdef FASTTIMER
16: #undef NONAP
17: #endif
18:
19: #ifdef V8
20: #define V7
21: #endif V8
22:
23: #include <stdio.h>
24: #include <ctype.h>
25: #include <setjmp.h>
26: #include <sys/param.h>
27:
28: #if defined (ATTSV) && ! defined (CDLIMIT)
29: #include <sys/fmgr.h>
30: #endif
31:
32: /*
33: * param.h includes types.h and signal.h in 4bsd
34: */
35: #ifdef V7
36: #include <sgtty.h>
37: #include <sys/timeb.h>
38: #else !V7
39: #include <termio.h>
40: #include <sys/types.h>
41: #include <signal.h>
42: #include <fcntl.h>
43: #endif
44:
45: #include <sys/stat.h>
46: #include <sys/dir.h>
47:
48: #ifdef BSD4_2
49: #include <sys/time.h>
50: #else !BSD4_2
51: #include <time.h>
52: #endif
53:
54: #include <sys/times.h>
55: #include <errno.h>
56:
57: #ifdef ATTSV
58: #include <sys/sysmacros.h>
59: #endif ATTSV
60:
61: #ifdef RT
62: #include "rt/types.h"
63: #include "rt/unix/param.h"
64: #include "rt/stat.h"
65: #include <sys/ustat.h>
66: #endif RT
67:
68: /* what mode should D. files have upon creation? */
69: #define DFILEMODE 0600
70:
71: /* what mode should C. files have upon creation? */
72: #define CFILEMODE 0644
73:
74: /* define the value of DIRMASK, for umask call */
75: /* used for creating system subdirectories */
76: #define DIRMASK 0022
77:
78: #define MAXSTART 300 /* how long to wait on startup */
79:
80: /* define the last characters for ACU (used for 801/212 dialers) */
81: #define ACULAST "<"
82:
83: /* caution - the fillowing names are also in Makefile
84: * any changes here have to also be made there
85: *
86: * it's a good idea to make directories .foo, since this ensures
87: * that they'll be ignored by processes that search subdirectories in SPOOL
88: *
89: * XQTDIR=/usr/spool/uucp/.Xqtdir
90: * CORRUPT=/usr/spool/uucp/.Corrupt
91: * LOGDIR=/usr/spool/uucp/.Log
92: * SEQDIR=/usr/spool/uucp/.Sequence
93: * STATDIR=/usr/spool/uucp/.Status
94: *
95: */
96:
97: /* where to put the STST. files? */
98: #define STATDIR "/usr/spool/uucp/.Status"
99:
100: /* where should logfiles be kept? */
101: #define LOGUUX "/usr/spool/uucp/.Log/uux"
102: #define LOGUUXQT "/usr/spool/uucp/.Log/uuxqt"
103: #define LOGUUCP "/usr/spool/uucp/.Log/uucp"
104: #define LOGCICO "/usr/spool/uucp/.Log/uucico"
105: #define CORRUPTDIR "/usr/spool/uucp/.Corrupt"
106:
107: /* some sites use /usr/lib/uucp/.XQTDIR here */
108: /* use caution since things are linked into there */
109: #define XQTDIR "/usr/spool/uucp/.Xqtdir"
110:
111: /* how much of a system name can we print in a [CX]. file? */
112: /* MAXBASENAME - 1 (pre) - 1 ('.') - 1 (grade) - 4 (sequence number) */
113: #define SYSNSIZE (MAXBASENAME - 7)
114:
115: #ifdef USRSPOOLLOCKS
116: #define LOCKPRE "/usr/spool/locks/LCK."
117: #else
118: #define LOCKPRE "/usr/spool/uucp/LCK."
119: #endif USRSPOOLLOCKS
120:
121: #define SQFILE "/usr/lib/uucp/SQFILE"
122: #define SQTMP "/usr/lib/uucp/SQTMP"
123: #define SLCKTIME 5400 /* system/device timeout (LCK.. files) */
124: #define SYSFILE "/usr/lib/uucp/Systems"
125: #define DEVFILE "/usr/lib/uucp/Devices"
126: #define DIALERFILE "/usr/lib/uucp/Dialers"
127: #define DIALFILE "/usr/lib/uucp/Dialcodes"
128: #define PFILE "/usr/lib/uucp/Permissions"
129:
130: #define SPOOL "/usr/spool/uucp"
131: #define SEQDIR "/usr/spool/uucp/.Sequence"
132:
133: #define X_LOCKTIME 3600
134: #ifdef USRSPOOLLOCKS
135: #define SEQLOCK "/usr/spool/locks/LCK.SQ."
136: #define SQLOCK "/usr/spool/locks/LCK.SQ"
137: #define X_LOCK "/usr/spool/locks/LCK.X"
138: #define S_LOCK "/usr/spool/locks/LCK.S"
139: #define X_LOCKDIR "/usr/spool/locks" /* must be dir part of above */
140: #else
141: #define SEQLOCK "/usr/spool/uucp/LCK.SQ."
142: #define SQLOCK "/usr/spool/uucp/LCK.SQ"
143: #define X_LOCK "/usr/spool/uucp/LCK.X"
144: #define S_LOCK "/usr/spool/uucp/LCK.S"
145: #define X_LOCKDIR "/usr/spool/uucp" /* must be dir part of above */
146: #endif USRSPOOLLOCKS
147: #define X_LOCKPRE "LCK.X" /* must be last part of above */
148:
149: #define PUBDIR "/usr/spool/uucppublic"
150: #define ADMIN "/usr/spool/uucp/.Admin"
151: #define ERRLOG "/usr/spool/uucp/.Admin/errors"
152: #define SYSLOG "/usr/spool/uucp/.Admin/xferstats"
153: #define RMTDEBUG "/usr/spool/uucp/.Admin/audit"
154: #define CLEANUPLOGFILE "/usr/spool/uucp/.Admin/uucleanup"
155:
156: #define WORKSPACE "/usr/spool/uucp/.Workspace"
157:
158: #define SQTIME 60
159: #define TRYCALLS 2 /* number of tries to dial call */
160: #define MINULIMIT (1L<<11) /* minimum reasonable ulimit */
161:
162: /*
163: * CDEBUG is for communication line debugging
164: * DEBUG is for program debugging
165: * #define SMALL to compile without the DEBUG code
166: */
167: #define CDEBUG(l, f, s) if (Debug >= l) fprintf(stderr, f, s)
168: #ifndef SMALL
169: #define DEBUG(l, f, s) if (Debug >= l) fprintf(stderr, f, s)
170: #else
171: #define DEBUG(l, f, s)
172: #endif SMALL
173:
174: /*
175: * VERBOSE is used by cu and ct to inform the user
176: * about the progress of connection attempts.
177: * In uucp, this will be NULL.
178: */
179:
180: #ifdef STANDALONE
181: #define VERBOSE(f, s) if (Verbose > 0) fprintf(stderr, f, s); else
182: #else
183: #define VERBOSE(f, s)
184: #endif
185:
186: #define PREFIX(pre, str) (strncmp((pre), (str), strlen(pre)) == SAME)
187: #define BASENAME(str, c) ((Bnptr = strrchr((str), c)) ? (Bnptr + 1) : (str))
188: #define EQUALS(a,b) ((a) && (b) && (strcmp((a),(b))==SAME))
189: #define EQUALSN(a,b,n) ((a) && (b) && (strncmp((a),(b),(n))==SAME))
190: #define LASTCHAR(s) (s+strlen(s)-1)
191:
192: #define SAME 0
193: #define ANYREAD 04
194: #define ANYWRITE 02
195: #define FAIL -1
196: #define SUCCESS 0
197: #define NULLCHAR '\0'
198: #define CNULL (char *) 0
199: #define STBNULL (struct sgttyb *) 0
200: #define MASTER 1
201: #define SLAVE 0
202: #define MAXBASENAME 14 /* should be DIRSIZ but 4.2bsd prohibits that */
203: #define MAXFULLNAME BUFSIZ
204: #define MAXNAMESIZE 64 /* /usr/spool/uucp/<14 chars>/<14 chars>+slop */
205: #define MAXMSGTIME 33
206: #define MAXEXPECTTIME 45
207: #define MAXCHARTIME 15
208: #define NAMESIZE MAXBASENAME+1
209: #define SIZEOFPID 10 /* maximum number of digits in a pid */
210: #define EOTMSG "\004\n\004\n"
211: #define CALLBACK 1
212:
213: /* manifest for chkpth flag */
214: #define CK_READ 0
215: #define CK_WRITE 1
216:
217: /*
218: * commands
219: */
220: #define SHELL "/bin/sh"
221: #define MAIL "mail"
222: #define UUCICO "/usr/lib/uucp/uucico"
223: #define UUSCHED "/usr/lib/uucp/uusched"
224: #define UUXQT "/usr/lib/uucp/uuxqt"
225: #define UUCP "uucp"
226: #ifdef V7
227: #define UUPS "/usr/lib/uucp/uups"
228: #endif
229:
230:
231: /* system status stuff */
232: #define SS_OK 0
233: #define SS_NO_DEVICE 1
234: #define SS_TIME_WRONG 2
235: #define SS_INPROGRESS 3
236: #define SS_CONVERSATION 4
237: #define SS_SEQBAD 5
238: #define SS_LOGIN_FAILED 6
239: #define SS_DIAL_FAILED 7
240: #define SS_BAD_LOG_MCH 8
241: #define SS_LOCKED_DEVICE 9
242: #define SS_ASSERT_ERROR 10
243: #define SS_BADSYSTEM 11
244: #define SS_CANT_ACCESS_DEVICE 12
245: #define SS_DEVICE_FAILED 13 /* No longer used */
246: #define SS_WRONG_MCH 14
247: #define SS_CALLBACK 15
248: #define SS_RLOCKED 16
249: #define SS_RUNKNOWN 17
250: #define SS_RLOGIN 18
251: #define SS_UNKNOWN_RESPONSE 19
252: #define SS_STARTUP 20
253: #define SS_CHAT_FAILED 21
254:
255: #define MAXPH 60 /* maximum phone string size */
256: #define MAXC BUFSIZ
257:
258: #define TRUE 1
259: #define FALSE 0
260: #define NAMEBUF 32
261:
262: /* structure of an Systems file line */
263: #define F_MAX 50 /* max number of fields in Systems file line */
264: #define F_NAME 0
265: #define F_TIME 1
266: #define F_TYPE 2
267: #define F_CLASS 3 /* an optional prefix and the speed */
268: #define F_PHONE 4
269: #define F_LOGIN 5
270:
271: /* structure of an Devices file line */
272: #define D_TYPE 0
273: #define D_LINE 1
274: #define D_CALLDEV 2
275: #define D_CLASS 3
276: #define D_CALLER 4
277: #define D_ARG 5
278: #define D_MAX 50 /* max number of fields in Devices file line */
279:
280: #define D_ACU 1
281: #define D_DIRECT 2
282: #define D_PROT 4
283:
284: /* past here, local changes are not recommended */
285: #define CMDPRE 'C'
286: #define DATAPRE 'D'
287: #define XQTPRE 'X'
288:
289: /*
290: * stuff for command execution
291: */
292: #define X_RQDFILE 'F'
293: #define X_STDIN 'I'
294: #define X_STDOUT 'O'
295: #define X_CMD 'C'
296: #define X_USER 'U'
297: #define X_BRINGBACK 'B'
298: #define X_MAILF 'M'
299: #define X_RETADDR 'R'
300: #define X_COMMENT '#'
301: #define X_NONZERO 'Z'
302: #define X_SENDNOTHING 'N'
303: #define X_SENDZERO 'n'
304:
305:
306: /* This structure describes call routines */
307: struct caller {
308: char *CA_type;
309: int (*CA_caller)();
310: };
311:
312: /* This structure describes dialing routines */
313: struct dialer {
314: char *DI_type;
315: int (*DI_dialer)();
316: };
317:
318: struct nstat {
319: int t_pid; /* process id */
320: long t_start; /* process id */
321: time_t t_beg; /* start time */
322: time_t t_scall; /* start call to system */
323: time_t t_ecall; /* end call to system */
324: time_t t_tacu; /* acu time */
325: time_t t_tlog; /* login time */
326: time_t t_sftp; /* start file transfer protocol */
327: time_t t_sxf; /* start xfer */
328: time_t t_exf; /* end xfer */
329: time_t t_eftp; /* end file transfer protocol */
330: time_t t_qtime; /* time file queued */
331: int t_ndial; /* # of dials */
332: int t_nlogs; /* # of login trys */
333: struct tms t_tbb; /* start execution times */
334: struct tms t_txfs; /* xfer start times */
335: struct tms t_txfe; /* xfer end times */
336: struct tms t_tga; /* garbage execution times */
337: };
338:
339: /* external declarations */
340:
341: extern int Ifn, Ofn;
342: extern int Debug, Verbose;
343: extern int Bspeed;
344: extern int Uid, Euid; /* user-id and effective-uid */
345: extern char Wrkdir[];
346: extern long Retrytime;
347: extern char **Env;
348: extern char Uucp[];
349: extern char Pchar;
350: extern struct nstat Nstat;
351: extern char Dc[]; /* line name */
352: extern char Fwdname[]; /* foward name */
353: extern int Seqn; /* sequence # */
354: extern int Role;
355: extern char Logfile[];
356: extern int linebaudrate; /* adjust sleep time on read in pk driver */
357: extern char Rmtname[];
358: extern char User[];
359: extern char Loginuser[];
360: extern char *Thisdir;
361: extern char *Spool;
362: extern char *Pubdir;
363: extern char Myname[];
364: extern char Progname[];
365: extern char RemSpool[];
366: extern char *Bnptr; /* used when BASENAME macro is expanded */
367: extern char *sys_errlist[];
368:
369: extern char Jobid[]; /* Jobid of current C. file */
370: extern int Uerror; /* global error code */
371: extern char *UerrorText[]; /* text for error code */
372:
373: /* Some global I need for section 2 and section 3 routines */
374: extern errno;
375: extern char *optarg; /* for getopt() */
376: extern int optind; /* for getopt() */
377:
378:
379: #define UERRORTEXT UerrorText[Uerror]
380: #define UTEXT(x) UerrorText[x]
381:
382: /* things get kind of gross beyond this point -- please stay out */
383:
384: #ifdef ATTSV
385: #define index strchr
386: #define rindex strrchr
387: #define vfork fork
388: #define ATTSVKILL
389: #define UNAME
390: #else
391: #define strchr index
392: #define strrchr rindex
393: #endif
394:
395: #ifdef lint
396: #define VERSION(x) ;
397: #define ASSERT(e, s1, s2, i1) ;
398:
399: #else NOT lint
400:
401: #define VERSION(x) static char sccsid[] = "x";
402: #define ASSERT(e, s1, s2, i1) if (!(e)) {\
403: assert(s1, s2, i1, sccsid, __FILE__, __LINE__);\
404: cleanup(FAIL);};
405: #endif
406:
407: extern struct stat __s_;
408: #define READANY(f) ((stat((f),&__s_)==0) && ((__s_.st_mode&(0004))!=0) )
409: #define READSOME(f) ((stat((f),&__s_)==0) && ((__s_.st_mode&(0444))!=0) )
410:
411: #define WRITEANY(f) ((stat((f),&__s_)==0) && ((__s_.st_mode&(0002))!=0) )
412: #define DIRECTORY(f) ((stat((f),&__s_)==0) && ((__s_.st_mode&(S_IFMT))==S_IFDIR) )
413: #define NOTEMPTY(f) ((stat((f),&__s_)==0) && (__s_.st_size!=0) )
414:
415: #ifndef BSD4_2
416: #define DIR FILE
417: #define opendir(x) fopen((x), "r")
418: #define closedir(x) fclose((x))
419: #endif BSD4_2
420:
421: /* standard functions used */
422:
423: extern char *strcat(), *strcpy(), *strncpy(), *strrchr();
424: extern char *strchr(), *strpbrk();
425: extern char *index(), *rindex(), *getlogin(), *ttyname(), *malloc();
426: extern char *calloc();
427: extern long times(), lseek(), atol();
428: extern time_t time();
429: extern int strlen(), strcmp(), strncmp();
430: extern int execle(), fork(), pipe(), close(), fcntl(), getopt();
431: extern struct tm *localtime();
432: extern FILE *popen();
433: #ifdef BSD4_2
434: extern char *sprintf();
435: #else
436: extern int sprintf();
437: #endif BSD4_2
438:
439: /* uucp functions and subroutine */
440: extern int anlwrk(), iswrk(), gtwvec(); /* anlwrk.c */
441: extern void chremdir(), mkremdir(); /* chremdir.c */
442: extern void toCorrupt(); /* cpmv.c */
443: extern int xcp(), xmv(); /* cpmv.c */
444:
445: extern int getargs(); /* getargs.c */
446: extern void bsfix(); /* getargs.c */
447: extern char *getprm(); /* getprm.c */
448:
449: extern void logent(), syslog(), closelog(); /* logent.c */
450: extern time_t millitick(); /* logent.c */
451:
452: extern char *protoString(); /* permission.c */
453: extern logFind(), mchFind(); /* permission.c */
454: extern chkperm(), chkpth(); /* permission.c */
455: extern cmdOK(), switchRole(); /* permission.c */
456: extern callBack(), requestOK(); /* permission.c */
457: extern void myName(); /* permission.c */
458:
459: extern void systat(); /* systat.c */
460: extern int ulockf(), checkLock(), delock(); /* ulockf.c */
461: extern int mlock(); /* ulockf.c */
462: extern void rmlock(), ultouch(); /* ulockf.c */
463: extern char *timeStamp(); /* utility.c */
464: extern void assert(), errent(); /* utility.c */
465: extern void uucpname(); /* uucpname.c */
466: extern int versys(); /* versys.c */
467: extern void xuuxqt(), xuucico(); /* xqt.c */
468:
469: #ifdef ATTSV
470: unsigned sleep();
471: void exit(), setbuf();
472: long ulimit();
473: #else !ATTSV
474: int sleep(), exit(), setbuf(), ftime();
475: #endif
476:
477: #ifndef NOUSTAT
478: #ifdef V7USTAT
479: struct ustat {
480: daddr_t f_tfree; /* total free */
481: ino_t f_tinode; /* total inodes free */
482: };
483: #else !NOUSTAT && !V7USTAT
484: #include <ustat.h>
485: #endif V7USTAT
486: #endif NOUSTAT
487:
488: #ifdef UNAME
489: #include <sys/utsname.h>
490: #endif UNAME
491:
492: #ifdef BSD4_2
493: char *gethostname();
494: #endif BSD4_2
495:
496: /* messages */
497: extern char *Ct_OPEN;
498: extern char *Ct_WRITE;
499: extern char *Ct_READ;
500: extern char *Ct_CREATE;
501: extern char *Ct_ALLOCATE;
502: extern char *Ct_LOCK;
503: extern char *Ct_STAT;
504: extern char *Ct_CHOWN;
505: extern char *Ct_CHMOD;
506: extern char *Ct_LINK;
507: extern char *Ct_CHDIR;
508: extern char *Ct_UNLINK;
509: extern char *Wr_ROLE;
510: extern char *Ct_CORRUPT;
511: extern char *Ct_FORK;
512: extern char *Ct_CLOSE;
513: extern char *Fl_EXISTS;
514: extern char *Ue_BADSYSTEM;
515: extern char *Ue_TIME_WRONG;
516: extern char *Ue_SYSTEM_LOCKED;
517: extern char *Ue_NO_DEVICE;
518: extern char *Ue_DIAL_FAILED;
519: extern char *Ue_LOGIN_FAILED;
520: extern char *Ue_SEQBAD;
521: extern char *Ue_BAD_LOG_MCH;
522: extern char *Ue_WRONG_MCH;
523: extern char *Ue_LOCKED_DEVICE;
524: extern char *Ue_ASSERT_ERROR;
525: extern char *Ue_CANT_ACCESS_DEVICE;
526: extern char *Ue_DEVICE_FAILED;
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.