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

Collapse All | Expand All

(-)openssh-3.6.1p1/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
	oEnableSSHKeysign,
117
	oEnableSSHKeysign, oConnectTimeout,
118
	oDeprecated
118
	oDeprecated
119
} OpCodes;
119
} OpCodes;
120
120
Lines 188-193 Link Here
188
	{ "clearallforwardings", oClearAllForwardings },
188
	{ "clearallforwardings", oClearAllForwardings },
189
	{ "enablesshkeysign", oEnableSSHKeysign },
189
	{ "enablesshkeysign", oEnableSSHKeysign },
190
	{ "nohostauthenticationforlocalhost", oNoHostAuthenticationForLocalhost },
190
	{ "nohostauthenticationforlocalhost", oNoHostAuthenticationForLocalhost },
191
	{ "connecttimeout", oConnectTimeout },
191
	{ NULL, oBadOption }
192
	{ NULL, oBadOption }
192
};
193
};
193
194
Lines 297-302 Link Here
297
		/* don't panic, but count bad options */
298
		/* don't panic, but count bad options */
298
		return -1;
299
		return -1;
299
		/* NOTREACHED */
300
		/* NOTREACHED */
301
	case oConnectTimeout:
302
		intptr = &options->connection_timeout;
303
parse_time:
304
		arg = strdelim(&s);
305
		if (!arg || *arg == '\0')
306
			fatal("%.200s line %d: Missing time argument.", filename, linenum);
307
		if ((value = convtime(arg)) == -1)
308
			fatal("%.200s line %d: Invalid time argument.", filename, linenum);
309
		if (*intptr == -1)
310
			*intptr = value;
311
		break;
312
300
	case oForwardAgent:
313
	case oForwardAgent:
301
		intptr = &options->forward_agent;
314
		intptr = &options->forward_agent;
302
parse_flag:
315
parse_flag:
Lines 770-775 Link Here
770
	options->compression_level = -1;
783
	options->compression_level = -1;
771
	options->port = -1;
784
	options->port = -1;
772
	options->connection_attempts = -1;
785
	options->connection_attempts = -1;
786
	options->connection_timeout = -1;
773
	options->number_of_password_prompts = -1;
787
	options->number_of_password_prompts = -1;
774
	options->cipher = -1;
788
	options->cipher = -1;
775
	options->ciphers = NULL;
789
	options->ciphers = NULL;
(-)openssh-3.6.1p1/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.6.1p1/ssh.c.ORIG (-1 / +1 lines)
Lines 619-625 Link Here
619
	/* Open a connection to the remote host. */
619
	/* Open a connection to the remote host. */
620
620
621
	if (ssh_connect(host, &hostaddr, options.port, IPv4or6,
621
	if (ssh_connect(host, &hostaddr, options.port, IPv4or6,
622
	    options.connection_attempts,
622
	    options.connection_attempts, options.connection_timeout,
623
#ifdef HAVE_CYGWIN
623
#ifdef HAVE_CYGWIN
624
	    options.use_privileged_port,
624
	    options.use_privileged_port,
625
#else
625
#else
(-)openssh-3.6.1p1/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
     ^[[1mConnectTimeout^[[0m
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
     ^[[1mDynamicForward^[[0m
122
     ^[[1mDynamicForward^[[0m
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.6.1p1/ssh_config.5.ORIG (+6 lines)
Lines 227-232 Link Here
227
The argument must be an integer.
227
The argument must be an integer.
228
This may be useful in scripts if the connection sometimes fails.
228
This may be useful in scripts if the connection sometimes fails.
229
The default is 1.
229
The default is 1.
230
.It Cm ConnectTimeout
231
Specifies the timeout used when connecting to the ssh
232
server, instead of using default system values. This value is used
233
only when the target is down or really unreachable, not when it
234
refuses the connection. This may be usefull for tools using ssh
235
for communication, as it avoid long TCP timeouts.
230
.It Cm DynamicForward
236
.It Cm DynamicForward
231
Specifies that a TCP/IP port on the local machine be forwarded
237
Specifies that a TCP/IP port on the local machine be forwarded
232
over the secure channel, and the application
238
over the secure channel, and the application
(-)openssh-3.6.1p1/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.6.1p1/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