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