|
|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T r
Length: 2560 (0xa00)
Types: TextFile
Notes: Tarfile:Truncated
Names: »rsh.c«
└─⟦9ae75bfbd⟧ Bits:30007242 EUUGD3: Starter Kit
└─⟦653021b30⟧ »EurOpenD3/utils/downtime.tar.Z«
└─⟦946c717da⟧
└─⟦this⟧ »libgen/rsh.c«
#ifndef lint
static char *RCSid = "$Header: rsh.c,v 1.1 88/04/19 14:08:55 mcooper Exp $";
#endif
/*
*------------------------------------------------------------------
*
* $Source: /usr/skat3/src/common/usc/lib/libgen/RCS/rsh.c,v $
* $Revision: 1.1 $
* $Date: 88/04/19 14:08:55 $
* $State: Exp $
* $Author: mcooper $
* $Locker: $
*
*------------------------------------------------------------------
*
* Michael A. Cooper
* Research and Development Group
* University Computing Services
* University of Southern California
* (mcooper@oberon.USC.EDU)
*
*------------------------------------------------------------------
*
* $Log: rsh.c,v $
* Revision 1.1 88/04/19 14:08:55 mcooper
* Initial revision
*
*
*------------------------------------------------------------------
*/
#include <stdio.h>
#include <sys/signal.h>
#include <sys/wait.h>
#include <setjmp.h>
#define RSH "/usr/ucb/rsh"
#define TESTCMD "/bin/date"
/*
* rshcheck - Stupid kludge to make sure rsh(1c) and other remote
* clientswill not hang.
* This often happens with Yellow Page clients who lose
* there domain server(s).
*/
int pid;
jmp_buf env;
rshcheck(host, user)
char *host, *user;
{
int rshtime();
int rshtimeout = 180; /* time out of 3 minutes */
int status, i;
if (host == NULL) {
return(2);
}
signal(SIGALRM, rshtime);
alarm(rshtimeout);
if (setjmp(env)) {
return(1);
} else {
if ((pid = fork()) == 0) {
(void) close(0);
(void) close(1);
(void) close(2);
if (user != NULL) {
execl(RSH, argv_zero(RSH), host, "-l", user, TESTCMD, 0);
} else {
execl(RSH, argv_zero(RSH), host, TESTCMD, 0);
}
perror("exec failed");
exit(127);
} else {
while ((i = wait(&status)) != pid && i != -1)
;
}
}
alarm(0);
return(0);
}
rshtime()
{
if (pid > 1) {
kill(pid, SIGKILL);
}
longjmp(env, 1);
}
/*
* rsh - Run an rsh(1c) request given a host, username, and
* a command to run.
*/
rsh(host, user, cmd)
char *host;
char *user;
char **cmd;
{
char **buf, **pp;
int w, pid, x;
union wait status;
if (host == NULL) {
return(-1);
}
pp = cmd;
x = 0;
while(*pp++ != NULL)
x++;
if ((buf = (char **) calloc(x+10, sizeof (char *))) == NULL) {
perror("calloc");
return(-1);
}
pp = buf;
*buf++ = (char *) argv_zero(RSH);
*buf++ = host;
if (user != NULL) {
*buf++ = "-l";
*buf++ = user;
}
while