Vendor import of OpenSSH 9.7p1

This commit is contained in:
Ed Maste 2024-03-17 13:47:10 -04:00
parent 38f55691cb
commit 9200ce3210
84 changed files with 2490 additions and 2710 deletions

21
.github/configs vendored
View file

@ -164,6 +164,11 @@ case "$config" in
libressl-*) libressl-*)
LIBCRYPTOFLAGS="--with-ssl-dir=/opt/libressl --with-rpath=-Wl,-rpath," LIBCRYPTOFLAGS="--with-ssl-dir=/opt/libressl --with-rpath=-Wl,-rpath,"
;; ;;
putty-*)
CONFIGFLAGS="--with-plink=/usr/local/bin/plink --with-puttygen=/usr/local/bin/puttygen"
# We don't need to rerun the regular tests, just the interop ones.
TEST_TARGET=interop-tests
;;
openssl-*) openssl-*)
LIBCRYPTOFLAGS="--with-ssl-dir=/opt/openssl --with-rpath=-Wl,-rpath," LIBCRYPTOFLAGS="--with-ssl-dir=/opt/openssl --with-rpath=-Wl,-rpath,"
# OpenSSL 1.1.1 specifically has a bug in its RNG that breaks reexec # OpenSSL 1.1.1 specifically has a bug in its RNG that breaks reexec
@ -269,20 +274,22 @@ case "${TARGET_HOST}" in
;; ;;
minix3) minix3)
CONFIGFLAGS="${CONFIGFLAGS} --disable-security-key" CONFIGFLAGS="${CONFIGFLAGS} --disable-security-key"
# Unix domain sockets don't work quite like we expect, so also
# disable FD passing (and thus multiplexing).
CONFIGFLAGS="${CONFIGFLAGS} --disable-fd-passing"
LIBCRYPTOFLAGS="--without-openssl" LIBCRYPTOFLAGS="--without-openssl"
# Minix does not have a loopback interface so we have to skip any # Minix does not have a loopback interface so we have to skip any
# test that relies on one. # test that relies on one.
# Also, Minix seems to be very limited in the number of select() # Also, Minix seems to be very limited in the number of select()
# calls that can be operating concurrently, so prune additional tests for that. # calls that can be operating concurrently, so prune additional tests for that.
T="addrmatch agent-restrict brokenkeys cfgmatch cfgmatchlisten cfgparse T="addrmatch agent-restrict brokenkeys cfgmatch cfgmatchlisten cfgparse
connect connect-uri exit-status forwarding hostkey-agent connect connect-uri dynamic-forward exit-status forwarding
key-options keyscan knownhosts-command login-timeout forward-control
hostkey-agent key-options keyscan knownhosts-command login-timeout
reconfigure reexec rekey scp scp-uri scp3 sftp sftp-badcmds reconfigure reexec rekey scp scp-uri scp3 sftp sftp-badcmds
sftp-batch sftp-cmds sftp-glob sftp-perm sftp-uri stderr-data sftp-batch sftp-cmds sftp-glob sftp-perm sftp-uri stderr-data
transfer" transfer"
# Unix domain sockets don't work quite like we expect, so also skip any tests
# that use multiplexing.
T="$T connection-timeout dynamic-forward forward-control multiplex"
SKIP_LTESTS="$(echo $T)" SKIP_LTESTS="$(echo $T)"
TEST_TARGET=t-exec TEST_TARGET=t-exec
SUDO="" SUDO=""
@ -320,6 +327,10 @@ case "$host" in
# modern versions don't ship with libcrypto. # modern versions don't ship with libcrypto.
LIBCRYPTOFLAGS="--without-openssl" LIBCRYPTOFLAGS="--without-openssl"
TEST_TARGET=t-exec TEST_TARGET=t-exec
# On some OS X runners we can't write to /var/empty.
CONFIGFLAGS="${CONFIGFLAGS} --with-privsep-path=/usr/local/empty"
case "$host" in case "$host" in
*-darwin22.*) *-darwin22.*)
# sudo -S nobody doesn't work on macos 13 for some reason. # sudo -S nobody doesn't work on macos 13 for some reason.

26
.github/setup_ci.sh vendored
View file

@ -142,6 +142,10 @@ for TARGET in $TARGETS; do
INSTALL_BORINGSSL=1 INSTALL_BORINGSSL=1
PACKAGES="${PACKAGES} cmake ninja-build" PACKAGES="${PACKAGES} cmake ninja-build"
;; ;;
putty-*)
INSTALL_PUTTY=$(echo "${TARGET}" | cut -f2 -d-)
PACKAGES="${PACKAGES} cmake"
;;
valgrind*) valgrind*)
PACKAGES="$PACKAGES valgrind" PACKAGES="$PACKAGES valgrind"
;; ;;
@ -241,3 +245,25 @@ if [ ! -z "${INSTALL_ZLIB}" ]; then
cd ${HOME}/zlib && ./configure && make && cd ${HOME}/zlib && ./configure && make &&
sudo make install prefix=/opt/zlib) sudo make install prefix=/opt/zlib)
fi fi
if [ ! -z "${INSTALL_PUTTY}" ]; then
ver="${INSTALL_PUTTY}"
case "${INSTALL_PUTTY}" in
snapshot)
tarball=putty.tar.gz
(cd /tmp && wget https://tartarus.org/~simon/putty-snapshots/${tarball})
;;
*)
tarball=putty-${ver}.tar.gz
(cd /tmp && wget https://the.earth.li/~sgtatham/putty/${ver}/${tarball})
;;
esac
(cd ${HOME} && tar xfz /tmp/${tarball} && cd putty-*
if [ -f CMakeLists.txt ]; then
cmake . && cmake --build . && sudo cmake --build . --target install
else
./configure && make && sudo make install
fi
)
/usr/local/bin/plink -V
fi

View file

@ -62,20 +62,32 @@ jobs:
- { target: ubuntu-latest, config: libressl-3.5.3 } - { target: ubuntu-latest, config: libressl-3.5.3 }
- { target: ubuntu-latest, config: libressl-3.6.1 } - { target: ubuntu-latest, config: libressl-3.6.1 }
- { target: ubuntu-latest, config: libressl-3.7.2 } - { target: ubuntu-latest, config: libressl-3.7.2 }
- { target: ubuntu-latest, config: libressl-3.8.2 } - { target: ubuntu-latest, config: libressl-3.8.3 }
- { target: ubuntu-latest, config: libressl-3.9.0 }
- { target: ubuntu-latest, config: openssl-master } - { target: ubuntu-latest, config: openssl-master }
- { target: ubuntu-latest, config: openssl-noec } - { target: ubuntu-latest, config: openssl-noec }
- { target: ubuntu-latest, config: openssl-1.1.1 } - { target: ubuntu-latest, config: openssl-1.1.1 }
- { target: ubuntu-latest, config: openssl-1.1.1t } - { target: ubuntu-latest, config: openssl-1.1.1t }
- { target: ubuntu-latest, config: openssl-1.1.1w } - { target: ubuntu-latest, config: openssl-1.1.1w }
- { target: ubuntu-latest, config: openssl-3.0.0 } - { target: ubuntu-latest, config: openssl-3.0.0 }
- { target: ubuntu-latest, config: openssl-3.0.12 } - { target: ubuntu-latest, config: openssl-3.0.13 }
- { target: ubuntu-latest, config: openssl-3.1.0 } - { target: ubuntu-latest, config: openssl-3.1.0 }
- { target: ubuntu-latest, config: openssl-3.1.4 } - { target: ubuntu-latest, config: openssl-3.1.5 }
- { target: ubuntu-latest, config: openssl-3.2.0 } - { target: ubuntu-latest, config: openssl-3.2.1 }
- { target: ubuntu-latest, config: openssl-1.1.1_stable } - { target: ubuntu-latest, config: openssl-1.1.1_stable }
- { target: ubuntu-latest, config: openssl-3.0 } # stable branch - { target: ubuntu-latest, config: openssl-3.0 } # stable branch
- { target: ubuntu-latest, config: openssl-3.2 } # stable branch - { target: ubuntu-latest, config: openssl-3.2 } # stable branch
- { target: ubuntu-latest, config: putty-0.71 }
- { target: ubuntu-latest, config: putty-0.72 }
- { target: ubuntu-latest, config: putty-0.73 }
- { target: ubuntu-latest, config: putty-0.74 }
- { target: ubuntu-latest, config: putty-0.75 }
- { target: ubuntu-latest, config: putty-0.76 }
- { target: ubuntu-latest, config: putty-0.77 }
- { target: ubuntu-latest, config: putty-0.78 }
- { target: ubuntu-latest, config: putty-0.79 }
- { target: ubuntu-latest, config: putty-0.80 }
- { target: ubuntu-latest, config: putty-snapshot }
- { target: ubuntu-latest, config: zlib-develop } - { target: ubuntu-latest, config: zlib-develop }
- { target: ubuntu-22.04, config: pam } - { target: ubuntu-22.04, config: pam }
- { target: ubuntu-22.04, config: krb5 } - { target: ubuntu-22.04, config: krb5 }

View file

@ -73,6 +73,7 @@ jobs:
- { target: fbsd14, config: pam, host: libvirt } - { target: fbsd14, config: pam, host: libvirt }
- { target: nbsd8, config: pam, host: libvirt } - { target: nbsd8, config: pam, host: libvirt }
- { target: nbsd9, config: pam, host: libvirt } - { target: nbsd9, config: pam, host: libvirt }
- { target: nbsd10, config: pam, host: libvirt }
# VMs with persistent disks that have their own runner. # VMs with persistent disks that have their own runner.
- { target: win10, config: default, host: win10 } - { target: win10, config: default, host: win10 }
- { target: win10, config: cygwin-release, host: win10 } - { target: win10, config: cygwin-release, host: win10 }

2
.gitignore vendored
View file

@ -18,6 +18,8 @@ survey.sh
**/*.so **/*.so
**/*.out **/*.out
**/*.a **/*.a
**/*.un~
**/.*.swp
autom4te.cache/ autom4te.cache/
scp scp
sftp sftp

View file

@ -1,3 +1,4 @@
509bb19bb9762a4b3b589af98bac2e730541b6d4 clean sshd random relinking kit
5317f294d63a876bfc861e19773b1575f96f027d remove libssh from makefiles 5317f294d63a876bfc861e19773b1575f96f027d remove libssh from makefiles
a337e886a49f96701ccbc4832bed086a68abfa85 Makefile changes a337e886a49f96701ccbc4832bed086a68abfa85 Makefile changes
f2c9feb26963615c4fece921906cf72e248b61ee more Makefile f2c9feb26963615c4fece921906cf72e248b61ee more Makefile
@ -27,6 +28,7 @@ cc12a9029833d222043aecd252d654965c351a69 moduli-gen Makefile
f9a0726d957cf10692a231996a1f34e7f9cdfeb0 moduli update f9a0726d957cf10692a231996a1f34e7f9cdfeb0 moduli update
1e0a2692b7e20b126dda60bf04999d1d30d959d8 sshd relinking makefile changes 1e0a2692b7e20b126dda60bf04999d1d30d959d8 sshd relinking makefile changes
e1dc11143f83082e3154d6094f9136d0dc2637ad more relinking makefile tweaks e1dc11143f83082e3154d6094f9136d0dc2637ad more relinking makefile tweaks
5a636f6ca7f25bfe775df4952f7aac90a7fcbbee moduli update
Old upstream tree: Old upstream tree:

2343
ChangeLog

File diff suppressed because it is too large Load diff

View file

@ -137,12 +137,12 @@ than as a named global or channel request to allow pings with very
short packet lengths, which would not be possible with other short packet lengths, which would not be possible with other
approaches. approaches.
1.9 transport: strict key exchange extension 1.10 transport: strict key exchange extension
OpenSSH supports a number of transport-layer hardening measures under OpenSSH supports a number of transport-layer hardening measures under
a "strict KEX" feature. This feature is signalled similarly to the a "strict KEX" feature. This feature is signalled similarly to the
RFC8308 ext-info feature: by including a additional algorithm in the RFC8308 ext-info feature: by including a additional algorithm in the
initiial SSH2_MSG_KEXINIT kex_algorithms field. The client may append initial SSH2_MSG_KEXINIT kex_algorithms field. The client may append
"kex-strict-c-v00@openssh.com" to its kex_algorithms and the server "kex-strict-c-v00@openssh.com" to its kex_algorithms and the server
may append "kex-strict-s-v00@openssh.com". These pseudo-algorithms may append "kex-strict-s-v00@openssh.com". These pseudo-algorithms
are only valid in the initial SSH2_MSG_KEXINIT and MUST be ignored are only valid in the initial SSH2_MSG_KEXINIT and MUST be ignored
@ -150,20 +150,21 @@ if they are present in subsequent SSH2_MSG_KEXINIT packets.
When an endpoint that supports this extension observes this algorithm When an endpoint that supports this extension observes this algorithm
name in a peer's KEXINIT packet, it MUST make the following changes to name in a peer's KEXINIT packet, it MUST make the following changes to
the the protocol: the protocol:
a) During initial KEX, terminate the connection if any unexpected or a) During initial KEX, terminate the connection if out-of-sequence
out-of-sequence packet is received. This includes terminating the packet or any message that is not strictly required by KEX is
connection if the first packet received is not SSH2_MSG_KEXINIT. received. This includes terminating the connection if the first
Unexpected packets for the purpose of strict KEX include messages packet received is not SSH2_MSG_KEXINIT. Unexpected packets for
that are otherwise valid at any time during the connection such as the purpose of strict KEX include messages that are otherwise
SSH2_MSG_DEBUG and SSH2_MSG_IGNORE. valid at any time during the connection such as SSH2_MSG_DEBUG,
SSH2_MSG_IGNORE or SSH2_MSG_UNIMPLEMENTED.
b) After sending or receiving a SSH2_MSG_NEWKEYS message, reset the b) After sending or receiving a SSH2_MSG_NEWKEYS message, reset the
packet sequence number to zero. This behaviour persists for the packet sequence number to zero. This behaviour persists for the
duration of the connection (i.e. not just the first duration of the connection (i.e. not just the first
SSH2_MSG_NEWKEYS). SSH2_MSG_NEWKEYS).
1.10 transport: SSH2_MSG_EXT_INFO during user authentication 1.11 transport: SSH2_MSG_EXT_INFO during user authentication
This protocol extension allows the SSH2_MSG_EXT_INFO to be sent This protocol extension allows the SSH2_MSG_EXT_INFO to be sent
during user authentication. RFC8308 does allow a second during user authentication. RFC8308 does allow a second
@ -735,6 +736,7 @@ identifiers:
The server will reply with a SSH_FXP_EXTENDED_REPLY: The server will reply with a SSH_FXP_EXTENDED_REPLY:
byte SSH_FXP_EXTENDED_REPLY byte SSH_FXP_EXTENDED_REPLY
uint32 id
string usernames string usernames
string groupnames string groupnames
@ -790,4 +792,4 @@ master instance and later clients.
OpenSSH extends the usual agent protocol. These changes are documented OpenSSH extends the usual agent protocol. These changes are documented
in the PROTOCOL.agent file. in the PROTOCOL.agent file.
$OpenBSD: PROTOCOL,v 1.51 2023/12/18 14:45:49 djm Exp $ $OpenBSD: PROTOCOL,v 1.55 2024/01/08 05:05:15 djm Exp $

View file

@ -91,7 +91,7 @@ with private keys as they are loaded from a PKCS#11 token.
bool certs_only bool certs_only
string certsblob string certsblob
Where "certsblob" constists of one or more certificates encoded as public Where "certsblob" consists of one or more certificates encoded as public
key blobs: key blobs:
string[] certificates string[] certificates
@ -112,4 +112,4 @@ A SSH_AGENTC_ADD_SMARTCARD_KEY_CONSTRAINED will return SSH_AGENT_SUCCESS
if any key (plain private or certificate) was successfully loaded, or if any key (plain private or certificate) was successfully loaded, or
SSH_AGENT_FAILURE if no key was loaded. SSH_AGENT_FAILURE if no key was loaded.
$OpenBSD: PROTOCOL.agent,v 1.21 2023/12/18 14:46:56 djm Exp $ $OpenBSD: PROTOCOL.agent,v 1.22 2023/12/20 00:06:25 jsg Exp $

View file

@ -188,8 +188,6 @@ For dynamically allocated listen port the server replies with
7. Requesting closure of port forwards 7. Requesting closure of port forwards
Note: currently unimplemented (server will always reply with MUX_S_FAILURE).
A client may request the master to close a port forward: A client may request the master to close a port forward:
uint32 MUX_C_CLOSE_FWD uint32 MUX_C_CLOSE_FWD
@ -295,4 +293,4 @@ XXX session inspection via master
XXX signals via mux request XXX signals via mux request
XXX list active connections via mux XXX list active connections via mux
$OpenBSD: PROTOCOL.mux,v 1.13 2022/01/01 01:55:30 jsg Exp $ $OpenBSD: PROTOCOL.mux,v 1.14 2024/01/08 05:11:18 djm Exp $

2
README
View file

@ -1,4 +1,4 @@
See https://www.openssh.com/releasenotes.html#9.6p1 for the release See https://www.openssh.com/releasenotes.html#9.7p1 for the release
notes. notes.
Please read https://www.openssh.com/report.html for bug reporting Please read https://www.openssh.com/report.html for bug reporting

View file

@ -53,11 +53,12 @@ Darwin does not provide a tun(4) driver required for OpenSSH-based
virtual private networks. The BSD manpage still exists, but the driver virtual private networks. The BSD manpage still exists, but the driver
has been removed in recent releases of Darwin and MacOS X. has been removed in recent releases of Darwin and MacOS X.
Nevertheless, tunnel support is known to work with Darwin 8 and Tunnel support is known to work with Darwin 8 and MacOS X 10.4 in
MacOS X 10.4 in Point-to-Point (Layer 3) and Ethernet (Layer 2) mode Point-to-Point (Layer 3) and Ethernet (Layer 2) mode using a third
using a third party driver. More information is available at: party driver. More information is available at:
http://www-user.rhrk.uni-kl.de/~nissler/tuntap/ https://tuntaposx.sourceforge.net
Recent Darwin/MacOS X versions are likely unsupported.
Linux Linux
----- -----

View file

