/*
* 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 2005 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"
/*
* uucleanup - This is a program based on the heuristics
* for cleaning up and doing something
* useful with old files left in the uucp queues.
* It also will send warning messags to users where requests are not
* going out due to failure to contact the remote system.
*
* This program knows a lot about the construction and
* contents of the C., D. and X. files. In addition, it
* thinks it knows what mail and netnews data files look like.
*
* At present, this is what is done:
* For WARNING messages:
* C. files of age given by -W option are read, looking for
* either user files to be sent or received, or
* mail to be sent. (Other remote execution that
* does not involve sending user files is not checked
* for now.) In either of the cases, the user is
* informed by mail that the request is not being
* processed due to lack of communications with the remote
* system, and the request will be deleted in the future
* if it the condition remains for several more days.
*
* For DELETIONS:
* C. files - if they reference only D. files, the C. is
* merely deleted, because the D. files are usually
* mail or news, and the later D. processing will
* take care of them.
* - if they reference files from the file system,
* a message is constructed that will contain a
* lines like
* We can't contact the remote.
*
* local!file -> remote!otherfile
*
* can't be executed.
* X. files - merely deleted at present - D.s will be taken
* care of later. Besides, some of the D.s are
* missing or else the X. wouldn't be left around.
* D. files - mail type data is sent to a local person if that
* is where it originated. If not, it is returned to the
* sender -- assumed to be from the first From line. If
* a sender can't be determing, the file is merely deleted.
* - rnews: if locally generated, just delete. If remote,
* the X. got lost, so execute rnews.
* other files - just delete them.
* .Workspace files over a day old
*
* Deletions and executions are logged in
*/
#include "uucp.h"
#ifdef V7
#define O_RDONLY 0
#endif
extern int _age(); /* find the age of a file */
extern void logit();
/* need these dummys to satisy some .o files */
void cleanup(){}
void systat(){}
void logent(){}
static void cleanworkspace(void);
/* types of D. files */
char *_Undeliverable[] = {
"Subject: Undeliverable Mail\n",
"This mail message is undeliverable.\n",
"(Probably to or from system '%s')\n",
"It was sent to you or by you.\n",
"Sorry for the inconvenience.\n",
"",
};
char *_CantContact[] = {
"Subject: Job Killed By uucp\n",
"We can't contact machine '%s'.\n",
" ", /* uucleanup will fill in variable text here */
" ", /* fill in jobid of killed job */
"",
};
char *_Warning[] = {
"Subject: Warning From uucp\n",
"We have been unable to contact machine '%s' since you queued your job.\n",
" ", /* wprocess FILLS IN THIS LINE OF TEXT */
"Attempts will continue for a few more days.\n",
"",
" ", /* wprocess FILLS IN THIS LINE WITH: uucp job id is JOBid. */
" ", /* FILL IN THE -m STRING IF SPECIFIED */
"",
};
int
int argc;
char *argv[];
char **envp;
{
int i, value;
switch(i){
case 's': /* for debugging - choose system */
break;
case 'x':
"WARNING: %s: invalid debug level %s ignored, using level 1\n",
Debug = 1;
}
#ifdef SMALL
"WARNING: uucleanup built with SMALL flag defined -- no debug info available\n");
#endif /* SMALL */
break;
case 'm':
break;
default:
exit(1);
case 'C':
case 'D':
case 'W':
case 'X':
case 'o':
if (value < 1) {
exit(1);
}
switch(i) {
case 'C':
break;
case 'D':
break;
case 'W':
break;
case 'X':
break;
case 'o':
break;
}
break;
}
}
exit(1);
}
exit(1);
}
exit(1);
}
continue;
if (*soptName)
break;
else
continue;
}
continue;
"CAN'T OPEN (%s): errno (%d)\n",
continue;
}
}
}
}
continue;
}
}
}
}
}
return (0);
}
/* procdtype - select the type of processing that a D. file should receive */
void
{
case D_DATA:
break;
case D_MAIL:
break;
case D_NEWS:
break;
case D_XFILE:
break;
default:
break;
}
return;
}
/* xprocess - X. file processing -- just remove the X. for now */
void
char *fullname;
{
errno = 0;
return;
}
/*
* cprocess - Process old C. files
*
*/
void
char *fullname;
{
struct stat s;
int ret;
return;
}
/* can't happen; _age() did stat of this file and file is opened */
return;
}
if (s.st_size == 0) { /* dummy C. for polling */
fullname);
errno = 0;
return;
}
/* Read the C. file and process it */
break;
}
ret = 0;
/* fill in line 3 of text */
if (*type == 'S') {
/* D. processing will return it later */
continue;
/* some data was requested -- tell user */
}
else if (*type == 'R') {
}
}
if (!*text) {
"cprocess: C. %s, mail returned (%d), unlink(%s)",
}
errno = 0;
return;
}
/*
* wprocess - send warning messages for C. == Wdays
*/
void
{
struct stat s;
int ret;
return;
}
/* can't happen; _age() did stat of this file and file is opened */
return;
}
if (s.st_size == 0) { /* dummy C. for polling */
return;
}
/* read C. and process it */
return;
}
/* set up the 6th text line of the mail message */
/* if Send type then do C. file processing */
if (*type == 'S') {
/* if this is a uux job - tell user about it */
/* if X.file can't be read then skip it */
break;
}
/* remove \n from end of buffer */
switch(*buf) {
/* save the file name */
case 'F':
break;
/* save return address */
case 'R':
break;
/* save machine, user */
case 'U':
break;
}
if (buf[0] != 'C')
continue;
else
/* give mail special handling */
else
/*
* this is mail; append
* user mail (xF_file).
*/
else
break;
}
break;
}
/* if so then D. processing will take of it later */
continue;
/* some data was requested -- tell user */
/* set up the 2nd text line of the mail message */
}
/* Receive C. file processing */
else if (*type == 'R') {
continue;
}
} /* end while - read C. lines loop */
"wprocess: %s: %s, warning message sent to %s, returned (%d)",
return;
}
/*
* oprocess - some unknown file just remove the file
*/
void
char *fullname;
{
return;
errno = 0;
return;
}
/*
* dDprocess - random D. file (not mail or rnews)
*--just delete it for now
*/
void
char *fullname;
{
errno = 0;
return;
}
/*
* dXprocess - process D. files that are destined for X. on remote
* --for now just delete it
*/
void
char *fullname;
{
errno = 0;
return;
}
/*
* dMprocess - process ophan D. mail files
* There are two types: ones generated locally and
* others that are from remotes. They can be identified
* by the system name following the D.
* Local ones have the local name.
*/
void
{
int ret;
}
else {
}
"dMprocess: mail %s to %s!%s, returned (%d), unlink(%s)",
errno = 0;
}
return;
}
/*
* dNprocess - process ophan D. netnews files
* There are two types: ones generated locally and
* others that are from remotes. They can be identified
* by the system name following the D.
* Local ones have the local name.
*/
void
{
int ret;
/* just delete it, the C. is gone */
fullname);
errno = 0;
}
else {
/* execute rnews with this file - the X. is missing */
"dNprocess: Remote - exec rnews %s: returned (%d), unlink(%s)",
errno = 0;
}
return;
}
/*
* _age - find the age of "file" in days
* return:
* age of file
* 0 - if stat fails
*/
int
char *fullname;
{
int e;
if (!ptime)
}
e = errno;
return(0);
}
/*
* dType - return the type of D. file
* return:
* FAIL - can't read D. file
* D_MAIL - mail message D. file
* D_NEWS - netnews D. file
* D_DATA - other kind of D. file
* D_XFILE - destined for X. on destination machine
*/
/* NLINES - number of lines of D. file to read to determine type */
int
char *fullname;
{
int i, type;
return(FAIL);
}
/* read first NLINES lines to determine file type */
for (i=0; i<NLINES; i++) {
break; /* no more lines */
break;
}
break;
}
break;
}
}
return(type);
}
/*
* sendMail - send mail file and message to user (local or remote)
* return:
* the return from the pclose - mail exit status
*/
int
char *mtext[];
{
char *p;
/* get rid of some stuff that could be dangerous */
*p = NULLCHAR;
}
*p = NULLCHAR;
}
else
return(-errno);
while (*mtext[0] )
"\n#############################################\n");
if (*file) {
/*next statement should never happen;I read once */
"##### Data File: ############################\n");
}
}
/*
* execRnews - execute rnews command with stdin file
* return:
* the return from the pclose - rnews exit status
*/
int
char *file;
{
return(-errno);
}
/*
* toWho - figure out who to send this dead mail to
* It is a guess;
* If there is a local address, send it there.
* If not, send it back where it came from.
* return:
* 0 - could not find system and user information
* 1 - found it
*/
int
char *file; /* the D. mail message file */
char **system; /* pointer to the system name */
char **user; /* pointer to the user name */
{
int i;
for (i=0; i<NLINES; i++) {
break; /* no more lines */
continue;
if ( !*fuser) {
}
return(1);
}
}
/* could not find local user - use first line */
if (!*fuser) /* didn't find all information */
return(0);
return(1);
}
/* analFrom - analyze From line
* return:
* 0 - didn't find both from and remote from info
* 1 - found info.
*/
int
{
char *s;
int i;
return(0);
for (i = 0; *s && *s != ' ' && *s != '\n'; i++)
user[i] = *s++;
/* look for "remote from" */
s++;
s = s + strlen("remote from ");
system[i] = *s++;
return(1);
}
}
return(0);
}
/*
* Make log entry
* text -> ptr to text string
* status errno number
* Returns:
* none
*/
void
char *text;
int status;
{
return;
}
return;
}
static void
cleanworkspace(void)
{
char f[MAXFULLNAME];
return;
}
return;
}
if (_age(f) >= 1)
if (unlink(f) != 0)
}