version 1.219, 2004/06/18 10:55:43 |
version 1.220, 2004/06/20 17:36:59 |
|
|
kill(control_server_pid, signo); |
kill(control_server_pid, signo); |
} |
} |
|
|
|
static int |
|
env_permitted(char *env) |
|
{ |
|
int i; |
|
char name[1024], *cp; |
|
|
|
strlcpy(name, env, sizeof(name)); |
|
if ((cp = strchr(name, '=')) == NULL) |
|
return (0); |
|
|
|
*cp = '\0'; |
|
|
|
for (i = 0; i < options.num_send_env; i++) |
|
if (match_pattern(name, options.send_env[i])) |
|
return (1); |
|
|
|
return (0); |
|
} |
|
|
static void |
static void |
control_client(const char *path) |
control_client(const char *path) |
{ |
{ |
struct sockaddr_un addr; |
struct sockaddr_un addr; |
int i, r, sock, exitval; |
int i, r, sock, exitval, num_env; |
Buffer m; |
Buffer m; |
char *cp; |
char *cp; |
extern char **environ; |
extern char **environ; |
|
|
buffer_append(&command, "\0", 1); |
buffer_append(&command, "\0", 1); |
buffer_put_cstring(&m, buffer_ptr(&command)); |
buffer_put_cstring(&m, buffer_ptr(&command)); |
|
|
/* Pass environment */ |
if (options.num_send_env == 0 || environ == NULL) { |
for (i = 0; environ != NULL && environ[i] != NULL; i++) |
buffer_put_int(&m, 0); |
; |
} else { |
buffer_put_int(&m, i); |
/* Pass environment */ |
for (i = 0; environ != NULL && environ[i] != NULL; i++) |
num_env = 0; |
buffer_put_cstring(&m, environ[i]); |
for (i = 0; environ[i] != NULL; i++) |
|
if (env_permitted(environ[i])) |
|
num_env++; /* Count */ |
|
|
|
buffer_put_int(&m, num_env); |
|
|
|
for (i = 0; environ[i] != NULL && num_env >= 0; i++, num_env--) |
|
if (env_permitted(environ[i])) |
|
buffer_put_cstring(&m, environ[i]); |
|
} |
|
|
if (ssh_msg_send(sock, /* version */0, &m) == -1) |
if (ssh_msg_send(sock, /* version */0, &m) == -1) |
fatal("%s: msg_send", __func__); |
fatal("%s: msg_send", __func__); |