Rewrite strerror to ssh_strerror
Signed-off-by: Norbert Pocs <npocs@redhat.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Этот коммит содержится в:
родитель
0dce42c8fd
Коммит
d92e389a80
16
src/bind.c
16
src/bind.c
@ -79,6 +79,7 @@ static socket_t bind_socket(ssh_bind sshbind, const char *hostname,
|
||||
int opt = 1;
|
||||
socket_t s;
|
||||
int rc;
|
||||
char err_msg[SSH_ERRNO_MSG_MAX] = {0};
|
||||
|
||||
ZERO_STRUCT(hints);
|
||||
|
||||
@ -98,7 +99,8 @@ static socket_t bind_socket(ssh_bind sshbind, const char *hostname,
|
||||
ai->ai_socktype,
|
||||
ai->ai_protocol);
|
||||
if (s == SSH_INVALID_SOCKET) {
|
||||
ssh_set_error(sshbind, SSH_FATAL, "%s", strerror(errno));
|
||||
ssh_set_error(sshbind, SSH_FATAL, "%s",
|
||||
ssh_strerror(errno, err_msg, SSH_ERRNO_MSG_MAX));
|
||||
freeaddrinfo (ai);
|
||||
return -1;
|
||||
}
|
||||
@ -108,7 +110,7 @@ static socket_t bind_socket(ssh_bind sshbind, const char *hostname,
|
||||
ssh_set_error(sshbind,
|
||||
SSH_FATAL,
|
||||
"Setting socket options failed: %s",
|
||||
strerror(errno));
|
||||
ssh_strerror(errno, err_msg, SSH_ERRNO_MSG_MAX));
|
||||
freeaddrinfo (ai);
|
||||
CLOSE_SOCKET(s);
|
||||
return -1;
|
||||
@ -120,7 +122,7 @@ static socket_t bind_socket(ssh_bind sshbind, const char *hostname,
|
||||
"Binding to %s:%d: %s",
|
||||
hostname,
|
||||
port,
|
||||
strerror(errno));
|
||||
ssh_strerror(errno, err_msg, SSH_ERRNO_MSG_MAX));
|
||||
freeaddrinfo (ai);
|
||||
CLOSE_SOCKET(s);
|
||||
return -1;
|
||||
@ -280,9 +282,10 @@ int ssh_bind_listen(ssh_bind sshbind) {
|
||||
}
|
||||
|
||||
if (listen(fd, 10) < 0) {
|
||||
char err_msg[] = {0};
|
||||
ssh_set_error(sshbind, SSH_FATAL,
|
||||
"Listening to socket %d: %s",
|
||||
fd, strerror(errno));
|
||||
fd, ssh_strerror(errno, err_msg, SSH_ERRNO_MSG_MAX));
|
||||
CLOSE_SOCKET(fd);
|
||||
ssh_key_free(sshbind->dsa);
|
||||
sshbind->dsa = NULL;
|
||||
@ -586,14 +589,15 @@ int ssh_bind_accept(ssh_bind sshbind, ssh_session session)
|
||||
|
||||
fd = accept(sshbind->bindfd, NULL, NULL);
|
||||
if (fd == SSH_INVALID_SOCKET) {
|
||||
char err_msg[SSH_ERRNO_MSG_MAX] = {0};
|
||||
if (errno == EINTR) {
|
||||
ssh_set_error(sshbind, SSH_EINTR,
|
||||
"Accepting a new connection (child signal error): %s",
|
||||
strerror(errno));
|
||||
ssh_strerror(errno, err_msg, SSH_ERRNO_MSG_MAX));
|
||||
} else {
|
||||
ssh_set_error(sshbind, SSH_FATAL,
|
||||
"Accepting a new connection: %s",
|
||||
strerror(errno));
|
||||
ssh_strerror(errno, err_msg, SSH_ERRNO_MSG_MAX));
|
||||
}
|
||||
return SSH_ERROR;
|
||||
}
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user