View | Details | Raw Unified | Return to bug 207 | Differences between
and this patch

Collapse All | Expand All

(-)openssh-3.4p1/readconf.c.ORIG (-1 / +15 lines)
Lines 114-120 Link Here
114
	oDynamicForward, oPreferredAuthentications, oHostbasedAuthentication,
114
	oDynamicForward, oPreferredAuthentications, oHostbasedAuthentication,
115
	oHostKeyAlgorithms, oBindAddress, oSmartcardDevice,
115
	oHostKeyAlgorithms, oBindAddress, oSmartcardDevice,
116
	oClearAllForwardings, oNoHostAuthenticationForLocalhost,
116
	oClearAllForwardings, oNoHostAuthenticationForLocalhost,
117
	oDeprecated
117
	oConnectTimeout, oDeprecated
118
} OpCodes;
118
} OpCodes;
119
119
120
/* Textual representations of the tokens. */
120
/* Textual representations of the tokens. */
Lines 186-191 Link Here
186
	{ "smartcarddevice", oSmartcardDevice },
186
	{ "smartcarddevice", oSmartcardDevice },
187
	{ "clearallforwardings", oClearAllForwardings },
187
	{ "clearallforwardings", oClearAllForwardings },
188
	{ "nohostauthenticationforlocalhost", oNoHostAuthenticationForLocalhost },
188
	{ "nohostauthenticationforlocalhost", oNoHostAuthenticationForLocalhost },
189
	{ "connecttimeout", oConnectTimeout },
189
	{ NULL, oBadOption }
190
	{ NULL, oBadOption }
190
};
191
};
191
192
Lines 293-298 Link Here
293
		/* don't panic, but count bad options */
294
		/* don't panic, but count bad options */
294
		return -1;
295
		return -1;
295
		/* NOTREACHED */
296
		/* NOTREACHED */
297
	case oConnectTimeout:
298
		intptr = &options->connection_timeout;
299
parse_time:
300
		arg = strdelim(&s);
301
		if (!arg || *arg == '\0')
302
			fatal("%.200s line %d: Missing time argument.", filename, linenum);
303
		if ((value = convtime(arg)) == -1)
304
			fatal("%.200s line %d: Invalid time argument.", filename, linenum);
305
		if (*intptr == -1)
306
			*intptr = value;
307
		break;
308
296
	case oForwardAgent:
309
	case oForwardAgent:
297
		intptr = &options->forward_agent;
310
		intptr = &options->forward_agent;
298
parse_flag:
311
parse_flag:
Lines 769-774 Link Here
769
	options->compression_level = -1;
782
	options->compression_level = -1;
770
	options->port = -1;
783
	options->port = -1;
771
	options->connection_attempts = -1;
784
	options->connection_attempts = -1;
785
	options->connection_timeout = -1;
772
	options->number_of_password_prompts = -1;
786
	options->number_of_password_prompts = -1;
773
	options->cipher = -1;
787
	options->cipher = -1;
774
	options->ciphers = NULL;
788
	options->ciphers = NULL;
(-)openssh-3.4p1/readconf.h.ORIG (+2 lines)
Lines 66-71 Link Here
66
	int     port;		/* Port to connect. */
66
	int     port;		/* Port to connect. */
67
	int     connection_attempts;	/* Max attempts (seconds) before
67
	int     connection_attempts;	/* Max attempts (seconds) before
68
					 * giving up */
68
					 * giving up */
69
	int     connection_timeout;	/* Max time (seconds) before
70
				 	 * aborting connection attempt */
69
	int     number_of_password_prompts;	/* Max number of password
71
	int     number_of_password_prompts;	/* Max number of password
70
						 * prompts. */
72
						 * prompts. */
71
	int     cipher;		/* Cipher to use. */
73
	int     cipher;		/* Cipher to use. */
(-)openssh-3.4p1/ssh.c.ORIG (-1 / +1 lines)
Lines 614-620 Link Here
614
	/* Open a connection to the remote host. */
614
	/* Open a connection to the remote host. */