@ -1,4 +1,4 @@
/* $OpenBSD: channels.c,v 1.435 2023/12/18 14:47:20 djm Exp $ */ /* $OpenBSD: channels.c,v 1.437 2024/03/06 02:59:59 djm Exp $ */
/* /*
* Author: Tatu Ylonen <ylo@cs.hut.fi> * Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@ -214,6 +214,9 @@ struct ssh_channels {
/* Channel timeouts by type */ /* Channel timeouts by type */
struct ssh_channel_timeout *timeouts; struct ssh_channel_timeout *timeouts;
size_t ntimeouts; size_t ntimeouts;
/* Global timeout for all OPEN channels */
int global_deadline;
time_t lastused;
}; };
/* helper */ /* helper */
@ -316,6 +319,11 @@ channel_add_timeout(struct ssh *ssh, const char *type_pattern,
{ {
struct ssh_channels *sc = ssh->chanctxt; struct ssh_channels *sc = ssh->chanctxt;
if (strcmp(type_pattern, "global") == 0) {
debug2_f("global channel timeout %d seconds", timeout_secs);
sc->global_deadline = timeout_secs;
return;
}
debug2_f("channel type \"%s\" timeout %d seconds", debug2_f("channel type \"%s\" timeout %d seconds",
type_pattern, timeout_secs); type_pattern, timeout_secs);
sc->timeouts = xrecallocarray(sc->timeouts, sc->ntimeouts, sc->timeouts = xrecallocarray(sc->timeouts, sc->ntimeouts,
@ -376,6 +384,38 @@ channel_set_xtype(struct ssh *ssh, int id, const char *xctype)
c->inactive_deadline); c->inactive_deadline);
} }
/*
* update "last used" time on a channel.
* NB. nothing else should update lastused except to clear it.
*/
static void
channel_set_used_time(struct ssh *ssh, Channel *c)
{
ssh->chanctxt->lastused = monotime();
if (c != NULL)
c->lastused = ssh->chanctxt->lastused;
}
/*
* Get the time at which a channel is due to time out for inactivity.
* Returns 0 if the channel is not due to time out ever.
*/
static time_t
channel_get_expiry(struct ssh *ssh, Channel *c)
{
struct ssh_channels *sc = ssh->chanctxt;
time_t expiry = 0, channel_expiry;
if (sc->lastused != 0 && sc->global_deadline != 0)
expiry = sc->lastused + sc->global_deadline;
if (c->lastused != 0 && c->inactive_deadline != 0) {
channel_expiry = c->lastused + c->inactive_deadline;
if (expiry == 0 || channel_expiry < expiry)
expiry = channel_expiry;
}
return expiry;
}
/* /*
* Register filedescriptors for a channel, used when allocating a channel or * Register filedescriptors for a channel, used when allocating a channel or
* when the channel consumer/producer is ready, e.g. shell exec'd * when the channel consumer/producer is ready, e.g. shell exec'd
@ -441,6 +481,8 @@ channel_register_fds(struct ssh *ssh, Channel *c, int rfd, int wfd, int efd,
if (efd != -1) if (efd != -1)
set_nonblock(efd); set_nonblock(efd);
} }
/* channel might be entering a larval state, so reset global timeout */
channel_set_used_time(ssh, NULL);
} }
/* /*
@ -1197,7 +1239,7 @@ channel_set_fds(struct ssh *ssh, int id, int rfd, int wfd, int efd,
channel_register_fds(ssh, c, rfd, wfd, efd, extusage, nonblock, is_tty); channel_register_fds(ssh, c, rfd, wfd, efd, extusage, nonblock, is_tty);
c->type = SSH_CHANNEL_OPEN; c->type = SSH_CHANNEL_OPEN;
c->lastused = monotime(); channel_set_used_time(ssh, c);
c->local_window = c->local_window_max = window_max; c->local_window = c->local_window_max = window_max;
if ((r = sshpkt_start(ssh, SSH2_MSG_CHANNEL_WINDOW_ADJUST)) != 0 || if ((r = sshpkt_start(ssh, SSH2_MSG_CHANNEL_WINDOW_ADJUST)) != 0 ||
@ -1368,7 +1410,7 @@ channel_pre_x11_open(struct ssh *ssh, Channel *c)
if (ret == 1) { if (ret == 1) {
c->type = SSH_CHANNEL_OPEN; c->type = SSH_CHANNEL_OPEN;
c->lastused = monotime(); channel_set_used_time(ssh, c);
channel_pre_open(ssh, c); channel_pre_open(ssh, c);
} else if (ret == -1) { } else if (ret == -1) {
logit("X11 connection rejected because of wrong " logit("X11 connection rejected because of wrong "
@ -2016,7 +2058,7 @@ channel_post_connecting(struct ssh *ssh, Channel *c)
c->self, c->connect_ctx.host, c->connect_ctx.port); c->self, c->connect_ctx.host, c->connect_ctx.port);
channel_connect_ctx_free(&c->connect_ctx); channel_connect_ctx_free(&c->connect_ctx);
c->type = SSH_CHANNEL_OPEN; c->type = SSH_CHANNEL_OPEN;
c->lastused = monotime(); channel_set_used_time(ssh, c);
if (isopen) { if (isopen) {
/* no message necessary */ /* no message necessary */
} else { } else {
@ -2108,7 +2150,7 @@ channel_handle_rfd(struct ssh *ssh, Channel *c)
goto rfail; goto rfail;
} }
if (nr != 0) if (nr != 0)
c->lastused = monotime(); channel_set_used_time(ssh, c);
return 1; return 1;
} }
@ -2134,7 +2176,7 @@ channel_handle_rfd(struct ssh *ssh, Channel *c)
} }
return -1; return -1;
} }
c->lastused = monotime(); channel_set_used_time(ssh, c);
if (c->input_filter != NULL) { if (c->input_filter != NULL) {
if (c->input_filter(ssh, c, buf, len) == -1) { if (c->input_filter(ssh, c, buf, len) == -1) {
debug2("channel %d: filter stops", c->self); debug2("channel %d: filter stops", c->self);
@ -2215,7 +2257,7 @@ channel_handle_wfd(struct ssh *ssh, Channel *c)
} }
return -1; return -1;
} }
c->lastused = monotime(); channel_set_used_time(ssh, c);
#ifndef BROKEN_TCGETATTR_ICANON #ifndef BROKEN_TCGETATTR_ICANON
if (c->isatty && dlen >= 1 && buf[0] != '\r') { if (c->isatty && dlen >= 1 && buf[0] != '\r') {
if (tcgetattr(c->wfd, &tio) == 0 && if (tcgetattr(c->wfd, &tio) == 0 &&
@ -2264,7 +2306,7 @@ channel_handle_efd_write(struct ssh *ssh, Channel *c)
if ((r = sshbuf_consume(c->extended, len)) != 0) if ((r = sshbuf_consume(c->extended, len)) != 0)
fatal_fr(r, "channel %i: consume", c->self); fatal_fr(r, "channel %i: consume", c->self);
c->local_consumed += len; c->local_consumed += len;
c->lastused = monotime(); channel_set_used_time(ssh, c);
} }
return 1; return 1;
} }
@ -2291,7 +2333,7 @@ channel_handle_efd_read(struct ssh *ssh, Channel *c)
channel_close_fd(ssh, c, &c->efd); channel_close_fd(ssh, c, &c->efd);
return 1; return 1;
} }
c->lastused = monotime(); channel_set_used_time(ssh, c);
if (c->extended_usage == CHAN_EXTENDED_IGNORE) if (c->extended_usage == CHAN_EXTENDED_IGNORE)
debug3("channel %d: discard efd", c->self); debug3("channel %d: discard efd", c->self);
else if ((r = sshbuf_put(c->extended, buf, len)) != 0) else if ((r = sshbuf_put(c->extended, buf, len)) != 0)
@ -2581,10 +2623,9 @@ channel_handler(struct ssh *ssh, int table, struct timespec *timeout)
continue; continue;
} }
if (ftab[c->type] != NULL) { if (ftab[c->type] != NULL) {
if (table == CHAN_PRE && if (table == CHAN_PRE && c->type == SSH_CHANNEL_OPEN &&
c->type == SSH_CHANNEL_OPEN && channel_get_expiry(ssh, c) != 0 &&
c->inactive_deadline != 0 && c->lastused != 0 && now >= channel_get_expiry(ssh, c)) {
now >= c->lastused + c->inactive_deadline) {
/* channel closed for inactivity */ /* channel closed for inactivity */
verbose("channel %d: closing after %u seconds " verbose("channel %d: closing after %u seconds "
"of inactivity", c->self, "of inactivity", c->self,
@ -2596,10 +2637,9 @@ channel_handler(struct ssh *ssh, int table, struct timespec *timeout)
/* inactivity timeouts must interrupt poll() */ /* inactivity timeouts must interrupt poll() */
if (timeout != NULL && if (timeout != NULL &&
c->type == SSH_CHANNEL_OPEN && c->type == SSH_CHANNEL_OPEN &&
c->lastused != 0 && channel_get_expiry(ssh, c) != 0) {
c->inactive_deadline != 0) {
ptimeout_deadline_monotime(timeout, ptimeout_deadline_monotime(timeout,
c->lastused + c->inactive_deadline); channel_get_expiry(ssh, c));
} }
} else if (timeout != NULL) { } else if (timeout != NULL) {
/* /*
@ -3205,9 +3245,8 @@ channel_proxy_downstream(struct ssh *ssh, Channel *downstream)
goto out; goto out;
} }
/* Record that connection to this host/port is permitted. */ /* Record that connection to this host/port is permitted. */
permission_set_add(ssh, FORWARD_USER, FORWARD_LOCAL, "<mux>", -1, permission_set_add(ssh, FORWARD_USER, FORWARD_LOCAL, "<mux>",
listen_host, NULL, (int)listen_port, downstream); -1, listen_host, NULL, (int)listen_port, downstream);
listen_host = NULL;
break; break;
case SSH2_MSG_CHANNEL_CLOSE: case SSH2_MSG_CHANNEL_CLOSE:
if (have < 4) if (have < 4)
@ -3558,7 +3597,7 @@ channel_input_open_confirmation(int type, u_int32_t seq, struct ssh *ssh)
c->open_confirm(ssh, c->self, 1, c->open_confirm_ctx); c->open_confirm(ssh, c->self, 1, c->open_confirm_ctx);
debug2_f("channel %d: callback done", c->self); debug2_f("channel %d: callback done", c->self);
} }
c->lastused = monotime(); channel_set_used_time(ssh, c);
debug2("channel %d: open confirm rwindow %u rmax %u", c->self, debug2("channel %d: open confirm rwindow %u rmax %u", c->self,
c->remote_window, c->remote_maxpacket); c->remote_window, c->remote_maxpacket);
return 0; return 0;

View file

@ -1,4 +1,4 @@
/* $OpenBSD: clientloop.c,v 1.402 2023/11/24 00:31:30 dtucker Exp $ */ /* $OpenBSD: clientloop.c,v 1.403 2024/02/21 05:57:34 djm Exp $ */
/* /*
* Author: Tatu Ylonen <ylo@cs.hut.fi> * Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@ -517,7 +517,7 @@ send_chaff(struct ssh *ssh)
{ {
int r; int r;
if ((ssh->kex->flags & KEX_HAS_PING) == 0) if (ssh->kex == NULL || (ssh->kex->flags & KEX_HAS_PING) == 0)
return 0; return 0;
/* XXX probabilistically send chaff? */ /* XXX probabilistically send chaff? */
/* /*

View file

@ -1963,6 +1963,9 @@
/* Define if you want to enable AIX4's authenticate function */ /* Define if you want to enable AIX4's authenticate function */
#undef WITH_AIXAUTHENTICATE #undef WITH_AIXAUTHENTICATE
/* Define if to enable DSA keys. */
#undef WITH_DSA
/* Define if you have/want arrays (cluster-wide session management, not C /* Define if you have/want arrays (cluster-wide session management, not C
arrays) */ arrays) */
#undef WITH_IRIX_ARRAY #undef WITH_IRIX_ARRAY

1340
configure vendored

File diff suppressed because it is too large Load diff

View file

@ -149,6 +149,7 @@ fi
use_stack_protector=1 use_stack_protector=1
use_toolchain_hardening=1 use_toolchain_hardening=1
use_retpoline=1
AC_ARG_WITH([stackprotect], AC_ARG_WITH([stackprotect],
[ --without-stackprotect Don't use compiler's stack protection], [ [ --without-stackprotect Don't use compiler's stack protection], [
if test "x$withval" = "xno"; then if test "x$withval" = "xno"; then
@ -159,6 +160,11 @@ AC_ARG_WITH([hardening],
if test "x$withval" = "xno"; then if test "x$withval" = "xno"; then
use_toolchain_hardening=0 use_toolchain_hardening=0
fi ]) fi ])
AC_ARG_WITH([retpoline],
[ --without-retpoline Enable retpoline spectre mitigation], [
if test "x$withval" = "xno"; then
use_retpoline=0
fi ])
# We use -Werror for the tests only so that we catch warnings like "this is # We use -Werror for the tests only so that we catch warnings like "this is
# on by default" for things like -fPIE. # on by default" for things like -fPIE.
@ -216,8 +222,6 @@ if test "$GCC" = "yes" || test "$GCC" = "egcs"; then
OSSH_CHECK_CFLAG_COMPILE([-Wbitwise-instead-of-logical]) OSSH_CHECK_CFLAG_COMPILE([-Wbitwise-instead-of-logical])
OSSH_CHECK_CFLAG_COMPILE([-fno-strict-aliasing]) OSSH_CHECK_CFLAG_COMPILE([-fno-strict-aliasing])
if test "x$use_toolchain_hardening" = "x1"; then if test "x$use_toolchain_hardening" = "x1"; then
OSSH_CHECK_CFLAG_COMPILE([-mretpoline]) # clang
OSSH_CHECK_LDFLAG_LINK([-Wl,-z,retpolineplt])
OSSH_CHECK_CFLAG_COMPILE([-D_FORTIFY_SOURCE=2]) OSSH_CHECK_CFLAG_COMPILE([-D_FORTIFY_SOURCE=2])
OSSH_CHECK_LDFLAG_LINK([-Wl,-z,relro]) OSSH_CHECK_LDFLAG_LINK([-Wl,-z,relro])
OSSH_CHECK_LDFLAG_LINK([-Wl,-z,now]) OSSH_CHECK_LDFLAG_LINK([-Wl,-z,now])
@ -240,6 +244,10 @@ if test "$GCC" = "yes" || test "$GCC" = "egcs"; then
esac esac
OSSH_CHECK_CFLAG_COMPILE([-ftrivial-auto-var-init=zero]) OSSH_CHECK_CFLAG_COMPILE([-ftrivial-auto-var-init=zero])
fi fi
if test "x$use_retpoline" = "x1"; then
OSSH_CHECK_CFLAG_COMPILE([-mretpoline]) # clang
OSSH_CHECK_LDFLAG_LINK([-Wl,-z,retpolineplt])
fi
AC_MSG_CHECKING([if $CC accepts -fno-builtin-memset]) AC_MSG_CHECKING([if $CC accepts -fno-builtin-memset])
saved_CFLAGS="$CFLAGS" saved_CFLAGS="$CFLAGS"
@ -2067,6 +2075,18 @@ AC_ARG_WITH([security-key-builtin],
[ enable_sk_internal=$withval ] [ enable_sk_internal=$withval ]
) )
disable_ecdsa=
AC_ARG_ENABLE([dsa-keys],
[ --disable-dsa-keys disable DSA key support [no]],
[
if test "x$enableval" = "xno" ; then
disable_ecdsa=1
fi
]
)
test -z "$disable_ecdsa" &&
AC_DEFINE([WITH_DSA], [1], [Define if to enable DSA keys.])
AC_SEARCH_LIBS([dlopen], [dl]) AC_SEARCH_LIBS([dlopen], [dl])
AC_CHECK_FUNCS([dlopen]) AC_CHECK_FUNCS([dlopen])
AC_CHECK_DECL([RTLD_NOW], [], [], [#include <dlfcn.h>]) AC_CHECK_DECL([RTLD_NOW], [], [], [#include <dlfcn.h>])
@ -2723,7 +2743,15 @@ AC_ARG_WITH([ssl-dir],
else else
CPPFLAGS="-I${withval} ${CPPFLAGS}" CPPFLAGS="-I${withval} ${CPPFLAGS}"
fi fi
openssl_bin_PATH="${PATH}${PATH_SEPARATOR}${withval}/bin${PATH_SEPARATOR}${withval}/apps" dnl Ensure specified openssl binary works, eg it can
dnl find its runtime libraries, before trying to use.
if test -x "${withval}/bin/openssl" && \
"${withval}/bin/openssl" version >/dev/null 2>&1; then
openssl_bin_PATH="${withval}/bin${PATH_SEPARATOR}${PATH}"
elif test -x "${withval}/apps/openssl" && \
"${withval}/apps/openssl" version >/dev/null 2>&1; then
openssl_bin_PATH="${withval}/apps${PATH_SEPARATOR}${PATH}"
fi
fi fi
] ]
) )
@ -2790,8 +2818,8 @@ if test "x$openssl" = "xyes" ; then
AC_MSG_RESULT([$ssl_header_ver]) AC_MSG_RESULT([$ssl_header_ver])
], ],
[ [
AC_MSG_RESULT([not found]) AC_MSG_RESULT([failed])
AC_MSG_ERROR([OpenSSL version header not found.]) AC_MSG_ERROR([OpenSSL version test program failed.])
], ],
[ [
AC_MSG_WARN([cross compiling: not checking]) AC_MSG_WARN([cross compiling: not checking])
@ -2994,7 +3022,7 @@ if test "x$openssl" = "xyes" ; then
fi fi
# Check for OpenSSL without EVP_aes_{192,256}_cbc # Check for OpenSSL without EVP_aes_{192,256}_cbc
AC_MSG_CHECKING([whether OpenSSL has crippled AES support]) AC_MSG_CHECKING([whether OpenSSL lacks support for AES 192/256])
AC_LINK_IFELSE( AC_LINK_IFELSE(
[AC_LANG_PROGRAM([[ [AC_LANG_PROGRAM([[
#include <stdlib.h> #include <stdlib.h>
@ -5293,6 +5321,16 @@ AC_DEFINE_UNQUOTED([_PATH_SSH_PIDDIR], ["$piddir"],
[Specify location of ssh.pid]) [Specify location of ssh.pid])
AC_SUBST([piddir]) AC_SUBST([piddir])
AC_ARG_ENABLE([fd-passing],
[ --disable-fd-passing disable file descriptor passsing [no]],
[
if test "x$enableval" = "xno" ; then
AC_DEFINE([DISABLE_FD_PASSING])
fi
]
)
dnl allow user to disable some login recording features dnl allow user to disable some login recording features
AC_ARG_ENABLE([lastlog], AC_ARG_ENABLE([lastlog],
[ --disable-lastlog disable use of lastlog even if detected [no]], [ --disable-lastlog disable use of lastlog even if detected [no]],

View file

@ -1,4 +1,4 @@
%global ver 9.6p1 %global ver 9.7p1
%global rel 1%{?dist} %global rel 1%{?dist}
# OpenSSH privilege separation requires a user & group ID # OpenSSH privilege separation requires a user & group ID

View file

@ -13,7 +13,7 @@
Summary: OpenSSH, a free Secure Shell (SSH) protocol implementation Summary: OpenSSH, a free Secure Shell (SSH) protocol implementation
Name: openssh Name: openssh
Version: 9.6p1 Version: 9.7p1
URL: https://www.openssh.com/ URL: https://www.openssh.com/
Release: 1 Release: 1
Source0: openssh-%{version}.tar.gz Source0: openssh-%{version}.tar.gz

View file

@ -1,4 +1,4 @@
/* $OpenBSD: gss-genr.c,v 1.28 2021/01/27 10:05:28 djm Exp $ */ /* $OpenBSD: gss-genr.c,v 1.29 2024/02/01 02:37:33 djm Exp $ */
/* /*
* Copyright (c) 2001-2007 Simon Wilkinson. All rights reserved. * Copyright (c) 2001-2007 Simon Wilkinson. All rights reserved.
@ -278,7 +278,7 @@ ssh_gssapi_check_mechanism(Gssctxt **ctx, gss_OID oid, const char *host)
gss_OID_desc spnego_oid = {6, (void *)"\x2B\x06\x01\x05\x05\x02"}; gss_OID_desc spnego_oid = {6, (void *)"\x2B\x06\x01\x05\x05\x02"};
/* RFC 4462 says we MUST NOT do SPNEGO */ /* RFC 4462 says we MUST NOT do SPNEGO */
if (oid->length == spnego_oid.length && if (oid->length == spnego_oid.length &&
(memcmp(oid->elements, spnego_oid.elements, oid->length) == 0)) (memcmp(oid->elements, spnego_oid.elements, oid->length) == 0))
return 0; /* false */ return 0; /* false */
@ -286,7 +286,7 @@ ssh_gssapi_check_mechanism(Gssctxt **ctx, gss_OID oid, const char *host)
ssh_gssapi_set_oid(*ctx, oid); ssh_gssapi_set_oid(*ctx, oid);
major = ssh_gssapi_import_name(*ctx, host); major = ssh_gssapi_import_name(*ctx, host);
if (!GSS_ERROR(major)) { if (!GSS_ERROR(major)) {
major = ssh_gssapi_init_ctx(*ctx, 0, GSS_C_NO_BUFFER, &token, major = ssh_gssapi_init_ctx(*ctx, 0, GSS_C_NO_BUFFER, &token,
NULL); NULL);
gss_release_buffer(&minor, &token); gss_release_buffer(&minor, &token);
if ((*ctx)->context != GSS_C_NO_CONTEXT) if ((*ctx)->context != GSS_C_NO_CONTEXT)
@ -294,7 +294,7 @@ ssh_gssapi_check_mechanism(Gssctxt **ctx, gss_OID oid, const char *host)
GSS_C_NO_BUFFER); GSS_C_NO_BUFFER);
} }
if (GSS_ERROR(major)) if (GSS_ERROR(major))
ssh_gssapi_delete_ctx(ctx); ssh_gssapi_delete_ctx(ctx);
return (!GSS_ERROR(major)); return (!GSS_ERROR(major));

31
kex.c
View file

@ -1,4 +1,4 @@
/* $OpenBSD: kex.c,v 1.184 2023/12/18 14:45:49 djm Exp $ */ /* $OpenBSD: kex.c,v 1.185 2024/01/08 00:34:33 djm Exp $ */
/* /*
* Copyright (c) 2000, 2001 Markus Friedl. All rights reserved. * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved.
* *
@ -772,10 +772,11 @@ static int
kex_input_newkeys(int type, u_int32_t seq, struct ssh *ssh) kex_input_newkeys(int type, u_int32_t seq, struct ssh *ssh)
{ {
struct kex *kex = ssh->kex; struct kex *kex = ssh->kex;
int r; int r, initial = (kex->flags & KEX_INITIAL) != 0;
char *cp, **prop;
debug("SSH2_MSG_NEWKEYS received"); debug("SSH2_MSG_NEWKEYS received");
if (kex->ext_info_c && (kex->flags & KEX_INITIAL) != 0) if (kex->ext_info_c && initial)
ssh_dispatch_set(ssh, SSH2_MSG_EXT_INFO, &kex_input_ext_info); ssh_dispatch_set(ssh, SSH2_MSG_EXT_INFO, &kex_input_ext_info);
ssh_dispatch_set(ssh, SSH2_MSG_NEWKEYS, &kex_protocol_error); ssh_dispatch_set(ssh, SSH2_MSG_NEWKEYS, &kex_protocol_error);
ssh_dispatch_set(ssh, SSH2_MSG_KEXINIT, &kex_input_kexinit); ssh_dispatch_set(ssh, SSH2_MSG_KEXINIT, &kex_input_kexinit);
@ -783,10 +784,32 @@ kex_input_newkeys(int type, u_int32_t seq, struct ssh *ssh)
return r; return r;
if ((r = ssh_set_newkeys(ssh, MODE_IN)) != 0) if ((r = ssh_set_newkeys(ssh, MODE_IN)) != 0)
return r; return r;
if (initial) {
/* Remove initial KEX signalling from proposal for rekeying */
if ((r = kex_buf2prop(kex->my, NULL, &prop)) != 0)
return r;
if ((cp = match_filter_denylist(prop[PROPOSAL_KEX_ALGS],
kex->server ?
"ext-info-s,kex-strict-s-v00@openssh.com" :
"ext-info-c,kex-strict-c-v00@openssh.com")) == NULL) {
error_f("match_filter_denylist failed");
goto fail;
}
free(prop[PROPOSAL_KEX_ALGS]);
prop[PROPOSAL_KEX_ALGS] = cp;
if ((r = kex_prop2buf(ssh->kex->my, prop)) != 0) {
error_f("kex_prop2buf failed");
fail:
kex_proposal_free_entries(prop);
free(prop);
return SSH_ERR_INTERNAL_ERROR;
}
kex_proposal_free_entries(prop);
free(prop);
}
kex->done = 1; kex->done = 1;
kex->flags &= ~KEX_INITIAL; kex->flags &= ~KEX_INITIAL;
sshbuf_reset(kex->peer); sshbuf_reset(kex->peer);
/* sshbuf_reset(kex->my); */
kex->flags &= ~KEX_INIT_SENT; kex->flags &= ~KEX_INIT_SENT;
free(kex->name); free(kex->name);
kex->name = NULL; kex->name = NULL;

10
kex.h
View file

@ -1,4 +1,4 @@
/* $OpenBSD: kex.h,v 1.121 2023/12/18 14:45:49 djm Exp $ */ /* $OpenBSD: kex.h,v 1.122 2024/02/02 00:13:34 djm Exp $ */
/* /*
* Copyright (c) 2000, 2001 Markus Friedl. All rights reserved. * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved.
@ -109,10 +109,10 @@ enum kex_exchange {
#define KEX_INIT_SENT 0x0001 #define KEX_INIT_SENT 0x0001
#define KEX_INITIAL 0x0002 #define KEX_INITIAL 0x0002
#define KEX_HAS_PUBKEY_HOSTBOUND 0x0004 #define KEX_HAS_PUBKEY_HOSTBOUND 0x0004
#define KEX_RSA_SHA2_256_SUPPORTED 0x0008 /* only set in server for now */ #define KEX_RSA_SHA2_256_SUPPORTED 0x0008 /* only set in server for now */
#define KEX_RSA_SHA2_512_SUPPORTED 0x0010 /* only set in server for now */ #define KEX_RSA_SHA2_512_SUPPORTED 0x0010 /* only set in server for now */
#define KEX_HAS_PING 0x0020 #define KEX_HAS_PING 0x0020
#define KEX_HAS_EXT_INFO_IN_AUTH 0x0040 #define KEX_HAS_EXT_INFO_IN_AUTH 0x0040
struct sshenc { struct sshenc {
char *name; char *name;

View file

@ -20,18 +20,24 @@ char *f2(char *s, ...) {
va_end(args); va_end(args);
return strdup(ret); return strdup(ret);
} }
const char *f3(int s) {
return s ? "good" : "gooder";
}
int main(int argc, char **argv) { int main(int argc, char **argv) {
(void)argv;
char b[256], *cp; char b[256], *cp;
const char *s;
/* Some math to catch -ftrapv problems in the toolchain */ /* Some math to catch -ftrapv problems in the toolchain */
int i = 123 * argc, j = 456 + argc, k = 789 - argc; int i = 123 * argc, j = 456 + argc, k = 789 - argc;
float l = i * 2.1; float l = i * 2.1;
double m = l / 0.5; double m = l / 0.5;
long long int n = argc * 12345LL, o = 12345LL * (long long int)argc; long long int n = argc * 12345LL, o = 12345LL * (long long int)argc;
(void)argv;
f(1); f(1);
snprintf(b, sizeof b, "%d %d %d %f %f %lld %lld\n", i,j,k,l,m,n,o); s = f3(f(2));
snprintf(b, sizeof b, "%d %d %d %f %f %lld %lld %s\n", i,j,k,l,m,n,o,s);
if (write(1, b, 0) == -1) exit(0); if (write(1, b, 0) == -1) exit(0);
cp = f2("%d %d %d %f %f %lld %lld\n", i,j,k,l,m,n,o); cp = f2("%d %d %d %f %f %lld %lld %s\n", i,j,k,l,m,n,o,s);
if (write(1, cp, 0) == -1) exit(0);
free(cp); free(cp);
/* /*
* Test fallthrough behaviour. clang 10's -Wimplicit-fallthrough does * Test fallthrough behaviour. clang 10's -Wimplicit-fallthrough does

15
misc.c
View file

@ -1,4 +1,4 @@
/* $OpenBSD: misc.c,v 1.189 2023/10/12 03:36:32 djm Exp $ */ /* $OpenBSD: misc.c,v 1.190 2024/03/04 02:16:11 djm Exp $ */
/* /*
* Copyright (c) 2000 Markus Friedl. All rights reserved. * Copyright (c) 2000 Markus Friedl. All rights reserved.
* Copyright (c) 2005-2020 Damien Miller. All rights reserved. * Copyright (c) 2005-2020 Damien Miller. All rights reserved.
@ -2644,6 +2644,19 @@ opt_array_append(const char *file, const int line, const char *directive,
opt_array_append2(file, line, directive, array, NULL, lp, s, 0); opt_array_append2(file, line, directive, array, NULL, lp, s, 0);
} }
void
opt_array_free2(char **array, int **iarray, u_int l)
{
u_int i;
if (array == NULL || l == 0)
return;
for (i = 0; i < l; i++)
free(array[i]);
free(array);
free(iarray);
}
sshsig_t sshsig_t
ssh_signal(int signum, sshsig_t handler) ssh_signal(int signum, sshsig_t handler)
{ {

3
misc.h
View file

@ -1,4 +1,4 @@
/* $OpenBSD: misc.h,v 1.106 2023/10/11 22:42:26 djm Exp $ */ /* $OpenBSD: misc.h,v 1.107 2024/03/04 02:16:11 djm Exp $ */
/* /*
* Author: Tatu Ylonen <ylo@cs.hut.fi> * Author: Tatu Ylonen <ylo@cs.hut.fi>
@ -210,6 +210,7 @@ void opt_array_append(const char *file, const int line,
void opt_array_append2(const char *file, const int line, void opt_array_append2(const char *file, const int line,
const char *directive, char ***array, int **iarray, u_int *lp, const char *directive, char ***array, int **iarray, u_int *lp,
const char *s, int i); const char *s, int i);
void opt_array_free2(char **array, int **iarray, u_int l);
struct timespec; struct timespec;
void ptimeout_init(struct timespec *pt); void ptimeout_init(struct timespec *pt);

View file

@ -71,4 +71,4 @@ STANDARDS
M. Friedl, N. Provos, and W. Simpson, Diffie-Hellman Group Exchange for M. Friedl, N. Provos, and W. Simpson, Diffie-Hellman Group Exchange for
the Secure Shell (SSH) Transport Layer Protocol, RFC 4419, March 2006. the Secure Shell (SSH) Transport Layer Protocol, RFC 4419, March 2006.
OpenBSD 7.3 April 16, 2022 OpenBSD 7.3 OpenBSD 7.5 April 16, 2022 OpenBSD 7.5

View file

@ -1,4 +1,4 @@
/* $OpenBSD: nchan.c,v 1.74 2022/02/01 23:32:51 djm Exp $ */ /* $OpenBSD: nchan.c,v 1.75 2024/02/01 02:37:33 djm Exp $ */
/* /*
* Copyright (c) 1999, 2000, 2001, 2002 Markus Friedl. All rights reserved. * Copyright (c) 1999, 2000, 2001, 2002 Markus Friedl. All rights reserved.
* *
@ -349,7 +349,7 @@ chan_is_dead(struct ssh *ssh, Channel *c, int do_send)
if (c->flags & CHAN_LOCAL) { if (c->flags & CHAN_LOCAL) {
debug2("channel %d: is dead (local)", c->self); debug2("channel %d: is dead (local)", c->self);
return 1; return 1;
} }
if (!(c->flags & CHAN_CLOSE_SENT)) { if (!(c->flags & CHAN_CLOSE_SENT)) {
if (do_send) { if (do_send) {
chan_send_close2(ssh, c); chan_send_close2(ssh, c);

View file

@ -33,6 +33,14 @@
#ifndef _GETOPT_H_ #ifndef _GETOPT_H_
#define _GETOPT_H_ #define _GETOPT_H_
#ifndef __THROW
# if defined __cplusplus
# define __THROW throw()
# else
# define __THROW
# endif
#endif
/* /*
* GNU-like getopt_long() and 4.4BSD getsubopt()/optreset extensions * GNU-like getopt_long() and 4.4BSD getsubopt()/optreset extensions
*/ */
@ -63,8 +71,8 @@ int getopt_long_only(int, char * const *, const char *,
#ifndef _GETOPT_DEFINED_ #ifndef _GETOPT_DEFINED_
#define _GETOPT_DEFINED_ #define _GETOPT_DEFINED_
int getopt(int, char * const *, const char *); int getopt(int, char * const *, const char *) __THROW;
int getsubopt(char **, char * const *, char **); int getsubopt(char **, char * const *, char **) __THROW;
extern char *optarg; /* getopt(3) external variables */ extern char *optarg; /* getopt(3) external variables */
extern int opterr; extern int opterr;

View file

@ -48,6 +48,14 @@
#include "blf.h" #include "blf.h"
#include "fnmatch.h" #include "fnmatch.h"
#ifndef __THROW
# if defined __cplusplus
# define __THROW throw()
# else
# define __THROW
# endif
#endif
#if defined(HAVE_LOGIN_CAP) && !defined(HAVE_LOGIN_GETPWCLASS) #if defined(HAVE_LOGIN_CAP) && !defined(HAVE_LOGIN_GETPWCLASS)
# include <login_cap.h> # include <login_cap.h>
# define login_getpwclass(pw) login_getclass(pw->pw_class) # define login_getpwclass(pw) login_getclass(pw->pw_class)
@ -187,7 +195,7 @@ int getgrouplist(const char *, gid_t, gid_t *, int *);
#endif #endif
#if !defined(HAVE_GETOPT) || !defined(HAVE_GETOPT_OPTRESET) #if !defined(HAVE_GETOPT) || !defined(HAVE_GETOPT_OPTRESET)
int BSDgetopt(int argc, char * const *argv, const char *opts); int BSDgetopt(int argc, char * const *argv, const char *opts) __THROW;
#include "openbsd-compat/getopt.h" #include "openbsd-compat/getopt.h"
#endif #endif

View file

@ -1,4 +1,4 @@
/* $OpenBSD: readconf.c,v 1.383 2023/10/12 02:18:18 djm Exp $ */ /* $OpenBSD: readconf.c,v 1.386 2024/03/04 04:13:18 djm Exp $ */
/* /*
* Author: Tatu Ylonen <ylo@cs.hut.fi> * Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@ -890,6 +890,20 @@ parse_token(const char *cp, const char *filename, int linenum,
return oBadOption; return oBadOption;
} }
static void
free_canon_cnames(struct allowed_cname *cnames, u_int n)
{
u_int i;
if (cnames == NULL || n == 0)
return;
for (i = 0; i < n; i++) {
free(cnames[i].source_list);
free(cnames[i].target_list);
}
free(cnames);
}
/* Multistate option parsing */ /* Multistate option parsing */
struct multistate { struct multistate {
char *key; char *key;
@ -1032,21 +1046,24 @@ process_config_line_depth(Options *options, struct passwd *pw, const char *host,
{ {
char *str, **charptr, *endofnumber, *keyword, *arg, *arg2, *p; char *str, **charptr, *endofnumber, *keyword, *arg, *arg2, *p;
char **cpptr, ***cppptr, fwdarg[256]; char **cpptr, ***cppptr, fwdarg[256];
u_int i, *uintptr, uvalue, max_entries = 0; u_int i, *uintptr, max_entries = 0;
int r, oactive, negated, opcode, *intptr, value, value2, cmdline = 0; int r, oactive, negated, opcode, *intptr, value, value2, cmdline = 0;
int remotefwd, dynamicfwd, ca_only = 0; int remotefwd, dynamicfwd, ca_only = 0, found = 0;
LogLevel *log_level_ptr; LogLevel *log_level_ptr;
SyslogFacility *log_facility_ptr; SyslogFacility *log_facility_ptr;
long long val64; long long val64;
size_t len; size_t len;
struct Forward fwd; struct Forward fwd;
const struct multistate *multistate_ptr; const struct multistate *multistate_ptr;
struct allowed_cname *cname;
glob_t gl; glob_t gl;
const char *errstr; const char *errstr;
char **oav = NULL, **av; char **oav = NULL, **av;
int oac = 0, ac; int oac = 0, ac;
int ret = -1; int ret = -1;
struct allowed_cname *cnames = NULL;
u_int ncnames = 0;
char **strs = NULL; /* string array arguments; freed implicitly */
u_int nstrs = 0;
if (activep == NULL) { /* We are processing a command line directive */ if (activep == NULL) { /* We are processing a command line directive */
cmdline = 1; cmdline = 1;
@ -1662,14 +1679,13 @@ process_config_line_depth(Options *options, struct passwd *pw, const char *host,
case oPermitRemoteOpen: case oPermitRemoteOpen:
uintptr = &options->num_permitted_remote_opens; uintptr = &options->num_permitted_remote_opens;
cppptr = &options->permitted_remote_opens; cppptr = &options->permitted_remote_opens;
uvalue = *uintptr; /* modified later */ found = *uintptr == 0;
i = 0;
while ((arg = argv_next(&ac, &av)) != NULL) { while ((arg = argv_next(&ac, &av)) != NULL) {
arg2 = xstrdup(arg); arg2 = xstrdup(arg);
/* Allow any/none only in first position */ /* Allow any/none only in first position */
if (strcasecmp(arg, "none") == 0 || if (strcasecmp(arg, "none") == 0 ||
strcasecmp(arg, "any") == 0) { strcasecmp(arg, "any") == 0) {
if (i > 0 || ac > 0) { if (nstrs > 0 || ac > 0) {
error("%s line %d: keyword %s \"%s\" " error("%s line %d: keyword %s \"%s\" "
"argument must appear alone.", "argument must appear alone.",
filename, linenum, keyword, arg); filename, linenum, keyword, arg);
@ -1695,17 +1711,20 @@ process_config_line_depth(Options *options, struct passwd *pw, const char *host,
lookup_opcode_name(opcode)); lookup_opcode_name(opcode));
} }
} }
if (*activep && uvalue == 0) { opt_array_append(filename, linenum,
opt_array_append(filename, linenum, lookup_opcode_name(opcode),
lookup_opcode_name(opcode), &strs, &nstrs, arg2);
cppptr, uintptr, arg2);
}
free(arg2); free(arg2);
i++;
} }
if (i == 0) if (nstrs == 0)
fatal("%s line %d: missing %s specification", fatal("%s line %d: missing %s specification",
filename, linenum, lookup_opcode_name(opcode)); filename, linenum, lookup_opcode_name(opcode));
if (found && *activep) {
*cppptr = strs;
*uintptr = nstrs;
strs = NULL; /* transferred */
nstrs = 0;
}
break; break;
case oClearAllForwardings: case oClearAllForwardings:
@ -1823,12 +1842,14 @@ process_config_line_depth(Options *options, struct passwd *pw, const char *host,
goto parse_int; goto parse_int;
case oSendEnv: case oSendEnv:
/* XXX appends to list; doesn't respect first-match-wins */
while ((arg = argv_next(&ac, &av)) != NULL) { while ((arg = argv_next(&ac, &av)) != NULL) {
if (*arg == '\0' || strchr(arg, '=') != NULL) { if (*arg == '\0' || strchr(arg, '=') != NULL) {
error("%s line %d: Invalid environment name.", error("%s line %d: Invalid environment name.",
filename, linenum); filename, linenum);
goto out; goto out;
} }
found = 1;
if (!*activep) if (!*activep)
continue; continue;
if (*arg == '-') { if (*arg == '-') {
@ -1840,27 +1861,38 @@ process_config_line_depth(Options *options, struct passwd *pw, const char *host,
lookup_opcode_name(opcode), lookup_opcode_name(opcode),
&options->send_env, &options->num_send_env, arg); &options->send_env, &options->num_send_env, arg);
} }
if (!found) {
fatal("%s line %d: no %s specified",
filename, linenum, keyword);
}
break; break;
case oSetEnv: case oSetEnv:
value = options->num_setenv; found = options->num_setenv == 0;
while ((arg = argv_next(&ac, &av)) != NULL) { while ((arg = argv_next(&ac, &av)) != NULL) {
if (strchr(arg, '=') == NULL) { if (strchr(arg, '=') == NULL) {
error("%s line %d: Invalid SetEnv.", error("%s line %d: Invalid SetEnv.",
filename, linenum); filename, linenum);
goto out; goto out;
} }
if (!*activep || value != 0) if (lookup_setenv_in_list(arg, strs, nstrs) != NULL) {
continue;
if (lookup_setenv_in_list(arg, options->setenv,
options->num_setenv) != NULL) {
debug2("%s line %d: ignoring duplicate env " debug2("%s line %d: ignoring duplicate env "
"name \"%.64s\"", filename, linenum, arg); "name \"%.64s\"", filename, linenum, arg);
continue; continue;
} }
opt_array_append(filename, linenum, opt_array_append(filename, linenum,
lookup_opcode_name(opcode), lookup_opcode_name(opcode),
&options->setenv, &options->num_setenv, arg); &strs, &nstrs, arg);
}
if (nstrs == 0) {
fatal("%s line %d: no %s specified",
filename, linenum, keyword);
}
if (found && *activep) {
options->setenv = strs;
options->num_setenv = nstrs;
strs = NULL; /* transferred */
nstrs = 0;
} }
break; break;
@ -2069,52 +2101,46 @@ process_config_line_depth(Options *options, struct passwd *pw, const char *host,
goto parse_flag; goto parse_flag;
case oCanonicalDomains: case oCanonicalDomains:
value = options->num_canonical_domains != 0; found = options->num_canonical_domains == 0;
i = 0;
while ((arg = argv_next(&ac, &av)) != NULL) { while ((arg = argv_next(&ac, &av)) != NULL) {
if (*arg == '\0') {
error("%s line %d: keyword %s empty argument",
filename, linenum, keyword);
goto out;
}
/* Allow "none" only in first position */ /* Allow "none" only in first position */
if (strcasecmp(arg, "none") == 0) { if (strcasecmp(arg, "none") == 0) {
if (i > 0 || ac > 0) { if (nstrs > 0 || ac > 0) {
error("%s line %d: keyword %s \"none\" " error("%s line %d: keyword %s \"none\" "
"argument must appear alone.", "argument must appear alone.",
filename, linenum, keyword); filename, linenum, keyword);
goto out; goto out;
} }
} }
i++;
if (!valid_domain(arg, 1, &errstr)) { if (!valid_domain(arg, 1, &errstr)) {
error("%s line %d: %s", filename, linenum, error("%s line %d: %s", filename, linenum,
errstr); errstr);
goto out; goto out;
} }
if (!*activep || value) opt_array_append(filename, linenum, keyword,
continue; &strs, &nstrs, arg);
if (options->num_canonical_domains >= }
MAX_CANON_DOMAINS) { if (nstrs == 0) {
error("%s line %d: too many hostname suffixes.", fatal("%s line %d: no %s specified",
filename, linenum); filename, linenum, keyword);
goto out; }
} if (found && *activep) {
options->canonical_domains[ options->canonical_domains = strs;
options->num_canonical_domains++] = xstrdup(arg); options->num_canonical_domains = nstrs;
strs = NULL; /* transferred */
nstrs = 0;
} }
break; break;
case oCanonicalizePermittedCNAMEs: case oCanonicalizePermittedCNAMEs:
value = options->num_permitted_cnames != 0; found = options->num_permitted_cnames == 0;
i = 0;
while ((arg = argv_next(&ac, &av)) != NULL) { while ((arg = argv_next(&ac, &av)) != NULL) {
/* /*
* Either 'none' (only in first position), '*' for * Either 'none' (only in first position), '*' for
* everything or 'list:list' * everything or 'list:list'
*/ */
if (strcasecmp(arg, "none") == 0) { if (strcasecmp(arg, "none") == 0) {
if (i > 0 || ac > 0) { if (ncnames > 0 || ac > 0) {
error("%s line %d: keyword %s \"none\" " error("%s line %d: keyword %s \"none\" "
"argument must appear alone.", "argument must appear alone.",
filename, linenum, keyword); filename, linenum, keyword);
@ -2135,20 +2161,23 @@ process_config_line_depth(Options *options, struct passwd *pw, const char *host,
*arg2 = '\0'; *arg2 = '\0';
arg2++; arg2++;
} }
i++; cnames = xrecallocarray(cnames, ncnames, ncnames + 1,
if (!*activep || value) sizeof(*cnames));
continue; cnames[ncnames].source_list = xstrdup(arg);
if (options->num_permitted_cnames >= cnames[ncnames].target_list = xstrdup(arg2);
MAX_CANON_DOMAINS) { ncnames++;
error("%s line %d: too many permitted CNAMEs.",
filename, linenum);
goto out;
}
cname = options->permitted_cnames +
options->num_permitted_cnames++;
cname->source_list = xstrdup(arg);
cname->target_list = xstrdup(arg2);
} }
if (ncnames == 0) {
fatal("%s line %d: no %s specified",
filename, linenum, keyword);
}
if (found && *activep) {
options->permitted_cnames = cnames;
options->num_permitted_cnames = ncnames;
cnames = NULL; /* transferred */
ncnames = 0;
}
/* un-transferred cnames is cleaned up before exit */
break; break;
case oCanonicalizeHostname: case oCanonicalizeHostname:
@ -2329,12 +2358,11 @@ process_config_line_depth(Options *options, struct passwd *pw, const char *host,
break; break;
case oChannelTimeout: case oChannelTimeout:
uvalue = options->num_channel_timeouts; found = options->num_channel_timeouts == 0;
i = 0;
while ((arg = argv_next(&ac, &av)) != NULL) { while ((arg = argv_next(&ac, &av)) != NULL) {
/* Allow "none" only in first position */ /* Allow "none" only in first position */
if (strcasecmp(arg, "none") == 0) { if (strcasecmp(arg, "none") == 0) {
if (i > 0 || ac > 0) { if (nstrs > 0 || ac > 0) {
error("%s line %d: keyword %s \"none\" " error("%s line %d: keyword %s \"none\" "
"argument must appear alone.", "argument must appear alone.",
filename, linenum, keyword); filename, linenum, keyword);
@ -2345,11 +2373,18 @@ process_config_line_depth(Options *options, struct passwd *pw, const char *host,
fatal("%s line %d: invalid channel timeout %s", fatal("%s line %d: invalid channel timeout %s",
filename, linenum, arg); filename, linenum, arg);
} }
if (!*activep || uvalue != 0)
continue;
opt_array_append(filename, linenum, keyword, opt_array_append(filename, linenum, keyword,
&options->channel_timeouts, &strs, &nstrs, arg);
&options->num_channel_timeouts, arg); }
if (nstrs == 0) {
fatal("%s line %d: no %s specified",
filename, linenum, keyword);
}
if (found && *activep) {
options->channel_timeouts = strs;
options->num_channel_timeouts = nstrs;
strs = NULL; /* transferred */
nstrs = 0;
} }
break; break;
@ -2381,6 +2416,8 @@ process_config_line_depth(Options *options, struct passwd *pw, const char *host,
/* success */ /* success */
ret = 0; ret = 0;
out: out:
free_canon_cnames(cnames, ncnames);
opt_array_free2(strs, NULL, nstrs);
argv_free(oav, oac); argv_free(oav, oac);
return ret; return ret;
} }
@ -2711,7 +2748,9 @@ fill_default_options(Options * options)
add_identity_file(options, "~/", add_identity_file(options, "~/",
_PATH_SSH_CLIENT_ID_ED25519_SK, 0); _PATH_SSH_CLIENT_ID_ED25519_SK, 0);
add_identity_file(options, "~/", _PATH_SSH_CLIENT_ID_XMSS, 0); add_identity_file(options, "~/", _PATH_SSH_CLIENT_ID_XMSS, 0);
#ifdef WITH_DSA
add_identity_file(options, "~/", _PATH_SSH_CLIENT_ID_DSA, 0); add_identity_file(options, "~/", _PATH_SSH_CLIENT_ID_DSA, 0);
#endif
} }
if (options->escape_char == -1) if (options->escape_char == -1)
options->escape_char = '~'; options->escape_char = '~';

View file

@ -1,4 +1,4 @@
/* $OpenBSD: readconf.h,v 1.154 2023/10/12 02:18:18 djm Exp $ */ /* $OpenBSD: readconf.h,v 1.156 2024/03/04 02:16:11 djm Exp $ */
/* /*
* Author: Tatu Ylonen <ylo@cs.hut.fi> * Author: Tatu Ylonen <ylo@cs.hut.fi>
@ -87,7 +87,7 @@ typedef struct {
char *sk_provider; /* Security key provider */ char *sk_provider; /* Security key provider */
int verify_host_key_dns; /* Verify host key using DNS */ int verify_host_key_dns; /* Verify host key using DNS */
int num_identity_files; /* Number of files for RSA/DSA identities. */ int num_identity_files; /* Number of files for identities. */
char *identity_files[SSH_MAX_IDENTITY_FILES]; char *identity_files[SSH_MAX_IDENTITY_FILES];
int identity_file_userprovided[SSH_MAX_IDENTITY_FILES]; int identity_file_userprovided[SSH_MAX_IDENTITY_FILES];
struct sshkey *identity_keys[SSH_MAX_IDENTITY_FILES]; struct sshkey *identity_keys[SSH_MAX_IDENTITY_FILES];
@ -155,12 +155,12 @@ typedef struct {
int proxy_use_fdpass; int proxy_use_fdpass;
int num_canonical_domains; int num_canonical_domains;
char *canonical_domains[MAX_CANON_DOMAINS]; char **canonical_domains;
int canonicalize_hostname; int canonicalize_hostname;
int canonicalize_max_dots; int canonicalize_max_dots;
int canonicalize_fallback_local; int canonicalize_fallback_local;
int num_permitted_cnames; int num_permitted_cnames;
struct allowed_cname permitted_cnames[MAX_CANON_DOMAINS]; struct allowed_cname *permitted_cnames;
char *revoked_host_keys; char *revoked_host_keys;

View file

@ -1,4 +1,4 @@
# $OpenBSD: Makefile,v 1.131 2023/12/18 14:50:08 djm Exp $ # $OpenBSD: Makefile,v 1.133 2024/01/11 04:50:28 djm Exp $
tests: prep file-tests t-exec unit tests: prep file-tests t-exec unit
@ -156,48 +156,67 @@ TEST_SSH_SSHKEYGEN?=ssh-keygen
CPPFLAGS=-I.. CPPFLAGS=-I..
t1: t1:
${TEST_SSH_SSHKEYGEN} -if ${.CURDIR}/rsa_ssh2.prv | diff - ${.CURDIR}/rsa_openssh.prv set -xe ; if ${TEST_SSH_SSH} -Q key | grep -q "^ssh-rsa" ; then \
tr '\n' '\r' <${.CURDIR}/rsa_ssh2.prv > ${.OBJDIR}/rsa_ssh2_cr.prv ${TEST_SSH_SSHKEYGEN} -if ${.CURDIR}/rsa_ssh2.prv | diff - ${.CURDIR}/rsa_openssh.prv ; \
${TEST_SSH_SSHKEYGEN} -if ${.OBJDIR}/rsa_ssh2_cr.prv | diff - ${.CURDIR}/rsa_openssh.prv tr '\n' '\r' <${.CURDIR}/rsa_ssh2.prv > ${.OBJDIR}/rsa_ssh2_cr.prv ; \
awk '{print $$0 "\r"}' ${.CURDIR}/rsa_ssh2.prv > ${.OBJDIR}/rsa_ssh2_crnl.prv ${TEST_SSH_SSHKEYGEN} -if ${.OBJDIR}/rsa_ssh2_cr.prv | diff - ${.CURDIR}/rsa_openssh.prv ; \
${TEST_SSH_SSHKEYGEN} -if ${.OBJDIR}/rsa_ssh2_crnl.prv | diff - ${.CURDIR}/rsa_openssh.prv awk '{print $$0 "\r"}' ${.CURDIR}/rsa_ssh2.prv > ${.OBJDIR}/rsa_ssh2_crnl.prv ; \
${TEST_SSH_SSHKEYGEN} -if ${.OBJDIR}/rsa_ssh2_crnl.prv | diff - ${.CURDIR}/rsa_openssh.prv ; \
fi
t2: t2:
cat ${.CURDIR}/rsa_openssh.prv > $(OBJ)/t2.out set -xe ; if ${TEST_SSH_SSH} -Q key | grep -q "^ssh-rsa" ; then \
chmod 600 $(OBJ)/t2.out cat ${.CURDIR}/rsa_openssh.prv > $(OBJ)/t2.out ; \
${TEST_SSH_SSHKEYGEN} -yf $(OBJ)/t2.out | diff - ${.CURDIR}/rsa_openssh.pub chmod 600 $(OBJ)/t2.out ; \
${TEST_SSH_SSHKEYGEN} -yf $(OBJ)/t2.out | diff - ${.CURDIR}/rsa_openssh.pub ; \
fi
t3: t3:
${TEST_SSH_SSHKEYGEN} -ef ${.CURDIR}/rsa_openssh.pub >$(OBJ)/t3.out set -xe ; if ${TEST_SSH_SSH} -Q key | grep -q "^ssh-rsa" ; then \
${TEST_SSH_SSHKEYGEN} -if $(OBJ)/t3.out | diff - ${.CURDIR}/rsa_openssh.pub ${TEST_SSH_SSHKEYGEN} -ef ${.CURDIR}/rsa_openssh.pub >$(OBJ)/t3.out ; \
${TEST_SSH_SSHKEYGEN} -if $(OBJ)/t3.out | diff - ${.CURDIR}/rsa_openssh.pub ; \
fi
t4: t4:
${TEST_SSH_SSHKEYGEN} -E md5 -lf ${.CURDIR}/rsa_openssh.pub |\ set -xe ; if ${TEST_SSH_SSH} -Q key | grep -q "^ssh-rsa" ; then \
awk '{print $$2}' | diff - ${.CURDIR}/t4.ok ${TEST_SSH_SSHKEYGEN} -E md5 -lf ${.CURDIR}/rsa_openssh.pub |\
awk '{print $$2}' | diff - ${.CURDIR}/t4.ok ; \
fi
t5: t5:
${TEST_SSH_SSHKEYGEN} -Bf ${.CURDIR}/rsa_openssh.pub |\ set -xe ; if ${TEST_SSH_SSH} -Q key | grep -q "^ssh-rsa" ; then \
awk '{print $$2}' | diff - ${.CURDIR}/t5.ok ${TEST_SSH_SSHKEYGEN} -Bf ${.CURDIR}/rsa_openssh.pub |\
awk '{print $$2}' | diff - ${.CURDIR}/t5.ok ; \
fi
t6: t6:
${TEST_SSH_SSHKEYGEN} -if ${.CURDIR}/dsa_ssh2.prv > $(OBJ)/t6.out1 set -xe ; if ${TEST_SSH_SSH} -Q key | grep -q "^ssh-dss" ; then \
${TEST_SSH_SSHKEYGEN} -if ${.CURDIR}/dsa_ssh2.pub > $(OBJ)/t6.out2 ${TEST_SSH_SSHKEYGEN} -if ${.CURDIR}/dsa_ssh2.prv > $(OBJ)/t6.out1 ; \
chmod 600 $(OBJ)/t6.out1 ${TEST_SSH_SSHKEYGEN} -if ${.CURDIR}/dsa_ssh2.pub > $(OBJ)/t6.out2 ; \
${TEST_SSH_SSHKEYGEN} -yf $(OBJ)/t6.out1 | diff - $(OBJ)/t6.out2 chmod 600 $(OBJ)/t6.out1 ; \
${TEST_SSH_SSHKEYGEN} -yf $(OBJ)/t6.out1 | diff - $(OBJ)/t6.out2 ; \
fi
$(OBJ)/t7.out: $(OBJ)/t7.out:
${TEST_SSH_SSHKEYGEN} -q -t rsa -N '' -f $@ set -xe ; if ${TEST_SSH_SSH} -Q key | grep -q "^ssh-dss" ; then \
${TEST_SSH_SSHKEYGEN} -q -t rsa -N '' -f $@ ; \
fi
t7: $(OBJ)/t7.out t7: $(OBJ)/t7.out
${TEST_SSH_SSHKEYGEN} -lf $(OBJ)/t7.out > /dev/null set -xe ; if ${TEST_SSH_SSH} -Q key | grep -q "^ssh-dss" ; then \
${TEST_SSH_SSHKEYGEN} -Bf $(OBJ)/t7.out > /dev/null ${TEST_SSH_SSHKEYGEN} -lf $(OBJ)/t7.out > /dev/null ; \
${TEST_SSH_SSHKEYGEN} -Bf $(OBJ)/t7.out > /dev/null ; \
fi
$(OBJ)/t8.out: $(OBJ)/t8.out:
${TEST_SSH_SSHKEYGEN} -q -t dsa -N '' -f $@ set -xe ; if ssh -Q key | grep -q "^ssh-dss" ; then \
${TEST_SSH_SSHKEYGEN} -q -t dsa -N '' -f $@ ; \
fi
t8: $(OBJ)/t8.out t8: $(OBJ)/t8.out
${TEST_SSH_SSHKEYGEN} -lf $(OBJ)/t8.out > /dev/null set -xe ; if ssh -Q key | grep -q "^ssh-dss" ; then \
${TEST_SSH_SSHKEYGEN} -Bf $(OBJ)/t8.out > /dev/null ${TEST_SSH_SSHKEYGEN} -lf $(OBJ)/t8.out > /dev/null ; \
${TEST_SSH_SSHKEYGEN} -Bf $(OBJ)/t8.out > /dev/null ; \
fi
$(OBJ)/t9.out: $(OBJ)/t9.out:
! ${TEST_SSH_SSH} -Q key-plain | grep ecdsa >/dev/null || \ ! ${TEST_SSH_SSH} -Q key-plain | grep ecdsa >/dev/null || \
@ -218,8 +237,10 @@ t10: $(OBJ)/t10.out
${TEST_SSH_SSHKEYGEN} -Bf $(OBJ)/t10.out > /dev/null ${TEST_SSH_SSHKEYGEN} -Bf $(OBJ)/t10.out > /dev/null
t11: t11:
${TEST_SSH_SSHKEYGEN} -E sha256 -lf ${.CURDIR}/rsa_openssh.pub |\ set -xe ; if ${TEST_SSH_SSH} -Q key | grep -q "^ssh-dss" ; then \
awk '{print $$2}' | diff - ${.CURDIR}/t11.ok ${TEST_SSH_SSHKEYGEN} -E sha256 -lf ${.CURDIR}/rsa_openssh.pub |\
awk '{print $$2}' | diff - ${.CURDIR}/t11.ok ; \
fi
$(OBJ)/t12.out: $(OBJ)/t12.out:
${TEST_SSH_SSHKEYGEN} -q -t ed25519 -N '' -C 'test-comment-1234' -f $@ ${TEST_SSH_SSHKEYGEN} -q -t ed25519 -N '' -C 'test-comment-1234' -f $@

View file

@ -1,10 +1,33 @@
# $OpenBSD: channel-timeout.sh,v 1.1 2023/01/06 08:07:39 djm Exp $ # $OpenBSD: channel-timeout.sh,v 1.2 2024/01/09 22:19:36 djm Exp $
# Placed in the Public Domain. # Placed in the Public Domain.
tid="channel timeout" tid="channel timeout"
# XXX not comprehensive. Still need -R -L agent X11 forwarding + interactive # XXX not comprehensive. Still need -R -L agent X11 forwarding + interactive
rm -f $OBJ/finished.* $OBJ/mux.*
MUXPATH=$OBJ/mux.$$
open_mux() {
${SSH} -nNfM -oControlPath=$MUXPATH -F $OBJ/ssh_proxy "$@" somehost ||
fatal "open mux failed"
test -e $MUXPATH || fatal "mux socket $MUXPATH not established"
}
close_mux() {
test -e $MUXPATH || fatal "mux socket $MUXPATH missing"
${SSH} -qF $OBJ/ssh_proxy -oControlPath=$MUXPATH -O exit somehost ||
fatal "could not terminate mux process"
for x in 1 2 3 4 5 6 7 8 9 10 ; do
test -e $OBJ/mux && break
sleep 1
done
test -e $MUXPATH && fatal "mux did not clean up"
}
mux_client() {
${SSH} -F $OBJ/ssh_proxy -oControlPath=$MUXPATH somehost "$@"
}
rm -f $OBJ/sshd_proxy.orig rm -f $OBJ/sshd_proxy.orig
cp $OBJ/sshd_proxy $OBJ/sshd_proxy.orig cp $OBJ/sshd_proxy $OBJ/sshd_proxy.orig
@ -24,6 +47,15 @@ if [ $r -ne 255 ]; then
fail "ssh returned unexpected error code $r" fail "ssh returned unexpected error code $r"
fi fi
verbose "command long timeout"
(cat $OBJ/sshd_proxy.orig ; echo "ChannelTimeout session:command=60") \
> $OBJ/sshd_proxy
${SSH} -F $OBJ/ssh_proxy somehost "exit 23"
r=$?
if [ $r -ne 23 ]; then
fail "ssh returned unexpected error code $r"
fi
verbose "command wildcard timeout" verbose "command wildcard timeout"
(cat $OBJ/sshd_proxy.orig ; echo "ChannelTimeout session:*=1") \ (cat $OBJ/sshd_proxy.orig ; echo "ChannelTimeout session:*=1") \
> $OBJ/sshd_proxy > $OBJ/sshd_proxy
@ -42,6 +74,45 @@ if [ $r -ne 23 ]; then
fail "ssh failed" fail "ssh failed"
fi fi
if config_defined DISABLE_FD_PASSING ; then
verbose "skipping multiplexing tests"
else
verbose "multiplexed command timeout"
(cat $OBJ/sshd_proxy.orig ; echo "ChannelTimeout session:command=1") \
> $OBJ/sshd_proxy
open_mux
mux_client "sleep 5 ; exit 23"
r=$?
if [ $r -ne 255 ]; then
fail "ssh returned unexpected error code $r"
fi
close_mux
verbose "irrelevant multiplexed command timeout"
(cat $OBJ/sshd_proxy.orig ; echo "ChannelTimeout session:shell=1") \
> $OBJ/sshd_proxy
open_mux
mux_client "sleep 5 ; exit 23"
r=$?
if [ $r -ne 23 ]; then
fail "ssh returned unexpected error code $r"
fi
close_mux
verbose "global command timeout"
(cat $OBJ/sshd_proxy.orig ; echo "ChannelTimeout global=10") \
> $OBJ/sshd_proxy
open_mux
mux_client "sleep 1 ; echo ok ; sleep 1; echo ok; sleep 60; touch $OBJ/finished.1" >/dev/null &
mux_client "sleep 60 ; touch $OBJ/finished.2" >/dev/null &
mux_client "sleep 2 ; touch $OBJ/finished.3" >/dev/null &
wait
test -f $OBJ/finished.1 && fail "first mux process completed"
test -f $OBJ/finished.2 && fail "second mux process completed"
test -f $OBJ/finished.3 || fail "third mux process did not complete"
close_mux
fi
# Set up a "slow sftp server" that sleeps before executing the real one. # Set up a "slow sftp server" that sleeps before executing the real one.
cat > $OBJ/slow-sftp-server.sh << _EOF cat > $OBJ/slow-sftp-server.sh << _EOF
#!/bin/sh #!/bin/sh
@ -88,4 +159,3 @@ if [ $r -ne 0 ]; then
fail "sftp failed" fail "sftp failed"
fi fi
cmp $DATA $COPY || fail "corrupted copy" cmp $DATA $COPY || fail "corrupted copy"

View file

@ -1,4 +1,4 @@
# $OpenBSD: dynamic-forward.sh,v 1.15 2023/01/06 08:50:33 dtucker Exp $ # $OpenBSD: dynamic-forward.sh,v 1.17 2024/03/08 11:34:10 dtucker Exp $
# Placed in the Public Domain. # Placed in the Public Domain.
tid="dynamic forwarding" tid="dynamic forwarding"
@ -20,6 +20,7 @@ start_ssh() {
arg="$2" arg="$2"
n=0 n=0
error="1" error="1"
# Use a multiplexed ssh so we can control its lifecycle.
trace "start dynamic -$direction forwarding, fork to background" trace "start dynamic -$direction forwarding, fork to background"
(cat $OBJ/ssh_config.orig ; echo "$arg") > $OBJ/ssh_config (cat $OBJ/ssh_config.orig ; echo "$arg") > $OBJ/ssh_config
${REAL_SSH} -vvvnNfF $OBJ/ssh_config -E$TEST_SSH_LOGFILE \ ${REAL_SSH} -vvvnNfF $OBJ/ssh_config -E$TEST_SSH_LOGFILE \
@ -56,9 +57,9 @@ check_socks() {
for s in 4 5; do for s in 4 5; do
for h in 127.0.0.1 localhost; do for h in 127.0.0.1 localhost; do
trace "testing ssh socks version $s host $h (-$direction)" trace "testing ssh socks version $s host $h (-$direction)"
${REAL_SSH} -q -F $OBJ/ssh_config \ ${REAL_SSH} -q -F $OBJ/ssh_config -o \
-o "ProxyCommand ${proxycmd}${s} $h $PORT 2>/dev/null" \ "ProxyCommand ${TEST_SHELL} -c '${proxycmd}${s} $h $PORT 2>/dev/null'" \
somehost cat ${DATA} > ${COPY} somehost cat ${DATA} > ${COPY}
r=$? r=$?
if [ "x$expect_success" = "xY" ] ; then if [ "x$expect_success" = "xY" ] ; then
if [ $r -ne 0 ] ; then if [ $r -ne 0 ] ; then

View file

@ -1,10 +1,10 @@
# NB. libssh and libopenbsd-compat should be built with the same sanitizer opts. # NB. libssh and libopenbsd-compat should be built with the same sanitizer opts.
CC=clang-11 CC=clang-16
CXX=clang++-11 CXX=clang++-16
FUZZ_FLAGS=-fsanitize=address,fuzzer -fno-omit-frame-pointer FUZZ_FLAGS=-fsanitize=address,fuzzer -fno-omit-frame-pointer
FUZZ_LIBS=-lFuzzer FUZZ_LIBS=-L/usr/lib/llvm-16/lib -lFuzzer
CXXFLAGS=-O2 -g -Wall -Wextra -Wno-unused-parameter -I ../../.. $(FUZZ_FLAGS) CXXFLAGS=-O2 -g -Wall -Wextra -Wno-unused-parameter -Wno-exceptions -I ../../.. $(FUZZ_FLAGS)
CFLAGS=$(CXXFLAGS) CFLAGS=$(CXXFLAGS)
LDFLAGS=-L ../../.. -L ../../../openbsd-compat -g $(FUZZ_FLAGS) LDFLAGS=-L ../../.. -L ../../../openbsd-compat -g $(FUZZ_FLAGS)
LIBS=-lssh -lopenbsd-compat -lmd -lcrypto -lfido2 -lcbor $(FUZZ_LIBS) LIBS=-lssh -lopenbsd-compat -lmd -lcrypto -lfido2 -lcbor $(FUZZ_LIBS)

View file

@ -175,3 +175,10 @@ test_one(const uint8_t* s, size_t slen)
cleanup_idtab(); cleanup_idtab();
cleanup_sockettab(); cleanup_sockettab();
} }
int
pkcs11_make_cert(const struct sshkey *priv,
const struct sshkey *certpub, struct sshkey **certprivp)
{
return -1; /* XXX */
}

View file

@ -8,8 +8,7 @@ tid="connection multiplexing"
trace "will use ProxyCommand $proxycmd" trace "will use ProxyCommand $proxycmd"
if config_defined DISABLE_FD_PASSING ; then if config_defined DISABLE_FD_PASSING ; then
echo "skipped (not supported on this platform)" skip "not supported on this platform (FD passing disabled)"
exit 0
fi fi
P=3301 # test port P=3301 # test port

View file

@ -1,24 +1,47 @@
# $OpenBSD: putty-ciphers.sh,v 1.11 2021/09/01 03:16:06 dtucker Exp $ # $OpenBSD: putty-ciphers.sh,v 1.13 2024/02/09 08:56:59 dtucker Exp $
# Placed in the Public Domain. # Placed in the Public Domain.
tid="putty ciphers" tid="putty ciphers"
if test "x$REGRESS_INTEROP_PUTTY" != "xyes" ; then puttysetup
skip "putty interop tests not enabled"
fi
# Re-enable ssh-rsa on older PuTTY versions. cp ${OBJ}/sshd_proxy ${OBJ}/sshd_proxy_bak
oldver="`${PLINK} --version | awk '/plink: Release/{if ($3<0.76)print "yes"}'`"
if [ "x$oldver" = "xyes" ]; then
echo "HostKeyAlgorithms +ssh-rsa" >> ${OBJ}/sshd_proxy
echo "PubkeyAcceptedKeyTypes +ssh-rsa" >> ${OBJ}/sshd_proxy
fi
for c in aes 3des aes128-ctr aes192-ctr aes256-ctr chacha20 ; do # Since there doesn't seem to be a way to set MACs on the PuTTY client side,
verbose "$tid: cipher $c" # we force each in turn on the server side, omitting the ones PuTTY doesn't
# support. Grepping the binary is pretty janky, but AFAIK there's no way to
# query for supported algos.
macs=""
for m in `${SSH} -Q MACs`; do
if strings "${PLINK}" | grep -E "^${m}$" >/dev/null; then
macs="${macs} ${m}"
else
trace "omitting unsupported MAC ${m}"
fi
done
ciphers=""
for c in `${SSH} -Q Ciphers`; do
if strings "${PLINK}" | grep -E "^${c}$" >/dev/null; then
ciphers="${ciphers} ${c}"
else
trace "omitting unsupported cipher ${c}"
fi
done
for c in default $ciphers; do
for m in default ${macs}; do
verbose "$tid: cipher $c mac $m"
cp ${OBJ}/.putty/sessions/localhost_proxy \ cp ${OBJ}/.putty/sessions/localhost_proxy \
${OBJ}/.putty/sessions/cipher_$c ${OBJ}/.putty/sessions/cipher_$c
echo "Cipher=$c" >> ${OBJ}/.putty/sessions/cipher_$c if [ "${c}" != "default" ]; then
echo "Cipher=$c" >> ${OBJ}/.putty/sessions/cipher_$c
fi
cp ${OBJ}/sshd_proxy_bak ${OBJ}/sshd_proxy
if [ "${m}" != "default" ]; then
echo "MACs $m" >> ${OBJ}/sshd_proxy
fi
rm -f ${COPY} rm -f ${COPY}
env HOME=$PWD ${PLINK} -load cipher_$c -batch -i ${OBJ}/putty.rsa2 \ env HOME=$PWD ${PLINK} -load cipher_$c -batch -i ${OBJ}/putty.rsa2 \
@ -27,6 +50,6 @@ for c in aes 3des aes128-ctr aes192-ctr aes256-ctr chacha20 ; do
fail "ssh cat $DATA failed" fail "ssh cat $DATA failed"
fi fi
cmp ${DATA} ${COPY} || fail "corrupted copy" cmp ${DATA} ${COPY} || fail "corrupted copy"
done
done done
rm -f ${COPY} rm -f ${COPY}

View file

@ -1,28 +1,36 @@
# $OpenBSD: putty-kex.sh,v 1.9 2021/09/01 03:16:06 dtucker Exp $ # $OpenBSD: putty-kex.sh,v 1.11 2024/02/09 08:56:59 dtucker Exp $
# Placed in the Public Domain. # Placed in the Public Domain.
tid="putty KEX" tid="putty KEX"
if test "x$REGRESS_INTEROP_PUTTY" != "xyes" ; then puttysetup
skip "putty interop tests not enabled"
fi
# Re-enable ssh-rsa on older PuTTY versions. cp ${OBJ}/sshd_proxy ${OBJ}/sshd_proxy_bak
oldver="`${PLINK} --version | awk '/plink: Release/{if ($3<0.76)print "yes"}'`"
if [ "x$oldver" = "xyes" ]; then
echo "HostKeyAlgorithms +ssh-rsa" >> ${OBJ}/sshd_proxy
echo "PubkeyAcceptedKeyTypes +ssh-rsa" >> ${OBJ}/sshd_proxy
fi
for k in dh-gex-sha1 dh-group1-sha1 dh-group14-sha1 ecdh ; do # Enable group1, which PuTTY now disables by default
verbose "$tid: kex $k" echo "KEX=dh-group1-sha1" >>${OBJ}/.putty/sessions/localhost_proxy
cp ${OBJ}/.putty/sessions/localhost_proxy \
${OBJ}/.putty/sessions/kex_$k
echo "KEX=$k" >> ${OBJ}/.putty/sessions/kex_$k
env HOME=$PWD ${PLINK} -load kex_$k -batch -i ${OBJ}/putty.rsa2 true # Grepping algos out of the binary is pretty janky, but AFAIK there's no way
if [ $? -ne 0 ]; then # to query supported algos.
fail "KEX $k failed" kex=""
for k in `$SSH -Q kex`; do
if strings "${PLINK}" | grep -E "^${k}$" >/dev/null; then
kex="${kex} ${k}"
else
trace "omitting unsupported KEX ${k}"
fi fi
done done
for k in ${kex}; do
verbose "$tid: kex $k"
cp ${OBJ}/sshd_proxy_bak ${OBJ}/sshd_proxy
echo "KexAlgorithms ${k}" >>${OBJ}/sshd_proxy
env HOME=$PWD ${PLINK} -v -load localhost_proxy -batch -i ${OBJ}/putty.rsa2 true \
2>${OBJ}/log/putty-kex-$k.log
if [ $? -ne 0 ]; then
fail "KEX $k failed"
fi
kexmsg=`grep -E '^Doing.* key exchange' ${OBJ}/log/putty-kex-$k.log`
trace putty: ${kexmsg}
done

View file

@ -1,18 +1,9 @@
# $OpenBSD: putty-transfer.sh,v 1.11 2021/09/01 03:16:06 dtucker Exp $ # $OpenBSD: putty-transfer.sh,v 1.12 2024/02/09 08:47:42 dtucker Exp $
# Placed in the Public Domain. # Placed in the Public Domain.
tid="putty transfer data" tid="putty transfer data"
if test "x$REGRESS_INTEROP_PUTTY" != "xyes" ; then puttysetup
skip "putty interop tests not enabled"
fi
# Re-enable ssh-rsa on older PuTTY versions.
oldver="`${PLINK} --version | awk '/plink: Release/{if ($3<0.76)print "yes"}'`"
if [ "x$oldver" = "xyes" ]; then
echo "HostKeyAlgorithms +ssh-rsa" >> ${OBJ}/sshd_proxy
echo "PubkeyAcceptedKeyTypes +ssh-rsa" >> ${OBJ}/sshd_proxy
fi
if [ "`${SSH} -Q compression`" = "none" ]; then if [ "`${SSH} -Q compression`" = "none" ]; then
comp="0" comp="0"

View file

@ -1,4 +1,4 @@
# $OpenBSD: test-exec.sh,v 1.105 2023/10/31 04:15:40 dtucker Exp $ # $OpenBSD: test-exec.sh,v 1.108 2024/03/08 11:34:10 dtucker Exp $
# Placed in the Public Domain. # Placed in the Public Domain.
#SUDO=sudo #SUDO=sudo
@ -104,6 +104,9 @@ DBCLIENT=/usr/local/bin/dbclient
DROPBEARKEY=/usr/local/bin/dropbearkey DROPBEARKEY=/usr/local/bin/dropbearkey
DROPBEARCONVERT=/usr/local/bin/dropbearconvert DROPBEARCONVERT=/usr/local/bin/dropbearconvert
# So we can override this in Portable.
TEST_SHELL="${TEST_SHELL:-/bin/sh}"
# Tools used by multiple tests # Tools used by multiple tests
NC=$OBJ/netcat NC=$OBJ/netcat
# Always use the one configure tells us to, even if that's empty. # Always use the one configure tells us to, even if that's empty.
@ -761,7 +764,11 @@ case "$SCRIPT" in
*) REGRESS_INTEROP_PUTTY=no ;; *) REGRESS_INTEROP_PUTTY=no ;;
esac esac
if test "$REGRESS_INTEROP_PUTTY" = "yes" ; then puttysetup() {
if test "x$REGRESS_INTEROP_PUTTY" != "xyes" ; then
skip "putty interop tests not enabled"
fi
mkdir -p ${OBJ}/.putty mkdir -p ${OBJ}/.putty
# Add a PuTTY key to authorized_keys # Add a PuTTY key to authorized_keys
@ -794,9 +801,24 @@ if test "$REGRESS_INTEROP_PUTTY" = "yes" ; then
echo "ProxyTelnetCommand=${OBJ}/sshd-log-wrapper.sh -i -f $OBJ/sshd_proxy" >> ${OBJ}/.putty/sessions/localhost_proxy echo "ProxyTelnetCommand=${OBJ}/sshd-log-wrapper.sh -i -f $OBJ/sshd_proxy" >> ${OBJ}/.putty/sessions/localhost_proxy
echo "ProxyLocalhost=1" >> ${OBJ}/.putty/sessions/localhost_proxy echo "ProxyLocalhost=1" >> ${OBJ}/.putty/sessions/localhost_proxy
PUTTYVER="`${PLINK} --version | awk '/plink: Release/{print $3}'`"
PUTTYMINORVER="`echo ${PUTTYVER} | cut -f2 -d.`"
verbose "plink version ${PUTTYVER} minor ${PUTTYMINORVER}"
# Re-enable ssh-rsa on older PuTTY versions since they don't do newer
# key types.
if [ "$PUTTYMINORVER" -lt "76" ]; then
echo "HostKeyAlgorithms +ssh-rsa" >> ${OBJ}/sshd_proxy
echo "PubkeyAcceptedKeyTypes +ssh-rsa" >> ${OBJ}/sshd_proxy
fi
if [ "$PUTTYMINORVER" -le "64" ]; then
echo "KexAlgorithms +diffie-hellman-group14-sha1" \
>>${OBJ}/sshd_proxy
fi
PUTTYDIR=${OBJ}/.putty PUTTYDIR=${OBJ}/.putty
export PUTTYDIR export PUTTYDIR
fi }
REGRESS_INTEROP_DROPBEAR=no REGRESS_INTEROP_DROPBEAR=no
if test -x "$DROPBEARKEY" -a -x "$DBCLIENT" -a -x "$DROPBEARCONVERT"; then if test -x "$DROPBEARKEY" -a -x "$DBCLIENT" -a -x "$DROPBEARCONVERT"; then

View file

@ -1,4 +1,4 @@
# $OpenBSD: Makefile.inc,v 1.15 2023/09/24 08:14:13 claudio Exp $ # $OpenBSD: Makefile.inc,v 1.16 2024/01/11 01:45:58 djm Exp $
.include <bsd.own.mk> .include <bsd.own.mk>
.include <bsd.obj.mk> .include <bsd.obj.mk>
@ -13,6 +13,11 @@ TEST_ENV?= MALLOC_OPTIONS=${MALLOC_OPTIONS}
# XXX detect from ssh binary? # XXX detect from ssh binary?
OPENSSL?= yes OPENSSL?= yes
DSAKEY?= yes
.if (${DSAKEY:L} == "yes")
CFLAGS+= -DWITH_DSA
.endif
.if (${OPENSSL:L} == "yes") .if (${OPENSSL:L} == "yes")
CFLAGS+= -DWITH_OPENSSL CFLAGS+= -DWITH_OPENSSL

View file

@ -1,4 +1,4 @@
/* $OpenBSD: test_iterate.c,v 1.8 2021/12/14 21:25:27 deraadt Exp $ */ /* $OpenBSD: test_iterate.c,v 1.9 2024/01/11 01:45:58 djm Exp $ */
/* /*
* Regress test for hostfile.h hostkeys_foreach() * Regress test for hostfile.h hostkeys_foreach()
* *
@ -94,6 +94,11 @@ check(struct hostkey_foreach_line *l, void *_ctx)
expected->no_parse_keytype == KEY_ECDSA) expected->no_parse_keytype == KEY_ECDSA)
skip = 1; skip = 1;
#endif /* OPENSSL_HAS_ECC */ #endif /* OPENSSL_HAS_ECC */
#ifndef WITH_DSA
if (expected->l.keytype == KEY_DSA ||
expected->no_parse_keytype == KEY_DSA)
skip = 1;
#endif
#ifndef WITH_OPENSSL #ifndef WITH_OPENSSL
if (expected->l.keytype == KEY_DSA || if (expected->l.keytype == KEY_DSA ||
expected->no_parse_keytype == KEY_DSA || expected->no_parse_keytype == KEY_DSA ||
@ -155,6 +160,10 @@ prepare_expected(struct expected *expected, size_t n)
if (expected[i].l.keytype == KEY_ECDSA) if (expected[i].l.keytype == KEY_ECDSA)
continue; continue;
#endif /* OPENSSL_HAS_ECC */ #endif /* OPENSSL_HAS_ECC */
#ifndef WITH_DSA
if (expected[i].l.keytype == KEY_DSA)
continue;
#endif
#ifndef WITH_OPENSSL #ifndef WITH_OPENSSL
switch (expected[i].l.keytype) { switch (expected[i].l.keytype) {
case KEY_RSA: case KEY_RSA:

View file

@ -1,4 +1,4 @@
/* $OpenBSD: test_kex.c,v 1.6 2021/12/14 21:25:27 deraadt Exp $ */ /* $OpenBSD: test_kex.c,v 1.7 2024/01/11 01:45:58 djm Exp $ */
/* /*
* Regress test KEX * Regress test KEX
* *
@ -179,7 +179,9 @@ do_kex(char *kex)
{ {
#ifdef WITH_OPENSSL #ifdef WITH_OPENSSL
do_kex_with_key(kex, KEY_RSA, 2048); do_kex_with_key(kex, KEY_RSA, 2048);
#ifdef WITH_DSA
do_kex_with_key(kex, KEY_DSA, 1024); do_kex_with_key(kex, KEY_DSA, 1024);
#endif
#ifdef OPENSSL_HAS_ECC #ifdef OPENSSL_HAS_ECC
do_kex_with_key(kex, KEY_ECDSA, 256); do_kex_with_key(kex, KEY_ECDSA, 256);
#endif /* OPENSSL_HAS_ECC */ #endif /* OPENSSL_HAS_ECC */

View file

@ -1,4 +1,4 @@
/* $OpenBSD: test_file.c,v 1.10 2021/12/14 21:25:27 deraadt Exp $ */ /* $OpenBSD: test_file.c,v 1.11 2024/01/11 01:45:58 djm Exp $ */
/* /*
* Regress test for sshkey.h key management API * Regress test for sshkey.h key management API
* *
@ -165,6 +165,7 @@ sshkey_file_tests(void)
sshkey_free(k1); sshkey_free(k1);
#ifdef WITH_DSA
TEST_START("parse DSA from private"); TEST_START("parse DSA from private");
buf = load_file("dsa_1"); buf = load_file("dsa_1");
ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf, "", &k1, NULL), 0); ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf, "", &k1, NULL), 0);
@ -255,6 +256,7 @@ sshkey_file_tests(void)
TEST_DONE(); TEST_DONE();
sshkey_free(k1); sshkey_free(k1);
#endif
#ifdef OPENSSL_HAS_ECC #ifdef OPENSSL_HAS_ECC
TEST_START("parse ECDSA from private"); TEST_START("parse ECDSA from private");

View file

@ -1,4 +1,4 @@
/* $OpenBSD: test_fuzz.c,v 1.13 2021/12/14 21:25:27 deraadt Exp $ */ /* $OpenBSD: test_fuzz.c,v 1.14 2024/01/11 01:45:58 djm Exp $ */
/* /*
* Fuzz tests for key parsing * Fuzz tests for key parsing
* *
@ -160,6 +160,7 @@ sshkey_fuzz_tests(void)
fuzz_cleanup(fuzz); fuzz_cleanup(fuzz);
TEST_DONE(); TEST_DONE();
#ifdef WITH_DSA
TEST_START("fuzz DSA private"); TEST_START("fuzz DSA private");
buf = load_file("dsa_1"); buf = load_file("dsa_1");
fuzz = fuzz_begin(FUZZ_BASE64, sshbuf_mutable_ptr(buf), fuzz = fuzz_begin(FUZZ_BASE64, sshbuf_mutable_ptr(buf),
@ -203,6 +204,7 @@ sshkey_fuzz_tests(void)
sshbuf_free(fuzzed); sshbuf_free(fuzzed);
fuzz_cleanup(fuzz); fuzz_cleanup(fuzz);
TEST_DONE(); TEST_DONE();
#endif
#ifdef OPENSSL_HAS_ECC #ifdef OPENSSL_HAS_ECC
TEST_START("fuzz ECDSA private"); TEST_START("fuzz ECDSA private");
@ -288,6 +290,7 @@ sshkey_fuzz_tests(void)
sshkey_free(k1); sshkey_free(k1);
TEST_DONE(); TEST_DONE();
#ifdef WITH_DSA
TEST_START("fuzz DSA public"); TEST_START("fuzz DSA public");
buf = load_file("dsa_1"); buf = load_file("dsa_1");
ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf, "", &k1, NULL), 0); ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf, "", &k1, NULL), 0);
@ -301,6 +304,7 @@ sshkey_fuzz_tests(void)
public_fuzz(k1); public_fuzz(k1);
sshkey_free(k1); sshkey_free(k1);
TEST_DONE(); TEST_DONE();
#endif
#ifdef OPENSSL_HAS_ECC #ifdef OPENSSL_HAS_ECC
TEST_START("fuzz ECDSA public"); TEST_START("fuzz ECDSA public");
@ -358,6 +362,7 @@ sshkey_fuzz_tests(void)
sshkey_free(k1); sshkey_free(k1);
TEST_DONE(); TEST_DONE();
#ifdef WITH_DSA
TEST_START("fuzz DSA sig"); TEST_START("fuzz DSA sig");
buf = load_file("dsa_1"); buf = load_file("dsa_1");
ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf, "", &k1, NULL), 0); ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf, "", &k1, NULL), 0);
@ -365,6 +370,7 @@ sshkey_fuzz_tests(void)
sig_fuzz(k1, NULL); sig_fuzz(k1, NULL);
sshkey_free(k1); sshkey_free(k1);
TEST_DONE(); TEST_DONE();
#endif
#ifdef OPENSSL_HAS_ECC #ifdef OPENSSL_HAS_ECC
TEST_START("fuzz ECDSA sig"); TEST_START("fuzz ECDSA sig");

View file

@ -1,4 +1,4 @@
/* $OpenBSD: test_sshkey.c,v 1.23 2023/01/04 22:48:57 tb Exp $ */ /* $OpenBSD: test_sshkey.c,v 1.24 2024/01/11 01:45:58 djm Exp $ */
/* /*
* Regress test for sshkey.h key management API * Regress test for sshkey.h key management API
* *
@ -180,14 +180,14 @@ get_private(const char *n)
void void
sshkey_tests(void) sshkey_tests(void)
{ {
struct sshkey *k1, *k2, *k3, *kf; struct sshkey *k1 = NULL, *k2 = NULL, *k3 = NULL, *kf = NULL;
#ifdef WITH_OPENSSL #ifdef WITH_OPENSSL
struct sshkey *k4, *kr, *kd; struct sshkey *k4 = NULL, *kr = NULL, *kd = NULL;
#ifdef OPENSSL_HAS_ECC #ifdef OPENSSL_HAS_ECC
struct sshkey *ke; struct sshkey *ke = NULL;
#endif /* OPENSSL_HAS_ECC */ #endif /* OPENSSL_HAS_ECC */
#endif /* WITH_OPENSSL */ #endif /* WITH_OPENSSL */
struct sshbuf *b; struct sshbuf *b = NULL;
TEST_START("new invalid"); TEST_START("new invalid");
k1 = sshkey_new(-42); k1 = sshkey_new(-42);
@ -208,12 +208,14 @@ sshkey_tests(void)
sshkey_free(k1); sshkey_free(k1);
TEST_DONE(); TEST_DONE();
#ifdef WITH_DSA
TEST_START("new/free KEY_DSA"); TEST_START("new/free KEY_DSA");
k1 = sshkey_new(KEY_DSA); k1 = sshkey_new(KEY_DSA);
ASSERT_PTR_NE(k1, NULL); ASSERT_PTR_NE(k1, NULL);
ASSERT_PTR_NE(k1->dsa, NULL); ASSERT_PTR_NE(k1->dsa, NULL);
sshkey_free(k1); sshkey_free(k1);
TEST_DONE(); TEST_DONE();
#endif
#ifdef OPENSSL_HAS_ECC #ifdef OPENSSL_HAS_ECC
TEST_START("new/free KEY_ECDSA"); TEST_START("new/free KEY_ECDSA");
@ -245,12 +247,14 @@ sshkey_tests(void)
ASSERT_PTR_EQ(k1, NULL); ASSERT_PTR_EQ(k1, NULL);
TEST_DONE(); TEST_DONE();
#ifdef WITH_DSA
TEST_START("generate KEY_DSA wrong bits"); TEST_START("generate KEY_DSA wrong bits");
ASSERT_INT_EQ(sshkey_generate(KEY_DSA, 2048, &k1), ASSERT_INT_EQ(sshkey_generate(KEY_DSA, 2048, &k1),
SSH_ERR_KEY_LENGTH); SSH_ERR_KEY_LENGTH);
ASSERT_PTR_EQ(k1, NULL); ASSERT_PTR_EQ(k1, NULL);
sshkey_free(k1); sshkey_free(k1);
TEST_DONE(); TEST_DONE();
#endif
#ifdef OPENSSL_HAS_ECC #ifdef OPENSSL_HAS_ECC
TEST_START("generate KEY_ECDSA wrong bits"); TEST_START("generate KEY_ECDSA wrong bits");
@ -273,6 +277,7 @@ sshkey_tests(void)
ASSERT_INT_EQ(BN_num_bits(rsa_n(kr)), 1024); ASSERT_INT_EQ(BN_num_bits(rsa_n(kr)), 1024);
TEST_DONE(); TEST_DONE();
#ifdef WITH_DSA
TEST_START("generate KEY_DSA"); TEST_START("generate KEY_DSA");
ASSERT_INT_EQ(sshkey_generate(KEY_DSA, 1024, &kd), 0); ASSERT_INT_EQ(sshkey_generate(KEY_DSA, 1024, &kd), 0);
ASSERT_PTR_NE(kd, NULL); ASSERT_PTR_NE(kd, NULL);
@ -280,6 +285,7 @@ sshkey_tests(void)
ASSERT_PTR_NE(dsa_g(kd), NULL); ASSERT_PTR_NE(dsa_g(kd), NULL);
ASSERT_PTR_NE(dsa_priv_key(kd), NULL); ASSERT_PTR_NE(dsa_priv_key(kd), NULL);
TEST_DONE(); TEST_DONE();
#endif
#ifdef OPENSSL_HAS_ECC #ifdef OPENSSL_HAS_ECC
TEST_START("generate KEY_ECDSA"); TEST_START("generate KEY_ECDSA");
@ -317,6 +323,7 @@ sshkey_tests(void)
sshkey_free(k1); sshkey_free(k1);
TEST_DONE(); TEST_DONE();
#ifdef WITH_DSA
TEST_START("demote KEY_DSA"); TEST_START("demote KEY_DSA");
ASSERT_INT_EQ(sshkey_from_private(kd, &k1), 0); ASSERT_INT_EQ(sshkey_from_private(kd, &k1), 0);
ASSERT_PTR_NE(k1, NULL); ASSERT_PTR_NE(k1, NULL);
@ -331,6 +338,7 @@ sshkey_tests(void)
ASSERT_INT_EQ(sshkey_equal(kd, k1), 1); ASSERT_INT_EQ(sshkey_equal(kd, k1), 1);
sshkey_free(k1); sshkey_free(k1);
TEST_DONE(); TEST_DONE();
#endif
#ifdef OPENSSL_HAS_ECC #ifdef OPENSSL_HAS_ECC
TEST_START("demote KEY_ECDSA"); TEST_START("demote KEY_ECDSA");
@ -382,9 +390,6 @@ sshkey_tests(void)
ASSERT_INT_EQ(sshkey_generate(KEY_RSA, 1024, &k1), 0); ASSERT_INT_EQ(sshkey_generate(KEY_RSA, 1024, &k1), 0);
ASSERT_INT_EQ(sshkey_equal(kr, k1), 0); ASSERT_INT_EQ(sshkey_equal(kr, k1), 0);
sshkey_free(k1); sshkey_free(k1);
ASSERT_INT_EQ(sshkey_generate(KEY_DSA, 1024, &k1), 0);
ASSERT_INT_EQ(sshkey_equal(kd, k1), 0);
sshkey_free(k1);
#ifdef OPENSSL_HAS_ECC #ifdef OPENSSL_HAS_ECC
ASSERT_INT_EQ(sshkey_generate(KEY_ECDSA, 256, &k1), 0); ASSERT_INT_EQ(sshkey_generate(KEY_ECDSA, 256, &k1), 0);
ASSERT_INT_EQ(sshkey_equal(ke, k1), 0); ASSERT_INT_EQ(sshkey_equal(ke, k1), 0);
@ -479,6 +484,7 @@ sshkey_tests(void)
sshkey_free(k2); sshkey_free(k2);
TEST_DONE(); TEST_DONE();
#ifdef WITH_DSA
TEST_START("sign and verify DSA"); TEST_START("sign and verify DSA");
k1 = get_private("dsa_1"); k1 = get_private("dsa_1");
ASSERT_INT_EQ(sshkey_load_public(test_data_file("dsa_2.pub"), &k2, ASSERT_INT_EQ(sshkey_load_public(test_data_file("dsa_2.pub"), &k2,
@ -487,6 +493,7 @@ sshkey_tests(void)
sshkey_free(k1); sshkey_free(k1);
sshkey_free(k2); sshkey_free(k2);
TEST_DONE(); TEST_DONE();
#endif
#ifdef OPENSSL_HAS_ECC #ifdef OPENSSL_HAS_ECC
TEST_START("sign and verify ECDSA"); TEST_START("sign and verify ECDSA");

View file

@ -1,4 +1,4 @@
/* $OpenBSD: tests.c,v 1.3 2021/12/14 21:25:27 deraadt Exp $ */ /* $OpenBSD: tests.c,v 1.4 2024/01/11 01:45:59 djm Exp $ */
/* /*
* Regress test for sshbuf.h buffer API * Regress test for sshbuf.h buffer API
* *
@ -103,9 +103,11 @@ tests(void)
check_sig("rsa.pub", "rsa.sig", msg, namespace); check_sig("rsa.pub", "rsa.sig", msg, namespace);
TEST_DONE(); TEST_DONE();
#ifdef WITH_DSA
TEST_START("check DSA signature"); TEST_START("check DSA signature");
check_sig("dsa.pub", "dsa.sig", msg, namespace); check_sig("dsa.pub", "dsa.sig", msg, namespace);
TEST_DONE(); TEST_DONE();
#endif
#ifdef OPENSSL_HAS_ECC #ifdef OPENSSL_HAS_ECC
TEST_START("check ECDSA signature"); TEST_START("check ECDSA signature");

2
scp.0
View file

@ -229,4 +229,4 @@ CAVEATS
requires careful quoting of any characters that have special meaning to requires careful quoting of any characters that have special meaning to
the remote shell, such as quote characters. the remote shell, such as quote characters.
OpenBSD 7.3 December 16, 2022 OpenBSD 7.3 OpenBSD 7.5 December 16, 2022 OpenBSD 7.5

View file

@ -1,4 +1,4 @@
/* $OpenBSD: servconf.c,v 1.403 2023/10/11 22:42:26 djm Exp $ */ /* $OpenBSD: servconf.c,v 1.405 2024/03/04 02:16:11 djm Exp $ */
/* /*
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
* All rights reserved * All rights reserved
@ -1298,12 +1298,12 @@ process_server_config_line_depth(ServerOptions *options, char *line,
struct include_list *includes) struct include_list *includes)
{ {
char *str, ***chararrayptr, **charptr, *arg, *arg2, *p, *keyword; char *str, ***chararrayptr, **charptr, *arg, *arg2, *p, *keyword;
int cmdline = 0, *intptr, value, value2, n, port, oactive, r, found; int cmdline = 0, *intptr, value, value2, n, port, oactive, r;
int ca_only = 0; int ca_only = 0, found = 0;
SyslogFacility *log_facility_ptr; SyslogFacility *log_facility_ptr;
LogLevel *log_level_ptr; LogLevel *log_level_ptr;
ServerOpCodes opcode; ServerOpCodes opcode;
u_int i, *uintptr, uvalue, flags = 0; u_int i, *uintptr, flags = 0;
size_t len; size_t len;
long long val64; long long val64;
const struct multistate *multistate_ptr; const struct multistate *multistate_ptr;
@ -1313,6 +1313,8 @@ process_server_config_line_depth(ServerOptions *options, char *line,
char **oav = NULL, **av; char **oav = NULL, **av;
int oac = 0, ac; int oac = 0, ac;
int ret = -1; int ret = -1;
char **strs = NULL; /* string array arguments; freed implicitly */
u_int nstrs = 0;
/* Strip trailing whitespace. Allow \f (form feed) at EOL only */ /* Strip trailing whitespace. Allow \f (form feed) at EOL only */
if ((len = strlen(line)) == 0) if ((len = strlen(line)) == 0)
@ -1775,7 +1777,6 @@ process_server_config_line_depth(ServerOptions *options, char *line,
case sLogVerbose: case sLogVerbose:
found = options->num_log_verbose == 0; found = options->num_log_verbose == 0;
i = 0;
while ((arg = argv_next(&ac, &av)) != NULL) { while ((arg = argv_next(&ac, &av)) != NULL) {
if (*arg == '\0') { if (*arg == '\0') {
error("%s line %d: keyword %s empty argument", error("%s line %d: keyword %s empty argument",
@ -1784,19 +1785,25 @@ process_server_config_line_depth(ServerOptions *options, char *line,
} }
/* Allow "none" only in first position */ /* Allow "none" only in first position */
if (strcasecmp(arg, "none") == 0) { if (strcasecmp(arg, "none") == 0) {
if (i > 0 || ac > 0) { if (nstrs > 0 || ac > 0) {
error("%s line %d: keyword %s \"none\" " error("%s line %d: keyword %s \"none\" "
"argument must appear alone.", "argument must appear alone.",
filename, linenum, keyword); filename, linenum, keyword);
goto out; goto out;
} }
} }
i++;
if (!found || !*activep)
continue;
opt_array_append(filename, linenum, keyword, opt_array_append(filename, linenum, keyword,
&options->log_verbose, &options->num_log_verbose, &strs, &nstrs, arg);
arg); }
if (nstrs == 0) {
fatal("%s line %d: no %s specified",
filename, linenum, keyword);
}
if (found && *activep) {
options->log_verbose = strs;
options->num_log_verbose = nstrs;
strs = NULL; /* transferred */
nstrs = 0;
} }
break; break;
@ -1822,16 +1829,22 @@ process_server_config_line_depth(ServerOptions *options, char *line,
chararrayptr = &options->allow_users; chararrayptr = &options->allow_users;
uintptr = &options->num_allow_users; uintptr = &options->num_allow_users;
parse_allowdenyusers: parse_allowdenyusers:
/* XXX appends to list; doesn't respect first-match-wins */
while ((arg = argv_next(&ac, &av)) != NULL) { while ((arg = argv_next(&ac, &av)) != NULL) {
if (*arg == '\0' || if (*arg == '\0' ||
match_user(NULL, NULL, NULL, arg) == -1) match_user(NULL, NULL, NULL, arg) == -1)
fatal("%s line %d: invalid %s pattern: \"%s\"", fatal("%s line %d: invalid %s pattern: \"%s\"",
filename, linenum, keyword, arg); filename, linenum, keyword, arg);
found = 1;
if (!*activep) if (!*activep)
continue; continue;
opt_array_append(filename, linenum, keyword, opt_array_append(filename, linenum, keyword,
chararrayptr, uintptr, arg); chararrayptr, uintptr, arg);
} }
if (!found) {
fatal("%s line %d: no %s specified",
filename, linenum, keyword);
}
break; break;
case sDenyUsers: case sDenyUsers:
@ -1842,16 +1855,22 @@ process_server_config_line_depth(ServerOptions *options, char *line,
case sAllowGroups: case sAllowGroups:
chararrayptr = &options->allow_groups; chararrayptr = &options->allow_groups;
uintptr = &options->num_allow_groups; uintptr = &options->num_allow_groups;
/* XXX appends to list; doesn't respect first-match-wins */
parse_allowdenygroups: parse_allowdenygroups:
while ((arg = argv_next(&ac, &av)) != NULL) { while ((arg = argv_next(&ac, &av)) != NULL) {
if (*arg == '\0') if (*arg == '\0')
fatal("%s line %d: empty %s pattern", fatal("%s line %d: empty %s pattern",
filename, linenum, keyword); filename, linenum, keyword);
found = 1;
if (!*activep) if (!*activep)
continue; continue;
opt_array_append(filename, linenum, keyword, opt_array_append(filename, linenum, keyword,
chararrayptr, uintptr, arg); chararrayptr, uintptr, arg);
} }
if (!found) {
fatal("%s line %d: no %s specified",
filename, linenum, keyword);
}
break; break;
case sDenyGroups: case sDenyGroups:
@ -1945,7 +1964,7 @@ process_server_config_line_depth(ServerOptions *options, char *line,
arg = argv_assemble(1, &arg); /* quote command correctly */ arg = argv_assemble(1, &arg); /* quote command correctly */
arg2 = argv_assemble(ac, av); /* rest of command */ arg2 = argv_assemble(ac, av); /* rest of command */
xasprintf(&options->subsystem_args[options->num_subsystems], xasprintf(&options->subsystem_args[options->num_subsystems],
"%s %s", arg, arg2); "%s%s%s", arg, *arg2 == '\0' ? "" : " ", arg2);
free(arg2); free(arg2);
argv_consume(&ac); argv_consume(&ac);
options->num_subsystems++; options->num_subsystems++;
@ -2035,7 +2054,7 @@ process_server_config_line_depth(ServerOptions *options, char *line,
* AuthorizedKeysFile /etc/ssh_keys/%u * AuthorizedKeysFile /etc/ssh_keys/%u
*/ */
case sAuthorizedKeysFile: case sAuthorizedKeysFile:
uvalue = options->num_authkeys_files; found = options->num_authkeys_files == 0;
while ((arg = argv_next(&ac, &av)) != NULL) { while ((arg = argv_next(&ac, &av)) != NULL) {
if (*arg == '\0') { if (*arg == '\0') {
error("%s line %d: keyword %s empty argument", error("%s line %d: keyword %s empty argument",
@ -2043,13 +2062,20 @@ process_server_config_line_depth(ServerOptions *options, char *line,
goto out; goto out;
} }
arg2 = tilde_expand_filename(arg, getuid()); arg2 = tilde_expand_filename(arg, getuid());
if (*activep && uvalue == 0) { opt_array_append(filename, linenum, keyword,
opt_array_append(filename, linenum, keyword, &strs, &nstrs, arg2);
&options->authorized_keys_files,
&options->num_authkeys_files, arg2);
}
free(arg2); free(arg2);
} }
if (nstrs == 0) {
fatal("%s line %d: no %s specified",
filename, linenum, keyword);
}
if (found && *activep) {
options->authorized_keys_files = strs;
options->num_authkeys_files = nstrs;
strs = NULL; /* transferred */
nstrs = 0;
}
break; break;
case sAuthorizedPrincipalsFile: case sAuthorizedPrincipalsFile:
@ -2075,34 +2101,47 @@ process_server_config_line_depth(ServerOptions *options, char *line,
goto parse_int; goto parse_int;
case sAcceptEnv: case sAcceptEnv:
/* XXX appends to list; doesn't respect first-match-wins */
while ((arg = argv_next(&ac, &av)) != NULL) { while ((arg = argv_next(&ac, &av)) != NULL) {
if (*arg == '\0' || strchr(arg, '=') != NULL) if (*arg == '\0' || strchr(arg, '=') != NULL)
fatal("%s line %d: Invalid environment name.", fatal("%s line %d: Invalid environment name.",
filename, linenum); filename, linenum);
found = 1;
if (!*activep) if (!*activep)
continue; continue;
opt_array_append(filename, linenum, keyword, opt_array_append(filename, linenum, keyword,
&options->accept_env, &options->num_accept_env, &options->accept_env, &options->num_accept_env,
arg); arg);
} }
if (!found) {
fatal("%s line %d: no %s specified",
filename, linenum, keyword);
}
break; break;
case sSetEnv: case sSetEnv:
uvalue = options->num_setenv; found = options->num_setenv == 0;
while ((arg = argv_next(&ac, &av)) != NULL) { while ((arg = argv_next(&ac, &av)) != NULL) {
if (*arg == '\0' || strchr(arg, '=') == NULL) if (*arg == '\0' || strchr(arg, '=') == NULL)
fatal("%s line %d: Invalid environment.", fatal("%s line %d: Invalid environment.",
filename, linenum); filename, linenum);
if (!*activep || uvalue != 0) if (lookup_setenv_in_list(arg, strs, nstrs) != NULL) {
continue;
if (lookup_setenv_in_list(arg, options->setenv,
options->num_setenv) != NULL) {
debug2("%s line %d: ignoring duplicate env " debug2("%s line %d: ignoring duplicate env "
"name \"%.64s\"", filename, linenum, arg); "name \"%.64s\"", filename, linenum, arg);
continue; continue;
} }
opt_array_append(filename, linenum, keyword, opt_array_append(filename, linenum, keyword,
&options->setenv, &options->num_setenv, arg); &strs, &nstrs, arg);
}
if (nstrs == 0) {
fatal("%s line %d: no %s specified",
filename, linenum, keyword);
}
if (found && *activep) {
options->setenv = strs;
options->num_setenv = nstrs;
strs = NULL; /* transferred */
nstrs = 0;
} }
break; break;
@ -2253,21 +2292,20 @@ process_server_config_line_depth(ServerOptions *options, char *line,
uintptr = &options->num_permitted_opens; uintptr = &options->num_permitted_opens;
chararrayptr = &options->permitted_opens; chararrayptr = &options->permitted_opens;
} }
arg = argv_next(&ac, &av); found = *uintptr == 0;
if (!arg || *arg == '\0') while ((arg = argv_next(&ac, &av)) != NULL) {
fatal("%s line %d: %s missing argument.", if (strcmp(arg, "any") == 0 ||
filename, linenum, keyword); strcmp(arg, "none") == 0) {
uvalue = *uintptr; /* modified later */ if (nstrs != 0) {
if (strcmp(arg, "any") == 0 || strcmp(arg, "none") == 0) { fatal("%s line %d: %s must appear "
if (*activep && uvalue == 0) { "alone on a %s line.",
*uintptr = 1; filename, linenum, arg, keyword);
*chararrayptr = xcalloc(1, }
sizeof(**chararrayptr)); opt_array_append(filename, linenum, keyword,
(*chararrayptr)[0] = xstrdup(arg); &strs, &nstrs, arg);
continue;
} }
break;
}
for (; arg != NULL && *arg != '\0'; arg = argv_next(&ac, &av)) {
if (opcode == sPermitListen && if (opcode == sPermitListen &&
strchr(arg, ':') == NULL) { strchr(arg, ':') == NULL) {
/* /*
@ -2289,12 +2327,20 @@ process_server_config_line_depth(ServerOptions *options, char *line,
fatal("%s line %d: %s bad port number", fatal("%s line %d: %s bad port number",
filename, linenum, keyword); filename, linenum, keyword);
} }
if (*activep && uvalue == 0) { opt_array_append(filename, linenum, keyword,
opt_array_append(filename, linenum, keyword, &strs, &nstrs, arg2);
chararrayptr, uintptr, arg2);
}
free(arg2); free(arg2);
} }
if (nstrs == 0) {
fatal("%s line %d: %s missing argument.",
filename, linenum, keyword);
}
if (found && *activep) {
*chararrayptr = strs;
*uintptr = nstrs;
strs = NULL; /* transferred */
nstrs = 0;
}
break; break;
case sForceCommand: case sForceCommand:
@ -2419,10 +2465,9 @@ process_server_config_line_depth(ServerOptions *options, char *line,
case sAuthenticationMethods: case sAuthenticationMethods:
found = options->num_auth_methods == 0; found = options->num_auth_methods == 0;
value = 0; /* seen "any" pseudo-method */ value = 0; /* seen "any" pseudo-method */
value2 = 0; /* successfully parsed any method */
while ((arg = argv_next(&ac, &av)) != NULL) { while ((arg = argv_next(&ac, &av)) != NULL) {
if (strcmp(arg, "any") == 0) { if (strcmp(arg, "any") == 0) {
if (options->num_auth_methods > 0) { if (nstrs > 0) {
fatal("%s line %d: \"any\" must " fatal("%s line %d: \"any\" must "
"appear alone in %s", "appear alone in %s",
filename, linenum, keyword); filename, linenum, keyword);
@ -2435,17 +2480,19 @@ process_server_config_line_depth(ServerOptions *options, char *line,
fatal("%s line %d: invalid %s method list.", fatal("%s line %d: invalid %s method list.",
filename, linenum, keyword); filename, linenum, keyword);
} }
value2 = 1;
if (!found || !*activep)
continue;
opt_array_append(filename, linenum, keyword, opt_array_append(filename, linenum, keyword,
&options->auth_methods, &strs, &nstrs, arg);
&options->num_auth_methods, arg);
} }
if (value2 == 0) { if (nstrs == 0) {
fatal("%s line %d: no %s specified", fatal("%s line %d: no %s specified",
filename, linenum, keyword); filename, linenum, keyword);
} }
if (found && *activep) {
options->auth_methods = strs;
options->num_auth_methods = nstrs;
strs = NULL; /* transferred */
nstrs = 0;
}
break; break;
case sStreamLocalBindMask: case sStreamLocalBindMask:
@ -2505,12 +2552,11 @@ process_server_config_line_depth(ServerOptions *options, char *line,
goto parse_int; goto parse_int;
case sChannelTimeout: case sChannelTimeout:
uvalue = options->num_channel_timeouts; found = options->num_channel_timeouts == 0;
i = 0;
while ((arg = argv_next(&ac, &av)) != NULL) { while ((arg = argv_next(&ac, &av)) != NULL) {
/* Allow "none" only in first position */ /* Allow "none" only in first position */
if (strcasecmp(arg, "none") == 0) { if (strcasecmp(arg, "none") == 0) {
if (i > 0 || ac > 0) { if (nstrs > 0 || ac > 0) {
error("%s line %d: keyword %s \"none\" " error("%s line %d: keyword %s \"none\" "
"argument must appear alone.", "argument must appear alone.",
filename, linenum, keyword); filename, linenum, keyword);
@ -2521,11 +2567,18 @@ process_server_config_line_depth(ServerOptions *options, char *line,
fatal("%s line %d: invalid channel timeout %s", fatal("%s line %d: invalid channel timeout %s",
filename, linenum, arg); filename, linenum, arg);
} }
if (!*activep || uvalue != 0)
continue;
opt_array_append(filename, linenum, keyword, opt_array_append(filename, linenum, keyword,
&options->channel_timeouts, &strs, &nstrs, arg);
&options->num_channel_timeouts, arg); }
if (nstrs == 0) {
fatal("%s line %d: no %s specified",
filename, linenum, keyword);
}
if (found && *activep) {
options->channel_timeouts = strs;
options->num_channel_timeouts = nstrs;
strs = NULL; /* transferred */
nstrs = 0;
} }
break; break;
@ -2565,6 +2618,7 @@ process_server_config_line_depth(ServerOptions *options, char *line,
/* success */ /* success */
ret = 0; ret = 0;
out: out:
opt_array_free2(strs, NULL, nstrs);
argv_free(oav, oac); argv_free(oav, oac);
return ret; return ret;
} }

View file

@ -1,4 +1,4 @@
/* $OpenBSD: session.c,v 1.336 2023/08/10 23:05:48 djm Exp $ */ /* $OpenBSD: session.c,v 1.337 2024/02/01 02:37:33 djm Exp $ */
/* /*
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
* All rights reserved * All rights reserved
@ -1327,7 +1327,7 @@ safely_chroot(const char *path, uid_t uid)
memcpy(component, path, cp - path); memcpy(component, path, cp - path);
component[cp - path] = '\0'; component[cp - path] = '\0';
} }
debug3_f("checking '%s'", component); debug3_f("checking '%s'", component);
if (stat(component, &st) != 0) if (stat(component, &st) != 0)

View file

@ -95,4 +95,4 @@ HISTORY
AUTHORS AUTHORS
Markus Friedl <markus@openbsd.org> Markus Friedl <markus@openbsd.org>
OpenBSD 7.3 July 27, 2021 OpenBSD 7.3 OpenBSD 7.5 July 27, 2021 OpenBSD 7.5

2
sftp.0
View file

@ -435,4 +435,4 @@ SEE ALSO
T. Ylonen and S. Lehtinen, SSH File Transfer Protocol, draft-ietf-secsh- T. Ylonen and S. Lehtinen, SSH File Transfer Protocol, draft-ietf-secsh-
filexfer-00.txt, January 2001, work in progress material. filexfer-00.txt, January 2001, work in progress material.
OpenBSD 7.3 December 16, 2022 OpenBSD 7.3 OpenBSD 7.5 December 16, 2022 OpenBSD 7.5

44
sftp.c
View file

@ -1,4 +1,4 @@
/* $OpenBSD: sftp.c,v 1.236 2023/09/10 23:12:32 djm Exp $ */ /* $OpenBSD: sftp.c,v 1.237 2024/02/01 02:37:33 djm Exp $ */
/* /*
* Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org> * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org>
* *
@ -177,24 +177,24 @@ struct CMD {
#define LOCAL 2 #define LOCAL 2
static const struct CMD cmds[] = { static const struct CMD cmds[] = {
{ "bye", I_QUIT, NOARGS, NOARGS }, { "bye", I_QUIT, NOARGS, NOARGS },
{ "cd", I_CHDIR, REMOTE, NOARGS }, { "cd", I_CHDIR, REMOTE, NOARGS },
{ "chdir", I_CHDIR, REMOTE, NOARGS }, { "chdir", I_CHDIR, REMOTE, NOARGS },
{ "chgrp", I_CHGRP, REMOTE, NOARGS }, { "chgrp", I_CHGRP, REMOTE, NOARGS },
{ "chmod", I_CHMOD, REMOTE, NOARGS }, { "chmod", I_CHMOD, REMOTE, NOARGS },
{ "chown", I_CHOWN, REMOTE, NOARGS }, { "chown", I_CHOWN, REMOTE, NOARGS },
{ "copy", I_COPY, REMOTE, LOCAL }, { "copy", I_COPY, REMOTE, LOCAL },
{ "cp", I_COPY, REMOTE, LOCAL }, { "cp", I_COPY, REMOTE, LOCAL },
{ "df", I_DF, REMOTE, NOARGS }, { "df", I_DF, REMOTE, NOARGS },
{ "dir", I_LS, REMOTE, NOARGS }, { "dir", I_LS, REMOTE, NOARGS },
{ "exit", I_QUIT, NOARGS, NOARGS }, { "exit", I_QUIT, NOARGS, NOARGS },
{ "get", I_GET, REMOTE, LOCAL }, { "get", I_GET, REMOTE, LOCAL },
{ "help", I_HELP, NOARGS, NOARGS }, { "help", I_HELP, NOARGS, NOARGS },
{ "lcd", I_LCHDIR, LOCAL, NOARGS }, { "lcd", I_LCHDIR, LOCAL, NOARGS },
{ "lchdir", I_LCHDIR, LOCAL, NOARGS }, { "lchdir", I_LCHDIR, LOCAL, NOARGS },
{ "lls", I_LLS, LOCAL, NOARGS }, { "lls", I_LLS, LOCAL, NOARGS },
{ "lmkdir", I_LMKDIR, LOCAL, NOARGS }, { "lmkdir", I_LMKDIR, LOCAL, NOARGS },
{ "ln", I_LINK, REMOTE, REMOTE }, { "ln", I_LINK, REMOTE, REMOTE },
{ "lpwd", I_LPWD, LOCAL, NOARGS }, { "lpwd", I_LPWD, LOCAL, NOARGS },
{ "ls", I_LS, REMOTE, NOARGS }, { "ls", I_LS, REMOTE, NOARGS },
{ "lumask", I_LUMASK, NOARGS, NOARGS }, { "lumask", I_LUMASK, NOARGS, NOARGS },
@ -203,17 +203,17 @@ static const struct CMD cmds[] = {
{ "mput", I_PUT, LOCAL, REMOTE }, { "mput", I_PUT, LOCAL, REMOTE },
{ "progress", I_PROGRESS, NOARGS, NOARGS }, { "progress", I_PROGRESS, NOARGS, NOARGS },
{ "put", I_PUT, LOCAL, REMOTE }, { "put", I_PUT, LOCAL, REMOTE },
{ "pwd", I_PWD, REMOTE, NOARGS }, { "pwd", I_PWD, REMOTE, NOARGS },
{ "quit", I_QUIT, NOARGS, NOARGS }, { "quit", I_QUIT, NOARGS, NOARGS },
{ "reget", I_REGET, REMOTE, LOCAL }, { "reget", I_REGET, REMOTE, LOCAL },
{ "rename", I_RENAME, REMOTE, REMOTE }, { "rename", I_RENAME, REMOTE, REMOTE },
{ "reput", I_REPUT, LOCAL, REMOTE }, { "reput", I_REPUT, LOCAL, REMOTE },
{ "rm", I_RM, REMOTE, NOARGS }, { "rm", I_RM, REMOTE, NOARGS },
{ "rmdir", I_RMDIR, REMOTE, NOARGS }, { "rmdir", I_RMDIR, REMOTE, NOARGS },
{ "symlink", I_SYMLINK, REMOTE, REMOTE }, { "symlink", I_SYMLINK, REMOTE, REMOTE },
{ "version", I_VERSION, NOARGS, NOARGS }, { "version", I_VERSION, NOARGS, NOARGS },
{ "!", I_SHELL, NOARGS, NOARGS }, { "!", I_SHELL, NOARGS, NOARGS },
{ "?", I_HELP, NOARGS, NOARGS }, { "?", I_HELP, NOARGS, NOARGS },
{ NULL, -1, -1, -1 } { NULL, -1, -1, -1 }
}; };

View file

@ -4,9 +4,9 @@ NAME
ssh-add M-bM-^@M-^S adds private key identities to the OpenSSH authentication agent ssh-add M-bM-^@M-^S adds private key identities to the OpenSSH authentication agent
SYNOPSIS SYNOPSIS
ssh-add [-cCDdKkLlqvXx] [-E fingerprint_hash] [-H hostkey_file] ssh-add [-CcDdKkLlqvXx] [-E fingerprint_hash] [-H hostkey_file]
[-h destination_constraint] [-S provider] [-t life] [file ...] [-h destination_constraint] [-S provider] [-t life] [file ...]
ssh-add -s pkcs11 [-vC] [certificate ...] ssh-add -s pkcs11 [-Cv] [certificate ...]
ssh-add -e pkcs11 ssh-add -e pkcs11
ssh-add -T pubkey ... ssh-add -T pubkey ...
@ -29,15 +29,15 @@ DESCRIPTION
The options are as follows: The options are as follows:
-C When loading keys into or deleting keys from the agent, process
certificates only and skip plain keys.
-c Indicates that added identities should be subject to confirmation -c Indicates that added identities should be subject to confirmation
before being used for authentication. Confirmation is performed before being used for authentication. Confirmation is performed
by ssh-askpass(1). Successful confirmation is signaled by a zero by ssh-askpass(1). Successful confirmation is signaled by a zero
exit status from ssh-askpass(1), rather than text entered into exit status from ssh-askpass(1), rather than text entered into
the requester. the requester.
-C When loading keys into or deleting keys from the agent, process
certificates only and skip plain keys.
-D Deletes all identities from the agent. -D Deletes all identities from the agent.
-d Instead of adding identities, removes identities from the agent. -d Instead of adding identities, removes identities from the agent.
@ -207,4 +207,4 @@ AUTHORS
created OpenSSH. Markus Friedl contributed the support for SSH protocol created OpenSSH. Markus Friedl contributed the support for SSH protocol
versions 1.5 and 2.0. versions 1.5 and 2.0.
OpenBSD 7.3 December 18, 2023 OpenBSD 7.3 OpenBSD 7.5 December 19, 2023 OpenBSD 7.5

View file

@ -1,4 +1,4 @@
.\" $OpenBSD: ssh-add.1,v 1.85 2023/12/18 14:46:56 djm Exp $ .\" $OpenBSD: ssh-add.1,v 1.86 2023/12/19 06:57:34 jmc Exp $
.\" .\"
.\" Author: Tatu Ylonen <ylo@cs.hut.fi> .\" Author: Tatu Ylonen <ylo@cs.hut.fi>
.\" Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland .\" Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@ -35,7 +35,7 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\" .\"
.Dd $Mdocdate: December 18 2023 $ .Dd $Mdocdate: December 19 2023 $
.Dt SSH-ADD 1 .Dt SSH-ADD 1
.Os .Os
.Sh NAME .Sh NAME
@ -43,7 +43,7 @@
.Nd adds private key identities to the OpenSSH authentication agent .Nd adds private key identities to the OpenSSH authentication agent
.Sh SYNOPSIS .Sh SYNOPSIS
.Nm ssh-add .Nm ssh-add
.Op Fl cCDdKkLlqvXx .Op Fl CcDdKkLlqvXx
.Op Fl E Ar fingerprint_hash .Op Fl E Ar fingerprint_hash
.Op Fl H Ar hostkey_file .Op Fl H Ar hostkey_file
.Op Fl h Ar destination_constraint .Op Fl h Ar destination_constraint
@ -52,7 +52,7 @@
.Op Ar .Op Ar
.Nm ssh-add .Nm ssh-add
.Fl s Ar pkcs11 .Fl s Ar pkcs11
.Op Fl vC .Op Fl Cv
.Op Ar certificate ... .Op Ar certificate ...
.Nm ssh-add .Nm ssh-add
.Fl e Ar pkcs11 .Fl e Ar pkcs11
@ -94,6 +94,9 @@ to work.
.Pp .Pp
The options are as follows: The options are as follows:
.Bl -tag -width Ds .Bl -tag -width Ds
.It Fl C
When loading keys into or deleting keys from the agent, process
certificates only and skip plain keys.
.It Fl c .It Fl c
Indicates that added identities should be subject to confirmation before Indicates that added identities should be subject to confirmation before
being used for authentication. being used for authentication.
@ -102,9 +105,6 @@ Confirmation is performed by
Successful confirmation is signaled by a zero exit status from Successful confirmation is signaled by a zero exit status from
.Xr ssh-askpass 1 , .Xr ssh-askpass 1 ,
rather than text entered into the requester. rather than text entered into the requester.
.It Fl C
When loading keys into or deleting keys from the agent, process
certificates only and skip plain keys.
.It Fl D .It Fl D
Deletes all identities from the agent. Deletes all identities from the agent.
.It Fl d .It Fl d

View file

@ -1,4 +1,4 @@
/* $OpenBSD: ssh-add.c,v 1.169 2023/12/18 14:46:56 djm Exp $ */ /* $OpenBSD: ssh-add.c,v 1.172 2024/01/11 01:45:36 djm Exp $ */
/* /*
* Author: Tatu Ylonen <ylo@cs.hut.fi> * Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@ -85,7 +85,9 @@ static char *default_files[] = {
_PATH_SSH_CLIENT_ID_ED25519, _PATH_SSH_CLIENT_ID_ED25519,
_PATH_SSH_CLIENT_ID_ED25519_SK, _PATH_SSH_CLIENT_ID_ED25519_SK,
_PATH_SSH_CLIENT_ID_XMSS, _PATH_SSH_CLIENT_ID_XMSS,
#ifdef WITH_DSA
_PATH_SSH_CLIENT_ID_DSA, _PATH_SSH_CLIENT_ID_DSA,
#endif
NULL NULL
}; };
@ -790,13 +792,13 @@ static void
usage(void) usage(void)
{ {
fprintf(stderr, fprintf(stderr,
"usage: ssh-add [-cDdKkLlqvXx] [-E fingerprint_hash] [-H hostkey_file]\n" "usage: ssh-add [-CcDdKkLlqvXx] [-E fingerprint_hash] [-H hostkey_file]\n"
" [-h destination_constraint] [-S provider] [-t life]\n" " [-h destination_constraint] [-S provider] [-t life]\n"
#ifdef WITH_XMSS #ifdef WITH_XMSS
" [-M maxsign] [-m minleft]\n" " [-M maxsign] [-m minleft]\n"
#endif #endif
" [file ...]\n" " [file ...]\n"
" ssh-add -s pkcs11\n" " ssh-add -s pkcs11 [-Cv] [certificate ...]\n"
" ssh-add -e pkcs11\n" " ssh-add -e pkcs11\n"
" ssh-add -T pubkey ...\n" " ssh-add -T pubkey ...\n"
); );
@ -817,7 +819,7 @@ main(int argc, char **argv)
LogLevel log_level = SYSLOG_LEVEL_INFO; LogLevel log_level = SYSLOG_LEVEL_INFO;
struct sshkey *k, **certs = NULL; struct sshkey *k, **certs = NULL;
struct dest_constraint **dest_constraints = NULL; struct dest_constraint **dest_constraints = NULL;
size_t ndest_constraints = 0i, ncerts = 0; size_t ndest_constraints = 0, ncerts = 0;
/* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */ /* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */
sanitise_stdfd(); sanitise_stdfd();

View file

@ -137,4 +137,4 @@ AUTHORS
created OpenSSH. Markus Friedl contributed the support for SSH protocol created OpenSSH. Markus Friedl contributed the support for SSH protocol
versions 1.5 and 2.0. versions 1.5 and 2.0.
OpenBSD 7.3 August 10, 2023 OpenBSD 7.3 OpenBSD 7.5 August 10, 2023 OpenBSD 7.5

View file

@ -1,4 +1,4 @@
/* $OpenBSD: ssh-agent.c,v 1.303 2023/12/18 14:48:08 djm Exp $ */ /* $OpenBSD: ssh-agent.c,v 1.306 2024/03/09 05:12:13 djm Exp $ */
/* /*
* Author: Tatu Ylonen <ylo@cs.hut.fi> * Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@ -162,6 +162,8 @@ int max_fd = 0;
pid_t parent_pid = -1; pid_t parent_pid = -1;
time_t parent_alive_interval = 0; time_t parent_alive_interval = 0;
sig_atomic_t signalled = 0;
/* pid of process for which cleanup_socket is applicable */ /* pid of process for which cleanup_socket is applicable */
pid_t cleanup_pid = 0; pid_t cleanup_pid = 0;
@ -250,6 +252,7 @@ free_dest_constraints(struct dest_constraint *dcs, size_t ndcs)
free(dcs); free(dcs);
} }
#ifdef ENABLE_PKCS11
static void static void
dup_dest_constraint_hop(const struct dest_constraint_hop *dch, dup_dest_constraint_hop(const struct dest_constraint_hop *dch,
struct dest_constraint_hop *out) struct dest_constraint_hop *out)
@ -289,6 +292,7 @@ dup_dest_constraints(const struct dest_constraint *dcs, size_t ndcs)
} }
return ret; return ret;
} }
#endif /* ENABLE_PKCS11 */
#ifdef DEBUG_CONSTRAINTS #ifdef DEBUG_CONSTRAINTS
static void static void
@ -1522,10 +1526,11 @@ no_identities(SocketEntry *e)
sshbuf_free(msg); sshbuf_free(msg);
} }
#ifdef ENABLE_PKCS11
/* Add an identity to idlist; takes ownership of 'key' and 'comment' */ /* Add an identity to idlist; takes ownership of 'key' and 'comment' */
static void static void
add_p11_identity(struct sshkey *key, char *comment, const char *provider, add_p11_identity(struct sshkey *key, char *comment, const char *provider,
time_t death, int confirm, struct dest_constraint *dest_constraints, time_t death, u_int confirm, struct dest_constraint *dest_constraints,
size_t ndest_constraints) size_t ndest_constraints)
{ {
Identity *id; Identity *id;
@ -1548,7 +1553,6 @@ add_p11_identity(struct sshkey *key, char *comment, const char *provider,
idtab->nentries++; idtab->nentries++;
} }
#ifdef ENABLE_PKCS11
static void static void
process_add_smartcard_key(SocketEntry *e) process_add_smartcard_key(SocketEntry *e)
{ {
@ -2060,7 +2064,7 @@ after_poll(struct pollfd *pfd, size_t npfd, u_int maxfds)
} }
static int static int
prepare_poll(struct pollfd **pfdp, size_t *npfdp, int *timeoutp, u_int maxfds) prepare_poll(struct pollfd **pfdp, size_t *npfdp, struct timespec *timeoutp, u_int maxfds)
{ {
struct pollfd *pfd = *pfdp; struct pollfd *pfd = *pfdp;
size_t i, j, npfd = 0; size_t i, j, npfd = 0;
@ -2126,14 +2130,8 @@ prepare_poll(struct pollfd **pfdp, size_t *npfdp, int *timeoutp, u_int maxfds)
if (parent_alive_interval != 0) if (parent_alive_interval != 0)
deadline = (deadline == 0) ? parent_alive_interval : deadline = (deadline == 0) ? parent_alive_interval :
MINIMUM(deadline, parent_alive_interval); MINIMUM(deadline, parent_alive_interval);
if (deadline == 0) { if (deadline != 0)
*timeoutp = -1; /* INFTIM */ ptimeout_deadline_sec(timeoutp, deadline);
} else {
if (deadline > INT_MAX / 1000)
*timeoutp = INT_MAX / 1000;
else
*timeoutp = deadline * 1000;
}
return (1); return (1);
} }
@ -2153,17 +2151,16 @@ void
cleanup_exit(int i) cleanup_exit(int i)
{ {
cleanup_socket(); cleanup_socket();
#ifdef ENABLE_PKCS11
pkcs11_terminate();
#endif
_exit(i); _exit(i);
} }
static void static void
cleanup_handler(int sig) cleanup_handler(int sig)
{ {
cleanup_socket(); signalled = sig;
#ifdef ENABLE_PKCS11
pkcs11_terminate();
#endif
_exit(2);
} }
static void static void
@ -2207,10 +2204,11 @@ main(int ac, char **av)
char pidstrbuf[1 + 3 * sizeof pid]; char pidstrbuf[1 + 3 * sizeof pid];
size_t len; size_t len;
mode_t prev_mask; mode_t prev_mask;
int timeout = -1; /* INFTIM */ struct timespec timeout;
struct pollfd *pfd = NULL; struct pollfd *pfd = NULL;
size_t npfd = 0; size_t npfd = 0;
u_int maxfds; u_int maxfds;
sigset_t nsigset, osigset;
/* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */ /* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */
sanitise_stdfd(); sanitise_stdfd();
@ -2446,13 +2444,25 @@ main(int ac, char **av)
ssh_signal(SIGHUP, cleanup_handler); ssh_signal(SIGHUP, cleanup_handler);
ssh_signal(SIGTERM, cleanup_handler); ssh_signal(SIGTERM, cleanup_handler);
sigemptyset(&nsigset);
sigaddset(&nsigset, SIGINT);
sigaddset(&nsigset, SIGHUP);
sigaddset(&nsigset, SIGTERM);
if (pledge("stdio rpath cpath unix id proc exec", NULL) == -1) if (pledge("stdio rpath cpath unix id proc exec", NULL) == -1)
fatal("%s: pledge: %s", __progname, strerror(errno)); fatal("%s: pledge: %s", __progname, strerror(errno));
platform_pledge_agent(); platform_pledge_agent();
while (1) { while (1) {
sigprocmask(SIG_BLOCK, &nsigset, &osigset);
if (signalled != 0) {
logit("exiting on signal %d", (int)signalled);
cleanup_exit(2);
}
ptimeout_init(&timeout);
prepare_poll(&pfd, &npfd, &timeout, maxfds); prepare_poll(&pfd, &npfd, &timeout, maxfds);
result = poll(pfd, npfd, timeout); result = ppoll(pfd, npfd, ptimeout_get_tsp(&timeout), &osigset);
sigprocmask(SIG_SETMASK, &osigset, NULL);
saved_errno = errno; saved_errno = errno;
if (parent_alive_interval != 0) if (parent_alive_interval != 0)
check_parent_exists(); check_parent_exists();

View file

@ -1,4 +1,4 @@
/* $OpenBSD: ssh-dss.c,v 1.49 2023/03/05 05:34:09 dtucker Exp $ */ /* $OpenBSD: ssh-dss.c,v 1.50 2024/01/11 01:45:36 djm Exp $ */
/* /*
* Copyright (c) 2000 Markus Friedl. All rights reserved. * Copyright (c) 2000 Markus Friedl. All rights reserved.
* *
@ -25,7 +25,7 @@
#include "includes.h" #include "includes.h"
#ifdef WITH_OPENSSL #if defined(WITH_OPENSSL) && defined(WITH_DSA)
#include <sys/types.h> #include <sys/types.h>
@ -453,4 +453,5 @@ const struct sshkey_impl sshkey_dsa_cert_impl = {
/* .keybits = */ 0, /* .keybits = */ 0,
/* .funcs = */ &sshkey_dss_funcs, /* .funcs = */ &sshkey_dss_funcs,
}; };
#endif /* WITH_OPENSSL */
#endif /* WITH_OPENSSL && WITH_DSA */

View file

@ -907,4 +907,4 @@ AUTHORS
created OpenSSH. Markus Friedl contributed the support for SSH protocol created OpenSSH. Markus Friedl contributed the support for SSH protocol
versions 1.5 and 2.0. versions 1.5 and 2.0.
OpenBSD 7.3 September 4, 2023 OpenBSD 7.3 OpenBSD 7.5 September 4, 2023 OpenBSD 7.5

View file

@ -1,4 +1,4 @@
/* $OpenBSD: ssh-keygen.c,v 1.471 2023/09/04 10:29:58 job Exp $ */ /* $OpenBSD: ssh-keygen.c,v 1.472 2024/01/11 01:45:36 djm Exp $ */
/* /*
* Author: Tatu Ylonen <ylo@cs.hut.fi> * Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1994 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland * Copyright (c) 1994 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@ -262,10 +262,12 @@ ask_filename(struct passwd *pw, const char *prompt)
name = _PATH_SSH_CLIENT_ID_ED25519; name = _PATH_SSH_CLIENT_ID_ED25519;
else { else {
switch (sshkey_type_from_name(key_type_name)) { switch (sshkey_type_from_name(key_type_name)) {
#ifdef WITH_DSA
case KEY_DSA_CERT: case KEY_DSA_CERT:
case KEY_DSA: case KEY_DSA:
name = _PATH_SSH_CLIENT_ID_DSA; name = _PATH_SSH_CLIENT_ID_DSA;
break; break;
#endif
#ifdef OPENSSL_HAS_ECC #ifdef OPENSSL_HAS_ECC
case KEY_ECDSA_CERT: case KEY_ECDSA_CERT:
case KEY_ECDSA: case KEY_ECDSA:
@ -376,10 +378,12 @@ do_convert_to_pkcs8(struct sshkey *k)
if (!PEM_write_RSA_PUBKEY(stdout, k->rsa)) if (!PEM_write_RSA_PUBKEY(stdout, k->rsa))
fatal("PEM_write_RSA_PUBKEY failed"); fatal("PEM_write_RSA_PUBKEY failed");
break; break;
#ifdef WITH_DSA
case KEY_DSA: case KEY_DSA:
if (!PEM_write_DSA_PUBKEY(stdout, k->dsa)) if (!PEM_write_DSA_PUBKEY(stdout, k->dsa))
fatal("PEM_write_DSA_PUBKEY failed"); fatal("PEM_write_DSA_PUBKEY failed");
break; break;
#endif
#ifdef OPENSSL_HAS_ECC #ifdef OPENSSL_HAS_ECC
case KEY_ECDSA: case KEY_ECDSA:
if (!PEM_write_EC_PUBKEY(stdout, k->ecdsa)) if (!PEM_write_EC_PUBKEY(stdout, k->ecdsa))
@ -400,10 +404,12 @@ do_convert_to_pem(struct sshkey *k)
if (!PEM_write_RSAPublicKey(stdout, k->rsa)) if (!PEM_write_RSAPublicKey(stdout, k->rsa))
fatal("PEM_write_RSAPublicKey failed"); fatal("PEM_write_RSAPublicKey failed");
break; break;
#ifdef WITH_DSA
case KEY_DSA: case KEY_DSA:
if (!PEM_write_DSA_PUBKEY(stdout, k->dsa)) if (!PEM_write_DSA_PUBKEY(stdout, k->dsa))
fatal("PEM_write_DSA_PUBKEY failed"); fatal("PEM_write_DSA_PUBKEY failed");
break; break;
#endif
#ifdef OPENSSL_HAS_ECC #ifdef OPENSSL_HAS_ECC
case KEY_ECDSA: case KEY_ECDSA:
if (!PEM_write_EC_PUBKEY(stdout, k->ecdsa)) if (!PEM_write_EC_PUBKEY(stdout, k->ecdsa))
@ -478,8 +484,10 @@ do_convert_private_ssh2(struct sshbuf *b)
u_int magic, i1, i2, i3, i4; u_int magic, i1, i2, i3, i4;
size_t slen; size_t slen;
u_long e; u_long e;
#ifdef WITH_DSA
BIGNUM *dsa_p = NULL, *dsa_q = NULL, *dsa_g = NULL; BIGNUM *dsa_p = NULL, *dsa_q = NULL, *dsa_g = NULL;
BIGNUM *dsa_pub_key = NULL, *dsa_priv_key = NULL; BIGNUM *dsa_pub_key = NULL, *dsa_priv_key = NULL;
#endif
BIGNUM *rsa_n = NULL, *rsa_e = NULL, *rsa_d = NULL; BIGNUM *rsa_n = NULL, *rsa_e = NULL, *rsa_d = NULL;
BIGNUM *rsa_p = NULL, *rsa_q = NULL, *rsa_iqmp = NULL; BIGNUM *rsa_p = NULL, *rsa_q = NULL, *rsa_iqmp = NULL;
@ -507,10 +515,12 @@ do_convert_private_ssh2(struct sshbuf *b)
} }
free(cipher); free(cipher);
if (strstr(type, "dsa")) { if (strstr(type, "rsa")) {
ktype = KEY_DSA;
} else if (strstr(type, "rsa")) {
ktype = KEY_RSA; ktype = KEY_RSA;
#ifdef WITH_DSA
} else if (strstr(type, "dsa")) {
ktype = KEY_DSA;
#endif
} else { } else {
free(type); free(type);
return NULL; return NULL;
@ -520,6 +530,7 @@ do_convert_private_ssh2(struct sshbuf *b)
free(type); free(type);
switch (key->type) { switch (key->type) {
#ifdef WITH_DSA
case KEY_DSA: case KEY_DSA:
if ((dsa_p = BN_new()) == NULL || if ((dsa_p = BN_new()) == NULL ||
(dsa_q = BN_new()) == NULL || (dsa_q = BN_new()) == NULL ||
@ -539,6 +550,7 @@ do_convert_private_ssh2(struct sshbuf *b)
fatal_f("DSA_set0_key failed"); fatal_f("DSA_set0_key failed");
dsa_pub_key = dsa_priv_key = NULL; /* transferred */ dsa_pub_key = dsa_priv_key = NULL; /* transferred */
break; break;
#endif
case KEY_RSA: case KEY_RSA:
if ((r = sshbuf_get_u8(b, &e1)) != 0 || if ((r = sshbuf_get_u8(b, &e1)) != 0 ||
(e1 < 30 && (r = sshbuf_get_u8(b, &e2)) != 0) || (e1 < 30 && (r = sshbuf_get_u8(b, &e2)) != 0) ||
@ -702,12 +714,14 @@ do_convert_from_pkcs8(struct sshkey **k, int *private)
(*k)->type = KEY_RSA; (*k)->type = KEY_RSA;
(*k)->rsa = EVP_PKEY_get1_RSA(pubkey); (*k)->rsa = EVP_PKEY_get1_RSA(pubkey);
break; break;
#ifdef WITH_DSA
case EVP_PKEY_DSA: case EVP_PKEY_DSA:
if ((*k = sshkey_new(KEY_UNSPEC)) == NULL) if ((*k = sshkey_new(KEY_UNSPEC)) == NULL)
fatal("sshkey_new failed"); fatal("sshkey_new failed");
(*k)->type = KEY_DSA; (*k)->type = KEY_DSA;
(*k)->dsa = EVP_PKEY_get1_DSA(pubkey); (*k)->dsa = EVP_PKEY_get1_DSA(pubkey);
break; break;
#endif
#ifdef OPENSSL_HAS_ECC #ifdef OPENSSL_HAS_ECC
case EVP_PKEY_EC: case EVP_PKEY_EC:
if ((*k = sshkey_new(KEY_UNSPEC)) == NULL) if ((*k = sshkey_new(KEY_UNSPEC)) == NULL)
@ -777,10 +791,12 @@ do_convert_from(struct passwd *pw)
fprintf(stdout, "\n"); fprintf(stdout, "\n");
} else { } else {
switch (k->type) { switch (k->type) {
#ifdef WITH_DSA
case KEY_DSA: case KEY_DSA:
ok = PEM_write_DSAPrivateKey(stdout, k->dsa, NULL, ok = PEM_write_DSAPrivateKey(stdout, k->dsa, NULL,
NULL, 0, NULL, NULL); NULL, 0, NULL, NULL);
break; break;
#endif
#ifdef OPENSSL_HAS_ECC #ifdef OPENSSL_HAS_ECC
case KEY_ECDSA: case KEY_ECDSA:
ok = PEM_write_ECPrivateKey(stdout, k->ecdsa, NULL, ok = PEM_write_ECPrivateKey(stdout, k->ecdsa, NULL,
@ -3752,9 +3768,11 @@ main(int argc, char **argv)
n += do_print_resource_record(pw, n += do_print_resource_record(pw,
_PATH_HOST_RSA_KEY_FILE, rr_hostname, _PATH_HOST_RSA_KEY_FILE, rr_hostname,
print_generic, opts, nopts); print_generic, opts, nopts);
#ifdef WITH_DSA
n += do_print_resource_record(pw, n += do_print_resource_record(pw,
_PATH_HOST_DSA_KEY_FILE, rr_hostname, _PATH_HOST_DSA_KEY_FILE, rr_hostname,
print_generic, opts, nopts); print_generic, opts, nopts);
#endif
n += do_print_resource_record(pw, n += do_print_resource_record(pw,
_PATH_HOST_ECDSA_KEY_FILE, rr_hostname, _PATH_HOST_ECDSA_KEY_FILE, rr_hostname,
print_generic, opts, nopts); print_generic, opts, nopts);

View file

@ -118,4 +118,4 @@ AUTHORS
Davison <wayned@users.sourceforge.net> added support for protocol version Davison <wayned@users.sourceforge.net> added support for protocol version
2. 2.
OpenBSD 7.3 February 10, 2023 OpenBSD 7.3 OpenBSD 7.5 February 10, 2023 OpenBSD 7.5

View file

@ -1,4 +1,4 @@
/* $OpenBSD: ssh-keyscan.c,v 1.153 2023/06/21 05:06:04 djm Exp $ */ /* $OpenBSD: ssh-keyscan.c,v 1.155 2024/01/11 01:45:36 djm Exp $ */
/* /*
* Copyright 1995, 1996 by David Mazieres <dm@lcs.mit.edu>. * Copyright 1995, 1996 by David Mazieres <dm@lcs.mit.edu>.
* *
@ -504,11 +504,11 @@ congreet(int s)
/* /*
* Read the server banner as per RFC4253 section 4.2. The "SSH-" * Read the server banner as per RFC4253 section 4.2. The "SSH-"
* protocol identification string may be preceeded by an arbitrarily * protocol identification string may be preceded by an arbitrarily
* large banner which we must read and ignore. Loop while reading * large banner which we must read and ignore. Loop while reading
* newline-terminated lines until we have one starting with "SSH-". * newline-terminated lines until we have one starting with "SSH-".
* The ID string cannot be longer than 255 characters although the * The ID string cannot be longer than 255 characters although the
* preceeding banner lines may (in which case they'll be discarded * preceding banner lines may (in which case they'll be discarded
* in multiple iterations of the outer loop). * in multiple iterations of the outer loop).
*/ */
for (;;) { for (;;) {
@ -791,9 +791,11 @@ main(int argc, char **argv)
int type = sshkey_type_from_name(tname); int type = sshkey_type_from_name(tname);
switch (type) { switch (type) {
#ifdef WITH_DSA
case KEY_DSA: case KEY_DSA:
get_keytypes |= KT_DSA; get_keytypes |= KT_DSA;
break; break;
#endif
case KEY_ECDSA: case KEY_ECDSA:
get_keytypes |= KT_ECDSA; get_keytypes |= KT_ECDSA;
break; break;

View file

@ -49,4 +49,4 @@ HISTORY
AUTHORS AUTHORS
Markus Friedl <markus@openbsd.org> Markus Friedl <markus@openbsd.org>
OpenBSD 7.3 March 31, 2022 OpenBSD 7.3 OpenBSD 7.5 March 31, 2022 OpenBSD 7.5

View file

@ -1,4 +1,4 @@
/* $OpenBSD: ssh-keysign.c,v 1.71 2022/08/01 11:09:26 djm Exp $ */ /* $OpenBSD: ssh-keysign.c,v 1.73 2024/01/11 01:51:16 djm Exp $ */
/* /*
* Copyright (c) 2002 Markus Friedl. All rights reserved. * Copyright (c) 2002 Markus Friedl. All rights reserved.
* *
@ -195,9 +195,14 @@ main(int argc, char **argv)
if (fd > 2) if (fd > 2)
close(fd); close(fd);
for (i = 0; i < NUM_KEYTYPES; i++)
key_fd[i] = -1;
i = 0; i = 0;
/* XXX This really needs to read sshd_config for the paths */ /* XXX This really needs to read sshd_config for the paths */
#ifdef WITH_DSA
key_fd[i++] = open(_PATH_HOST_DSA_KEY_FILE, O_RDONLY); key_fd[i++] = open(_PATH_HOST_DSA_KEY_FILE, O_RDONLY);
#endif
key_fd[i++] = open(_PATH_HOST_ECDSA_KEY_FILE, O_RDONLY); key_fd[i++] = open(_PATH_HOST_ECDSA_KEY_FILE, O_RDONLY);
key_fd[i++] = open(_PATH_HOST_ED25519_KEY_FILE, O_RDONLY); key_fd[i++] = open(_PATH_HOST_ED25519_KEY_FILE, O_RDONLY);
key_fd[i++] = open(_PATH_HOST_XMSS_KEY_FILE, O_RDONLY); key_fd[i++] = open(_PATH_HOST_XMSS_KEY_FILE, O_RDONLY);

View file

@ -457,6 +457,7 @@ pkcs11_make_cert(const struct sshkey *priv,
RSA_set_method(ret->rsa, helper->rsa_meth); RSA_set_method(ret->rsa, helper->rsa_meth);
if (helper->nrsa++ >= INT_MAX) if (helper->nrsa++ >= INT_MAX)
fatal_f("RSA refcount error"); fatal_f("RSA refcount error");
#if defined(OPENSSL_HAS_ECC) && defined(HAVE_EC_KEY_METHOD_NEW)
} else if (priv->type == KEY_ECDSA) { } else if (priv->type == KEY_ECDSA) {
if ((helper = helper_by_ec(priv->ecdsa)) == NULL || if ((helper = helper_by_ec(priv->ecdsa)) == NULL ||
helper->fd == -1) helper->fd == -1)
@ -466,6 +467,7 @@ pkcs11_make_cert(const struct sshkey *priv,
EC_KEY_set_method(ret->ecdsa, helper->ec_meth); EC_KEY_set_method(ret->ecdsa, helper->ec_meth);
if (helper->nec++ >= INT_MAX) if (helper->nec++ >= INT_MAX)
fatal_f("EC refcount error"); fatal_f("EC refcount error");
#endif
} else } else
fatal_f("unknown key type %s", sshkey_type(priv)); fatal_f("unknown key type %s", sshkey_type(priv));

View file

@ -32,4 +32,4 @@ HISTORY
AUTHORS AUTHORS
Markus Friedl <markus@openbsd.org> Markus Friedl <markus@openbsd.org>
OpenBSD 7.3 April 29, 2022 OpenBSD 7.3 OpenBSD 7.5 April 29, 2022 OpenBSD 7.5

2
ssh.0
View file

@ -1020,4 +1020,4 @@ AUTHORS
created OpenSSH. Markus Friedl contributed the support for SSH protocol created OpenSSH. Markus Friedl contributed the support for SSH protocol
versions 1.5 and 2.0. versions 1.5 and 2.0.
OpenBSD 7.3 October 11, 2023 OpenBSD 7.3 OpenBSD 7.5 October 11, 2023 OpenBSD 7.5

6
ssh.c
View file

@ -1,4 +1,4 @@
/* $OpenBSD: ssh.c,v 1.599 2023/12/18 14:47:44 djm Exp $ */ /* $OpenBSD: ssh.c,v 1.600 2024/01/11 01:45:36 djm Exp $ */
/* /*
* Author: Tatu Ylonen <ylo@cs.hut.fi> * Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@ -1687,11 +1687,15 @@ main(int ac, char **av)
L_CERT(_PATH_HOST_ECDSA_KEY_FILE, 0); L_CERT(_PATH_HOST_ECDSA_KEY_FILE, 0);
L_CERT(_PATH_HOST_ED25519_KEY_FILE, 1); L_CERT(_PATH_HOST_ED25519_KEY_FILE, 1);
L_CERT(_PATH_HOST_RSA_KEY_FILE, 2); L_CERT(_PATH_HOST_RSA_KEY_FILE, 2);
#ifdef WITH_DSA
L_CERT(_PATH_HOST_DSA_KEY_FILE, 3); L_CERT(_PATH_HOST_DSA_KEY_FILE, 3);
#endif
L_PUBKEY(_PATH_HOST_ECDSA_KEY_FILE, 4); L_PUBKEY(_PATH_HOST_ECDSA_KEY_FILE, 4);
L_PUBKEY(_PATH_HOST_ED25519_KEY_FILE, 5); L_PUBKEY(_PATH_HOST_ED25519_KEY_FILE, 5);
L_PUBKEY(_PATH_HOST_RSA_KEY_FILE, 6); L_PUBKEY(_PATH_HOST_RSA_KEY_FILE, 6);
#ifdef WITH_DSA
L_PUBKEY(_PATH_HOST_DSA_KEY_FILE, 7); L_PUBKEY(_PATH_HOST_DSA_KEY_FILE, 7);
#endif
L_CERT(_PATH_HOST_XMSS_KEY_FILE, 8); L_CERT(_PATH_HOST_XMSS_KEY_FILE, 8);
L_PUBKEY(_PATH_HOST_XMSS_KEY_FILE, 9); L_PUBKEY(_PATH_HOST_XMSS_KEY_FILE, 9);
if (loaded == 0) if (loaded == 0)

View file

@ -1,4 +1,4 @@
/* $OpenBSD: ssh_api.c,v 1.27 2021/04/03 06:18:41 djm Exp $ */ /* $OpenBSD: ssh_api.c,v 1.28 2024/01/09 21:39:14 djm Exp $ */
/* /*
* Copyright (c) 2012 Markus Friedl. All rights reserved. * Copyright (c) 2012 Markus Friedl. All rights reserved.
* *
@ -82,6 +82,7 @@ int
ssh_init(struct ssh **sshp, int is_server, struct kex_params *kex_params) ssh_init(struct ssh **sshp, int is_server, struct kex_params *kex_params)
{ {
char *myproposal[PROPOSAL_MAX] = { KEX_CLIENT }; char *myproposal[PROPOSAL_MAX] = { KEX_CLIENT };
char *populated[PROPOSAL_MAX];
struct ssh *ssh; struct ssh *ssh;
char **proposal; char **proposal;
static int called; static int called;
@ -99,10 +100,19 @@ ssh_init(struct ssh **sshp, int is_server, struct kex_params *kex_params)
/* Initialize key exchange */ /* Initialize key exchange */
proposal = kex_params ? kex_params->proposal : myproposal; proposal = kex_params ? kex_params->proposal : myproposal;
if ((r = kex_ready(ssh, proposal)) != 0) { kex_proposal_populate_entries(ssh, populated,
proposal[PROPOSAL_KEX_ALGS],
proposal[PROPOSAL_ENC_ALGS_CTOS],
proposal[PROPOSAL_MAC_ALGS_CTOS],
proposal[PROPOSAL_COMP_ALGS_CTOS],
proposal[PROPOSAL_SERVER_HOST_KEY_ALGS]);
r = kex_ready(ssh, populated);
kex_proposal_free_entries(populated);
if (r != 0) {
ssh_free(ssh); ssh_free(ssh);
return r; return r;
} }
ssh->kex->server = is_server; ssh->kex->server = is_server;
if (is_server) { if (is_server) {
#ifdef WITH_OPENSSL #ifdef WITH_OPENSSL

View file

@ -55,11 +55,12 @@ DESCRIPTION
Match keyword are satisfied. Match conditions are specified Match keyword are satisfied. Match conditions are specified
using one or more criteria or the single token all which always using one or more criteria or the single token all which always
matches. The available criteria keywords are: canonical, final, matches. The available criteria keywords are: canonical, final,
exec, localnetwork, host, originalhost, Tag, user, and localuser. exec, localnetwork, host, originalhost, tagged, user, and
The all criteria must appear alone or immediately after canonical localuser. The all criteria must appear alone or immediately
or final. Other criteria may be combined arbitrarily. All after canonical or final. Other criteria may be combined
criteria but all, canonical, and final require an argument. arbitrarily. All criteria but all, canonical, and final require
Criteria may be negated by prepending an exclamation mark (M-bM-^@M-^X!M-bM-^@M-^Y). an argument. Criteria may be negated by prepending an
exclamation mark (M-bM-^@M-^X!M-bM-^@M-^Y).
The canonical keyword matches only when the configuration file is The canonical keyword matches only when the configuration file is
being re-parsed after hostname canonicalization (see the being re-parsed after hostname canonicalization (see the
@ -226,17 +227,23 @@ DESCRIPTION
ChannelTimeout ChannelTimeout
Specifies whether and how quickly ssh(1) should close inactive Specifies whether and how quickly ssh(1) should close inactive
channels. Timeouts are specified as one or more M-bM-^@M-^\type=intervalM-bM-^@M-^] channels. Timeouts are specified as one or more M-bM-^@M-^\type=intervalM-bM-^@M-^]
pairs separated by whitespace, where the M-bM-^@M-^\typeM-bM-^@M-^] must be a channel pairs separated by whitespace, where the M-bM-^@M-^\typeM-bM-^@M-^] must be the
type name (as described in the table below), optionally special keyword M-bM-^@M-^\globalM-bM-^@M-^] or a channel type name from the list
containing wildcard characters. below, optionally containing wildcard characters.
The timeout value M-bM-^@M-^\intervalM-bM-^@M-^] is specified in seconds or may use The timeout value M-bM-^@M-^\intervalM-bM-^@M-^] is specified in seconds or may use
any of the units documented in the TIME FORMATS section. For any of the units documented in the TIME FORMATS section. For
example, M-bM-^@M-^\session=5mM-bM-^@M-^] would cause the interactive session to example, M-bM-^@M-^\session=5mM-bM-^@M-^] would cause interactive sessions to
terminate after five minutes of inactivity. Specifying a zero terminate after five minutes of inactivity. Specifying a zero
value disables the inactivity timeout. value disables the inactivity timeout.
The available channel types include: The special timeout M-bM-^@M-^\globalM-bM-^@M-^] applies to all active channels,
taken together. Traffic on any active channel will reset the
timeout, but when the timeout expires then all open channels will
be closed. Note that this global timeout is not matched by
wildcards and must be specified explicitly.
The available channel type names include:
agent-connection agent-connection
Open connections to ssh-agent(1). Open connections to ssh-agent(1).
@ -1415,4 +1422,4 @@ AUTHORS
created OpenSSH. Markus Friedl contributed the support for SSH protocol created OpenSSH. Markus Friedl contributed the support for SSH protocol
versions 1.5 and 2.0. versions 1.5 and 2.0.
OpenBSD 7.3 October 12, 2023 OpenBSD 7.3 OpenBSD 7.5 February 21, 2024 OpenBSD 7.5

View file

@ -33,8 +33,8 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\" .\"
.\" $OpenBSD: ssh_config.5,v 1.391 2023/10/12 02:18:18 djm Exp $ .\" $OpenBSD: ssh_config.5,v 1.394 2024/02/21 06:01:13 djm Exp $
.Dd $Mdocdate: October 12 2023 $ .Dd $Mdocdate: February 21 2024 $
.Dt SSH_CONFIG 5 .Dt SSH_CONFIG 5
.Os .Os
.Sh NAME .Sh NAME
@ -144,7 +144,7 @@ The available criteria keywords are:
.Cm localnetwork , .Cm localnetwork ,
.Cm host , .Cm host ,
.Cm originalhost , .Cm originalhost ,
.Cm Tag , .Cm tagged ,
.Cm user , .Cm user ,
and and
.Cm localuser . .Cm localuser .
@ -463,8 +463,10 @@ Timeouts are specified as one or more
.Dq type=interval .Dq type=interval
pairs separated by whitespace, where the pairs separated by whitespace, where the
.Dq type .Dq type
must be a channel type name (as described in the table below), optionally must be the special keyword
containing wildcard characters. .Dq global
or a channel type name from the list below, optionally containing
wildcard characters.
.Pp .Pp
The timeout value The timeout value
.Dq interval .Dq interval
@ -473,11 +475,19 @@ is specified in seconds or may use any of the units documented in the
section. section.
For example, For example,
.Dq session=5m .Dq session=5m
would cause the interactive session to terminate after five minutes of would cause interactive sessions to terminate after five minutes of
inactivity. inactivity.
Specifying a zero value disables the inactivity timeout. Specifying a zero value disables the inactivity timeout.
.Pp .Pp
The available channel types include: The special timeout
.Dq global
applies to all active channels, taken together.
Traffic on any active channel will reset the timeout, but when the timeout
expires then all open channels will be closed.
Note that this global timeout is not matched by wildcards and must be
specified explicitly.
.Pp
The available channel type names include:
.Bl -tag -width Ds .Bl -tag -width Ds
.It Cm agent-connection .It Cm agent-connection
Open connections to Open connections to

View file

@ -1,4 +1,4 @@
/* $OpenBSD: sshbuf-getput-crypto.c,v 1.10 2022/05/25 06:03:44 djm Exp $ */ /* $OpenBSD: sshbuf-getput-crypto.c,v 1.11 2024/02/01 02:37:33 djm Exp $ */
/* /*
* Copyright (c) 2011 Damien Miller * Copyright (c) 2011 Damien Miller
* *
@ -123,7 +123,7 @@ sshbuf_get_eckey(struct sshbuf *buf, EC_KEY *v)
SSHBUF_ABORT(); SSHBUF_ABORT();
return SSH_ERR_INTERNAL_ERROR; return SSH_ERR_INTERNAL_ERROR;
} }
return 0; return 0;
} }
#endif /* OPENSSL_HAS_ECC */ #endif /* OPENSSL_HAS_ECC */

View file

@ -1,4 +1,4 @@
/* $OpenBSD: sshconnect.c,v 1.365 2023/11/20 02:50:00 djm Exp $ */ /* $OpenBSD: sshconnect.c,v 1.366 2024/01/11 01:45:36 djm Exp $ */
/* /*
* Author: Tatu Ylonen <ylo@cs.hut.fi> * Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@ -1595,7 +1595,9 @@ show_other_keys(struct hostkeys *hostkeys, struct sshkey *key)
{ {
int type[] = { int type[] = {
KEY_RSA, KEY_RSA,
#ifdef WITH_DSA
KEY_DSA, KEY_DSA,
#endif
KEY_ECDSA, KEY_ECDSA,
KEY_ED25519, KEY_ED25519,
KEY_XMSS, KEY_XMSS,

View file

@ -1,4 +1,4 @@
/* $OpenBSD: sshconnect2.c,v 1.371 2023/12/18 14:45:49 djm Exp $ */ /* $OpenBSD: sshconnect2.c,v 1.372 2024/01/08 00:34:34 djm Exp $ */
/* /*
* Copyright (c) 2000 Markus Friedl. All rights reserved. * Copyright (c) 2000 Markus Friedl. All rights reserved.
* Copyright (c) 2008 Damien Miller. All rights reserved. * Copyright (c) 2008 Damien Miller. All rights reserved.
@ -221,7 +221,7 @@ ssh_kex2(struct ssh *ssh, char *host, struct sockaddr *hostaddr, u_short port,
const struct ssh_conn_info *cinfo) const struct ssh_conn_info *cinfo)
{ {
char *myproposal[PROPOSAL_MAX]; char *myproposal[PROPOSAL_MAX];
char *s, *all_key, *hkalgs = NULL; char *all_key, *hkalgs = NULL;
int r, use_known_hosts_order = 0; int r, use_known_hosts_order = 0;
xxx_host = host; xxx_host = host;
@ -249,14 +249,12 @@ ssh_kex2(struct ssh *ssh, char *host, struct sockaddr *hostaddr, u_short port,
fatal_fr(r, "kex_assemble_namelist"); fatal_fr(r, "kex_assemble_namelist");
free(all_key); free(all_key);
if ((s = kex_names_cat(options.kex_algorithms, "ext-info-c")) == NULL)
fatal_f("kex_names_cat");
if (use_known_hosts_order) if (use_known_hosts_order)
hkalgs = order_hostkeyalgs(host, hostaddr, port, cinfo); hkalgs = order_hostkeyalgs(host, hostaddr, port, cinfo);
kex_proposal_populate_entries(ssh, myproposal, s, options.ciphers, kex_proposal_populate_entries(ssh, myproposal,
options.macs, compression_alg_list(options.compression), options.kex_algorithms, options.ciphers, options.macs,
compression_alg_list(options.compression),
hkalgs ? hkalgs : options.hostkeyalgorithms); hkalgs ? hkalgs : options.hostkeyalgorithms);
free(hkalgs); free(hkalgs);
@ -281,13 +279,7 @@ ssh_kex2(struct ssh *ssh, char *host, struct sockaddr *hostaddr, u_short port,
ssh->kex->verify_host_key=&verify_host_key_callback; ssh->kex->verify_host_key=&verify_host_key_callback;
ssh_dispatch_run_fatal(ssh, DISPATCH_BLOCK, &ssh->kex->done); ssh_dispatch_run_fatal(ssh, DISPATCH_BLOCK, &ssh->kex->done);
kex_proposal_free_entries(myproposal);
/* remove ext-info from the KEX proposals for rekeying */
free(myproposal[PROPOSAL_KEX_ALGS]);
myproposal[PROPOSAL_KEX_ALGS] =
compat_kex_proposal(ssh, options.kex_algorithms);
if ((r = kex_prop2buf(ssh->kex->my, myproposal)) != 0)
fatal_r(r, "kex_prop2buf");
#ifdef DEBUG_KEXDH #ifdef DEBUG_KEXDH
/* send 1st encrypted/maced/compressed message */ /* send 1st encrypted/maced/compressed message */
@ -297,7 +289,6 @@ ssh_kex2(struct ssh *ssh, char *host, struct sockaddr *hostaddr, u_short port,
(r = ssh_packet_write_wait(ssh)) != 0) (r = ssh_packet_write_wait(ssh)) != 0)
fatal_fr(r, "send packet"); fatal_fr(r, "send packet");
#endif #endif
kex_proposal_free_entries(myproposal);
} }
/* /*

2
sshd.0
View file

@ -683,4 +683,4 @@ AUTHORS
versions 1.5 and 2.0. Niels Provos and Markus Friedl contributed support versions 1.5 and 2.0. Niels Provos and Markus Friedl contributed support
for privilege separation. for privilege separation.
OpenBSD 7.3 September 19, 2023 OpenBSD 7.3 OpenBSD 7.5 September 19, 2023 OpenBSD 7.5

4
sshd.c
View file

@ -1,4 +1,4 @@
/* $OpenBSD: sshd.c,v 1.601 2023/12/18 14:45:49 djm Exp $ */ /* $OpenBSD: sshd.c,v 1.602 2024/01/08 00:34:34 djm Exp $ */
/* /*
* Author: Tatu Ylonen <ylo@cs.hut.fi> * Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@ -2428,6 +2428,7 @@ do_ssh2_kex(struct ssh *ssh)
kex->sign = sshd_hostkey_sign; kex->sign = sshd_hostkey_sign;
ssh_dispatch_run_fatal(ssh, DISPATCH_BLOCK, &kex->done); ssh_dispatch_run_fatal(ssh, DISPATCH_BLOCK, &kex->done);
kex_proposal_free_entries(myproposal);
#ifdef DEBUG_KEXDH #ifdef DEBUG_KEXDH
/* send 1st encrypted/maced/compressed message */ /* send 1st encrypted/maced/compressed message */
@ -2437,7 +2438,6 @@ do_ssh2_kex(struct ssh *ssh)
(r = ssh_packet_write_wait(ssh)) != 0) (r = ssh_packet_write_wait(ssh)) != 0)
fatal_fr(r, "send test"); fatal_fr(r, "send test");
#endif #endif
kex_proposal_free_entries(myproposal);
debug("KEX done"); debug("KEX done");
} }

View file

@ -229,17 +229,23 @@ DESCRIPTION
ChannelTimeout ChannelTimeout
Specifies whether and how quickly sshd(8) should close inactive Specifies whether and how quickly sshd(8) should close inactive
channels. Timeouts are specified as one or more M-bM-^@M-^\type=intervalM-bM-^@M-^] channels. Timeouts are specified as one or more M-bM-^@M-^\type=intervalM-bM-^@M-^]
pairs separated by whitespace, where the M-bM-^@M-^\typeM-bM-^@M-^] must be a channel pairs separated by whitespace, where the M-bM-^@M-^\typeM-bM-^@M-^] must be the
type name (as described in the table below), optionally special keyword M-bM-^@M-^\globalM-bM-^@M-^] or a channel type name from the list
containing wildcard characters. below, optionally containing wildcard characters.
The timeout value M-bM-^@M-^\intervalM-bM-^@M-^] is specified in seconds or may use The timeout value M-bM-^@M-^\intervalM-bM-^@M-^] is specified in seconds or may use
any of the units documented in the TIME FORMATS section. For any of the units documented in the TIME FORMATS section. For
example, M-bM-^@M-^\session:*=5mM-bM-^@M-^] would cause all sessions to terminate example, M-bM-^@M-^\session=5mM-bM-^@M-^] would cause interactive sessions to
after five minutes of inactivity. Specifying a zero value terminate after five minutes of inactivity. Specifying a zero
disables the inactivity timeout. value disables the inactivity timeout.
The available channel types include: The special timeout M-bM-^@M-^\globalM-bM-^@M-^] applies to all active channels,
taken together. Traffic on any active channel will reset the
timeout, but when the timeout expires then all open channels will
be closed. Note that this global timeout is not matched by
wildcards and must be specified explicitly.
The available channel type names include:
agent-connection agent-connection
Open connections to ssh-agent(1). Open connections to ssh-agent(1).
@ -254,15 +260,12 @@ DESCRIPTION
have been established to a sshd(8) listening on behalf of have been established to a sshd(8) listening on behalf of
a ssh(1) remote forwarding, i.e. RemoteForward. a ssh(1) remote forwarding, i.e. RemoteForward.
session:command session
Command execution sessions. The interactive main session, including shell session,
command execution, scp(1), sftp(1), etc.
session:shell tun-connection
Interactive shell sessions. Open TunnelForward connections.
session:subsystem:...
Subsystem sessions, e.g. for sftp(1), which could be
identified as session:subsystem:sftp.
x11-connection x11-connection
Open X11 forwarding sessions. Open X11 forwarding sessions.
@ -277,8 +280,7 @@ DESCRIPTION
client from requesting another channel of the same type. In client from requesting another channel of the same type. In
particular, expiring an inactive forwarding session does not particular, expiring an inactive forwarding session does not
prevent another identical forwarding from being subsequently prevent another identical forwarding from being subsequently
created. See also UnusedConnectionTimeout, which may be used in created.
conjunction with this option.
The default is not to expire channels of any type for inactivity. The default is not to expire channels of any type for inactivity.
@ -286,10 +288,10 @@ DESCRIPTION
Specifies the pathname of a directory to chroot(2) to after Specifies the pathname of a directory to chroot(2) to after
authentication. At session startup sshd(8) checks that all authentication. At session startup sshd(8) checks that all
components of the pathname are root-owned directories which are components of the pathname are root-owned directories which are
not writable by any other user or group. After the chroot, not writable by group or others. After the chroot, sshd(8)
sshd(8) changes the working directory to the user's home changes the working directory to the user's home directory.
directory. Arguments to ChrootDirectory accept the tokens Arguments to ChrootDirectory accept the tokens described in the
described in the TOKENS section. TOKENS section.
The ChrootDirectory must contain the necessary files and The ChrootDirectory must contain the necessary files and
directories to support the user's session. For an interactive directories to support the user's session. For an interactive
@ -1084,7 +1086,11 @@ DESCRIPTION
Alternately the name internal-sftp implements an in-process SFTP Alternately the name internal-sftp implements an in-process SFTP
server. This may simplify configurations using ChrootDirectory server. This may simplify configurations using ChrootDirectory
to force a different filesystem root on clients. to force a different filesystem root on clients. It accepts the
same command line arguments as sftp-server and even though it is
in-process, settings such as LogLevel or SyslogFacility do not
apply to it and must be set explicitly via command line
arguments.
By default no subsystems are defined. By default no subsystems are defined.
@ -1287,4 +1293,4 @@ AUTHORS
versions 1.5 and 2.0. Niels Provos and Markus Friedl contributed support versions 1.5 and 2.0. Niels Provos and Markus Friedl contributed support
for privilege separation. for privilege separation.
OpenBSD 7.3 July 28, 2023 OpenBSD 7.3 OpenBSD 7.5 February 21, 2024 OpenBSD 7.5

View file

@ -33,8 +33,8 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\" .\"
.\" $OpenBSD: sshd_config.5,v 1.350 2023/07/28 05:42:36 jmc Exp $ .\" $OpenBSD: sshd_config.5,v 1.355 2024/02/21 06:17:29 djm Exp $
.Dd $Mdocdate: July 28 2023 $ .Dd $Mdocdate: February 21 2024 $
.Dt SSHD_CONFIG 5 .Dt SSHD_CONFIG 5
.Os .Os
.Sh NAME .Sh NAME
@ -409,8 +409,10 @@ Timeouts are specified as one or more
.Dq type=interval .Dq type=interval
pairs separated by whitespace, where the pairs separated by whitespace, where the
.Dq type .Dq type
must be a channel type name (as described in the table below), optionally must be the special keyword
containing wildcard characters. .Dq global
or a channel type name from the list below, optionally containing
wildcard characters.
.Pp .Pp
The timeout value The timeout value
.Dq interval .Dq interval
@ -418,11 +420,20 @@ is specified in seconds or may use any of the units documented in the
.Sx TIME FORMATS .Sx TIME FORMATS
section. section.
For example, For example,
.Dq session:*=5m .Dq session=5m
would cause all sessions to terminate after five minutes of inactivity. would cause interactive sessions to terminate after five minutes of
inactivity.
Specifying a zero value disables the inactivity timeout. Specifying a zero value disables the inactivity timeout.
.Pp .Pp
The available channel types include: The special timeout
.Dq global
applies to all active channels, taken together.
Traffic on any active channel will reset the timeout, but when the timeout
expires then all open channels will be closed.
Note that this global timeout is not matched by wildcards and must be
specified explicitly.
.Pp
The available channel type names include:
.Bl -tag -width Ds .Bl -tag -width Ds
.It Cm agent-connection .It Cm agent-connection
Open connections to Open connections to
@ -443,15 +454,15 @@ listening on behalf of a
.Xr ssh 1 .Xr ssh 1
remote forwarding, i.e.\& remote forwarding, i.e.\&
.Cm RemoteForward . .Cm RemoteForward .
.It Cm session:command .It Cm session
Command execution sessions. The interactive main session, including shell session, command execution,
.It Cm session:shell .Xr scp 1 ,
Interactive shell sessions.
.It Cm session:subsystem:...
Subsystem sessions, e.g. for
.Xr sftp 1 , .Xr sftp 1 ,
which could be identified as etc.
.Cm session:subsystem:sftp . .It Cm tun-connection
Open
.Cm TunnelForward
connections.
.It Cm x11-connection .It Cm x11-connection
Open X11 forwarding sessions. Open X11 forwarding sessions.
.El .El
@ -465,9 +476,6 @@ close the SSH connection, nor does it prevent a client from
requesting another channel of the same type. requesting another channel of the same type.
In particular, expiring an inactive forwarding session does not prevent In particular, expiring an inactive forwarding session does not prevent
another identical forwarding from being subsequently created. another identical forwarding from being subsequently created.
See also
.Cm UnusedConnectionTimeout ,
which may be used in conjunction with this option.
.Pp .Pp
The default is not to expire channels of any type for inactivity. The default is not to expire channels of any type for inactivity.
.It Cm ChrootDirectory .It Cm ChrootDirectory
@ -477,7 +485,7 @@ to after authentication.
At session startup At session startup
.Xr sshd 8 .Xr sshd 8
checks that all components of the pathname are root-owned directories checks that all components of the pathname are root-owned directories
which are not writable by any other user or group. which are not writable by group or others.
After the chroot, After the chroot,
.Xr sshd 8 .Xr sshd 8
changes the working directory to the user's home directory. changes the working directory to the user's home directory.
@ -1118,7 +1126,8 @@ DEBUG and DEBUG1 are equivalent.
DEBUG2 and DEBUG3 each specify higher levels of debugging output. DEBUG2 and DEBUG3 each specify higher levels of debugging output.
Logging with a DEBUG level violates the privacy of users and is not recommended. Logging with a DEBUG level violates the privacy of users and is not recommended.
.It Cm LogVerbose .It Cm LogVerbose
Specify one or more overrides to LogLevel. Specify one or more overrides to
.Cm LogLevel .
An override consists of a pattern lists that matches the source file, function An override consists of a pattern lists that matches the source file, function
and line number to force detailed logging for. and line number to force detailed logging for.
For example, an override pattern of: For example, an override pattern of:
@ -1783,6 +1792,14 @@ implements an in-process SFTP server.
This may simplify configurations using This may simplify configurations using
.Cm ChrootDirectory .Cm ChrootDirectory
to force a different filesystem root on clients. to force a different filesystem root on clients.
It accepts the same command line arguments as
.Cm sftp-server
and even though it is in-process, settings such as
.Cm LogLevel
or
.Cm SyslogFacility
do not apply to it and must be set explicitly via
command line arguments.
.Pp .Pp
By default no subsystems are defined. By default no subsystems are defined.
.It Cm SyslogFacility .It Cm SyslogFacility

View file

@ -1,4 +1,4 @@
/* $OpenBSD: sshkey.c,v 1.140 2023/10/16 08:40:00 dtucker Exp $ */ /* $OpenBSD: sshkey.c,v 1.142 2024/01/11 01:45:36 djm Exp $ */
/* /*
* Copyright (c) 2000, 2001 Markus Friedl. All rights reserved. * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved.
* Copyright (c) 2008 Alexander von Gernler. All rights reserved. * Copyright (c) 2008 Alexander von Gernler. All rights reserved.
@ -121,8 +121,10 @@ extern const struct sshkey_impl sshkey_rsa_sha256_impl;
extern const struct sshkey_impl sshkey_rsa_sha256_cert_impl; extern const struct sshkey_impl sshkey_rsa_sha256_cert_impl;
extern const struct sshkey_impl sshkey_rsa_sha512_impl; extern const struct sshkey_impl sshkey_rsa_sha512_impl;
extern const struct sshkey_impl sshkey_rsa_sha512_cert_impl; extern const struct sshkey_impl sshkey_rsa_sha512_cert_impl;
# ifdef WITH_DSA
extern const struct sshkey_impl sshkey_dss_impl; extern const struct sshkey_impl sshkey_dss_impl;
extern const struct sshkey_impl sshkey_dsa_cert_impl; extern const struct sshkey_impl sshkey_dsa_cert_impl;
# endif
#endif /* WITH_OPENSSL */ #endif /* WITH_OPENSSL */
#ifdef WITH_XMSS #ifdef WITH_XMSS
extern const struct sshkey_impl sshkey_xmss_impl; extern const struct sshkey_impl sshkey_xmss_impl;
@ -152,8 +154,10 @@ const struct sshkey_impl * const keyimpls[] = {
&sshkey_ecdsa_sk_webauthn_impl, &sshkey_ecdsa_sk_webauthn_impl,
# endif /* ENABLE_SK */ # endif /* ENABLE_SK */
# endif /* OPENSSL_HAS_ECC */ # endif /* OPENSSL_HAS_ECC */
# ifdef WITH_DSA
&sshkey_dss_impl, &sshkey_dss_impl,
&sshkey_dsa_cert_impl, &sshkey_dsa_cert_impl,
# endif
&sshkey_rsa_impl, &sshkey_rsa_impl,
&sshkey_rsa_cert_impl, &sshkey_rsa_cert_impl,
&sshkey_rsa_sha256_impl, &sshkey_rsa_sha256_impl,
@ -1927,7 +1931,7 @@ sshkey_from_blob_internal(struct sshbuf *b, struct sshkey **keyp,
goto out; goto out;
} }
if (sshkey_type_is_cert(type)) { if (sshkey_type_is_cert(type)) {
/* Skip nonce that preceeds all certificates */ /* Skip nonce that precedes all certificates */
if (sshbuf_get_string_direct(b, NULL, NULL) != 0) { if (sshbuf_get_string_direct(b, NULL, NULL) != 0) {
ret = SSH_ERR_INVALID_FORMAT; ret = SSH_ERR_INVALID_FORMAT;
goto out; goto out;
@ -3230,6 +3234,7 @@ sshkey_private_to_blob_pem_pkcs8(struct sshkey *key, struct sshbuf *buf,
goto out; goto out;
switch (key->type) { switch (key->type) {
#ifdef WITH_DSA
case KEY_DSA: case KEY_DSA:
if (format == SSHKEY_PRIVATE_PEM) { if (format == SSHKEY_PRIVATE_PEM) {
success = PEM_write_bio_DSAPrivateKey(bio, key->dsa, success = PEM_write_bio_DSAPrivateKey(bio, key->dsa,
@ -3238,6 +3243,7 @@ sshkey_private_to_blob_pem_pkcs8(struct sshkey *key, struct sshbuf *buf,
success = EVP_PKEY_set1_DSA(pkey, key->dsa); success = EVP_PKEY_set1_DSA(pkey, key->dsa);
} }
break; break;
#endif
#ifdef OPENSSL_HAS_ECC #ifdef OPENSSL_HAS_ECC
case KEY_ECDSA: case KEY_ECDSA:
if (format == SSHKEY_PRIVATE_PEM) { if (format == SSHKEY_PRIVATE_PEM) {
@ -3466,6 +3472,7 @@ sshkey_parse_private_pem_fileblob(struct sshbuf *blob, int type,
} }
if ((r = sshkey_check_rsa_length(prv, 0)) != 0) if ((r = sshkey_check_rsa_length(prv, 0)) != 0)
goto out; goto out;
#ifdef WITH_DSA
} else if (EVP_PKEY_base_id(pk) == EVP_PKEY_DSA && } else if (EVP_PKEY_base_id(pk) == EVP_PKEY_DSA &&
(type == KEY_UNSPEC || type == KEY_DSA)) { (type == KEY_UNSPEC || type == KEY_DSA)) {
if ((prv = sshkey_new(KEY_UNSPEC)) == NULL) { if ((prv = sshkey_new(KEY_UNSPEC)) == NULL) {
@ -3477,6 +3484,7 @@ sshkey_parse_private_pem_fileblob(struct sshbuf *blob, int type,
#ifdef DEBUG_PK #ifdef DEBUG_PK
DSA_print_fp(stderr, prv->dsa, 8); DSA_print_fp(stderr, prv->dsa, 8);
#endif #endif
#endif
#ifdef OPENSSL_HAS_ECC #ifdef OPENSSL_HAS_ECC
} else if (EVP_PKEY_base_id(pk) == EVP_PKEY_EC && } else if (EVP_PKEY_base_id(pk) == EVP_PKEY_EC &&
(type == KEY_UNSPEC || type == KEY_ECDSA)) { (type == KEY_UNSPEC || type == KEY_ECDSA)) {

View file

@ -1,4 +1,4 @@
/* $OpenBSD: sshsig.c,v 1.34 2023/12/08 09:18:39 markus Exp $ */ /* $OpenBSD: sshsig.c,v 1.35 2024/03/08 22:16:32 djm Exp $ */
/* /*
* Copyright (c) 2019 Google LLC * Copyright (c) 2019 Google LLC
* *
@ -746,7 +746,7 @@ parse_principals_key_and_options(const char *path, u_long linenum, char *line,
*keyp = NULL; *keyp = NULL;
cp = line; cp = line;
cp = cp + strspn(cp, " \t"); /* skip leading whitespace */ cp = cp + strspn(cp, " \t\n\r"); /* skip leading whitespace */
if (*cp == '#' || *cp == '\0') if (*cp == '#' || *cp == '\0')
return SSH_ERR_KEY_NOT_FOUND; /* blank or all-comment line */ return SSH_ERR_KEY_NOT_FOUND; /* blank or all-comment line */

View file

@ -1,6 +1,6 @@
/* $OpenBSD: version.h,v 1.100 2023/12/18 14:48:44 djm Exp $ */ /* $OpenBSD: version.h,v 1.101 2024/03/11 04:59:47 djm Exp $ */
#define SSH_VERSION "OpenSSH_9.6" #define SSH_VERSION "OpenSSH_9.7"
#define SSH_PORTABLE "p1" #define SSH_PORTABLE "p1"
#define SSH_RELEASE SSH_VERSION SSH_PORTABLE #define SSH_RELEASE SSH_VERSION SSH_PORTABLE

View file

@ -1,4 +1,4 @@
/* $OpenBSD: xmss_hash.c,v 1.3 2022/04/20 16:00:25 millert Exp $ */ /* $OpenBSD: xmss_hash.c,v 1.4 2023/12/20 00:06:25 jsg Exp $ */
/* /*
hash.c version 20160722 hash.c version 20160722
Andreas Hülsing Andreas Hülsing
@ -74,7 +74,7 @@ int prf(unsigned char *out, const unsigned char *in, const unsigned char *key, u
} }
/* /*
* Implemts H_msg * Implements H_msg
*/ */
int h_msg(unsigned char *out, const unsigned char *in, unsigned long long inlen, const unsigned char *key, const unsigned int keylen, const unsigned int n) int h_msg(unsigned char *out, const unsigned char *in, unsigned long long inlen, const unsigned char *key, const unsigned int keylen, const unsigned int n)
{ {