mirror of
https://github.com/tmate-io/tmate-ssh-server.git
synced 2020-11-18 19:53:51 -08:00
Sync OpenBSD patchset 477:
There isn't much point in doing lstat before connect so instead just do connect and handle ENOENT from it which is a little tidier.
This commit is contained in:
parent
ee1cc9f415
commit
6b4b4c78cf
24
client.c
24
client.c
@ -1,4 +1,4 @@
|
|||||||
/* $Id: client.c,v 1.82 2009-10-28 23:11:07 tcunha Exp $ */
|
/* $Id: client.c,v 1.83 2009-11-02 21:40:44 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -59,19 +59,6 @@ client_init(char *path, int cmdflags, int flags)
|
|||||||
setproctitle("client (%s)", rpathbuf);
|
setproctitle("client (%s)", rpathbuf);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (lstat(path, &sb) != 0) {
|
|
||||||
if (cmdflags & CMD_STARTSERVER && errno == ENOENT) {
|
|
||||||
if ((fd = server_start(path)) == -1)
|
|
||||||
goto start_failed;
|
|
||||||
goto server_started;
|
|
||||||
}
|
|
||||||
goto not_found;
|
|
||||||
}
|
|
||||||
if (!S_ISSOCK(sb.st_mode)) {
|
|
||||||
errno = ENOTSOCK;
|
|
||||||
goto not_found;
|
|
||||||
}
|
|
||||||
|
|
||||||
memset(&sa, 0, sizeof sa);
|
memset(&sa, 0, sizeof sa);
|
||||||
sa.sun_family = AF_UNIX;
|
sa.sun_family = AF_UNIX;
|
||||||
size = strlcpy(sa.sun_path, path, sizeof sa.sun_path);
|
size = strlcpy(sa.sun_path, path, sizeof sa.sun_path);
|
||||||
@ -84,9 +71,14 @@ client_init(char *path, int cmdflags, int flags)
|
|||||||
fatal("socket failed");
|
fatal("socket failed");
|
||||||
|
|
||||||
if (connect(fd, (struct sockaddr *) &sa, SUN_LEN(&sa)) == -1) {
|
if (connect(fd, (struct sockaddr *) &sa, SUN_LEN(&sa)) == -1) {
|
||||||
if (errno == ECONNREFUSED) {
|
if (!(cmdflags & CMD_STARTSERVER))
|
||||||
if (unlink(path) != 0 || !(cmdflags & CMD_STARTSERVER))
|
goto not_found;
|
||||||
|
switch (errno) {
|
||||||
|
case ECONNREFUSED:
|
||||||
|
if (unlink(path) != 0)
|
||||||
goto not_found;
|
goto not_found;
|
||||||
|
/* FALLTHROUGH */
|
||||||
|
case ENOENT:
|
||||||
if ((fd = server_start(path)) == -1)
|
if ((fd = server_start(path)) == -1)
|
||||||
goto start_failed;
|
goto start_failed;
|
||||||
goto server_started;
|
goto server_started;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user