615
615
616
	if (ssh_connect(host, &hostaddr, options.port, IPv4or6,
616
	if (ssh_connect(host, &hostaddr, options.port, IPv4or6,
617
	    options.connection_attempts,
617
	    options.connection_attempts, options.connection_timeout,
618
#ifdef HAVE_CYGWIN
618
#ifdef HAVE_CYGWIN
619
	    options.use_privileged_port,
619
	    options.use_privileged_port,
620
#else
620
#else
(-)openssh-3.4p1/ssh_config.0.ORIG (+7 lines)
Lines 111-116 Link Here
111
             exiting.  The argument must be an integer.  This may be useful in
111
             exiting.  The argument must be an integer.  This may be useful in
112
             scripts if the connection sometimes fails.  The default is 1.
112
             scripts if the connection sometimes fails.  The default is 1.
113
113
114
     ConnectTimeout
115
             Specifies the timeout used when connecting to the ssh server,
116
             instead of using default system values. This value is used only 
117
             when the target is down or really unreachable, not when it refuses
118
             the connection. This may be usefull for tools using ssh for
119
             communication, as it avoid long TCP timeouts.
120
114
     DynamicForward
121
     DynamicForward
115
             Specifies that a TCP/IP port on the local machine be forwarded
122
             Specifies that a TCP/IP port on the local machine be forwarded
116
             over the secure channel, and the application protocol is then
123
             over the secure channel, and the application protocol is then
(-)openssh-3.4p1/ssh_config.5.ORIG (+6 lines)
Lines 220-225 Link Here
220
The argument must be an integer.
220
The argument must be an integer.
221
This may be useful in scripts if the connection sometimes fails.
221
This may be useful in scripts if the connection sometimes fails.
222
The default is 1.
222
The default is 1.
223
.It Cm ConnectTimeout
224
Specifies the timeout used when connecting to the ssh
225
server, instead of using default system values. This value is used
226
only when the target is down or really unreachable, not when it
227
refuses the connection. This may be usefull for tools using ssh
228
for communication, as it avoid long TCP timeouts.
223
.It Cm DynamicForward
229
.It Cm DynamicForward
224
Specifies that a TCP/IP port on the local machine be forwarded
230
Specifies that a TCP/IP port on the local machine be forwarded
225
over the secure channel, and the application
231
over the secure channel, and the application
(-)openssh-3.4p1/sshconnect.c.ORIG (-2 / +58 lines)
Lines 211-216 Link Here
211
	return sock;
211
	return sock;
212
}
212
}
213
213
214
int
215
timeout_connect(int sockfd, const struct sockaddr *serv_addr,
216
	socklen_t addrlen, int timeout)
217
{
218
	fd_set *fdset;
219
	struct timeval tv;
220
	socklen_t optlen;
221
	int fdsetsz, optval, rc;
222
223
	if (timeout <= 0)
224
		return(connect(sockfd, serv_addr, addrlen));
225
226
	if (fcntl(sockfd, F_SETFL, O_NONBLOCK) < 0)
227
		return -1;
228
229
	rc = connect(sockfd, serv_addr, addrlen);
230
	if (rc == 0)
231
		return 0;
232
	if (errno != EINPROGRESS)
233
		return -1;
234
235
	fdsetsz = howmany(sockfd+1, NFDBITS) * sizeof(fd_mask);
236
	fdset = (fd_set *)xmalloc(fdsetsz);
237
	memset(fdset, 0, fdsetsz);
238
	FD_SET(sockfd, fdset);
239
	tv.tv_sec = timeout;
240
	tv.tv_usec = 0;
241
	rc=select(sockfd+1, NULL, fdset, NULL, &tv);
242
243
	switch(rc) {
244
	case 0:
245
		errno = ETIMEDOUT;
246
	case -1:
247
		return -1;
248
		break;
249
	case 1:
250
		optval = 0;
251
		optlen = sizeof(optval);
252
		if (getsockopt(sockfd, SOL_SOCKET, SO_ERROR, &optval, &optlen) == -1)
253
			return -1;
254
		if (optval != 0)
255
		{
256
			errno = optval;
257
			return -1;
258
		}
259
		return 0;
260
261
	default:
262
		/* Should not occur */
263
		return -1;
264
		break;
265
	}
266
	return -1;
267
}
268
214
/*
269
/*
215
 * Opens a TCP/IP connection to the remote server on the given host.
270
 * Opens a TCP/IP connection to the remote server on the given host.
216
 * The address of the remote host will be returned in hostaddr.
271
 * The address of the remote host will be returned in hostaddr.
Lines 230-236 Link Here
230
 */
285
 */
231
int
286
int
232
ssh_connect(const char *host, struct sockaddr_storage * hostaddr,
287
ssh_connect(const char *host, struct sockaddr_storage * hostaddr,
233
    u_short port, int family, int connection_attempts,
288
    u_short port, int family, int connection_attempts, int connection_timeout,
234
    int needpriv, const char *proxy_command)
289
    int needpriv, const char *proxy_command)
235
{
290
{
236
	int gaierr;
291
	int gaierr;
Lines 300-306 Link Here
300
				/* Any error is already output */
355
				/* Any error is already output */
301
				continue;
356
				continue;
302
357
303
			if (connect(sock, ai->ai_addr, ai->ai_addrlen) >= 0) {
358
			if (timeout_connect(sock, ai->ai_addr, ai->ai_addrlen,
359
					connection_timeout) >= 0) {
304
				/* Successful connection. */
360
				/* Successful connection. */
305
				memcpy(hostaddr, ai->ai_addr, ai->ai_addrlen);
361
				memcpy(hostaddr, ai->ai_addr, ai->ai_addrlen);
306
				break;
362
				break;
(-)openssh-3.4p1/sshconnect.h.ORIG (-1 / +1 lines)
Lines 35-41 Link Here
35
35
36
int
36
int
37
ssh_connect(const char *, struct sockaddr_storage *, u_short, int, int,
37
ssh_connect(const char *, struct sockaddr_storage *, u_short, int, int,
38
    int, const char *);
38
    int, int, const char *);
39
39
40
void
40
void
41
ssh_login(Sensitive *, const char *, struct sockaddr *, struct passwd *);
41
ssh_login(Sensitive *, const char *, struct sockaddr *, struct passwd *);

Return to bug 207