summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.bin/ssh/packet.c15
-rw-r--r--usr.bin/ssh/packet.h4
-rw-r--r--usr.bin/ssh/session.c9
-rw-r--r--usr.bin/ssh/ssh.c10
-rw-r--r--usr.bin/ssh/sshconnect.c17
-rw-r--r--usr.bin/ssh/sshd.c8
6 files changed, 38 insertions, 25 deletions
diff --git a/usr.bin/ssh/packet.c b/usr.bin/ssh/packet.c
index 1f81591f072..f457fc12aef 100644
--- a/usr.bin/ssh/packet.c
+++ b/usr.bin/ssh/packet.c
@@ -37,7 +37,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: packet.c,v 1.42 2001/01/09 21:19:50 markus Exp $");
+RCSID("$OpenBSD: packet.c,v 1.43 2001/01/13 18:32:50 markus Exp $");
#include "xmalloc.h"
#include "buffer.h"
@@ -1230,9 +1230,12 @@ packet_not_very_much_data_to_write()
/* Informs that the current session is interactive. Sets IP flags for that. */
void
-packet_set_interactive(int interactive, int keepalives)
+packet_set_interactive(int interactive)
{
- int on = 1;
+ static int called = 0;
+ if (called)
+ return;
+ called = 1;
/* Record that we are in interactive mode. */
interactive_mode = interactive;
@@ -1240,12 +1243,6 @@ packet_set_interactive(int interactive, int keepalives)
/* Only set socket options if using a socket. */
if (!packet_connection_is_on_socket())
return;
- if (keepalives) {
- /* Set keepalives if requested. */
- if (setsockopt(connection_in, SOL_SOCKET, SO_KEEPALIVE, (void *) &on,
- sizeof(on)) < 0)
- error("setsockopt SO_KEEPALIVE: %.100s", strerror(errno));
- }
/*
* IPTOS_LOWDELAY and IPTOS_THROUGHPUT are IPv4 only
*/
diff --git a/usr.bin/ssh/packet.h b/usr.bin/ssh/packet.h
index 597fbb1514b..00f0c377822 100644
--- a/usr.bin/ssh/packet.h
+++ b/usr.bin/ssh/packet.h
@@ -11,7 +11,7 @@
* called by a name other than "ssh" or "Secure Shell".
*/
-/* RCSID("$OpenBSD: packet.h,v 1.18 2000/12/19 23:17:57 markus Exp $"); */
+/* RCSID("$OpenBSD: packet.h,v 1.19 2001/01/13 18:32:50 markus Exp $"); */
#ifndef PACKET_H
#define PACKET_H
@@ -65,7 +65,7 @@ void packet_start_compression(int level);
* Informs that the current session is interactive. Sets IP flags for
* optimal performance in interactive use.
*/
-void packet_set_interactive(int interactive, int keepalives);
+void packet_set_interactive(int interactive);
/* Returns true if the current connection is interactive. */
int packet_is_interactive(void);
diff --git a/usr.bin/ssh/session.c b/usr.bin/ssh/session.c
index 48028a6f662..ec250f519b1 100644
--- a/usr.bin/ssh/session.c
+++ b/usr.bin/ssh/session.c
@@ -33,7 +33,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: session.c,v 1.46 2001/01/04 22:41:03 markus Exp $");
+RCSID("$OpenBSD: session.c,v 1.47 2001/01/13 18:32:50 markus Exp $");
#include "xmalloc.h"
#include "ssh.h"
@@ -364,10 +364,6 @@ do_authenticated(struct passwd * pw)
case SSH_CMSG_EXEC_SHELL:
case SSH_CMSG_EXEC_CMD:
- /* Set interactive/non-interactive mode. */
- packet_set_interactive(have_pty || s->display != NULL,
- options.keepalives);
-
if (type == SSH_CMSG_EXEC_CMD) {
command = packet_get_string(&dlen);
debug("Exec command '%.500s'", command);
@@ -497,6 +493,8 @@ do_exec_no_pty(Session *s, const char *command, struct passwd * pw)
if (pid < 0)
packet_disconnect("fork failed: %.100s", strerror(errno));
s->pid = pid;
+ /* Set interactive/non-interactive mode. */
+ packet_set_interactive(s->display);
#ifdef USE_PIPES
/* We are the parent. Close the child sides of the pipes. */
close(pin[0]);
@@ -603,6 +601,7 @@ do_exec_pty(Session *s, const char *command, struct passwd * pw)
s->ptymaster = ptymaster;
/* Enter interactive session. */
+ packet_set_interactive(1);
if (compat20) {
session_set_fds(s, ptyfd, fdout, -1);
} else {
diff --git a/usr.bin/ssh/ssh.c b/usr.bin/ssh/ssh.c
index 44734d53ec8..41af8bedf9d 100644
--- a/usr.bin/ssh/ssh.c
+++ b/usr.bin/ssh/ssh.c
@@ -39,7 +39,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: ssh.c,v 1.79 2000/12/27 11:51:54 markus Exp $");
+RCSID("$OpenBSD: ssh.c,v 1.80 2001/01/13 18:32:50 markus Exp $");
#include <openssl/evp.h>
#include <openssl/dsa.h>
@@ -841,8 +841,7 @@ ssh_session(void)
}
}
/* Tell the packet module whether this is an interactive session. */
- packet_set_interactive(interactive, options.keepalives);
-
+ packet_set_interactive(interactive);
/* Request authentication agent forwarding if appropriate. */
check_agent_present();
@@ -896,6 +895,8 @@ void
ssh_session2_callback(int id, void *arg)
{
int len;
+ int interactive = 0;
+
debug("client_init id %d arg %d", id, (int)arg);
if (no_shell_flag)
@@ -919,6 +920,7 @@ ssh_session2_callback(int id, void *arg)
packet_put_int(ws.ws_ypixel);
packet_put_cstring(""); /* XXX: encode terminal modes */
packet_send();
+ interactive = 1;
/* XXX wait for reply */
}
if (options.forward_x11 &&
@@ -929,6 +931,7 @@ ssh_session2_callback(int id, void *arg)
/* Request forwarding with authentication spoofing. */
debug("Requesting X11 forwarding with authentication spoofing.");
x11_request_forwarding_with_spoofing(id, proto, data);
+ interactive = 1;
/* XXX wait for reply */
}
@@ -953,6 +956,7 @@ ssh_session2_callback(int id, void *arg)
/* channel_callback(id, SSH2_MSG_OPEN_CONFIGMATION, client_init, 0); */
done:
/* register different callback, etc. XXX */
+ packet_set_interactive(interactive);
client_set_session_ident(id);
}
diff --git a/usr.bin/ssh/sshconnect.c b/usr.bin/ssh/sshconnect.c
index e4c8c92697e..8d24f8852cc 100644
--- a/usr.bin/ssh/sshconnect.c
+++ b/usr.bin/ssh/sshconnect.c
@@ -13,7 +13,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: sshconnect.c,v 1.89 2001/01/04 22:41:03 markus Exp $");
+RCSID("$OpenBSD: sshconnect.c,v 1.90 2001/01/13 18:32:50 markus Exp $");
#include <openssl/bn.h>
#include <openssl/dsa.h>
@@ -187,12 +187,13 @@ ssh_connect(const char *host, struct sockaddr_storage * hostaddr,
int anonymous, uid_t original_real_uid,
const char *proxy_command)
{
+ int gaierr;
+ int on = 1;
int sock = -1, attempt;
- struct servent *sp;
- struct addrinfo hints, *ai, *aitop;
char ntop[NI_MAXHOST], strport[NI_MAXSERV];
- int gaierr;
+ struct addrinfo hints, *ai, *aitop;
struct linger linger;
+ struct servent *sp;
debug("ssh_connect: getuid %u geteuid %u anon %d",
(u_int) getuid(), (u_int) geteuid(), anonymous);
@@ -294,7 +295,13 @@ ssh_connect(const char *host, struct sockaddr_storage * hostaddr,
/* setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void *)&on, sizeof(on)); */
linger.l_onoff = 1;
linger.l_linger = 5;
- setsockopt(sock, SOL_SOCKET, SO_LINGER, (void *) &linger, sizeof(linger));
+ setsockopt(sock, SOL_SOCKET, SO_LINGER, (void *)&linger, sizeof(linger));
+
+ /* Set keepalives if requested. */
+ if (options.keepalives &&
+ setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, (void *)&on,
+ sizeof(on)) < 0)
+ error("setsockopt SO_KEEPALIVE: %.100s", strerror(errno));
/* Set the connection. */
packet_set_connection(sock, sock);
diff --git a/usr.bin/ssh/sshd.c b/usr.bin/ssh/sshd.c
index 03c4adde6f8..c21fec64849 100644
--- a/usr.bin/ssh/sshd.c
+++ b/usr.bin/ssh/sshd.c
@@ -40,7 +40,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: sshd.c,v 1.149 2001/01/13 18:03:07 markus Exp $");
+RCSID("$OpenBSD: sshd.c,v 1.150 2001/01/13 18:32:51 markus Exp $");
#include "xmalloc.h"
#include "rsa.h"
@@ -1061,6 +1061,12 @@ main(int ac, char **av)
linger.l_linger = 5;
setsockopt(sock_in, SOL_SOCKET, SO_LINGER, (void *) &linger, sizeof(linger));
+ /* Set keepalives if requested. */
+ if (options.keepalives &&
+ setsockopt(sock_in, SOL_SOCKET, SO_KEEPALIVE, (void *)&on,
+ sizeof(on)) < 0)
+ error("setsockopt SO_KEEPALIVE: %.100s", strerror(errno));
+
/*
* Register our connection. This turns encryption off because we do
* not have a key.