/*
* 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"
#include "uucp.h"
#include "log.h"
/*
* execute commands set up by a uux command,
* usually from a remote machine - set by uucp.
*/
#ifndef V7
#else
#endif
static int chkFile();
static int doFileChk();
int
int argc;
char *argv[];
char *envp[];
{
void onintr();
/* Set locale environment variables local definitions */
#if !defined(TEXT_DOMAIN) /* Should be defined by cc -D */
#endif
(void) textdomain(TEXT_DOMAIN);
/* choose LOGFILE */
/*
* get local system name
*/
Pchar = 'Q';
Ofn = 1;
Ifn = 0;
switch (ret) {
/*
* debugging level
*/
case 'x':
if (Debug <= 0)
Debug = 1;
break;
case 's':
/*
* fake out uuxqt and use the argument as if
* it were the spool directory for the purpose
* of determining what subdirectories to search
* this will cause uuxqt to only run on the sub
* baz and gorp in the Spool directory. Trust me.
*/
(MAXFULLNAME - sizeof (SEQLOCK)));
break;
default:
exit(1);
}
}
exit(1);
}
acInit("rexe");
scInit("rexe");
} else {
if (maxnumb < 0) {
} else {
exit(0);
}
}
}
/*
* determine user who started uuxqt (in principle)
*/
if (Uid == 0)
/* look for special characters in remote name */
/* ignore naughty name */
cleanup(101);
}
}
} else {
/* skip naughty names */
continue;
}
continue;
}
}
cleanup(0);
/* NOTREACHED */
return (0);
}
void
int code;
{
}
/*
* catch signal then cleanup and exit
*/
void
int inter;
{
}
/*
* stash an X. file so we can process them sorted first by grade, then by
* sequence number
*/
static void
char *file;
{
if (xcachesize < XCACHESIZE) {
}
}
/*
* xcompare
* comparison routine for for qsort()
*/
static int
{
/* assumes file name is X.siteG1234 */
/* use -strcmp() so that xstash is sorted largest first */
/* pull files out of the stash from largest index to smallest */
}
/*
* xsort
* sort the cached X. files,
* largest (last) to smallest (next to be processed)
*/
static void
xsort()
{
}
/*
* xget
* return smallest X. file in cache
* (hint: it's the last one in the array)
*/
static int
char *file;
{
if (xcachesize > 0) {
return (1);
} else {
/* avoid horror of xcachesize < 0 (impossible, you say?)! */
xcachesize = 0;
return (0);
}
}
/*
* get a file to execute
* file -> a read to return filename in
* returns:
* 0 -> no file
* 1 -> file to execute
*/
int
{
if (xcachesize == 0) {
/* open spool directory */
/* this was an ASSERT, but it's not so bad as all that */
return (0);
/* scan spool directory looking for X. files to stash */
/* look for x prefix */
continue;
/* check to see if required files have arrived */
if (xcachesize >= XCACHESIZE)
break;
}
xsort();
}
}
/*
* check for needed files
* file -> name of file to check
* return:
* 0 -> not ready
* 1 -> all files ready
*/
int
char *file;
{
return (FALSE);
/*
* look at required files
*/
continue;
/*
* expand file name
*/
/*
* see if file exists
*/
return (FALSE);
}
}
return (TRUE);
}
/*
* remove execute files to x-directory
*
* _Xfile is a global
* return:
* none
*/
void
{
return;
}
/*
* (void) unlink each file belonging to job
*/
continue;
continue;
}
}
/*
* move execute files to x-directory
* _Xfile is a global
* return:
* none
*/
void
{
return;
}
continue;
continue;
/*
* expand file names and move to
* execute directory
* Make files readable by anyone
*/
continue; /* execution will fail later */
/*
* tfull will have been canonicalized. If
* it still points to XQTDIR, allow us to
* write there.
*/
continue; /* execution will fail later */
/* otherwise, keep going */
}
}
}
/*
* undo what mv_Xfiles did
* _Xfile is a global
* return:
* none
*/
void
{
return;
}
continue;
continue;
/*
* expand file names and move back to
* spool directory
* Make files readable by uucp
*/
/* i know we're in .Xqtdir, but ... */
continue;
}
}
/*
* chkpart - checks the string (ptr points to it) for illegal command or
* file permission restriction - called recursively
* to check lines that have `string` or (string) form.
* _Cmd is the buffer where the command is built up.
* _CargType is the type of the next C line argument
*
* Return:
* BAD_FILE if a non permitted file is found
* BAD_COMMAND if non permitted command is found
* 0 - ok
*/
static int
{
int ret;
/* _CargType is the arg type for this iteration (cmd or file) */
switch (*prm) {
/* End of command delimiter */
case ';':
case '^':
case '&':
case '|':
continue;
/* Other delimiter */
case '>':
case '<':
continue;
case '`': /* don't allow any ` commands */
case '\\':
return (BAD_COMMAND);
/* Some allowable quoted string */
case '(':
case '"':
case '\'':
/* must recurse */
/* put leading white space & first char into command */
/* recurse */
return (ret);
}
/* put last char into command */
continue;
case '2':
continue;
}
/* fall through if not "2>" */
default: /* check for command or file */
break;
}
if (*rqtcmd == '~')
return (BAD_COMMAND);
continue;
}
if (*rqtcmd == '~')
return (BAD_FILE);
} else {
}
}
if (whitesp[0] != '\0')
/* restore any trailing white space */
return (0); /* all ok */
}
/*
* chkFile - try to find a path name in the prm.
* if found, check it for access permission.
*
* check file access permissions
* if ! in name assume that access on local machine is required
*
* Return:
* BAD_FILE - not permitted
* 0 - ok
*/
static int
{
switch (*prm) {
case '~':
case '/':
return (BAD_FILE);
else
return (0);
/*NOTREACHED*/
case '!':
/*NOTREACHED*/
default:
break;
}
return (0);
}
if (doFileChk(p))
return (BAD_FILE);
else
return (0);
}
/* there is at least one '!' - see if it refers to my system */
else /* not my system - not my worry */
return (0);
}
/*
* doFileChk - check file path permission
* NOTE: file is assumed to be a buffer that expfile an
* write into.
* Return
* BAD_FILE - not allowed
* 0 - ok
*/
static int
{
return (BAD_FILE);
else
return (0);
}
/*
* return stuff to user
* user -> user to notify
* rmt -> system name where user resides
* file -> file to return (generally contains input)
* cmd -> command that was to be executed
* buf -> user friendly face saving uplifting edifying missive
* errfile -> stderr output from cmd xeqn
* return:
* none
*/
static void
{
else
}
/*
* uucpst - send the status message back using a uucp command
* NOTE - this would be better if the file could be appended.
* - suggestion for the future - if rmail would take a file name
* instead of just person, then that facility would be correct,
* and this routine would not be needed.
*/
static void
{
int status;
return;
/* copy back stderr */
}
/* start uucp */
(void) close(0);
(void) close(1);
(void) close(2);
ucloselog();
_exit(100);
}
if (pid == -1)
return;
break;
}
void
char *dirname;
{
char fdgrade(); /* returns default service grade on system */
char *p;
continue;
}
/*
* initialize to defaults
*/
badfiles = 0;
initSeq();
store_status = 0;
return_stdin = 0;
/*
* interpret JCL card
*/
switch (buf[0]) {
case X_USER:
/*
* user name
* (ignore Rmtname)
* The utmpx username field is 32 characters long;
* UUCP usage truncates system name to 14 bytes.
*/
break;
case X_STDIN:
/*
* standard input
*/
badfiles = 1;
}
break;
case X_STDOUT:
/*
* standard output
*/
*p = NULLCHAR; /* these are dangerous */
break;
badfiles = 1;
}
break;
case X_STDERR: /* standard error */
*p = NULLCHAR; /* these are dangerous */
break;
badfiles = 1;
}
break;
case X_CMD: /* command to execute */
break;
case X_MAILF: /* put status in _Sfile */
store_status = 1;
break;
case X_SENDNOTHING: /* no failure notification */
send_nothing++;
break;
case X_SENDZERO: /* success notification */
send_zero++;
break;
case X_NONZERO: /* failure notification */
send_nonzero++;
break;
case X_BRINGBACK: /* return stdin on command failure */
return_stdin = 1;
break;
case X_RETADDR:
/*
* return address -- is user's name
* put "Rmtname!" in front of it so mail
* will always get back to remote system.
*/
/*
* Creates string of Rmtname!Rmtname!user which
* confuses rmail.
* (void) strcat(strcat(strcpy(retaddr, Rmtname), "!"),
* retuser);
*/
break;
case X_JOBID:
/*
* job id for notification
* (should be MAXBASENAME, not 14, but no can do)
*/
break;
default:
break;
}
}
/* get rid of stuff that can be dangerous */
*p = NULLCHAR;
}
/* this is a bad X. file - just get rid of it */
continue;
}
/*
* send_nothing must be explicitly requested to avert failure status
* send_zero must be explicitly requested for success notification
*/
if (!send_nothing)
send_nonzero++;
/*
* command execution
*/
/*
* generate a temporary file (if necessary)
* to hold output to be shipped back
*/
else {
tempname);
}
/*
* generate a temporary file (if necessary)
* to hold errors to be shipped back
*/
/*
* This is what really should be done. However for compatibility
* for the interim at least, we will always create temp file
* so we can return error output. If this temp file IS conditionally
* created, we must remove the unlink() of errDfile at the end
* else {
*/
/*
* }
*/
/* initialize command line */
/* set up two environment variables, remote machine name */
/* and remote user name if available from R line */
/*
* xcu4 requires that uucp *does* expand wildcards and uux *does not*
* expand wild cards... Further restrictions are that uux must work
* with every other uucp / uux that initiated a request, so nothing
* strange can been done to communicate that it was uucp that sent
* the request and not uux, What we settle on here is looking for
* the command name uucp and expanding wildcards in only that case.
* It is true that a user can spoof this using uux, but in reality
* this would be identical to using the uucp command to start with.
*/
"%s %s UU_MACHINE=%s UU_USER=%s "
" export UU_MACHINE UU_USER PATH; ",
} else {
"%s %s UU_MACHINE=%s UU_USER=%s "
" export UU_MACHINE UU_USER PATH; set -f; ",
}
/*
* check to see if command can be executed
*/
if (cmdok == BAD_COMMAND) {
} else {
}
scWlog(); /* log security vialotion */
if (send_nonzero)
if (store_status)
goto rmfiles;
}
/* move files to execute directory and change to that directory */
mv_Xfiles();
/* invoke shell to execute command */
cpucycle();
if (ret == 0)
else
unmv_Xfiles(); /* put things back */
cleanup(1);
}
if (ret == 0) { /* exit == signal == 0 */
} else { /* exit != 0 */
if (exitcode) {
/* exit != 0 */
"exited with status %d", exitcode);
} else {
/* signal != 0 */
}
}
/* change back to spool directory */
/* remove file */
rm_Xfiles();
/*
* We used to append stderr to stdout. Since stderr can
* now be specified separately, never append it to stdout.
* It can still be gotten via -s status file option.
*/
/*
* if output is on this machine copy output
* there, otherwise spawn job to send to send
* output elsewhere.
*/
scWrite();
"\nCould not move stdout to %s,", fout);
"\n\tstdout left in %s.", fout);
else
sizeof (msgbuf));
}
} else {
char *bname;
else
dqueue);
}
}
/*
* if stderr is on this machine copy output
* there, otherwise spawn job to send to send
* it elsewhere.
*/
scWrite();
"\nCould not move stderr to %s,", ferr);
"\n\tstderr left in %s", ferr);
} else {
sizeof (msgbuf));
}
}
} else {
char *bname;
else
}
} else {
/*
* If we conditionally create stderr tempfile, we must
*/
}
if (ret == 0) {
if (send_zero)
if (store_status)
} else {
if (send_nonzero)
if (store_status)
}
/* delete job files in spool directory */
continue;
}
}
}