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

Collapse All | Expand All

(-)roaming_client.c (-1 / +1 lines)
Lines 256-262 wait_for_roaming_reconnect(void) Link Here
256
		if (c != '\n' && c != '\r')
256
		if (c != '\n' && c != '\r')
257
			continue;
257
			continue;
258
258
259
		if (ssh_connect(host, &hostaddr, options.port,
259
		if (ssh_connect(&host, &hostaddr, options.port,
260
		    options.address_family, 1, &timeout_ms,
260
		    options.address_family, 1, &timeout_ms,
261
		    options.tcp_keep_alive, options.use_privileged_port,
261
		    options.tcp_keep_alive, options.use_privileged_port,
262
		    options.proxy_command) == 0 && roaming_resume() == 0) {
262
		    options.proxy_command) == 0 && roaming_resume() == 0) {
(-)ssh.c (-2 / +3 lines)
Lines 645-651 main(int ac, char **av) Link Here
645
	 * file if the user specifies a config file on the command line.
645
	 * file if the user specifies a config file on the command line.
646
	 */
646
	 */
647
	if (config != NULL) {
647
	if (config != NULL) {
648
		if (!read_config_file(config, host, &options, SSHCONF_USERCONF))
648
		if (strcasecmp(config, "none") != 0 &&
649
		    !read_config_file(config, host, &options, SSHCONF_USERCONF))
649
			fatal("Can't open user config file %.100s: "
650
			fatal("Can't open user config file %.100s: "
650
			    "%.100s", config, strerror(errno));
651
			    "%.100s", config, strerror(errno));
651
	} else {
652
	} else {
Lines 757-763 main(int ac, char **av) Link Here
757
	timeout_ms = options.connection_timeout * 1000;
758
	timeout_ms = options.connection_timeout * 1000;
758
759
759
	/* Open a connection to the remote host. */
760
	/* Open a connection to the remote host. */
760
	if (ssh_connect(host, &hostaddr, options.port,
761
	if (ssh_connect(&host, &hostaddr, options.port,
761
	    options.address_family, options.connection_attempts, &timeout_ms,
762
	    options.address_family, options.connection_attempts, &timeout_ms,
762
	    options.tcp_keep_alive, 
763
	    options.tcp_keep_alive, 
763
	    original_effective_uid == 0 && options.use_privileged_port,
764
	    original_effective_uid == 0 && options.use_privileged_port,
(-)sshconnect.c (-7 / +23 lines)
Lines 331-345 timeout_connect(int sockfd, const struct Link Here
331
 * the daemon.
331
 * the daemon.
332
 */
332
 */
333
int
333
int
334
ssh_connect(const char *host, struct sockaddr_storage * hostaddr,
334
ssh_connect(char **hostp, struct sockaddr_storage *hostaddr,
335
    u_short port, int family, int connection_attempts, int *timeout_ms,
335
    u_short port, int family, int connection_attempts, int *timeout_ms,
336
    int want_keepalive, int needpriv, const char *proxy_command)
336
    int want_keepalive, int needpriv, const char *proxy_command)
337
{
337
{
338
	int gaierr;
338
	int gaierr;
339
	int on = 1;
339
	int on = 1;
340
	int sock = -1, attempt;
340
	int sock = -1, attempt, replace_host = 0;
341
	char ntop[NI_MAXHOST], strport[NI_MAXSERV];
341
	char ntop[NI_MAXHOST], strport[NI_MAXSERV];
342
	struct addrinfo hints, *ai, *aitop;
342
	struct addrinfo hints, *ai, *aitop;
343
	const char *host = *hostp;
343
344
344
	debug2("ssh_connect: needpriv %d", needpriv);
345
	debug2("ssh_connect: needpriv %d", needpriv);
345
346
Lines 349-361 ssh_connect(const char *host, struct soc Link Here
349
350
350
	/* No proxy command. */
351
	/* No proxy command. */
351
352
353
	/* Try numeric address first */
352
	memset(&hints, 0, sizeof(hints));
354
	memset(&hints, 0, sizeof(hints));
353
	hints.ai_family = family;
355
	hints.ai_family = family;
354
	hints.ai_socktype = SOCK_STREAM;
356
	hints.ai_socktype = SOCK_STREAM;
357
	hints.ai_flags = AI_NUMERICHOST|AI_NUMERICSERV;
355
	snprintf(strport, sizeof strport, "%u", port);
358
	snprintf(strport, sizeof strport, "%u", port);
356
	if ((gaierr = getaddrinfo(host, strport, &hints, &aitop)) != 0)
359
	if ((gaierr = getaddrinfo(host, strport, &hints, &aitop)) == 0) {
357
		fatal("%s: Could not resolve hostname %.100s: %s", __progname,
360
		/* Hostname was numeric. arrange to use it later */
358
		    host, ssh_gai_strerror(gaierr));
361
		replace_host = 1;
362
	} else {
363
		debug3("%s: could not parse hostname %.100s as numeric: %s",
364
		    __func__, host, ssh_gai_strerror(gaierr));
365
		memset(&hints, 0, sizeof(hints));
366
		hints.ai_family = family;
367
		hints.ai_socktype = SOCK_STREAM;
368
		snprintf(strport, sizeof strport, "%u", port);
369
		if ((gaierr = getaddrinfo(host, strport, &hints, &aitop)) != 0)
370
			fatal("%s: Could not resolve hostname %.100s: %s",
371
			    __progname, host, ssh_gai_strerror(gaierr));
372
	}
359
373
360
	for (attempt = 0; attempt < connection_attempts; attempt++) {
374
	for (attempt = 0; attempt < connection_attempts; attempt++) {
361
		if (attempt > 0) {
375
		if (attempt > 0) {
Lines 400-406 ssh_connect(const char *host, struct soc Link Here
400
		if (sock != -1)
414
		if (sock != -1)
401
			break;	/* Successful connection. */
415
			break;	/* Successful connection. */
402
	}
416
	}
403
404
	freeaddrinfo(aitop);
417
	freeaddrinfo(aitop);
405
418
406
	/* Return failure if we didn't get a successful connection. */
419
	/* Return failure if we didn't get a successful connection. */
Lines 410-415 ssh_connect(const char *host, struct soc Link Here
410
		return (-1);
423
		return (-1);
411
	}
424
	}
412
425
426
	if (replace_host)
427
		*hostp = xstrdup(ntop);
428
413
	debug("Connection established.");
429
	debug("Connection established.");
414
430
415
	/* Set SO_KEEPALIVE if requested. */
431
	/* Set SO_KEEPALIVE if requested. */
Lines 744-750 check_host_key(char *hostname, struct so Link Here
744
		load_hostkeys(host_hostkeys, host, system_hostfiles[i]);
760
		load_hostkeys(host_hostkeys, host, system_hostfiles[i]);
745
761
746
	ip_hostkeys = NULL;
762
	ip_hostkeys = NULL;
747
	if (!want_cert && options.check_host_ip) {
763
	if (options.check_host_ip) {
748
		ip_hostkeys = init_hostkeys();
764
		ip_hostkeys = init_hostkeys();
749
		for (i = 0; i < num_user_hostfiles; i++)
765
		for (i = 0; i < num_user_hostfiles; i++)
750
			load_hostkeys(ip_hostkeys, ip, user_hostfiles[i]);
766
			load_hostkeys(ip_hostkeys, ip, user_hostfiles[i]);
(-)sshconnect.h (-1 / +1 lines)
Lines 32-38 struct Sensitive { Link Here
32
};
32
};
33
33
34
int
34
int
35
ssh_connect(const char *, struct sockaddr_storage *, u_short, int, int,
35
ssh_connect(char **, struct sockaddr_storage *, u_short, int, int,
36
    int *, int, int, const char *);
36
    int *, int, int, const char *);
37
void	 ssh_kill_proxy_command(void);
37
void	 ssh_kill_proxy_command(void);
38
38

Return to bug 2074