mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-15 21:05:08 +00:00
f374ba41f5
Release notes are available at https://www.openssh.com/txt/release-9.2 OpenSSH 9.2 contains fixes for two security problems and a memory safety problem. The memory safety problem is not believed to be exploitable. These fixes have already been committed to OpenSSH 9.1 in FreeBSD. Some other notable items from the release notes: * ssh(1): add a new EnableEscapeCommandline ssh_config(5) option that controls whether the client-side ~C escape sequence that provides a command-line is available. Among other things, the ~C command-line could be used to add additional port-forwards at runtime. * sshd(8): add support for channel inactivity timeouts via a new sshd_config(5) ChannelTimeout directive. This allows channels that have not seen traffic in a configurable interval to be automatically closed. Different timeouts may be applied to session, X11, agent and TCP forwarding channels. * sshd(8): add a sshd_config UnusedConnectionTimeout option to terminate client connections that have no open channels for a length of time. This complements the ChannelTimeout option above. * sshd(8): add a -V (version) option to sshd like the ssh client has. * scp(1), sftp(1): add a -X option to both scp(1) and sftp(1) to allow control over some SFTP protocol parameters: the copy buffer length and the number of in-flight requests, both of which are used during upload/download. Previously these could be controlled in sftp(1) only. This makes them available in both SFTP protocol clients using the same option character sequence. * ssh-keyscan(1): allow scanning of complete CIDR address ranges, e.g. "ssh-keyscan 192.168.0.0/24". If a CIDR range is passed, then it will be expanded to all possible addresses in the range including the all-0s and all-1s addresses. bz#976 * ssh(1): support dynamic remote port forwarding in escape command-line's -R processing. bz#3499 MFC after: 1 week Sponsored by: The FreeBSD Foundation
116 lines
3.1 KiB
C
116 lines
3.1 KiB
C
/*
|
|
* Copyright (c) 2004, 2005, 2007 Darren Tucker (dtucker at zip com au).
|
|
*
|
|
* Permission to use, copy, modify, and distribute this software for any
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
* copyright notice and this permission notice appear in all copies.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
*/
|
|
|
|
#include "includes.h"
|
|
#if !defined(HAVE_PPOLL) || !defined(HAVE_POLL) || defined(BROKEN_POLL)
|
|
|
|
#include <sys/types.h>
|
|
#include <sys/time.h>
|
|
#ifdef HAVE_SYS_PARAM_H
|
|
# include <sys/param.h>
|
|
#endif
|
|
#ifdef HAVE_SYS_SELECT_H
|
|
# include <sys/select.h>
|
|
#endif
|
|
|
|
#include <errno.h>
|
|
#include <signal.h>
|
|
#include <stdlib.h>
|
|
#include <unistd.h>
|
|
#include "bsd-poll.h"
|
|
|
|
#if !defined(HAVE_PPOLL) || defined(BROKEN_POLL)
|
|
/*
|
|
* A minimal implementation of ppoll(2), built on top of pselect(2).
|
|
*
|
|
* Only supports POLLIN, POLLOUT and POLLPRI flags in pfd.events and
|
|
* revents. Notably POLLERR, POLLHUP and POLLNVAL are not supported.
|
|
*
|
|
* Supports pfd.fd = -1 meaning "unused" although it's not standard.
|
|
*/
|
|
|
|
int
|
|
ppoll(struct pollfd *fds, nfds_t nfds, const struct timespec *tmoutp,
|
|
const sigset_t *sigmask)
|
|
{
|
|
nfds_t i;
|
|
int ret, fd, maxfd = 0;
|
|
fd_set readfds, writefds, exceptfds;
|
|
|
|
for (i = 0; i < nfds; i++) {
|
|
fd = fds[i].fd;
|
|
if (fd != -1 && fd >= FD_SETSIZE) {
|
|
errno = EINVAL;
|
|
return -1;
|
|
}
|
|
maxfd = MAX(maxfd, fd);
|
|
}
|
|
|
|
/* populate event bit vectors for the events we're interested in */
|
|
FD_ZERO(&readfds);
|
|
FD_ZERO(&writefds);
|
|
FD_ZERO(&exceptfds);
|
|
for (i = 0; i < nfds; i++) {
|
|
fd = fds[i].fd;
|
|
if (fd == -1)
|
|
continue;
|
|
if (fds[i].events & POLLIN)
|
|
FD_SET(fd, &readfds);
|
|
if (fds[i].events & POLLOUT)
|
|
FD_SET(fd, &writefds);
|
|
if (fds[i].events & POLLPRI)
|
|
FD_SET(fd, &exceptfds);
|
|
}
|
|
|
|
ret = pselect(maxfd + 1, &readfds, &writefds, &exceptfds, tmoutp, sigmask);
|
|
|
|
/* scan through select results and set poll() flags */
|
|
for (i = 0; i < nfds; i++) {
|
|
fd = fds[i].fd;
|
|
fds[i].revents = 0;
|
|
if (fd == -1)
|
|
continue;
|
|
if ((fds[i].events & POLLIN) && FD_ISSET(fd, &readfds))
|
|
fds[i].revents |= POLLIN;
|
|
if ((fds[i].events & POLLOUT) && FD_ISSET(fd, &writefds))
|
|
fds[i].revents |= POLLOUT;
|
|
if ((fds[i].events & POLLPRI) && FD_ISSET(fd, &exceptfds))
|
|
fds[i].revents |= POLLPRI;
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
#endif /* !HAVE_PPOLL || BROKEN_POLL */
|
|
|
|
#if !defined(HAVE_POLL) || defined(BROKEN_POLL)
|
|
int
|
|
poll(struct pollfd *fds, nfds_t nfds, int timeout)
|
|
{
|
|
struct timespec ts, *tsp = NULL;
|
|
|
|
/* poll timeout is msec, ppoll is timespec (sec + nsec) */
|
|
if (timeout >= 0) {
|
|
ts.tv_sec = timeout / 1000;
|
|
ts.tv_nsec = (timeout % 1000) * 1000000;
|
|
tsp = &ts;
|
|
}
|
|
|
|
return ppoll(fds, nfds, tsp, NULL);
|
|
}
|
|
#endif /* !HAVE_POLL || BROKEN_POLL */
|
|
|
|
#endif /* !HAVE_PPOLL || !HAVE_POLL || BROKEN_POLL */
|