version 1.74, 2001/04/17 19:34:25 |
version 1.74.2.1, 2001/06/12 22:31:48 |
|
|
extern int startup_pipe; |
extern int startup_pipe; |
extern void destroy_sensitive_data(void); |
extern void destroy_sensitive_data(void); |
|
|
/* Local Xauthority file. */ |
|
static char *xauthfile; |
|
|
|
/* original command from peer. */ |
/* original command from peer. */ |
char *original_command = NULL; |
char *original_command = NULL; |
|
|
|
|
do_authenticated2(authctxt); |
do_authenticated2(authctxt); |
else |
else |
do_authenticated1(authctxt); |
do_authenticated1(authctxt); |
} |
|
|
|
/* |
/* remove agent socket */ |
* Remove local Xauthority file. |
if (auth_get_socket_name()) |
*/ |
auth_sock_cleanup_proc(authctxt->pw); |
void |
|
xauthfile_cleanup_proc(void *ignore) |
|
{ |
|
debug("xauthfile_cleanup_proc called"); |
|
|
|
if (xauthfile != NULL) { |
|
char *p; |
|
unlink(xauthfile); |
|
p = strrchr(xauthfile, '/'); |
|
if (p != NULL) { |
|
*p = '\0'; |
|
rmdir(xauthfile); |
|
} |
|
xfree(xauthfile); |
|
xauthfile = NULL; |
|
} |
|
} |
} |
|
|
/* |
/* |
|
|
{ |
{ |
Session *s; |
Session *s; |
char *command; |
char *command; |
int success, type, fd, n_bytes, plen, screen_flag, have_pty = 0; |
int success, type, n_bytes, plen, screen_flag, have_pty = 0; |
int compression_level = 0, enable_compression_after_reply = 0; |
int compression_level = 0, enable_compression_after_reply = 0; |
u_int proto_len, data_len, dlen; |
u_int proto_len, data_len, dlen; |
|
|
|
|
if (s->display == NULL) |
if (s->display == NULL) |
break; |
break; |
|
|
/* Setup to always have a local .Xauthority. */ |
|
xauthfile = xmalloc(MAXPATHLEN); |
|
strlcpy(xauthfile, "/tmp/ssh-XXXXXXXX", MAXPATHLEN); |
|
temporarily_use_uid(s->pw); |
|
if (mkdtemp(xauthfile) == NULL) { |
|
restore_uid(); |
|
error("private X11 dir: mkdtemp %s failed: %s", |
|
xauthfile, strerror(errno)); |
|
xfree(xauthfile); |
|
xauthfile = NULL; |
|
/* XXXX remove listening channels */ |
|
break; |
|
} |
|
strlcat(xauthfile, "/cookies", MAXPATHLEN); |
|
fd = open(xauthfile, O_RDWR|O_CREAT|O_EXCL, 0600); |
|
if (fd >= 0) |
|
close(fd); |
|
restore_uid(); |
|
fatal_add_cleanup(xauthfile_cleanup_proc, NULL); |
|
success = 1; |
success = 1; |
break; |
break; |
|
|
|
|
|
|
if (command != NULL) |
if (command != NULL) |
xfree(command); |
xfree(command); |
/* Cleanup user's local Xauthority file. */ |
|
if (xauthfile) |
|
xauthfile_cleanup_proc(NULL); |
|
return; |
return; |
|
|
default: |
default: |
|
|
} |
} |
#endif /* KRB4 */ |
#endif /* KRB4 */ |
|
|
if (xauthfile) |
|
child_set_env(&env, &envsize, "XAUTHORITY", xauthfile); |
|
if (auth_get_socket_name() != NULL) |
if (auth_get_socket_name() != NULL) |
child_set_env(&env, &envsize, SSH_AUTHSOCKET_ENV_NAME, |
child_set_env(&env, &envsize, SSH_AUTHSOCKET_ENV_NAME, |
auth_get_socket_name()); |
auth_get_socket_name()); |
|
|
int |
int |
session_x11_req(Session *s) |
session_x11_req(Session *s) |
{ |
{ |
int fd; |
|
if (no_x11_forwarding_flag) { |
if (no_x11_forwarding_flag) { |
debug("X11 forwarding disabled in user configuration file."); |
debug("X11 forwarding disabled in user configuration file."); |
return 0; |
return 0; |
|
|
debug("X11 forwarding disabled in server configuration file."); |
debug("X11 forwarding disabled in server configuration file."); |
return 0; |
return 0; |
} |
} |
if (xauthfile != NULL) { |
|
debug("X11 fwd already started."); |
|
return 0; |
|
} |
|
|
|
debug("Received request for X11 forwarding with auth spoofing."); |
debug("Received request for X11 forwarding with auth spoofing."); |
if (s->display != NULL) |
if (s->display != NULL) |
packet_disconnect("Protocol error: X11 display already set."); |
packet_disconnect("Protocol error: X11 display already set."); |
|
|
xfree(s->auth_data); |
xfree(s->auth_data); |
return 0; |
return 0; |
} |
} |
xauthfile = xmalloc(MAXPATHLEN); |
|
strlcpy(xauthfile, "/tmp/ssh-XXXXXXXX", MAXPATHLEN); |
|
temporarily_use_uid(s->pw); |
|
if (mkdtemp(xauthfile) == NULL) { |
|
restore_uid(); |
|
error("private X11 dir: mkdtemp %s failed: %s", |
|
xauthfile, strerror(errno)); |
|
xfree(xauthfile); |
|
xauthfile = NULL; |
|
xfree(s->auth_proto); |
|
xfree(s->auth_data); |
|
/* XXXX remove listening channels */ |
|
return 0; |
|
} |
|
strlcat(xauthfile, "/cookies", MAXPATHLEN); |
|
fd = open(xauthfile, O_RDWR|O_CREAT|O_EXCL, 0600); |
|
if (fd >= 0) |
|
close(fd); |
|
restore_uid(); |
|
fatal_add_cleanup(xauthfile_cleanup_proc, s); |
|
return 1; |
return 1; |
} |
} |
|
|
|
|
{ |
{ |
|
|
server_loop2(); |
server_loop2(); |
if (xauthfile) |
|
xauthfile_cleanup_proc(NULL); |
|
} |
} |