4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
22 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
23 /* All Rights Reserved */
25 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
26 * Use is subject to license terms.
33 #pragma ident "%Z%%M% %I% %E% SMI"
69 #include <sys/param.h>
72 * param.h includes types.h and signal.h in 4bsd
76 #include <sys/timeb.h>
79 #include <sys/types.h>
94 #include <sys/times.h>
98 #include <sys/mkdev.h>
102 #include "rt/types.h"
103 #include "rt/unix/param.h"
105 #include <sys/ustat.h>
108 /* what mode should user files be allowed to have upon creation? */
109 /* NOTE: This does not allow setuid or execute bits on transfer. */
110 #define LEGALMODE (mode_t) 0666
112 /* what mode should public files have upon creation? */
113 #define PUB_FILEMODE (mode_t) 0666
115 /* what mode should log files have upon creation? */
116 #define LOGFILEMODE (mode_t) 0644
118 /* what mode should C. files have upon creation? */
119 #define CFILEMODE (mode_t) 0644
121 /* what mode should D. files have upon creation? */
122 #define DFILEMODE (mode_t) 0600
124 /* define the value of PUBMASK, used for creating "public" directories */
125 #define PUBMASK (mode_t) 0000
127 /* what mode should public directories have upon creation? */
128 #define PUB_DIRMODE (mode_t) 0777
130 /* define the value of DIRMASK, used for creating "system" subdirectories */
131 #define DIRMASK (mode_t) 0022
133 #define MAXSTART 300 /* how long to wait on startup */
135 /* define the last characters for ACU (used for 801/212 dialers) */
138 /* caution - the fillowing names are also in Makefile
139 * any changes here have to also be made there
141 * it's a good idea to make directories .foo, since this ensures
142 * that they'll be ignored by processes that search subdirectories in SPOOL
144 * XQTDIR=/var/uucp/.Xqtdir
145 * CORRUPT=/var/uucp/.Corrupt
146 * LOGDIR=/var/uucp/.Log
147 * SEQDIR=/var/uucp/.Sequence
148 * STATDIR=/var/uucp/.Status
152 /* where to put the STST. files? */
153 #define STATDIR "/var/uucp/.Status"
155 /* where should logfiles be kept? */
156 #define LOGUUX "/var/uucp/.Log/uux"
157 #define LOGUUXQT "/var/uucp/.Log/uuxqt"
158 #define LOGUUCP "/var/uucp/.Log/uucp"
159 #define LOGCICO "/var/uucp/.Log/uucico"
160 #define CORRUPTDIR "/var/uucp/.Corrupt"
162 /* some sites use /var/uucp/.XQTDIR here */
163 /* use caution since things are linked into there */
164 #define XQTDIR "/var/uucp/.Xqtdir"
166 /* how much of a system name can we print in a [CX]. file? */
167 /* MAXBASENAME - 1 (pre) - 1 ('.') - 1 (grade) - 4 (sequence number) */
168 #define SYSNSIZE (MAXBASENAME - 7)
171 #define LOCKPRE "/var/spool/locks/LCK."
173 #define LOCKPRE "/var/spool/uucp/LCK."
174 #endif /* USRSPOOLLOCKS */
176 #define SQFILE "/etc/uucp/SQFILE"
177 #define SQTMP "/etc/uucp/SQTMP"
178 #define SLCKTIME 5400 /* system/device timeout (LCK.. files) */
179 #define DIALCODES "/etc/uucp/Dialcodes"
180 #define PERMISSIONS "/etc/uucp/Permissions"
182 #define SPOOL "/var/spool/uucp"
183 #define SEQDIR "/var/uucp/.Sequence"
185 #define X_LOCKTIME 3600
187 #define SEQLOCK "/var/spool/locks/LCK.SQ."
188 #define SQLOCK "/var/spool/locks/LCK.SQ"
189 #define X_LOCK "/var/spool/locks/LCK.X"
190 #define S_LOCK "/var/spool/locks/LCK.S"
191 #define L_LOCK "/var/spool/locks/LK"
192 #define X_LOCKDIR "/var/spool/locks" /* must be dir part of above */
194 #define SEQLOCK "/var/spool/uucp/LCK.SQ."
195 #define SQLOCK "/var/spool/uucp/LCK.SQ"
196 #define X_LOCK "/var/spool/uucp/LCK.X"
197 #define S_LOCK "/var/spool/uucp/LCK.S"
198 #define L_LOCK "/var/spool/uucp/LK"
199 #define X_LOCKDIR "/var/spool/uucp" /* must be dir part of above */
200 #endif /* USRSPOOLLOCKS */
201 #define X_LOCKPRE "LCK.X" /* must be last part of above */
203 #define PUBDIR "/var/spool/uucppublic"
204 #define ADMIN "/var/uucp/.Admin"
205 #define ERRLOG "/var/uucp/.Admin/errors"
206 #define SYSLOG "/var/uucp/.Admin/xferstats"
207 #define RMTDEBUG "/var/uucp/.Admin/audit"
208 #define CLEANUPLOGFILE "/var/uucp/.Admin/uucleanup"
209 #define CMDLOG "/var/uucp/.Admin/command"
210 #define PERFLOG "/var/uucp/.Admin/perflog"
211 #define ACCOUNT "/var/uucp/.Admin/account"
212 #define SECURITY "/var/uucp/.Admin/security"
214 #define WORKSPACE "/var/uucp/.Workspace"
217 #define TRYCALLS 2 /* number of tries to dial call */
218 #define MINULIMIT (1L<<11) /* minimum reasonable ulimit */
219 #define MAX_LOCKTRY 5 /* number of attempts to lock device */
222 * CDEBUG is for communication line debugging
223 * DEBUG is for program debugging
224 * #define SMALL to compile without the DEBUG code
228 #define CDEBUG(l, f, s) if (Debug >= l) (void)fprintf(stderr, f, s)
230 #define CDEBUG(l, f, s)
235 #define DEBUG(l, f, s) if (Debug >= l) (void)fprintf(stderr, f, s)
237 #define DEBUG(l, f, s)
241 * VERBOSE is used by cu and ct to inform the user of progress
242 * In other programs, the Value of Verbose is always 0.
244 #define VERBOSE(f, s) { if (Verbose > 0) (void)fprintf(stderr, f, s); }
246 #define PREFIX(pre, str) (strncmp((pre), (str), strlen(pre)) == SAME)
247 #define BASENAME(str, c) ((Bnptr = strrchr((str), c)) ? (Bnptr + 1) : (str))
248 #define EQUALS(a,b) ((a != CNULL) && (b != CNULL) && (strcmp((a),(b))==SAME))
249 #define EQUALSN(a,b,n) ((a != CNULL) && (b != CNULL) && (strncmp((a),(b),(n))==SAME))
250 #define LASTCHAR(s) (s+strlen(s)-1)
257 #define NULLCHAR '\0'
258 #define CNULL (char *) 0
259 #define STBNULL (struct sgttyb *) 0
262 #define MAXBASENAME 14 /* should be DIRSIZ but that is now fs dependent */
263 #define MAXFULLNAME BUFSIZ
264 #define MAXNAMESIZE 64 /* /var/spool/uucp/<14 chars>/<14 chars>+slop */
265 #define CONNECTTIME 30
266 #define EXPECTTIME 45
268 #define NAMESIZE MAXBASENAME+1
269 #define SIZEOFPID 10 /* maximum number of digits in a pid */
270 #define EOTMSG "\004\n\004\n"
273 /* manifests for sysfiles.c's sysaccess() */
274 /* check file access for REAL user id */
275 #define ACCESS_SYSTEMS 1
276 #define ACCESS_DEVICES 2
277 #define ACCESS_DIALERS 3
278 /* check file access for EFFECTIVE user id */
279 #define EACCESS_SYSTEMS 4
280 #define EACCESS_DEVICES 5
281 #define EACCESS_DIALERS 6
283 /* manifest for chkpth flag */
290 #define SHELL "/usr/bin/sh"
292 #define UUCICO "/usr/lib/uucp/uucico"
293 #define UUXQT "/usr/lib/uucp/uuxqt"
294 #define UUX "/usr/bin/uux"
295 #define UUCP "/usr/bin/uucp"
298 /* system status stuff */
300 #define SS_NO_DEVICE 1
301 #define SS_TIME_WRONG 2
302 #define SS_INPROGRESS 3
303 #define SS_CONVERSATION 4
305 #define SS_LOGIN_FAILED 6
306 #define SS_DIAL_FAILED 7
307 #define SS_BAD_LOG_MCH 8
308 #define SS_LOCKED_DEVICE 9
309 #define SS_ASSERT_ERROR 10
310 #define SS_BADSYSTEM 11
311 #define SS_CANT_ACCESS_DEVICE 12
312 #define SS_DEVICE_FAILED 13 /* used for interface failure */
313 #define SS_WRONG_MCH 14
314 #define SS_CALLBACK 15
315 #define SS_RLOCKED 16
316 #define SS_RUNKNOWN 17
318 #define SS_UNKNOWN_RESPONSE 19
319 #define SS_STARTUP 20
320 #define SS_CHAT_FAILED 21
321 #define SS_CALLBACK_LOOP 22
323 #define MAXPH 60 /* maximum phone string size */
330 /* The call structure is used by ct.c, cu.c, and dial.c. */
333 char *speed
; /* transmission baud rate */
334 char *line
; /* device name for outgoing line */
335 char *telno
; /* ptr to tel-no digit string */
336 char *type
; /* type of device to use for call. */
339 /* structure of an Systems file line */
340 #define F_MAX 50 /* max number of fields in Systems file line */
344 #define F_CLASS 3 /* an optional prefix and the speed */
348 /* structure of an Devices file line */
355 #define D_MAX 50 /* max number of fields in Devices file line */
361 #define GRADES "/etc/uucp/Grades"
363 #define D_QUEUE 'Z' /* default queue */
365 /* past here, local changes are not recommended */
371 * stuff for command execution
373 #define X_RQDFILE 'F'
379 #define X_BRINGBACK 'B'
381 #define X_RETADDR 'R'
382 #define X_COMMENT '#'
383 #define X_NONZERO 'Z'
384 #define X_SENDNOTHING 'N'
385 #define X_SENDZERO 'n'
388 /* This structure describes call routines */
394 /* structure for a saved C file */
398 char sys
[NAMESIZE
+5];
399 char sgrade
[NAMESIZE
];
404 /* This structure describes dialing routines */
411 pid_t t_pid
; /* process id */
412 time_t t_start
; /* start time */
413 time_t t_scall
; /* start call to system */
414 time_t t_ecall
; /* end call to system */
415 time_t t_tacu
; /* acu time */
416 time_t t_tlog
; /* login time */
417 time_t t_sftp
; /* start file transfer protocol */
418 time_t t_sxf
; /* start xfer */
419 time_t t_exf
; /* end xfer */
420 time_t t_eftp
; /* end file transfer protocol */
421 time_t t_qtime
; /* time file queued */
422 int t_ndial
; /* # of dials */
423 int t_nlogs
; /* # of login trys */
424 struct tms t_tbb
; /* start execution times */
425 struct tms t_txfs
; /* xfer start times */
426 struct tms t_txfe
; /* xfer end times */
427 struct tms t_tga
; /* garbage execution times */
430 /* This structure describes the values from Limits file */
432 int totalmax
; /* overall limit */
433 int sitemax
; /* limit per site */
434 char mode
[64]; /* uucico mode */
437 /* external declarations */
439 EXTERN
int (*Read
)(), (*Write
)();
440 #if defined(__STDC__)
441 EXTERN
int (*Ioctl
)(int,int,...);
443 EXTERN
int (*Ioctl
)();
446 EXTERN
int Debug
, Verbose
;
447 EXTERN uid_t Uid
, Euid
; /* user-id and effective-uid */
449 EXTERN mode_t Dev_mode
; /* save device mode here */
450 EXTERN
char Wrkdir
[];
451 EXTERN
long Retrytime
;
455 EXTERN
struct nstat Nstat
;
456 EXTERN
char Dc
[]; /* line name */
457 EXTERN
int Seqn
; /* sequence # */
459 EXTERN
int Sgrades
; /* flag for administrator defined service grades */
461 EXTERN
char Logfile
[];
462 EXTERN
char Rmtname
[];
463 EXTERN
char JobGrade
[];
465 EXTERN
char Loginuser
[];
468 EXTERN
char Myname
[];
469 EXTERN
char Progname
[];
470 EXTERN
char RemSpool
[];
471 EXTERN
char *Bnptr
; /* used when BASENAME macro is expanded */
472 EXTERN
int SizeCheck
; /* ulimit check supported flag */
473 EXTERN
long RemUlimit
; /* remote ulimit if supported */
474 EXTERN
int Restart
; /* checkpoint restart supported flag */
476 EXTERN
char Jobid
[]; /* Jobid of current C. file */
477 EXTERN
int Uerror
; /* global error code */
478 EXTERN
char *UerrorText
[]; /* text for error code */
480 #define UERRORTEXT UerrorText[Uerror]
481 #define UTEXT(x) UerrorText[x]
483 /* things get kind of tricky beyond this point -- please stay out */
487 #define rindex strrchr
493 #define strrchr rindex
496 EXTERN
struct stat __s_
;
497 #define READANY(f) ((stat((f),&__s_)==0) && ((__s_.st_mode&(0004))!=0) )
498 #define READSOME(f) ((stat((f),&__s_)==0) && ((__s_.st_mode&(0444))!=0) )
500 #define WRITEANY(f) ((stat((f),&__s_)==0) && ((__s_.st_mode&(0002))!=0) )
501 #define DIRECTORY(f) ((stat((f),&__s_)==0) && ((__s_.st_mode&(S_IFMT))==S_IFDIR) )
502 #define NOTEMPTY(f) ((stat((f),&__s_)==0) && (__s_.st_size!=0) )
504 /* standard functions used */
506 extern char *strcat(), *strcpy(), *strncpy(), *strrchr();
507 extern char *strchr(), *strpbrk();
508 extern char *index(), *rindex(), *getlogin(), *ttyname(); /*, *malloc();
509 extern char *calloc(); */
511 extern time_t time();
512 extern int pipe(), close(), getopt();
513 extern struct tm
*localtime();
514 extern FILE *popen();
516 extern char *sprintf();
519 /* uucp functions and subroutine */
520 EXTERN
void (*genbrk
)();
521 extern int iswrk(), gtwvec(); /* anlwrk.c */
522 extern void findgrade(); /* grades.c */
523 extern void chremdir(), mkremdir(); /* chremdir.c */
524 extern void toCorrupt(); /* cpmv.c */
525 extern int xmv(); /* cpmv.c */
527 EXTERN
int getargs(); /* getargs.c */
528 EXTERN
void bsfix(); /* getargs.c */
529 extern char *getprm(); /* getprm.c */
531 extern char *next_token(); /* permission.c */
532 extern char *nextarg(); /* permission.c */
533 extern int getuline(); /* permission.c */
535 EXTERN
void logent(), syslog(), closelog(); /* logent.c */
536 extern void commandlog(); /* logent.c */
537 extern time_t millitick(); /* logent.c */
539 extern unsigned long getfilesize(); /* statlog.c */
540 extern void putfilesize(); /* statlog.c */
542 EXTERN
char *protoString(); /* permission.c */
543 extern int logFind(), mchFind(); /* permission.c */
544 extern int chkperm(), chkpth(); /* permission.c */
545 extern int cmdOK(), switchRole(); /* permission.c */
546 extern int callBack(), requestOK(); /* permission.c */
547 extern int noSpool(); /* permission.c */
548 extern void myName(); /* permission.c */
550 extern int mkdirs(); /* expfile.c */
551 extern int scanlimit(); /* limits.c */
552 extern void systat(); /* systat.c */
553 EXTERN
int fd_mklock(), fd_cklock(); /* ulockf.c */
554 EXTERN
int fn_cklock(); /* ulockf.c */
555 EXTERN
int mklock(), cklock(), mlock(); /* ulockf.c */
556 EXTERN
void fd_rmlock(), delock(), rmlock(); /* ulockf.c */
557 extern char *timeStamp(); /* utility.c */
558 EXTERN
void assert(), errent(); /* utility.c */
559 extern void uucpname(); /* uucpname.c */
560 extern int versys(); /* versys.c */
561 extern void xuuxqt(), xuucico(); /* xqt.c */
562 EXTERN
void cleanup(); /* misc main.c */
564 #define ASSERT(e, s1, s2, i1) if (!(e)) {\
565 assert(s1, s2, i1, __FILE__, __LINE__);\
570 void exit(), setbuf();
573 int sleep(), exit(), setbuf(), ftime();
577 #include <sys/utsname.h>
583 daddr_t f_tfree
; /* total free */
584 ino_t f_tinode
; /* total inodes free */
586 #else /* !NOUSTAT && !V7USTAT */
596 EXTERN
char *Ct_OPEN
;
597 EXTERN
char *Ct_WRITE
;
598 EXTERN
char *Ct_READ
;
599 EXTERN
char *Ct_CREATE
;
600 EXTERN
char *Ct_ALLOCATE
;
601 EXTERN
char *Ct_LOCK
;
602 EXTERN
char *Ct_STAT
;
603 EXTERN
char *Ct_CHOWN
;
604 EXTERN
char *Ct_CHMOD
;
605 EXTERN
char *Ct_LINK
;
606 EXTERN
char *Ct_CHDIR
;
607 EXTERN
char *Ct_UNLINK
;
608 EXTERN
char *Wr_ROLE
;
609 EXTERN
char *Ct_CORRUPT
;
610 EXTERN
char *Ct_FORK
;
611 EXTERN
char *Ct_CLOSE
;
612 EXTERN
char *Ct_BADOWN
;
613 EXTERN
char *Fl_EXISTS
;