9 |
|
*/ |
10 |
|
|
11 |
|
#include <stdio.h> |
12 |
– |
#include <sys/types.h> |
12 |
|
#include <signal.h> |
13 |
|
#include <fcntl.h> |
14 |
+ |
#include "selcall.h" |
15 |
|
#include "netproc.h" |
16 |
+ |
#include "paths.h" |
17 |
|
#include "vfork.h" |
17 |
– |
/* Remote shell location */ |
18 |
– |
#ifdef sgi |
19 |
– |
#define RSH "/usr/bsd/rsh" |
20 |
– |
#endif |
21 |
– |
#ifdef _AUX_SOURCE |
22 |
– |
#define RSH "/usr/bin/remsh" |
23 |
– |
#endif |
24 |
– |
#ifndef RSH |
25 |
– |
#define RSH "/usr/ucb/rsh" |
26 |
– |
#endif |
27 |
– |
/* select call compatibility stuff */ |
28 |
– |
#ifndef FD_SETSIZE |
29 |
– |
#include <sys/param.h> |
30 |
– |
#define FD_SETSIZE NOFILE /* maximum # select file descriptors */ |
31 |
– |
#endif |
32 |
– |
#ifndef FD_SET |
33 |
– |
#ifndef NFDBITS |
34 |
– |
#define NFDBITS (8*sizeof(int)) /* number of bits per fd_mask */ |
35 |
– |
#endif |
36 |
– |
#define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS))) |
37 |
– |
#define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS))) |
38 |
– |
#define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS))) |
39 |
– |
#ifndef BSD |
40 |
– |
#define bzero(d,n) (void)memset(d,0,n) |
41 |
– |
#endif |
42 |
– |
#define FD_ZERO(p) bzero((char *)(p), sizeof(*(p))) |
43 |
– |
#endif |
18 |
|
|
19 |
|
PSERVER *pslist = NULL; /* global process server list */ |
20 |
|
|
21 |
|
static PROC *pindex[FD_SETSIZE]; /* process index table */ |
22 |
|
|
23 |
|
static char ourhost[64]; /* this host name */ |
24 |
< |
static char ourdir[128]; /* our working directory */ |
24 |
> |
static char ourdir[MAXPATH]; /* our working directory */ |
25 |
|
static char ouruser[32]; /* our user name */ |
26 |
|
static char *ourshell; /* our user's shell */ |
27 |
|
|
28 |
|
static fd_set errdesc; /* error file descriptors */ |
29 |
|
static int maxfd; /* maximum assigned descriptor */ |
30 |
|
|
31 |
+ |
extern char *remsh; /* externally defined remote shell program */ |
32 |
+ |
|
33 |
|
extern char *malloc(), *realloc(); |
34 |
|
extern char *getenv(); |
35 |
|
|
47 |
|
if (ps == NULL) |
48 |
|
return(NULL); |
49 |
|
if (!ourhost[0]) { /* initialize */ |
50 |
< |
char dirtmp[128]; |
50 |
> |
char dirtmp[MAXPATH]; |
51 |
|
register char *cp; |
52 |
|
register int len; |
53 |
|
|
54 |
|
strcpy(ourhost, myhostname()); |
55 |
< |
getcwd(dirtmp, sizeof(dirtmp)); |
55 |
> |
getwd(dirtmp); |
56 |
|
if ((cp = getenv("HOME")) != NULL) { |
57 |
|
if (!strcmp(cp, dirtmp)) |
58 |
|
ourdir[0] = '\0'; |
153 |
|
char *command; |
154 |
|
int (*compf)(); |
155 |
|
{ |
156 |
< |
char *av[12]; |
156 |
> |
char udirt[MAXPATH]; |
157 |
> |
char *av[16]; |
158 |
|
int pfd[2], pid; |
159 |
|
register int i; |
160 |
|
|
182 |
|
close(pfd[1]); |
183 |
|
} |
184 |
|
if (ps->hostname[0]) { /* rsh command */ |
185 |
< |
av[i=0] = RSH; |
185 |
> |
av[i=0] = remsh; |
186 |
|
av[++i] = ps->hostname; |
187 |
< |
av[++i] = "-n"; /* no stdin */ |
188 |
< |
if (ps->username[0]) { |
187 |
> |
av[++i] = "-n"; /* no stdin */ |
188 |
> |
if (ps->username[0]) { /* different user */ |
189 |
|
av[++i] = "-l"; |
190 |
|
av[++i] = ps->username; |
191 |
+ |
av[++i] = "cd"; |
192 |
+ |
udirt[0] = '~'; |
193 |
+ |
strcpy(udirt+1, ouruser); |
194 |
+ |
av[++i] = udirt; |
195 |
+ |
av[++i] = ";"; |
196 |
|
} |
197 |
< |
if (ps->directory[0]) { |
197 |
> |
if (ps->directory[0]) { /* change directory */ |
198 |
|
av[++i] = "cd"; |
199 |
|
av[++i] = ps->directory; |
200 |
|
av[++i] = ";"; |