uucico.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 1995 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* uucp file transfer program:
* to place a call to a remote machine, login, and
* copy files between the two machines.
*/
/*
* Added check to limit the total number of uucicos as defined
* in the Limits file.
*
* Added -f flag to "force execution", ignoring the limit on the
* number of uucicos. This will be used when invoking uucico from
* Uutry.
*/
#include "uucp.h"
#include "log.h"
#ifndef V7
#endif /* V7 */
#ifdef TLI
#endif /* TLI */
extern unsigned msgtime;
int uuxqtflag = 0;
#define USAGE "Usage: %s [-x NUM] [-r [0|1]] -s SYSTEM -u USERID -d SPOOL -i INTERFACE [-f]\n"
extern void closedem();
#ifdef NOSTRANGERS
static void checkrmt(); /* See if we want to talk to remote. */
#endif /* NOSTRANGERS */
extern char *Mytype;
char *argv[];
char **envp;
{
static char *pskip();
extern void setservice();
#ifndef ATTSVR3
void setTZ();
#endif /* ATTSVR3 */
char *ttyn;
char *iface; /* interface name */
char cb[128];
char lockname[MAXFULLNAME];
int maxnumb;
int force = 0; /* set to force execution, ignoring uucico limit */
/* Set locale environment variables local definitions */
#if !defined(TEXT_DOMAIN) /* Should be defined by cc -D */
#endif
(void) textdomain(TEXT_DOMAIN);
if (Uid == 0)
closedem();
Pchar = 'C';
#ifdef SIGUSR1
#endif
#ifdef SIGUSR2
#endif
#ifdef BSD4_2
#endif /*BSD4_2*/
pfInit();
scInit("xfer");
iface = "UNIX";
switch (ret) {
case 'd':
" access spool directory %s\n"),
exit(1);
}
break;
case 'c':
break;
case 'f':
++force;
break;
case 'r':
" '%s' for -r argument\n" USAGE),
exit(1);
}
break;
case 's':
gettext("%s: %s not in Systems file\n"),
cleanup(101);
}
/* set args for possible xuuxqt call */
/* if versys put a longer name in, truncate it again */
break;
case 'x':
if (Debug <= 0)
Debug = 1;
if (Debug > 9)
Debug = 9;
break;
case 'u':
break;
case 'i':
/* interface type */
break;
default:
exit(1);
}
}
}
/* limit the total number of uucicos */
if (force) {
} else {
if (maxnumb < 0) {
} else {
cleanup(101);
}
}
}
cleanup(101);
}
/* get Myname - it depends on who I'm calling--Rmtname */
cleanup(101);
}
acInit("xfer");
}
#ifndef ATTSVR3
setTZ();
#endif /* ATTSVR3 */
}
cleanup(101);
}
/*master setup will be called from processdev()*/
cleanup(101);
}
/*
* initial handshake
*/
(void) savline();
/* get MyName - use logFind to check PERMISSIONS file */
/*
* timed out
*/
(void) restline();
exit(0);
}
for (;;) {
if (ret != 0) {
(void) alarm(0);
(void) restline();
exit(0);
}
if (msg[0] == 'S')
break;
}
(void) alarm(0);
q = &msg[1];
p = pskip(q);
seq = 0;
while (p && *p == '-') {
q = pskip(p);
switch(*(++p)) {
case 'x':
if (Debug <= 0)
Debug = 1;
break;
case 'Q':
if (seq < 0)
seq = 0;
break;
#ifdef MAXGRADE
case 'v': /* version -- -vname=val or -vname */
isalnum(p[6]))
MaxGrade = p[6];
break;
#endif /* MAXGRADE */
case 'R':
Restart++;
p++;
break;
case 'U':
SizeCheck++;
break;
default:
break;
}
p = q;
}
cleanup(101);
}
if (Restart)
#ifdef NOSTRANGERS
checkrmt(); /* Do we know the remote system. */
#else
#endif /* NOSTRANGERS */
cleanup(101);
}
/* validate login using PERMISSIONS file */
scWrite(); /* log security violation */
cleanup(101);
}
/*
* set up for call back
*/
} else {
}
cleanup(101);
}
cleanup(101);
}
if (Restart) {
if (SizeCheck)
else
} else
(void) cmtseq();
} else {
ulkseq();
cleanup(101);
}
else
else
} else
/* set args for possible xuuxqt call */
}
/*
* Ensure reasonable ulimit (MINULIMIT)
*/
#ifndef V7
{
long minulimit;
}
#endif
cleanup(101);
}
/*
* master part
*/
sleep(3);
}
/*
* Find the highest priority job grade that has
* jobs to do. This is needed to form the lock name.
*/
/*
* Lock the job grade if there is one to process.
*/
Rmtname);
cleanup(100);
}
} else {
}
if (Ofn < 0) {
cleanup(101);
} else {
else
}
}
cleanup(101);
}
/* give slow guys lots of time to thrash */
for (;;) {
if (ret != 0) {
continue; /* try again */
}
if (msg[0] == 'S')
break;
}
(void) alarm(0);
/* This may be a problem, we check up to MAXBASENAME
* characters now. The old comment was:
* this is a problem. We'd like to compare with an
* untruncated Rmtname but we fear incompatability.
* So we'll look at most 6 chars (at most).
*/
cleanup(101);
}
}
#ifdef MAXGRADE
}
#endif /* MAXGRADE */
for (;;) {
if (ret != 0) {
(void) alarm(0);
ulkseq();
cleanup(101);
}
if (msg[0] == 'R')
break;
}
(void) alarm(0);
/* check for rejects from remote */
Uerror = 0;
Uerror = SS_RLOCKED;
if (Uerror) {
ulkseq();
cleanup(101);
}
(void) cmtseq();
/*
* See if we have any additional parameters on the OK
*/
while (p && *p == '-') {
q = pskip(p);
switch(*(++p)) {
case 'R':
Restart++;
p++;
break;
case 'U':
SizeCheck++;
break;
case 'x':
if (!Debug) {
if (Debug <= 0)
Debug = 1;
}
break;
default:
break;
}
p = q;
}
}
}
* hanging for hours in imsg().
*/
cleanup(101);
}
(void) alarm(0);
Uerror = SS_STARTUP;
exitcode = 101;
} else {
if (exitcode == 0) {
} else {
}
for (;;) {
if (ret != 0)
break;
if (msg[0] == 'O')
break;
}
}
(void) alarm(0);
}
/*NOTREACHED*/
}
/*
* clean and exit with "code" status
*/
void
register int code;
{
closedem();
alarm(0); /* Turn off timer. */
cleanTM();
}
short TM_cnt = 0;
char TM_name[MAXNAMESIZE];
void
cleanTM()
{
register int i;
char tm_name[MAXNAMESIZE];
for(i=0; i < TM_cnt; i++) {
}
return;
}
void
char *file;
{
if (TM_cnt == 0)
TM_cnt++;
return;
}
/*
* intrrupt - remove locks and exit
*/
void
register int inter;
{
char str[30];
/* I'm putting a test for zero here because I saw it happen
* and don't know how or why, but it seemed to then loop
* here for ever?
*/
if (inter == 0)
exit(99);
pfEndfile("PARTIAL FILE");
}
void
int inter;
{
char cb[20];
closedem();
abort();
}
/*
* catch SIGALRM routine
*/
void
timeout()
{
}
/* skip to next field */
static char *
pskip(p)
register char *p;
{
do
*p++ = NULLCHAR;
while (*p == ' ');
return(p);
}
void
closedem()
{
register i, maxfiles;
#ifdef ATTSVR3
#else /* !ATTSVR3 */
#ifdef BSD4_2
maxfiles = getdtablesize();
#else /* BSD4_2 */
#endif /* BSD4_2 */
#endif /* ATTSVR3 */
for ( i = 3; i < maxfiles; i++ )
(void) close(i);
return;
}
#ifndef ATTSVR3
/*
* setTZ()
*
* if login "shell" is uucico (i.e., Role == SLAVE), must set
* timezone env variable TZ. otherwise will default to EST.
*/
#define LINELEN 81
void
setTZ()
{
extern char *fgets();
register int i;
return;
++bp;
*(bp+i) = '\0';
return;
}
}
return;
}
#endif /* ATTSVR3 */
#ifdef NOSTRANGERS
/*
* Function: checkrmt
*
* If NOSTRANGERS is defined, see if the remote system is in our systems
* file. If it is not, execute NOSTRANGERS and then reject the call.
*/
static void
checkrmt ()
{
char ** eVarPtr; /* Pointer to environment variable. */
int status; /* Exit status of child. */
/* here's the place to look the remote system up in the Systems file.
* If the command NOSTRANGERS is executable and
* If they're not in my file then hang up */
/*
* Ignore hangup in case remote goes away before we can
* finish logging.
*/
scWrite(); /* log unknown remote system */
if ( procid == 0 ) {
/*
* Before execing the no strangers program, there is
* a security aspect to consider. If NOSTRANGERS is
* not a full path name, then the PATH environment
* variable will provide places to look for the file.
* To be safe, we will set the PATH environment
* variable before we do the exec.
*/
/* Find PATH in current environment and change it. */
}
} else if (procid < 0) {
} else {
}
cleanup(101);
}
}
#endif /* NOSTRANGERS */