/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1990-2011 AT&T Intellectual Property *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Glenn Fowler <gsf@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
/*
* Glenn Fowler
* AT&T Bell Laboratories
*
* remote coshell server shell support
*/
#include "service.h"
#include <proc.h>
/*
* single quote s into sp
*/
static void
{
register int c;
while (c = *s++)
{
}
}
/*
* open a new shell connection to sp
* error output to fd
*/
int
{
char* sh;
if (!sp)
{
if (fd >= 0)
}
return 0;
else
{
{
if (fd >= 0)
return -1;
}
{
if (xp)
vp = 0;
goto nospace;
}
goto nospace;
{
sfprintf(vp, "%s=%s %s=%s %s='%s %s' COINIT='%s' %s /dev/fd/4 >/dev/null 2>&1 3<%s 4<&3 5>&- 6>&- 7>&- 8>&- 9>&- &", CO_ENV_HOST, sp->name, CO_ENV_TYPE, sp->type, CO_ENV_SHELL, opt_info.argv[0], state.service, (sp->flags & SETRATING) ? "rating=0;" : "", sh, state.mesg);
av[0] = "sh";
}
else
{
sfprintf(vp, "%s -c 'trap \"\" HUP; %s=%s %s=%s %s= COINIT='\\''%s%s'\\'' %s /dev/fd/4 >/dev/null 2>&1 3<%s 4<&3 5>&- 6>&- 7>&- 8>&- 9>&- &'", sh, CO_ENV_HOST, sp->name, CO_ENV_TYPE, sp->type, CO_ENV_SHELL, (sp->flags & SETRATING) ? "rating=0;" : "", state.profile ? state.profile : "", sh, state.mesg);
}
goto nospace;
av[3] = 0;
{
if (fd >= 0)
sfstrclose(xp);
sfstrclose(vp);
return -1;
}
{
}
sfstrclose(xp);
sfstrclose(vp);
return 0;
}
return -1;
if (fd >= 0)
if (xp)
sfstrclose(xp);
if (vp)
sfstrclose(vp);
return -1;
}
/*
* close shell sp if open
* error output to fd
*/
void
{
{
{
}
if (sp->idle_override)
{
sp->idle_override = 0;
}
{
}
{
{
}
}
}
{
}
}
/*
* send command in the exec message msg to a shell for user fd
* if jp!=0 then the msg was popped off jp->sp's delay queue
*/
void
{
int n;
int id;
int flags;
char* s;
char* cmd;
char* act;
char* pwd;
char* out;
char* err;
char* att;
char* env;
char* end;
char* red;
if (tokscan(msg, &end, "%s %d %d %s %s %s %s %s %s", NiL, &id, &flags, &pwd, &out, &err, &att, &env, &act) != 9)
{
goto noexec;
}
{
/*
* find a shell slot
*/
if (state.running >= (state.perserver + state.jobwait) || con[fd].info.user.running >= state.peruser)
{
}
{
{
}
goto noexec;
}
{
goto noexec;
}
if (!jp)
{
/*
* find a free job slot
*/
for (;;)
{
{
jp = 0;
goto noexec;
}
}
{
}
}
}
{
return;
}
sfprintf(state.string, "{\ntrap 'set %s$?; trap \"\" 0; print -u3 x %d $1 $(times); 3>&-; exit $1' 0 HUP INT QUIT TERM%s\n",
if (!out)
{
else
{
}
}
if (!err)
{
else
{
}
}
sfprintf(state.string, "%s\ntypeset -i%d ___=${!:-$$}\nexport %s=%..*u${___#%d#}\neval '%s", env ? env : "", TEMPBASE, CO_ENV_TEMP, TEMPBASE, sp->addr, TEMPBASE, (flags & CO_SILENT) ? "" : "set -x\n");
/*
*/
{
goto nojob;
}
{
goto nojob;
}
goto noexec;
return;
return;
}
/*
* check for queued jobs on shells hung during open
* call if state.shellwait>0
*/
void
shellcheck(void)
{
do
{
{
}
}