10 |
|
|
11 |
|
#include <stdio.h> |
12 |
|
#include <sys/types.h> |
13 |
+ |
#ifdef INCL_SEL_H |
14 |
+ |
#include <sys/select.h> |
15 |
+ |
#endif |
16 |
|
#include <signal.h> |
17 |
|
#include <fcntl.h> |
18 |
|
#include "netproc.h" |
19 |
+ |
#include "paths.h" |
20 |
|
#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 |
21 |
|
/* select call compatibility stuff */ |
22 |
|
#ifndef FD_SETSIZE |
23 |
|
#include <sys/param.h> |
41 |
|
static PROC *pindex[FD_SETSIZE]; /* process index table */ |
42 |
|
|
43 |
|
static char ourhost[64]; /* this host name */ |
44 |
< |
static char ourdir[128]; /* our working directory */ |
44 |
> |
static char ourdir[MAXPATH]; /* our working directory */ |
45 |
|
static char ouruser[32]; /* our user name */ |
46 |
|
static char *ourshell; /* our user's shell */ |
47 |
|
|
48 |
|
static fd_set errdesc; /* error file descriptors */ |
49 |
|
static int maxfd; /* maximum assigned descriptor */ |
50 |
|
|
51 |
+ |
extern char *remsh; /* externally defined remote shell program */ |
52 |
+ |
|
53 |
|
extern char *malloc(), *realloc(); |
54 |
|
extern char *getenv(); |
55 |
|
|
67 |
|
if (ps == NULL) |
68 |
|
return(NULL); |
69 |
|
if (!ourhost[0]) { /* initialize */ |
70 |
< |
char dirtmp[128]; |
70 |
> |
char dirtmp[MAXPATH]; |
71 |
|
register char *cp; |
72 |
|
register int len; |
73 |
|
|
74 |
|
strcpy(ourhost, myhostname()); |
75 |
< |
getcwd(dirtmp, sizeof(dirtmp)); |
75 |
> |
getwd(dirtmp); |
76 |
|
if ((cp = getenv("HOME")) != NULL) { |
77 |
|
if (!strcmp(cp, dirtmp)) |
78 |
|
ourdir[0] = '\0'; |
173 |
|
char *command; |
174 |
|
int (*compf)(); |
175 |
|
{ |
176 |
< |
char *av[12]; |
176 |
> |
char udirt[MAXPATH]; |
177 |
> |
char *av[16]; |
178 |
|
int pfd[2], pid; |
179 |
|
register int i; |
180 |
|
|
202 |
|
close(pfd[1]); |
203 |
|
} |
204 |
|
if (ps->hostname[0]) { /* rsh command */ |
205 |
< |
av[i=0] = RSH; |
205 |
> |
av[i=0] = remsh; |
206 |
|
av[++i] = ps->hostname; |
207 |
< |
av[++i] = "-n"; /* no stdin */ |
208 |
< |
if (ps->username[0]) { |
207 |
> |
av[++i] = "-n"; /* no stdin */ |
208 |
> |
if (ps->username[0]) { /* different user */ |
209 |
|
av[++i] = "-l"; |
210 |
|
av[++i] = ps->username; |
211 |
+ |
av[++i] = "cd"; |
212 |
+ |
udirt[0] = '~'; |
213 |
+ |
strcpy(udirt+1, ouruser); |
214 |
+ |
av[++i] = udirt; |
215 |
+ |
av[++i] = ";"; |
216 |
|
} |
217 |
< |
if (ps->directory[0]) { |
217 |
> |
if (ps->directory[0]) { /* change directory */ |
218 |
|
av[++i] = "cd"; |
219 |
|
av[++i] = ps->directory; |
220 |
|
av[++i] = ";"; |