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

Collapse All | Expand All

(-)openssh-3.5p1/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.5p1/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.5p1/ssh.c.ORIG (-1 / +1 lines)
Lines 616-622 Link Here
616
	/* Open a connection to the remote host. */
616
	/* Open a connection to the remote host. */
617
617
618
	if (ssh_connect(host, &hostaddr, options.port, IPv4or6,
618
	if (ssh_connect(host, &hostaddr, options.port, IPv4or6,
619
	    options.connection_attempts,
619
	    options.connection_attempts, options.connection_timeout,
620
#ifdef HAVE_CYGWIN
620
#ifdef HAVE_CYGWIN
621
	    options.use_privileged_port,
621
	    options.use_privileged_port,
622
#else
622
#else
(-)openssh-3.5p1/ssh_config.0.ORIG (+7 lines)
Lines 112-117 Link Here
112
             exiting.  The argument must be an integer.  This may be useful in
112
             exiting.  The argument must be an integer.  This may be useful in
113
             scripts if the connection sometimes fails.  The default is 1.
113
             scripts if the connection sometimes fails.  The default is 1.
114
114
115
     ConnectTimeout
116
             Specifies the timeout used when connecting to the ssh server,
117
             instead of using default system values. This value is used only 
118
             when the target is down or really unreachable, not when it refuses
119
             the connection. This may be usefull for tools using ssh for
120
             communication, as it avoid long TCP timeouts.
121
115
     DynamicForward
122
     DynamicForward
116
             Specifies that a TCP/IP port on the local machine be forwarded
123
             Specifies that a TCP/IP port on the local machine be forwarded
117
             over the secure channel, and the application protocol is then
124
             over the secure channel, and the application protocol is then
(-)openssh-3.5p1/ssh_config.5.ORIG (+6 lines)
Lines 226-231 Link Here
226
The argument must be an integer.
226
The argument must be an integer.
227
This may be useful in scripts if the connection sometimes fails.
227
This may be useful in scripts if the connection sometimes fails.
228
The default is 1.
228
The default is 1.
229
.It Cm ConnectTimeout
230
Specifies the timeout used when connecting to the ssh
231
server, instead of using default system values. This value is used
232
only when the target is down or really unreachable, not when it
233
refuses the connection. This may be usefull for tools using ssh
234
for communication, as it avoid long TCP timeouts.
229
.It Cm DynamicForward
235
.It Cm DynamicForward
230
Specifies that a TCP/IP port on the local machine be forwarded
236
Specifies that a TCP/IP port on the local machine be forwarded
231
over the secure channel, and the application
237
over the secure channel, and the application
(-)openssh-3.5p1/sshconnect.c.ORIG (-2 / +58 lines)
Lines 212-217 Link Here
212
	return sock;
212
	return sock;
213
}
213
}
214
214
215
int
216
timeout_connect(int sockfd, const struct sockaddr *serv_addr,
217
	socklen_t addrlen, int timeout)
218
{
219
	fd_set *fdset;
220
	struct timeval tv;
221
	socklen_t optlen;
222
	int fdsetsz, optval, rc;
223
224
	if (timeout <= 0)
225
		return(connect(sockfd, serv_addr, addrlen));
226
227
	if (fcntl(sockfd, F_SETFL, O_NONBLOCK) < 0)
228
		return -1;
229
230
	rc = connect(sockfd, serv_addr, addrlen);
231
	if (rc == 0)
232
		return 0;
233
	if (errno != EINPROGRESS)
234
		return -1;
235
236
	fdsetsz = howmany(sockfd+1, NFDBITS) * sizeof(fd_mask);
237
	fdset = (fd_set *)xmalloc(fdsetsz);
238
	memset(fdset, 0, fdsetsz);
239
	FD_SET(sockfd, fdset);
240
	tv.tv_sec = timeout;
241
	tv.tv_usec = 0;
242
	rc=select(sockfd+1, NULL, fdset, NULL, &tv);
243
244
	switch(rc) {
245
	case 0:
246
		errno = ETIMEDOUT;
247
	case -1:
248
		return -1;
249
		break;
250
	case 1:
251
		optval = 0;
252
		optlen = sizeof(optval);
253
		if (getsockopt(sockfd, SOL_SOCKET, SO_ERROR, &optval, &optlen) == -1)
254
			return -1;
255
		if (optval != 0)
256
		{
257
			errno = optval;
258
			return -1;
259
		}
260
		return 0;
261
262
	default:
263
		/* Should not occur */
264
		return -1;
265
		break;
266
	}
267
	return -1;
268
}
269
215
/*
270
/*
216
 * Opens a TCP/IP connection to the remote server on the given host.
271
 * Opens a TCP/IP connection to the remote server on the given host.
217
 * The address of the remote host will be returned in hostaddr.
272
 * The address of the remote host will be returned in hostaddr.
Lines 231-237 Link Here
231
 */
286
 */
232
int
287
int
233
ssh_connect(const char *host, struct sockaddr_storage * hostaddr,
288
ssh_connect(const char *host, struct sockaddr_storage * hostaddr,
234
    u_short port, int family, int connection_attempts,
289
    u_short port, int family, int connection_attempts, int connection_timeout,
235
    int needpriv, const char *proxy_command)
290
    int needpriv, const char *proxy_command)
236
{
291
{
237
	int gaierr;
292
	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.5p1/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