uucp.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 (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include "uucp.h"
/*
* uucp
* user id
* make a copy in spool directory
*/
int Copy = 0;
static int _Transfer = 0;
char Nuser[32];
char *Ropt = " ";
char Optns[10];
int Mail = 0;
int Notify = 0;
char Sfile[MAXFULLNAME];
char *argv[];
char **envp;
{
char *jid();
int ret;
int errors = 0;
short jflag = 0; /* -j flag Jobid printout */
extern int split();
/* Set locale environment variables local definitions */
#if !defined(TEXT_DOMAIN) /* Should be defined by cc -D */
#endif
(void) textdomain(TEXT_DOMAIN);
/* this fails in some versions, but it doesn't hurt */
if (Uid == 0)
/* choose LOGFILE */
Pchar = 'U';
Grade = 'A';
}
/*
* find name of local system
*/
Optns[0] = '-';
/*
* find id of user who spawned command to
* determine
*/
/*
*/
switch (ret) {
/*
* make a copy of the file in the spool
* directory.
*/
case 'C':
Copy = 1;
break;
/*
* not used (default)
*/
case 'c':
break;
/*
* not used (default)
*/
case 'd':
break;
case 'f':
break;
/*
* set service grade
*/
case 'g':
if (!Sgrades) {
else {
" administrator defined service"
" grades available on this"
" machine.\n"));
" service grades range from"
" [A-Z][a-z] only.\n"));
cleanup(-1);
}
}
else {
}
break;
case 'j': /* job id */
jflag = 1;
break;
/*
* send notification to local user
*/
case 'm':
Mail = 1;
break;
/*
* send notification to user on remote
* if no user specified do not send notification
*/
case 'n':
/*
* We should add "n" option to Optns only once,
* even if multiple -n option are passed to uucp
*/
if (!Notify) {
Notify = 1;
}
/*
* We do the copy multiple times when multiple
* -n options are specified, but
* only the last -n value is used.
*/
break;
/*
* create JCL files but do not start uucico
*/
case 'r':
Ropt = "-r";
break;
/*
* return status file
*/
case 's':
/* "m" needed for compatability */
break;
/*
* turn on debugging
*/
case 'x':
if (Debug <= 0)
Debug = 1;
#ifdef SMALL
" flag defined -- no debug info available\n"));
#endif /* SMALL */
break;
default:
usage();
break;
}
}
if (fopt) {
if (*fopt != '/')
else
}
else
return (2);
/*
* work in WORKSPACE directory
*/
if (ret != 0) {
" get help\n"), WORKSPACE);
cleanup(-12);
}
usage();
}
/*
* set up "to" system and file names
*/
/* get real Myname - it depends on who I'm calling--Rmtname */
}
}
/*
* if there are more than 2 argsc, file2 is a directory
*/
/*
* do each from argument
*/
}
}
/* source files can have at most one ! */
/* syntax error */
exit(2);
}
/*
* check for required remote expansion of file names -- generate
* and execute a uux command
* e.g.
* uucp owl!~/dan/.. ~/dan/
*
* NOTE: The source file part must be full path name.
* If ~ it will be expanded locally - it assumes the remote
* names are the same.
*/
/* do a uux command */
exit(6);
/* get real Myname - it depends on who I'm calling--Rmtname */
continue;
}
/*
* check for forwarding -- generate and execute a uux command
* e.g.
* uucp uucp.c raven!owl!~/dan/
*/
continue;
}
/*
* check for both source and destination on other systems --
* generate and execute a uux command
*/
continue;
}
} else {
/* get real Myname - it depends on who I'm calling--Rmtname */
}
errors++;
}
/* move the work files to their proper places */
commitall();
/*
* Wait for all background uux processes to finish so
* that our caller will know that we're done with all
* input files and it's safe to remove them.
*/
;
/*
* do not spawn daemon if -r option specified
*/
if (*Ropt != '-') {
#ifndef V7
long limit;
char msg[100];
}
else
#endif
}
if (jflag) {
}
/*NOTREACHED*/
}
/*
* cleanup lock files before exiting
*/
void
register int code;
{
static int first = 1;
if (first) {
first = 0;
if (code != 0)
wfabort(); /* this may be extreme -- abort all work */
}
if (code < 0) {
}
else if (code > 0) {
"uucp failed partially: %d file(s) sent; %d error(s)\n"),
}
}
/*
* generate copy files for s1!f1 -> s2!f2
* Note: only one remote machine, other situations
* have been taken care of in main.
* return:
* 0 -> success
* Non-zero -> failure
*/
int
{
type = 0;
type = 1;
type = 2;
switch (type) {
case 0:
/*
* all work here
*/
/*
* check access control permissions
*/
return(-6);
return(-7);
cleanup(1);
}
/*
* copy file locally
*
* Changed from uidxcp() to fic file made and owner
* being modified for existing files, and local file
* name expansion.
*/
perror("popen");
return (FAIL);
}
return (FAIL);
}
/*
* if user specified -m, notify "local" user
*/
if ( Mail ) {
"REQUEST: %s!%s --> %s!%s (%s)\n(SYSTEM %s) copy succeeded\n",
}
/*
* if user specified -n, notify "remote" user
*/
if ( Notify ) {
}
return(0);
case 1:
/*
* receive file
*/
/*
* expand source and destination file names
* and check access permissions
*/
if (file1[0] != '~')
return(6);
return(7);
/*
* insert JCL card in file
*/
break;
case 2:
/*
* send file
*/
return(6);
/* XQTDIR hook enables 3rd party uux requests (cough) */
return(7);
return(8);
}
return(9);
}
/* see if I can read this file as read uid, gid */
gettext("uucp can't read (%s) mode (%o)\n"),
return(3);
}
/*
* make a copy of file in spool directory
*/
return(5);
}
break;
}
_Transfer++;
return(0);
}
/*
* syscfile(file, sys)
* char *file, *sys;
*
* get the cfile for system sys (creat if need be)
* return stream pointer
*
* returns
* stream pointer to open cfile
*
*/
static FILE *
{
} else
return(cfp);
}
/*
* generate and execute a uux command
*/
void
{
char * xarg[6];
int narg = 0;
int i;
/* get real Myname - it depends on who I'm calling--rmt */
if (*Ropt != ' ')
exit(6);
}
else
else
else
}
else {
exit(7);
}
for (i=0; i < narg; i++) {
}
if (fork() == 0) {
exit(0);
}
return;
}
void
usage()
{
"Usage: %s [-c|-C] [-d|-f] [-g GRADE] [-jm] [-n USER]\\\n"
"[-r] [-s FILE] [-x DEBUG_LEVEL] source-files destination-file\n"),
Progname);
cleanup(-2);
}