Merge remote-tracking branch 'origin/latestw' into latestw_all
This commit is contained in:
commit
42670c7867
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: auth2-pubkey.c,v 1.61 2016/12/30 22:08:02 djm Exp $ */
|
||||
/* $OpenBSD: auth2-pubkey.c,v 1.62 2017/01/30 01:03:00 djm Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2000 Markus Friedl. All rights reserved.
|
||||
*
|
||||
|
@ -622,9 +622,12 @@ process_principals(FILE *f, char *file, struct passwd *pw,
|
|||
{
|
||||
char line[SSH_MAX_PUBKEY_BYTES], *cp, *ep, *line_opts;
|
||||
u_long linenum = 0;
|
||||
u_int i;
|
||||
u_int i, found_principal = 0;
|
||||
|
||||
while (read_keyfile_line(f, file, line, sizeof(line), &linenum) != -1) {
|
||||
/* Always consume entire input */
|
||||
if (found_principal)
|
||||
continue;
|
||||
/* Skip leading whitespace. */
|
||||
for (cp = line; *cp == ' ' || *cp == '\t'; cp++)
|
||||
;
|
||||
|
@ -657,11 +660,12 @@ process_principals(FILE *f, char *file, struct passwd *pw,
|
|||
if (auth_parse_options(pw, line_opts,
|
||||
file, linenum) != 1)
|
||||
continue;
|
||||
return 1;
|
||||
found_principal = 1;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return found_principal;
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -829,6 +833,9 @@ check_authkeys_file(FILE *f, char *file, Key* key, struct passwd *pw)
|
|||
char *cp, *key_options = NULL, *fp = NULL;
|
||||
const char *reason = NULL;
|
||||
|
||||
/* Always consume entrire file */
|
||||
if (found_key)
|
||||
continue;
|
||||
if (found != NULL)
|
||||
key_free(found);
|
||||
found = key_new(key_is_cert(key) ? KEY_UNSPEC : key->type);
|
||||
|
@ -915,7 +922,7 @@ check_authkeys_file(FILE *f, char *file, Key* key, struct passwd *pw)
|
|||
file, linenum, key_type(found), fp);
|
||||
free(fp);
|
||||
found_key = 1;
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (found != NULL)
|
||||
|
|
12
auth2.c
12
auth2.c
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: auth2.c,v 1.136 2016/05/02 08:49:03 djm Exp $ */
|
||||
/* $OpenBSD: auth2.c,v 1.137 2017/02/03 23:05:57 djm Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2000 Markus Friedl. All rights reserved.
|
||||
*
|
||||
|
@ -212,6 +212,7 @@ input_service_request(int type, u_int32_t seq, void *ctxt)
|
|||
static int
|
||||
input_userauth_request(int type, u_int32_t seq, void *ctxt)
|
||||
{
|
||||
struct ssh *ssh = active_state; /* XXX */
|
||||
Authctxt *authctxt = ctxt;
|
||||
Authmethod *m = NULL;
|
||||
char *user, *service, *method, *style = NULL;
|
||||
|
@ -235,9 +236,10 @@ input_userauth_request(int type, u_int32_t seq, void *ctxt)
|
|||
authctxt->user = xstrdup(user);
|
||||
if (authctxt->pw && strcmp(service, "ssh-connection")==0) {
|
||||
authctxt->valid = 1;
|
||||
debug2("input_userauth_request: setting up authctxt for %s", user);
|
||||
debug2("%s: setting up authctxt for %s",
|
||||
__func__, user);
|
||||
} else {
|
||||
logit("input_userauth_request: invalid user %s", user);
|
||||
/* Invalid user, fake password information */
|
||||
authctxt->pw = fakepw();
|
||||
#ifdef SSH_AUDIT_EVENTS
|
||||
PRIVSEP(audit_event(SSH_INVALID_USER));
|
||||
|
@ -247,6 +249,8 @@ input_userauth_request(int type, u_int32_t seq, void *ctxt)
|
|||
if (options.use_pam)
|
||||
PRIVSEP(start_pam(authctxt));
|
||||
#endif
|
||||
ssh_packet_set_log_preamble(ssh, "%suser %s",
|
||||
authctxt->valid ? "authenticating " : "invalid ", user);
|
||||
setproctitle("%s%s", authctxt->valid ? user : "unknown",
|
||||
use_privsep ? " [net]" : "");
|
||||
authctxt->service = xstrdup(service);
|
||||
|
@ -292,6 +296,7 @@ void
|
|||
userauth_finish(Authctxt *authctxt, int authenticated, const char *method,
|
||||
const char *submethod)
|
||||
{
|
||||
struct ssh *ssh = active_state; /* XXX */
|
||||
char *methods;
|
||||
int partial = 0;
|
||||
|
||||
|
@ -353,6 +358,7 @@ userauth_finish(Authctxt *authctxt, int authenticated, const char *method,
|
|||
packet_write_wait();
|
||||
/* now we can break out */
|
||||
authctxt->success = 1;
|
||||
ssh_packet_set_log_preamble(ssh, "user %s", authctxt->user);
|
||||
} else {
|
||||
|
||||
/* Allow initial try of "none" auth without failure penalty */
|
||||
|
|
33
channels.c
33
channels.c
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: channels.c,v 1.356 2016/10/18 17:32:54 dtucker Exp $ */
|
||||
/* $OpenBSD: channels.c,v 1.357 2017/02/01 02:59:09 dtucker Exp $ */
|
||||
/*
|
||||
* Author: Tatu Ylonen <ylo@cs.hut.fi>
|
||||
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
|
||||
|
@ -3067,7 +3067,7 @@ channel_input_port_open(int type, u_int32_t seq, void *ctxt)
|
|||
}
|
||||
packet_check_eom();
|
||||
c = channel_connect_to_port(host, host_port,
|
||||
"connected socket", originator_string);
|
||||
"connected socket", originator_string, NULL, NULL);
|
||||
free(originator_string);
|
||||
free(host);
|
||||
if (c == NULL) {
|
||||
|
@ -4028,9 +4028,13 @@ channel_connect_ctx_free(struct channel_connect *cctx)
|
|||
memset(cctx, 0, sizeof(*cctx));
|
||||
}
|
||||
|
||||
/* Return CONNECTING channel to remote host:port or local socket path */
|
||||
/*
|
||||
* Return CONNECTING channel to remote host:port or local socket path,
|
||||
* passing back the failure reason if appropriate.
|
||||
*/
|
||||
static Channel *
|
||||
connect_to(const char *name, int port, char *ctype, char *rname)
|
||||
connect_to_reason(const char *name, int port, char *ctype, char *rname,
|
||||
int *reason, const char **errmsg)
|
||||
{
|
||||
struct addrinfo hints;
|
||||
int gaierr;
|
||||
|
@ -4071,7 +4075,12 @@ connect_to(const char *name, int port, char *ctype, char *rname)
|
|||
hints.ai_family = IPv4or6;
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
snprintf(strport, sizeof strport, "%d", port);
|
||||
if ((gaierr = getaddrinfo(name, strport, &hints, &cctx.aitop)) != 0) {
|
||||
if ((gaierr = getaddrinfo(name, strport, &hints, &cctx.aitop))
|
||||
!= 0) {
|
||||
if (errmsg != NULL)
|
||||
*errmsg = ssh_gai_strerror(gaierr);
|
||||
if (reason != NULL)
|
||||
*reason = SSH2_OPEN_CONNECT_FAILED;
|
||||
error("connect_to %.100s: unknown host (%s)", name,
|
||||
ssh_gai_strerror(gaierr));
|
||||
return NULL;
|
||||
|
@ -4094,6 +4103,13 @@ connect_to(const char *name, int port, char *ctype, char *rname)
|
|||
return c;
|
||||
}
|
||||
|
||||
/* Return CONNECTING channel to remote host:port or local socket path */
|
||||
static Channel *
|
||||
connect_to(const char *name, int port, char *ctype, char *rname)
|
||||
{
|
||||
return connect_to_reason(name, port, ctype, rname, NULL, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* returns either the newly connected channel or the downstream channel
|
||||
* that needs to deal with this connection.
|
||||
|
@ -4138,7 +4154,8 @@ channel_connect_by_listen_path(const char *path, char *ctype, char *rname)
|
|||
|
||||
/* Check if connecting to that port is permitted and connect. */
|
||||
Channel *
|
||||
channel_connect_to_port(const char *host, u_short port, char *ctype, char *rname)
|
||||
channel_connect_to_port(const char *host, u_short port, char *ctype,
|
||||
char *rname, int *reason, const char **errmsg)
|
||||
{
|
||||
int i, permit, permit_adm = 1;
|
||||
|
||||
|
@ -4163,9 +4180,11 @@ channel_connect_to_port(const char *host, u_short port, char *ctype, char *rname
|
|||
if (!permit || !permit_adm) {
|
||||
logit("Received request to connect to host %.100s port %d, "
|
||||
"but the request was denied.", host, port);
|
||||
if (reason != NULL)
|
||||
*reason = SSH2_OPEN_ADMINISTRATIVELY_PROHIBITED;
|
||||
return NULL;
|
||||
}
|
||||
return connect_to(host, port, ctype, rname);
|
||||
return connect_to_reason(host, port, ctype, rname, reason, errmsg);
|
||||
}
|
||||
|
||||
/* Check if connecting to that path is permitted and connect. */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: channels.h,v 1.120 2016/10/18 17:32:54 dtucker Exp $ */
|
||||
/* $OpenBSD: channels.h,v 1.121 2017/02/01 02:59:09 dtucker Exp $ */
|
||||
|
||||
/*
|
||||
* Author: Tatu Ylonen <ylo@cs.hut.fi>
|
||||
|
@ -275,7 +275,8 @@ void channel_update_permitted_opens(int, int);
|
|||
void channel_clear_permitted_opens(void);
|
||||
void channel_clear_adm_permitted_opens(void);
|
||||
void channel_print_adm_permitted_opens(void);
|
||||
Channel *channel_connect_to_port(const char *, u_short, char *, char *);
|
||||
Channel *channel_connect_to_port(const char *, u_short, char *, char *, int *,
|
||||
const char **);
|
||||
Channel *channel_connect_to_path(const char *, char *, char *);
|
||||
Channel *channel_connect_stdio_fwd(const char*, u_short, int, int);
|
||||
Channel *channel_connect_by_listen_address(const char *, u_short,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: clientloop.c,v 1.289 2016/09/30 09:19:13 markus Exp $ */
|
||||
/* $OpenBSD: clientloop.c,v 1.290 2017/01/29 21:35:23 dtucker Exp $ */
|
||||
/*
|
||||
* Author: Tatu Ylonen <ylo@cs.hut.fi>
|
||||
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
|
||||
|
@ -991,7 +991,7 @@ process_cmdline(void)
|
|||
CHANNEL_CANCEL_PORT_STATIC,
|
||||
&options.fwd_opts) > 0;
|
||||
if (!ok) {
|
||||
logit("Unkown port forwarding.");
|
||||
logit("Unknown port forwarding.");
|
||||
goto out;
|
||||
}
|
||||
logit("Canceled forwarding.");
|
||||
|
|
48
compat.c
48
compat.c
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: compat.c,v 1.99 2016/05/24 02:31:57 dtucker Exp $ */
|
||||
/* $OpenBSD: compat.c,v 1.100 2017/02/03 23:01:19 djm Exp $ */
|
||||
/*
|
||||
* Copyright (c) 1999, 2000, 2001, 2002 Markus Friedl. All rights reserved.
|
||||
*
|
||||
|
@ -37,6 +37,7 @@
|
|||
#include "compat.h"
|
||||
#include "log.h"
|
||||
#include "match.h"
|
||||
#include "kex.h"
|
||||
|
||||
int compat13 = 0;
|
||||
int compat20 = 0;
|
||||
|
@ -250,42 +251,14 @@ proto_spec(const char *spec)
|
|||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* Filters a proposal string, excluding any algorithm matching the 'filter'
|
||||
* pattern list.
|
||||
*/
|
||||
static char *
|
||||
filter_proposal(char *proposal, const char *filter)
|
||||
{
|
||||
Buffer b;
|
||||
char *orig_prop, *fix_prop;
|
||||
char *cp, *tmp;
|
||||
|
||||
buffer_init(&b);
|
||||
tmp = orig_prop = xstrdup(proposal);
|
||||
while ((cp = strsep(&tmp, ",")) != NULL) {
|
||||
if (match_pattern_list(cp, filter, 0) != 1) {
|
||||
if (buffer_len(&b) > 0)
|
||||
buffer_append(&b, ",", 1);
|
||||
buffer_append(&b, cp, strlen(cp));
|
||||
} else
|
||||
debug2("Compat: skipping algorithm \"%s\"", cp);
|
||||
}
|
||||
buffer_append(&b, "\0", 1);
|
||||
fix_prop = xstrdup((char *)buffer_ptr(&b));
|
||||
buffer_free(&b);
|
||||
free(orig_prop);
|
||||
|
||||
return fix_prop;
|
||||
}
|
||||
|
||||
char *
|
||||
compat_cipher_proposal(char *cipher_prop)
|
||||
{
|
||||
if (!(datafellows & SSH_BUG_BIGENDIANAES))
|
||||
return cipher_prop;
|
||||
debug2("%s: original cipher proposal: %s", __func__, cipher_prop);
|
||||
cipher_prop = filter_proposal(cipher_prop, "aes*");
|
||||
if ((cipher_prop = match_filter_list(cipher_prop, "aes*")) == NULL)
|
||||
fatal("match_filter_list failed");
|
||||
debug2("%s: compat cipher proposal: %s", __func__, cipher_prop);
|
||||
if (*cipher_prop == '\0')
|
||||
fatal("No supported ciphers found");
|
||||
|
@ -298,7 +271,8 @@ compat_pkalg_proposal(char *pkalg_prop)
|
|||
if (!(datafellows & SSH_BUG_RSASIGMD5))
|
||||
return pkalg_prop;
|
||||
debug2("%s: original public key proposal: %s", __func__, pkalg_prop);
|
||||
pkalg_prop = filter_proposal(pkalg_prop, "ssh-rsa");
|
||||
if ((pkalg_prop = match_filter_list(pkalg_prop, "ssh-rsa")) == NULL)
|
||||
fatal("match_filter_list failed");
|
||||
debug2("%s: compat public key proposal: %s", __func__, pkalg_prop);
|
||||
if (*pkalg_prop == '\0')
|
||||
fatal("No supported PK algorithms found");
|
||||
|
@ -312,10 +286,14 @@ compat_kex_proposal(char *p)
|
|||
return p;
|
||||
debug2("%s: original KEX proposal: %s", __func__, p);
|
||||
if ((datafellows & SSH_BUG_CURVE25519PAD) != 0)
|
||||
p = filter_proposal(p, "curve25519-sha256@libssh.org");
|
||||
if ((p = match_filter_list(p,
|
||||
"curve25519-sha256@libssh.org")) == NULL)
|
||||
fatal("match_filter_list failed");
|
||||
if ((datafellows & SSH_OLD_DHGEX) != 0) {
|
||||
p = filter_proposal(p, "diffie-hellman-group-exchange-sha256");
|
||||
p = filter_proposal(p, "diffie-hellman-group-exchange-sha1");
|
||||
if ((p = match_filter_list(p,
|
||||
"diffie-hellman-group-exchange-sha256,"
|
||||
"diffie-hellman-group-exchange-sha1")) == NULL)
|
||||
fatal("match_filter_list failed");
|
||||
}
|
||||
debug2("%s: compat KEX proposal: %s", __func__, p);
|
||||
if (*p == '\0')
|
||||
|
|
60
configure.ac
60
configure.ac
|
@ -740,6 +740,9 @@ main() { if (NSVersionOfRunTimeLibrary("System") >= (60 << 16))
|
|||
use_pie=auto
|
||||
check_for_libcrypt_later=1
|
||||
check_for_openpty_ctty_bug=1
|
||||
dnl Target SUSv3/POSIX.1-2001 plus BSD specifics.
|
||||
dnl _DEFAULT_SOURCE is the new name for _BSD_SOURCE
|
||||
CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=600 -D_BSD_SOURCE -D_DEFAULT_SOURCE"
|
||||
AC_DEFINE([PAM_TTY_KLUDGE], [1],
|
||||
[Work around problematic Linux PAM modules handling of PAM_TTY])
|
||||
AC_DEFINE([LOCKED_PASSWD_PREFIX], ["!"],
|
||||
|
@ -1471,36 +1474,47 @@ AC_ARG_WITH([skey],
|
|||
LDNS_MSG="no"
|
||||
AC_ARG_WITH(ldns,
|
||||
[ --with-ldns[[=PATH]] Use ldns for DNSSEC support (optionally in PATH)],
|
||||
[
|
||||
if test "x$withval" != "xno" ; then
|
||||
[
|
||||
ldns=""
|
||||
if test "x$withval" = "xyes" ; then
|
||||
AC_PATH_TOOL([LDNSCONFIG], [ldns-config], [no])
|
||||
if test "x$PKGCONFIG" = "xno"; then
|
||||
CPPFLAGS="$CPPFLAGS -I${withval}/include"
|
||||
LDFLAGS="$LDFLAGS -L${withval}/lib"
|
||||
LIBS="-lldns $LIBS"
|
||||
ldns=yes
|
||||
else
|
||||
LIBS="$LIBS `$LDNSCONFIG --libs`"
|
||||
CPPFLAGS="$CPPFLAGS `$LDNSCONFIG --cflags`"
|
||||
fi
|
||||
elif test "x$withval" != "xno" ; then
|
||||
CPPFLAGS="$CPPFLAGS -I${withval}/include"
|
||||
LDFLAGS="$LDFLAGS -L${withval}/lib"
|
||||
LIBS="-lldns $LIBS"
|
||||
ldns=yes
|
||||
fi
|
||||
|
||||
if test "x$withval" != "xyes" ; then
|
||||
CPPFLAGS="$CPPFLAGS -I${withval}/include"
|
||||
LDFLAGS="$LDFLAGS -L${withval}/lib"
|
||||
fi
|
||||
|
||||
AC_DEFINE(HAVE_LDNS, 1, [Define if you want ldns support])
|
||||
LIBS="-lldns $LIBS"
|
||||
LDNS_MSG="yes"
|
||||
|
||||
AC_MSG_CHECKING([for ldns support])
|
||||
AC_LINK_IFELSE(
|
||||
[AC_LANG_SOURCE([[
|
||||
# Verify that it works.
|
||||
if test "x$ldns" = "xyes" ; then
|
||||
AC_DEFINE(HAVE_LDNS, 1, [Define if you want ldns support])
|
||||
LDNS_MSG="yes"
|
||||
AC_MSG_CHECKING([for ldns support])
|
||||
AC_LINK_IFELSE(
|
||||
[AC_LANG_SOURCE([[
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <ldns/ldns.h>
|
||||
int main() { ldns_status status = ldns_verify_trusted(NULL, NULL, NULL, NULL); status=LDNS_STATUS_OK; exit(0); }
|
||||
]])
|
||||
],
|
||||
[AC_MSG_RESULT(yes)],
|
||||
]])
|
||||
],
|
||||
[AC_MSG_RESULT(yes)],
|
||||
[
|
||||
AC_MSG_RESULT(no)
|
||||
AC_MSG_ERROR([** Incomplete or missing ldns libraries.])
|
||||
])
|
||||
fi
|
||||
]
|
||||
)
|
||||
fi
|
||||
])
|
||||
|
||||
# Check whether user wants libedit support
|
||||
LIBEDIT_MSG="no"
|
||||
|
@ -1771,11 +1785,8 @@ AC_CHECK_FUNCS([ \
|
|||
warn \
|
||||
])
|
||||
|
||||
dnl Wide character support. Linux man page says it needs _XOPEN_SOURCE.
|
||||
saved_CFLAGS="$CFLAGS"
|
||||
CFLAGS="$CFLAGS -D_XOPEN_SOURCE"
|
||||
dnl Wide character support.
|
||||
AC_CHECK_FUNCS([mblen mbtowc nl_langinfo wcwidth])
|
||||
CFLAGS="$saved_CFLAGS"
|
||||
|
||||
TEST_SSH_UTF8=${TEST_SSH_UTF8:=yes}
|
||||
AC_MSG_CHECKING([for utf8 locale support])
|
||||
|
@ -5083,6 +5094,7 @@ echo " Smartcard support: $SCARD_MSG"
|
|||
echo " S/KEY support: $SKEY_MSG"
|
||||
echo " MD5 password support: $MD5_MSG"
|
||||
echo " libedit support: $LIBEDIT_MSG"
|
||||
echo " libldns support: $LDNS_MSG"
|
||||
echo " Solaris process contract support: $SPC_MSG"
|
||||
echo " Solaris project support: $SP_MSG"
|
||||
echo " Solaris privilege support: $SPP_MSG"
|
||||
|
|
21
kex.c
21
kex.c
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: kex.c,v 1.127 2016/10/10 19:28:48 markus Exp $ */
|
||||
/* $OpenBSD: kex.c,v 1.128 2017/02/03 23:01:19 djm Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2000, 2001 Markus Friedl. All rights reserved.
|
||||
*
|
||||
|
@ -211,7 +211,8 @@ kex_names_cat(const char *a, const char *b)
|
|||
/*
|
||||
* Assemble a list of algorithms from a default list and a string from a
|
||||
* configuration file. The user-provided string may begin with '+' to
|
||||
* indicate that it should be appended to the default.
|
||||
* indicate that it should be appended to the default or '-' that the
|
||||
* specified names should be removed.
|
||||
*/
|
||||
int
|
||||
kex_assemble_names(const char *def, char **list)
|
||||
|
@ -222,14 +223,18 @@ kex_assemble_names(const char *def, char **list)
|
|||
*list = strdup(def);
|
||||
return 0;
|
||||
}
|
||||
if (**list != '+') {
|
||||
return 0;
|
||||
if (**list == '+') {
|
||||
if ((ret = kex_names_cat(def, *list + 1)) == NULL)
|
||||
return SSH_ERR_ALLOC_FAIL;
|
||||
free(*list);
|
||||
*list = ret;
|
||||
} else if (**list == '-') {
|
||||
if ((ret = match_filter_list(def, *list + 1)) == NULL)
|
||||
return SSH_ERR_ALLOC_FAIL;
|
||||
free(*list);
|
||||
*list = ret;
|
||||
}
|
||||
|
||||
if ((ret = kex_names_cat(def, *list + 1)) == NULL)
|
||||
return SSH_ERR_ALLOC_FAIL;
|
||||
free(*list);
|
||||
*list = ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
31
match.c
31
match.c
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: match.c,v 1.33 2016/11/06 05:46:37 djm Exp $ */
|
||||
/* $OpenBSD: match.c,v 1.34 2017/02/03 23:01:19 djm Exp $ */
|
||||
/*
|
||||
* Author: Tatu Ylonen <ylo@cs.hut.fi>
|
||||
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
|
||||
|
@ -284,3 +284,32 @@ match_list(const char *client, const char *server, u_int *next)
|
|||
free(s);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Filters a comma-separated list of strings, excluding any entry matching
|
||||
* the 'filter' pattern list. Caller must free returned string.
|
||||
*/
|
||||
char *
|
||||
match_filter_list(const char *proposal, const char *filter)
|
||||
{
|
||||
size_t len = strlen(proposal) + 1;
|
||||
char *fix_prop = malloc(len);
|
||||
char *orig_prop = strdup(proposal);
|
||||
char *cp, *tmp;
|
||||
|
||||
if (fix_prop == NULL || orig_prop == NULL)
|
||||
return NULL;
|
||||
|
||||
tmp = orig_prop;
|
||||
*fix_prop = '\0';
|
||||
while ((cp = strsep(&tmp, ",")) != NULL) {
|
||||
if (match_pattern_list(cp, filter, 0) != 1) {
|
||||
if (*fix_prop != '\0')
|
||||
strlcat(fix_prop, ",", len);
|
||||
strlcat(fix_prop, cp, len);
|
||||
}
|
||||
}
|
||||
free(orig_prop);
|
||||
return fix_prop;
|
||||
}
|
||||
|
||||
|
|
3
match.h
3
match.h
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: match.h,v 1.16 2015/05/04 06:10:48 djm Exp $ */
|
||||
/* $OpenBSD: match.h,v 1.17 2017/02/03 23:01:19 djm Exp $ */
|
||||
|
||||
/*
|
||||
* Author: Tatu Ylonen <ylo@cs.hut.fi>
|
||||
|
@ -20,6 +20,7 @@ int match_hostname(const char *, const char *);
|
|||
int match_host_and_ip(const char *, const char *, const char *);
|
||||
int match_user(const char *, const char *, const char *, const char *);
|
||||
char *match_list(const char *, const char *, u_int *);
|
||||
char *match_filter_list(const char *, const char *);
|
||||
|
||||
/* addrmatch.c */
|
||||
int addr_match_list(const char *, const char *);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: monitor.c,v 1.166 2016/09/28 16:33:06 djm Exp $ */
|
||||
/* $OpenBSD: monitor.c,v 1.167 2017/02/03 23:05:57 djm Exp $ */
|
||||
/*
|
||||
* Copyright 2002 Niels Provos <provos@citi.umich.edu>
|
||||
* Copyright 2002 Markus Friedl <markus@openbsd.org>
|
||||
|
@ -283,6 +283,7 @@ monitor_permit_authentications(int permit)
|
|||
void
|
||||
monitor_child_preauth(Authctxt *_authctxt, struct monitor *pmonitor)
|
||||
{
|
||||
struct ssh *ssh = active_state; /* XXX */
|
||||
struct mon_table *ent;
|
||||
int authenticated = 0, partial = 0;
|
||||
|
||||
|
@ -356,6 +357,7 @@ monitor_child_preauth(Authctxt *_authctxt, struct monitor *pmonitor)
|
|||
|
||||
debug("%s: %s has been authenticated by privileged process",
|
||||
__func__, authctxt->user);
|
||||
ssh_packet_set_log_preamble(ssh, "user %s", authctxt->user);
|
||||
|
||||
mm_get_keystate(pmonitor);
|
||||
|
||||
|
@ -695,6 +697,7 @@ mm_answer_sign(int sock, Buffer *m)
|
|||
int
|
||||
mm_answer_pwnamallow(int sock, Buffer *m)
|
||||
{
|
||||
struct ssh *ssh = active_state; /* XXX */
|
||||
char *username;
|
||||
struct passwd *pwent;
|
||||
int allowed = 0;
|
||||
|
@ -739,6 +742,8 @@ mm_answer_pwnamallow(int sock, Buffer *m)
|
|||
buffer_put_cstring(m, pwent->pw_shell);
|
||||
|
||||
out:
|
||||
ssh_packet_set_log_preamble(ssh, "%suser %s",
|
||||
authctxt->valid ? "authenticating" : "invalid ", authctxt->user);
|
||||
buffer_put_string(m, &options, sizeof(options));
|
||||
|
||||
#define M_CP_STROPT(x) do { \
|
||||
|
|
7
mux.c
7
mux.c
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: mux.c,v 1.63 2016/10/19 23:21:56 dtucker Exp $ */
|
||||
/* $OpenBSD: mux.c,v 1.64 2017/01/21 11:32:04 guenther Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2002-2008 Damien Miller <djm@openbsd.org>
|
||||
*
|
||||
|
@ -2161,7 +2161,6 @@ int
|
|||
muxclient(const char *path)
|
||||
{
|
||||
struct sockaddr_un addr;
|
||||
socklen_t sun_len;
|
||||
int sock;
|
||||
u_int pid;
|
||||
|
||||
|
@ -2185,8 +2184,6 @@ muxclient(const char *path)
|
|||
|
||||
memset(&addr, '\0', sizeof(addr));
|
||||
addr.sun_family = AF_UNIX;
|
||||
sun_len = offsetof(struct sockaddr_un, sun_path) +
|
||||
strlen(path) + 1;
|
||||
|
||||
if (strlcpy(addr.sun_path, path,
|
||||
sizeof(addr.sun_path)) >= sizeof(addr.sun_path))
|
||||
|
@ -2196,7 +2193,7 @@ muxclient(const char *path)
|
|||
if ((sock = socket(PF_UNIX, SOCK_STREAM, 0)) < 0)
|
||||
fatal("%s socket(): %s", __func__, strerror(errno));
|
||||
|
||||
if (connect(sock, (struct sockaddr *)&addr, sun_len) == -1) {
|
||||
if (connect(sock, (struct sockaddr *)&addr, sizeof(addr)) == -1) {
|
||||
switch (muxclient_command) {
|
||||
case SSHMUX_COMMAND_OPEN:
|
||||
case SSHMUX_COMMAND_STDIO_FWD:
|
||||
|
|
70
packet.c
70
packet.c
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: packet.c,v 1.243 2016/10/11 21:47:45 djm Exp $ */
|
||||
/* $OpenBSD: packet.c,v 1.245 2017/02/03 23:03:33 djm Exp $ */
|
||||
/*
|
||||
* Author: Tatu Ylonen <ylo@cs.hut.fi>
|
||||
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
|
||||
|
@ -352,6 +352,25 @@ ssh_packet_get_mux(struct ssh *ssh)
|
|||
return ssh->state->mux;
|
||||
}
|
||||
|
||||
int
|
||||
ssh_packet_set_log_preamble(struct ssh *ssh, const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
int r;
|
||||
|
||||
free(ssh->log_preamble);
|
||||
if (fmt == NULL)
|
||||
ssh->log_preamble = NULL;
|
||||
else {
|
||||
va_start(args, fmt);
|
||||
r = vasprintf(&ssh->log_preamble, fmt, args);
|
||||
va_end(args);
|
||||
if (r < 0 || ssh->log_preamble == NULL)
|
||||
return SSH_ERR_ALLOC_FAIL;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
ssh_packet_stop_discard(struct ssh *ssh)
|
||||
{
|
||||
|
@ -1049,7 +1068,7 @@ ssh_packet_need_rekeying(struct ssh *ssh, u_int outbound_packet_len)
|
|||
|
||||
/* Time-based rekeying */
|
||||
if (state->rekey_interval != 0 &&
|
||||
state->rekey_time + state->rekey_interval <= monotime())
|
||||
(int64_t)state->rekey_time + state->rekey_interval <= monotime())
|
||||
return 1;
|
||||
|
||||
/* Always rekey when MAX_PACKETS sent in either direction */
|
||||
|
@ -2074,27 +2093,36 @@ ssh_packet_send_debug(struct ssh *ssh, const char *fmt,...)
|
|||
fatal("%s: %s", __func__, ssh_err(r));
|
||||
}
|
||||
|
||||
static void
|
||||
fmt_connection_id(struct ssh *ssh, char *s, size_t l)
|
||||
{
|
||||
snprintf(s, l, "%.200s%s%s port %d",
|
||||
ssh->log_preamble ? ssh->log_preamble : "",
|
||||
ssh->log_preamble ? " " : "",
|
||||
ssh_remote_ipaddr(ssh), ssh_remote_port(ssh));
|
||||
}
|
||||
|
||||
/*
|
||||
* Pretty-print connection-terminating errors and exit.
|
||||
*/
|
||||
void
|
||||
sshpkt_fatal(struct ssh *ssh, const char *tag, int r)
|
||||
{
|
||||
char remote_id[512];
|
||||
|
||||
fmt_connection_id(ssh, remote_id, sizeof(remote_id));
|
||||
|
||||
switch (r) {
|
||||
case SSH_ERR_CONN_CLOSED:
|
||||
logdie("Connection closed by %.200s port %d",
|
||||
ssh_remote_ipaddr(ssh), ssh_remote_port(ssh));
|
||||
logdie("Connection closed by %s", remote_id);
|
||||
case SSH_ERR_CONN_TIMEOUT:
|
||||
logdie("Connection %s %.200s port %d timed out",
|
||||
ssh->state->server_side ? "from" : "to",
|
||||
ssh_remote_ipaddr(ssh), ssh_remote_port(ssh));
|
||||
logdie("Connection %s %s timed out",
|
||||
ssh->state->server_side ? "from" : "to", remote_id);
|
||||
case SSH_ERR_DISCONNECTED:
|
||||
logdie("Disconnected from %.200s port %d",
|
||||
ssh_remote_ipaddr(ssh), ssh_remote_port(ssh));
|
||||
logdie("Disconnected from %s", remote_id);
|
||||
case SSH_ERR_SYSTEM_ERROR:
|
||||
if (errno == ECONNRESET)
|
||||
logdie("Connection reset by %.200s port %d",
|
||||
ssh_remote_ipaddr(ssh), ssh_remote_port(ssh));
|
||||
logdie("Connection reset by %s", remote_id);
|
||||
/* FALLTHROUGH */
|
||||
case SSH_ERR_NO_CIPHER_ALG_MATCH:
|
||||
case SSH_ERR_NO_MAC_ALG_MATCH:
|
||||
|
@ -2102,17 +2130,16 @@ sshpkt_fatal(struct ssh *ssh, const char *tag, int r)
|
|||
case SSH_ERR_NO_KEX_ALG_MATCH:
|
||||
case SSH_ERR_NO_HOSTKEY_ALG_MATCH:
|
||||
if (ssh && ssh->kex && ssh->kex->failed_choice) {
|
||||
logdie("Unable to negotiate with %.200s port %d: %s. "
|
||||
"Their offer: %s", ssh_remote_ipaddr(ssh),
|
||||
ssh_remote_port(ssh), ssh_err(r),
|
||||
logdie("Unable to negotiate with %s: %s. "
|
||||
"Their offer: %s", remote_id, ssh_err(r),
|
||||
ssh->kex->failed_choice);
|
||||
}
|
||||
/* FALLTHROUGH */
|
||||
default:
|
||||
logdie("%s%sConnection %s %.200s port %d: %s",
|
||||
logdie("%s%sConnection %s %s: %s",
|
||||
tag != NULL ? tag : "", tag != NULL ? ": " : "",
|
||||
ssh->state->server_side ? "from" : "to",
|
||||
ssh_remote_ipaddr(ssh), ssh_remote_port(ssh), ssh_err(r));
|
||||
remote_id, ssh_err(r));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2125,7 +2152,7 @@ sshpkt_fatal(struct ssh *ssh, const char *tag, int r)
|
|||
void
|
||||
ssh_packet_disconnect(struct ssh *ssh, const char *fmt,...)
|
||||
{
|
||||
char buf[1024];
|
||||
char buf[1024], remote_id[512];
|
||||
va_list args;
|
||||
static int disconnecting = 0;
|
||||
int r;
|
||||
|
@ -2138,12 +2165,13 @@ ssh_packet_disconnect(struct ssh *ssh, const char *fmt,...)
|
|||
* Format the message. Note that the caller must make sure the
|
||||
* message is of limited size.
|
||||
*/
|
||||
fmt_connection_id(ssh, remote_id, sizeof(remote_id));
|
||||
va_start(args, fmt);
|
||||
vsnprintf(buf, sizeof(buf), fmt, args);
|
||||
va_end(args);
|
||||
|
||||
/* Display the error locally */
|
||||
logit("Disconnecting: %.100s", buf);
|
||||
logit("Disconnecting %s: %.100s", remote_id, buf);
|
||||
|
||||
/*
|
||||
* Send the disconnect message to the other side, and wait
|
||||
|
@ -2396,10 +2424,10 @@ ssh_packet_send_ignore(struct ssh *ssh, int nbytes)
|
|||
}
|
||||
|
||||
void
|
||||
ssh_packet_set_rekey_limits(struct ssh *ssh, u_int64_t bytes, time_t seconds)
|
||||
ssh_packet_set_rekey_limits(struct ssh *ssh, u_int64_t bytes, u_int32_t seconds)
|
||||
{
|
||||
debug3("rekey after %llu bytes, %d seconds", (unsigned long long)bytes,
|
||||
(int)seconds);
|
||||
debug3("rekey after %llu bytes, %u seconds", (unsigned long long)bytes,
|
||||
(unsigned int)seconds);
|
||||
ssh->state->rekey_limit = bytes;
|
||||
ssh->state->rekey_interval = seconds;
|
||||
}
|
||||
|
|
9
packet.h
9
packet.h
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: packet.h,v 1.74 2016/10/11 21:47:45 djm Exp $ */
|
||||
/* $OpenBSD: packet.h,v 1.76 2017/02/03 23:03:33 djm Exp $ */
|
||||
|
||||
/*
|
||||
* Author: Tatu Ylonen <ylo@cs.hut.fi>
|
||||
|
@ -62,6 +62,9 @@ struct ssh {
|
|||
char *local_ipaddr;
|
||||
int local_port;
|
||||
|
||||
/* Optional preamble for log messages (e.g. username) */
|
||||
char *log_preamble;
|
||||
|
||||
/* Dispatcher table */
|
||||
dispatch_fn *dispatch[DISPATCH_MAX];
|
||||
/* number of packets to ignore in the dispatcher */
|
||||
|
@ -104,6 +107,8 @@ void ssh_packet_set_server(struct ssh *);
|
|||
void ssh_packet_set_authenticated(struct ssh *);
|
||||
void ssh_packet_set_mux(struct ssh *);
|
||||
int ssh_packet_get_mux(struct ssh *);
|
||||
int ssh_packet_set_log_preamble(struct ssh *, const char *, ...)
|
||||
__attribute__((format(printf, 2, 3)));
|
||||
|
||||
int ssh_packet_log_type(u_char);
|
||||
|
||||
|
@ -154,7 +159,7 @@ int ssh_remote_port(struct ssh *);
|
|||
const char *ssh_local_ipaddr(struct ssh *);
|
||||
int ssh_local_port(struct ssh *);
|
||||
|
||||
void ssh_packet_set_rekey_limits(struct ssh *, u_int64_t, time_t);
|
||||
void ssh_packet_set_rekey_limits(struct ssh *, u_int64_t, u_int32_t);
|
||||
time_t ssh_packet_get_rekey_timeout(struct ssh *);
|
||||
|
||||
void *ssh_packet_get_input(struct ssh *);
|
||||
|
|
99
readconf.c
99
readconf.c
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: readconf.c,v 1.262 2016/10/25 04:08:13 jsg Exp $ */
|
||||
/* $OpenBSD: readconf.c,v 1.268 2017/02/03 23:01:19 djm Exp $ */
|
||||
/*
|
||||
* Author: Tatu Ylonen <ylo@cs.hut.fi>
|
||||
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
|
||||
|
@ -93,7 +93,7 @@
|
|||
|
||||
Host books.com
|
||||
RemoteForward 9999 shadows.cs.hut.fi:9999
|
||||
Cipher 3des
|
||||
Ciphers 3des-cbc
|
||||
|
||||
Host fascist.blob.com
|
||||
Port 23123
|
||||
|
@ -108,7 +108,7 @@
|
|||
PublicKeyAuthentication no
|
||||
|
||||
Host *.su
|
||||
Cipher none
|
||||
Ciphers aes128-ctr
|
||||
PasswordAuthentication no
|
||||
|
||||
Host vpn.fake.com
|
||||
|
@ -180,6 +180,44 @@ static struct {
|
|||
const char *name;
|
||||
OpCodes opcode;
|
||||
} keywords[] = {
|
||||
/* Deprecated options */
|
||||
{ "fallbacktorsh", oDeprecated },
|
||||
{ "globalknownhostsfile2", oDeprecated },
|
||||
{ "rhostsauthentication", oDeprecated },
|
||||
{ "userknownhostsfile2", oDeprecated },
|
||||
{ "useroaming", oDeprecated },
|
||||
{ "usersh", oDeprecated },
|
||||
|
||||
/* Unsupported options */
|
||||
{ "afstokenpassing", oUnsupported },
|
||||
{ "kerberosauthentication", oUnsupported },
|
||||
{ "kerberostgtpassing", oUnsupported },
|
||||
|
||||
/* Sometimes-unsupported options */
|
||||
#if defined(GSSAPI)
|
||||
{ "gssapiauthentication", oGssAuthentication },
|
||||
{ "gssapidelegatecredentials", oGssDelegateCreds },
|
||||
# else
|
||||
{ "gssapiauthentication", oUnsupported },
|
||||
{ "gssapidelegatecredentials", oUnsupported },
|
||||
#endif
|
||||
#ifdef ENABLE_PKCS11
|
||||
{ "smartcarddevice", oPKCS11Provider },
|
||||
{ "pkcs11provider", oPKCS11Provider },
|
||||
# else
|
||||
{ "smartcarddevice", oUnsupported },
|
||||
{ "pkcs11provider", oUnsupported },
|
||||
#endif
|
||||
#ifdef WITH_SSH1
|
||||
{ "rsaauthentication", oRSAAuthentication },
|
||||
{ "rhostsrsaauthentication", oRhostsRSAAuthentication },
|
||||
{ "compressionlevel", oCompressionLevel },
|
||||
# else
|
||||
{ "rsaauthentication", oUnsupported },
|
||||
{ "rhostsrsaauthentication", oUnsupported },
|
||||
{ "compressionlevel", oUnsupported },
|
||||
#endif
|
||||
|
||||
{ "forwardagent", oForwardAgent },
|
||||
{ "forwardx11", oForwardX11 },
|
||||
{ "forwardx11trusted", oForwardX11Trusted },
|
||||
|
@ -188,30 +226,15 @@ static struct {
|
|||
{ "xauthlocation", oXAuthLocation },
|
||||
{ "gatewayports", oGatewayPorts },
|
||||
{ "useprivilegedport", oUsePrivilegedPort },
|
||||
{ "rhostsauthentication", oDeprecated },
|
||||
{ "passwordauthentication", oPasswordAuthentication },
|
||||
{ "kbdinteractiveauthentication", oKbdInteractiveAuthentication },
|
||||
{ "kbdinteractivedevices", oKbdInteractiveDevices },
|
||||
{ "rsaauthentication", oRSAAuthentication },
|
||||
{ "pubkeyauthentication", oPubkeyAuthentication },
|
||||
{ "dsaauthentication", oPubkeyAuthentication }, /* alias */
|
||||
{ "rhostsrsaauthentication", oRhostsRSAAuthentication },
|
||||
{ "hostbasedauthentication", oHostbasedAuthentication },
|
||||
{ "challengeresponseauthentication", oChallengeResponseAuthentication },
|
||||
{ "skeyauthentication", oChallengeResponseAuthentication }, /* alias */
|
||||
{ "tisauthentication", oChallengeResponseAuthentication }, /* alias */
|
||||
{ "kerberosauthentication", oUnsupported },
|
||||
{ "kerberostgtpassing", oUnsupported },
|
||||
{ "afstokenpassing", oUnsupported },
|
||||
#if defined(GSSAPI)
|
||||
{ "gssapiauthentication", oGssAuthentication },
|
||||
{ "gssapidelegatecredentials", oGssDelegateCreds },
|
||||
#else
|
||||
{ "gssapiauthentication", oUnsupported },
|
||||
{ "gssapidelegatecredentials", oUnsupported },
|
||||
#endif
|
||||
{ "fallbacktorsh", oDeprecated },
|
||||
{ "usersh", oDeprecated },
|
||||
{ "identityfile", oIdentityFile },
|
||||
{ "identityfile2", oIdentityFile }, /* obsolete */
|
||||
{ "identitiesonly", oIdentitiesOnly },
|
||||
|
@ -233,15 +256,12 @@ static struct {
|
|||
{ "match", oMatch },
|
||||
{ "escapechar", oEscapeChar },
|
||||
{ "globalknownhostsfile", oGlobalKnownHostsFile },
|
||||
{ "globalknownhostsfile2", oDeprecated },
|
||||
{ "userknownhostsfile", oUserKnownHostsFile },
|
||||
{ "userknownhostsfile2", oDeprecated },
|
||||
{ "connectionattempts", oConnectionAttempts },
|
||||
{ "batchmode", oBatchMode },
|
||||
{ "checkhostip", oCheckHostIP },
|
||||
{ "stricthostkeychecking", oStrictHostKeyChecking },
|
||||
{ "compression", oCompression },
|
||||
{ "compressionlevel", oCompressionLevel },
|
||||
{ "tcpkeepalive", oTCPKeepAlive },
|
||||
{ "keepalive", oTCPKeepAlive }, /* obsolete */
|
||||
{ "numberofpasswordprompts", oNumberOfPasswordPrompts },
|
||||
|
@ -250,13 +270,6 @@ static struct {
|
|||
{ "preferredauthentications", oPreferredAuthentications },
|
||||
{ "hostkeyalgorithms", oHostKeyAlgorithms },
|
||||
{ "bindaddress", oBindAddress },
|
||||
#ifdef ENABLE_PKCS11
|
||||
{ "smartcarddevice", oPKCS11Provider },
|
||||
{ "pkcs11provider", oPKCS11Provider },
|
||||
#else
|
||||
{ "smartcarddevice", oUnsupported },
|
||||
{ "pkcs11provider", oUnsupported },
|
||||
#endif
|
||||
{ "clearallforwardings", oClearAllForwardings },
|
||||
{ "enablesshkeysign", oEnableSSHKeysign },
|
||||
{ "verifyhostkeydns", oVerifyHostKeyDNS },
|
||||
|
@ -277,7 +290,6 @@ static struct {
|
|||
{ "localcommand", oLocalCommand },
|
||||
{ "permitlocalcommand", oPermitLocalCommand },
|
||||
{ "visualhostkey", oVisualHostKey },
|
||||
{ "useroaming", oDeprecated },
|
||||
{ "kexalgorithms", oKexAlgorithms },
|
||||
{ "ipqos", oIPQoS },
|
||||
{ "requesttty", oRequestTTY },
|
||||
|
@ -835,11 +847,11 @@ process_config_line_depth(Options *options, struct passwd *pw, const char *host,
|
|||
activep = &cmdline;
|
||||
}
|
||||
|
||||
/* Strip trailing whitespace */
|
||||
/* Strip trailing whitespace. Allow \f (form feed) at EOL only */
|
||||
if ((len = strlen(line)) == 0)
|
||||
return 0;
|
||||
for (len--; len > 0; len--) {
|
||||
if (strchr(WHITESPACE, line[len]) == NULL)
|
||||
if (strchr(WHITESPACE "\f", line[len]) == NULL)
|
||||
break;
|
||||
line[len] = '\0';
|
||||
}
|
||||
|
@ -1187,7 +1199,7 @@ parse_int:
|
|||
arg = strdelim(&s);
|
||||
if (!arg || *arg == '\0')
|
||||
fatal("%.200s line %d: Missing argument.", filename, linenum);
|
||||
if (!ciphers_valid(*arg == '+' ? arg + 1 : arg))
|
||||
if (*arg != '-' && !ciphers_valid(*arg == '+' ? arg + 1 : arg))
|
||||
fatal("%.200s line %d: Bad SSH2 cipher spec '%s'.",
|
||||
filename, linenum, arg ? arg : "<NONE>");
|
||||
if (*activep && options->ciphers == NULL)
|
||||
|
@ -1198,7 +1210,7 @@ parse_int:
|
|||
arg = strdelim(&s);
|
||||
if (!arg || *arg == '\0')
|
||||
fatal("%.200s line %d: Missing argument.", filename, linenum);
|
||||
if (!mac_valid(*arg == '+' ? arg + 1 : arg))
|
||||
if (*arg != '-' && !mac_valid(*arg == '+' ? arg + 1 : arg))
|
||||
fatal("%.200s line %d: Bad SSH2 Mac spec '%s'.",
|
||||
filename, linenum, arg ? arg : "<NONE>");
|
||||
if (*activep && options->macs == NULL)
|
||||
|
@ -1210,7 +1222,8 @@ parse_int:
|
|||
if (!arg || *arg == '\0')
|
||||
fatal("%.200s line %d: Missing argument.",
|
||||
filename, linenum);
|
||||
if (!kex_names_valid(*arg == '+' ? arg + 1 : arg))
|
||||
if (*arg != '-' &&
|
||||
!kex_names_valid(*arg == '+' ? arg + 1 : arg))
|
||||
fatal("%.200s line %d: Bad SSH2 KexAlgorithms '%s'.",
|
||||
filename, linenum, arg ? arg : "<NONE>");
|
||||
if (*activep && options->kex_algorithms == NULL)
|
||||
|
@ -1224,7 +1237,8 @@ parse_keytypes:
|
|||
if (!arg || *arg == '\0')
|
||||
fatal("%.200s line %d: Missing argument.",
|
||||
filename, linenum);
|
||||
if (!sshkey_names_valid2(*arg == '+' ? arg + 1 : arg, 1))
|
||||
if (*arg != '-' &&
|
||||
!sshkey_names_valid2(*arg == '+' ? arg + 1 : arg, 1))
|
||||
fatal("%s line %d: Bad key types '%s'.",
|
||||
filename, linenum, arg ? arg : "<NONE>");
|
||||
if (*activep && *charptr == NULL)
|
||||
|
@ -1507,6 +1521,11 @@ parse_keytypes:
|
|||
flags | SSHCONF_CHECKPERM |
|
||||
(oactive ? 0 : SSHCONF_NEVERMATCH),
|
||||
activep, depth + 1);
|
||||
if (r != 1 && errno != ENOENT) {
|
||||
fatal("Can't open user config file "
|
||||
"%.100s: %.100s", gl.gl_pathv[i],
|
||||
strerror(errno));
|
||||
}
|
||||
/*
|
||||
* don't let Match in includes clobber the
|
||||
* containing file's Match state.
|
||||
|
@ -2453,10 +2472,10 @@ dump_cfg_forwards(OpCodes code, u_int count, const struct Forward *fwds)
|
|||
/* oDynamicForward */
|
||||
for (i = 0; i < count; i++) {
|
||||
fwd = &fwds[i];
|
||||
if (code == oDynamicForward &&
|
||||
if (code == oDynamicForward && fwd->connect_host != NULL &&
|
||||
strcmp(fwd->connect_host, "socks") != 0)
|
||||
continue;
|
||||
if (code == oLocalForward &&
|
||||
if (code == oLocalForward && fwd->connect_host != NULL &&
|
||||
strcmp(fwd->connect_host, "socks") == 0)
|
||||
continue;
|
||||
printf("%s", lookup_opcode_name(code));
|
||||
|
@ -2529,8 +2548,10 @@ dump_client_config(Options *o, const char *host)
|
|||
dump_cfg_fmtint(oProxyUseFdpass, o->proxy_use_fdpass);
|
||||
dump_cfg_fmtint(oPubkeyAuthentication, o->pubkey_authentication);
|
||||
dump_cfg_fmtint(oRequestTTY, o->request_tty);
|
||||
#ifdef WITH_RSA1
|
||||
dump_cfg_fmtint(oRhostsRSAAuthentication, o->rhosts_rsa_authentication);
|
||||
dump_cfg_fmtint(oRSAAuthentication, o->rsa_authentication);
|
||||
#endif
|
||||
dump_cfg_fmtint(oStreamLocalBindUnlink, o->fwd_opts.streamlocal_bind_unlink);
|
||||
dump_cfg_fmtint(oStrictHostKeyChecking, o->strict_host_key_checking);
|
||||
dump_cfg_fmtint(oTCPKeepAlive, o->tcp_keep_alive);
|
||||
|
@ -2542,7 +2563,9 @@ dump_client_config(Options *o, const char *host)
|
|||
|
||||
/* Integer options */
|
||||
dump_cfg_int(oCanonicalizeMaxDots, o->canonicalize_max_dots);
|
||||
#ifdef WITH_SSH1
|
||||
dump_cfg_int(oCompressionLevel, o->compression_level);
|
||||
#endif
|
||||
dump_cfg_int(oConnectionAttempts, o->connection_attempts);
|
||||
dump_cfg_int(oForwardX11Timeout, o->forward_x11_timeout);
|
||||
dump_cfg_int(oNumberOfPasswordPrompts, o->number_of_password_prompts);
|
||||
|
@ -2562,7 +2585,9 @@ dump_client_config(Options *o, const char *host)
|
|||
dump_cfg_string(oLocalCommand, o->local_command);
|
||||
dump_cfg_string(oLogLevel, log_level_name(o->log_level));
|
||||
dump_cfg_string(oMacs, o->macs ? o->macs : KEX_CLIENT_MAC);
|
||||
#ifdef ENABLE_PKCS11
|
||||
dump_cfg_string(oPKCS11Provider, o->pkcs11_provider);
|
||||
#endif
|
||||
dump_cfg_string(oPreferredAuthentications, o->preferred_authentications);
|
||||
dump_cfg_string(oPubkeyAcceptedKeyTypes, o->pubkey_key_types);
|
||||
dump_cfg_string(oRevokedHostKeys, o->revoked_host_keys);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $OpenBSD: agent-getpeereid.sh,v 1.7 2016/09/26 21:34:38 bluhm Exp $
|
||||
# $OpenBSD: agent-getpeereid.sh,v 1.8 2017/01/06 02:51:16 djm Exp $
|
||||
# Placed in the Public Domain.
|
||||
|
||||
tid="disallow agent attach from other uid"
|
||||
|
@ -32,17 +32,17 @@ if [ $r -ne 0 ]; then
|
|||
else
|
||||
chmod 644 ${SSH_AUTH_SOCK}
|
||||
|
||||
ssh-add -l > /dev/null 2>&1
|
||||
${SSHADD} -l > /dev/null 2>&1
|
||||
r=$?
|
||||
if [ $r -ne 1 ]; then
|
||||
fail "ssh-add failed with $r != 1"
|
||||
fi
|
||||
if test -z "$sudo" ; then
|
||||
# doas
|
||||
${SUDO} -n -u ${UNPRIV} ssh-add -l 2>/dev/null
|
||||
${SUDO} -n -u ${UNPRIV} ${SSHADD} -l 2>/dev/null
|
||||
else
|
||||
# sudo
|
||||
< /dev/null ${SUDO} -S -u ${UNPRIV} ssh-add -l 2>/dev/null
|
||||
< /dev/null ${SUDO} -S -u ${UNPRIV} ${SSHADD} -l 2>/dev/null
|
||||
fi
|
||||
r=$?
|
||||
if [ $r -lt 2 ]; then
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $OpenBSD: forwarding.sh,v 1.16 2016/04/14 23:57:17 djm Exp $
|
||||
# $OpenBSD: forwarding.sh,v 1.19 2017/01/30 05:22:14 djm Exp $
|
||||
# Placed in the Public Domain.
|
||||
|
||||
tid="local and remote forwarding"
|
||||
|
@ -11,7 +11,6 @@ base=33
|
|||
last=$PORT
|
||||
fwd=""
|
||||
CTL=$OBJ/ctl-sock
|
||||
rm -f $CTL
|
||||
|
||||
for j in 0 1 2; do
|
||||
for i in 0 1 2; do
|
||||
|
@ -29,7 +28,8 @@ for p in ${SSH_PROTOCOLS}; do
|
|||
q=$p
|
||||
fi
|
||||
trace "start forwarding, fork to background"
|
||||
${SSH} -$p -F $OBJ/ssh_config -f $fwd somehost sleep 10
|
||||
rm -f $CTL
|
||||
${SSH} -S $CTL -M -$p -F $OBJ/ssh_config -f $fwd somehost sleep 10
|
||||
|
||||
trace "transfer over forwarded channels and check result"
|
||||
${SSH} -$q -F $OBJ/ssh_config -p$last -o 'ConnectionAttempts=4' \
|
||||
|
@ -37,7 +37,7 @@ for p in ${SSH_PROTOCOLS}; do
|
|||
test -s ${COPY} || fail "failed copy of ${DATA}"
|
||||
cmp ${DATA} ${COPY} || fail "corrupted copy of ${DATA}"
|
||||
|
||||
sleep 10
|
||||
${SSH} -F $OBJ/ssh_config -S $CTL -O exit somehost
|
||||
done
|
||||
|
||||
for p in ${SSH_PROTOCOLS}; do
|
||||
|
@ -52,7 +52,7 @@ for d in L R; do
|
|||
-$d ${base}04:127.0.0.1:$PORT \
|
||||
-oExitOnForwardFailure=yes somehost true
|
||||
if [ $? != 0 ]; then
|
||||
fail "connection failed, should not"
|
||||
fatal "connection failed, should not"
|
||||
else
|
||||
# this one should fail
|
||||
${SSH} -q -$p -F $OBJ/ssh_config \
|
||||
|
@ -75,30 +75,32 @@ for p in ${SSH_PROTOCOLS}; do
|
|||
${SSH} -$p -F $OBJ/ssh_config -oClearAllForwardings=yes somehost true
|
||||
|
||||
trace "clear local forward proto $p"
|
||||
${SSH} -$p -f -F $OBJ/ssh_config -L ${base}01:127.0.0.1:$PORT \
|
||||
rm -f $CTL
|
||||
${SSH} -S $CTL -M -$p -f -F $OBJ/ssh_config -L ${base}01:127.0.0.1:$PORT \
|
||||
-oClearAllForwardings=yes somehost sleep 10
|
||||
if [ $? != 0 ]; then
|
||||
fail "connection failed with cleared local forwarding"
|
||||
else
|
||||
# this one should fail
|
||||
${SSH} -$p -F $OBJ/ssh_config -p ${base}01 true \
|
||||
${SSH} -$p -F $OBJ/ssh_config -p ${base}01 somehost true \
|
||||
>>$TEST_REGRESS_LOGFILE 2>&1 && \
|
||||
fail "local forwarding not cleared"
|
||||
fi
|
||||
sleep 10
|
||||
${SSH} -F $OBJ/ssh_config -S $CTL -O exit somehost
|
||||
|
||||
trace "clear remote forward proto $p"
|
||||
${SSH} -$p -f -F $OBJ/ssh_config -R ${base}01:127.0.0.1:$PORT \
|
||||
rm -f $CTL
|
||||
${SSH} -S $CTL -M -$p -f -F $OBJ/ssh_config -R ${base}01:127.0.0.1:$PORT \
|
||||
-oClearAllForwardings=yes somehost sleep 10
|
||||
if [ $? != 0 ]; then
|
||||
fail "connection failed with cleared remote forwarding"
|
||||
else
|
||||
# this one should fail
|
||||
${SSH} -$p -F $OBJ/ssh_config -p ${base}01 true \
|
||||
${SSH} -$p -F $OBJ/ssh_config -p ${base}01 somehost true \
|
||||
>>$TEST_REGRESS_LOGFILE 2>&1 && \
|
||||
fail "remote forwarding not cleared"
|
||||
fi
|
||||
sleep 10
|
||||
${SSH} -F $OBJ/ssh_config -S $CTL -O exit somehost
|
||||
done
|
||||
|
||||
for p in 2; do
|
||||
|
@ -115,6 +117,7 @@ echo "LocalForward ${base}01 127.0.0.1:$PORT" >> $OBJ/ssh_config
|
|||
echo "RemoteForward ${base}02 127.0.0.1:${base}01" >> $OBJ/ssh_config
|
||||
for p in ${SSH_PROTOCOLS}; do
|
||||
trace "config file: start forwarding, fork to background"
|
||||
rm -f $CTL
|
||||
${SSH} -S $CTL -M -$p -F $OBJ/ssh_config -f somehost sleep 10
|
||||
|
||||
trace "config file: transfer over forwarded channels and check result"
|
||||
|
@ -123,21 +126,24 @@ for p in ${SSH_PROTOCOLS}; do
|
|||
test -s ${COPY} || fail "failed copy of ${DATA}"
|
||||
cmp ${DATA} ${COPY} || fail "corrupted copy of ${DATA}"
|
||||
|
||||
${SSH} -S $CTL -O exit somehost
|
||||
${SSH} -F $OBJ/ssh_config -S $CTL -O exit somehost
|
||||
done
|
||||
|
||||
for p in 2; do
|
||||
trace "transfer over chained unix domain socket forwards and check result"
|
||||
rm -f $OBJ/unix-[123].fwd
|
||||
${SSH} -f -F $OBJ/ssh_config -R${base}01:[$OBJ/unix-1.fwd] somehost sleep 10
|
||||
${SSH} -f -F $OBJ/ssh_config -L[$OBJ/unix-1.fwd]:[$OBJ/unix-2.fwd] somehost sleep 10
|
||||
${SSH} -f -F $OBJ/ssh_config -R[$OBJ/unix-2.fwd]:[$OBJ/unix-3.fwd] somehost sleep 10
|
||||
${SSH} -f -F $OBJ/ssh_config -L[$OBJ/unix-3.fwd]:127.0.0.1:$PORT somehost sleep 10
|
||||
rm -f $CTL $CTL.[123]
|
||||
${SSH} -S $CTL -M -f -F $OBJ/ssh_config -R${base}01:[$OBJ/unix-1.fwd] somehost sleep 10
|
||||
${SSH} -S $CTL.1 -M -f -F $OBJ/ssh_config -L[$OBJ/unix-1.fwd]:[$OBJ/unix-2.fwd] somehost sleep 10
|
||||
${SSH} -S $CTL.2 -M -f -F $OBJ/ssh_config -R[$OBJ/unix-2.fwd]:[$OBJ/unix-3.fwd] somehost sleep 10
|
||||
${SSH} -S $CTL.3 -M -f -F $OBJ/ssh_config -L[$OBJ/unix-3.fwd]:127.0.0.1:$PORT somehost sleep 10
|
||||
${SSH} -F $OBJ/ssh_config -p${base}01 -o 'ConnectionAttempts=4' \
|
||||
somehost cat ${DATA} > ${COPY}
|
||||
test -s ${COPY} || fail "failed copy ${DATA}"
|
||||
cmp ${DATA} ${COPY} || fail "corrupted copy of ${DATA}"
|
||||
|
||||
#wait
|
||||
sleep 10
|
||||
${SSH} -F $OBJ/ssh_config -S $CTL -O exit somehost
|
||||
${SSH} -F $OBJ/ssh_config -S $CTL.1 -O exit somehost
|
||||
${SSH} -F $OBJ/ssh_config -S $CTL.2 -O exit somehost
|
||||
${SSH} -F $OBJ/ssh_config -S $CTL.3 -O exit somehost
|
||||
done
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
# $OpenBSD: integrity.sh,v 1.19 2016/11/25 02:56:49 dtucker Exp $
|
||||
# $OpenBSD: integrity.sh,v 1.20 2017/01/06 02:26:10 dtucker Exp $
|
||||
# Placed in the Public Domain.
|
||||
|
||||
tid="integrity"
|
||||
cp $OBJ/sshd_proxy $OBJ/sshd_proxy_bak
|
||||
|
||||
# start at byte 2900 (i.e. after kex) and corrupt at different offsets
|
||||
# XXX the test hangs if we modify the low bytes of the packet length
|
||||
# XXX and ssh tries to read...
|
||||
tries=10
|
||||
startoffset=2900
|
||||
macs=`${SSH} -Q mac`
|
||||
|
@ -27,6 +25,7 @@ for m in $macs; do
|
|||
elen=0
|
||||
epad=0
|
||||
emac=0
|
||||
etmo=0
|
||||
ecnt=0
|
||||
skip=0
|
||||
for off in `jot $tries $startoffset`; do
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: tests.c,v 1.3 2016/09/21 17:03:54 djm Exp $ */
|
||||
/* $OpenBSD: tests.c,v 1.4 2017/02/03 23:01:42 djm Exp $ */
|
||||
/*
|
||||
* Regress test for matching functions
|
||||
*
|
||||
|
@ -103,6 +103,25 @@ tests(void)
|
|||
/* XXX negated ASSERT_INT_EQ(addr_match_list("127.0.0.1", "!127.0.0.2,10.0.0.1"), 1); */
|
||||
TEST_DONE();
|
||||
|
||||
#define CHECK_FILTER(string,filter,expected) \
|
||||
do { \
|
||||
char *result = match_filter_list((string), (filter)); \
|
||||
ASSERT_STRING_EQ(result, expected); \
|
||||
free(result); \
|
||||
} while (0)
|
||||
|
||||
TEST_START("match_filter_list");
|
||||
CHECK_FILTER("a,b,c", "", "a,b,c");
|
||||
CHECK_FILTER("a,b,c", "a", "b,c");
|
||||
CHECK_FILTER("a,b,c", "b", "a,c");
|
||||
CHECK_FILTER("a,b,c", "c", "a,b");
|
||||
CHECK_FILTER("a,b,c", "a,b", "c");
|
||||
CHECK_FILTER("a,b,c", "a,c", "b");
|
||||
CHECK_FILTER("a,b,c", "b,c", "a");
|
||||
CHECK_FILTER("a,b,c", "a,b,c", "");
|
||||
CHECK_FILTER("a,b,c", "b,c", "a");
|
||||
CHECK_FILTER("", "a,b,c", "");
|
||||
TEST_DONE();
|
||||
/*
|
||||
* XXX TODO
|
||||
* int match_host_and_ip(const char *, const char *, const char *);
|
||||
|
|
23
servconf.c
23
servconf.c
|
@ -1,5 +1,5 @@
|
|||
|
||||
/* $OpenBSD: servconf.c,v 1.301 2016/11/30 03:00:05 djm Exp $ */
|
||||
/* $OpenBSD: servconf.c,v 1.304 2017/02/03 23:01:19 djm Exp $ */
|
||||
/*
|
||||
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
|
||||
* All rights reserved
|
||||
|
@ -270,7 +270,7 @@ fill_default_server_options(ServerOptions *options)
|
|||
if (options->gss_cleanup_creds == -1)
|
||||
options->gss_cleanup_creds = 1;
|
||||
if (options->gss_strict_acceptor == -1)
|
||||
options->gss_strict_acceptor = 0;
|
||||
options->gss_strict_acceptor = 1;
|
||||
if (options->password_authentication == -1)
|
||||
options->password_authentication = 1;
|
||||
if (options->kbd_interactive_authentication == -1)
|
||||
|
@ -971,6 +971,15 @@ process_server_config_line(ServerOptions *options, char *line,
|
|||
long long val64;
|
||||
const struct multistate *multistate_ptr;
|
||||
|
||||
/* Strip trailing whitespace. Allow \f (form feed) at EOL only */
|
||||
if ((len = strlen(line)) == 0)
|
||||
return 0;
|
||||
for (len--; len > 0; len--) {
|
||||
if (strchr(WHITESPACE "\f", line[len]) == NULL)
|
||||
break;
|
||||
line[len] = '\0';
|
||||
}
|
||||
|
||||
cp = line;
|
||||
if ((arg = strdelim(&cp)) == NULL)
|
||||
return 0;
|
||||
|
@ -1173,7 +1182,8 @@ process_server_config_line(ServerOptions *options, char *line,
|
|||
if (!arg || *arg == '\0')
|
||||
fatal("%s line %d: Missing argument.",
|
||||
filename, linenum);
|
||||
if (!sshkey_names_valid2(*arg == '+' ? arg + 1 : arg, 1))
|
||||
if (*arg != '-' &&
|
||||
!sshkey_names_valid2(*arg == '+' ? arg + 1 : arg, 1))
|
||||
fatal("%s line %d: Bad key types '%s'.",
|
||||
filename, linenum, arg ? arg : "<NONE>");
|
||||
if (*activep && *charptr == NULL)
|
||||
|
@ -1432,7 +1442,7 @@ process_server_config_line(ServerOptions *options, char *line,
|
|||
arg = strdelim(&cp);
|
||||
if (!arg || *arg == '\0')
|
||||
fatal("%s line %d: Missing argument.", filename, linenum);
|
||||
if (!ciphers_valid(*arg == '+' ? arg + 1 : arg))
|
||||
if (*arg != '-' && !ciphers_valid(*arg == '+' ? arg + 1 : arg))
|
||||
fatal("%s line %d: Bad SSH2 cipher spec '%s'.",
|
||||
filename, linenum, arg ? arg : "<NONE>");
|
||||
if (options->ciphers == NULL)
|
||||
|
@ -1443,7 +1453,7 @@ process_server_config_line(ServerOptions *options, char *line,
|
|||
arg = strdelim(&cp);
|
||||
if (!arg || *arg == '\0')
|
||||
fatal("%s line %d: Missing argument.", filename, linenum);
|
||||
if (!mac_valid(*arg == '+' ? arg + 1 : arg))
|
||||
if (*arg != '-' && !mac_valid(*arg == '+' ? arg + 1 : arg))
|
||||
fatal("%s line %d: Bad SSH2 mac spec '%s'.",
|
||||
filename, linenum, arg ? arg : "<NONE>");
|
||||
if (options->macs == NULL)
|
||||
|
@ -1455,7 +1465,8 @@ process_server_config_line(ServerOptions *options, char *line,
|
|||
if (!arg || *arg == '\0')
|
||||
fatal("%s line %d: Missing argument.",
|
||||
filename, linenum);
|
||||
if (!kex_names_valid(*arg == '+' ? arg + 1 : arg))
|
||||
if (*arg != '-' &&
|
||||
!kex_names_valid(*arg == '+' ? arg + 1 : arg))
|
||||
fatal("%s line %d: Bad SSH2 KexAlgorithms '%s'.",
|
||||
filename, linenum, arg ? arg : "<NONE>");
|
||||
if (options->kex_algorithms == NULL)
|
||||
|
|
36
serverloop.c
36
serverloop.c
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: serverloop.c,v 1.189 2016/12/14 00:36:34 djm Exp $ */
|
||||
/* $OpenBSD: serverloop.c,v 1.191 2017/02/01 02:59:09 dtucker Exp $ */
|
||||
/*
|
||||
* Author: Tatu Ylonen <ylo@cs.hut.fi>
|
||||
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
|
||||
|
@ -430,7 +430,7 @@ server_input_keep_alive(int type, u_int32_t seq, void *ctxt)
|
|||
}
|
||||
|
||||
static Channel *
|
||||
server_request_direct_tcpip(void)
|
||||
server_request_direct_tcpip(int *reason, const char **errmsg)
|
||||
{
|
||||
Channel *c = NULL;
|
||||
char *target, *originator;
|
||||
|
@ -449,11 +449,13 @@ server_request_direct_tcpip(void)
|
|||
if ((options.allow_tcp_forwarding & FORWARD_LOCAL) != 0 &&
|
||||
!no_port_forwarding_flag && !options.disable_forwarding) {
|
||||
c = channel_connect_to_port(target, target_port,
|
||||
"direct-tcpip", "direct-tcpip");
|
||||
"direct-tcpip", "direct-tcpip", reason, errmsg);
|
||||
} else {
|
||||
logit("refused local port forward: "
|
||||
"originator %s port %d, target %s port %d",
|
||||
originator, originator_port, target, target_port);
|
||||
if (reason != NULL)
|
||||
*reason = SSH2_OPEN_ADMINISTRATIVELY_PROHIBITED;
|
||||
}
|
||||
|
||||
free(originator);
|
||||
|
@ -468,6 +470,10 @@ server_request_direct_streamlocal(void)
|
|||
Channel *c = NULL;
|
||||
char *target, *originator;
|
||||
u_short originator_port;
|
||||
struct passwd *pw = the_authctxt->pw;
|
||||
|
||||
if (pw == NULL || !the_authctxt->valid)
|
||||
fatal("server_input_global_request: no/invalid user");
|
||||
|
||||
target = packet_get_string(NULL);
|
||||
originator = packet_get_string(NULL);
|
||||
|
@ -480,7 +486,7 @@ server_request_direct_streamlocal(void)
|
|||
/* XXX fine grained permissions */
|
||||
if ((options.allow_streamlocal_forwarding & FORWARD_LOCAL) != 0 &&
|
||||
!no_port_forwarding_flag && !options.disable_forwarding &&
|
||||
use_privsep) {
|
||||
(pw->pw_uid == 0 || use_privsep)) {
|
||||
c = channel_connect_to_path(target,
|
||||
"direct-streamlocal@openssh.com", "direct-streamlocal");
|
||||
} else {
|
||||
|
@ -577,7 +583,8 @@ server_input_channel_open(int type, u_int32_t seq, void *ctxt)
|
|||
{
|
||||
Channel *c = NULL;
|
||||
char *ctype;
|
||||
int rchan;
|
||||
const char *errmsg = NULL;
|
||||
int rchan, reason = SSH2_OPEN_CONNECT_FAILED;
|
||||
u_int rmaxpack, rwindow, len;
|
||||
|
||||
ctype = packet_get_string(&len);
|
||||
|
@ -591,7 +598,7 @@ server_input_channel_open(int type, u_int32_t seq, void *ctxt)
|
|||
if (strcmp(ctype, "session") == 0) {
|
||||
c = server_request_session();
|
||||
} else if (strcmp(ctype, "direct-tcpip") == 0) {
|
||||
c = server_request_direct_tcpip();
|
||||
c = server_request_direct_tcpip(&reason, &errmsg);
|
||||
} else if (strcmp(ctype, "direct-streamlocal@openssh.com") == 0) {
|
||||
c = server_request_direct_streamlocal();
|
||||
} else if (strcmp(ctype, "tun@openssh.com") == 0) {
|
||||
|
@ -614,9 +621,9 @@ server_input_channel_open(int type, u_int32_t seq, void *ctxt)
|
|||
debug("server_input_channel_open: failure %s", ctype);
|
||||
packet_start(SSH2_MSG_CHANNEL_OPEN_FAILURE);
|
||||
packet_put_int(rchan);
|
||||
packet_put_int(SSH2_OPEN_ADMINISTRATIVELY_PROHIBITED);
|
||||
packet_put_int(reason);
|
||||
if (!(datafellows & SSH_BUG_OPENFAILURE)) {
|
||||
packet_put_cstring("open failed");
|
||||
packet_put_cstring(errmsg ? errmsg : "open failed");
|
||||
packet_put_cstring("");
|
||||
}
|
||||
packet_send();
|
||||
|
@ -702,6 +709,10 @@ server_input_global_request(int type, u_int32_t seq, void *ctxt)
|
|||
int want_reply;
|
||||
int r, success = 0, allocated_listen_port = 0;
|
||||
struct sshbuf *resp = NULL;
|
||||
struct passwd *pw = the_authctxt->pw;
|
||||
|
||||
if (pw == NULL || !the_authctxt->valid)
|
||||
fatal("server_input_global_request: no/invalid user");
|
||||
|
||||
rtype = packet_get_string(NULL);
|
||||
want_reply = packet_get_char();
|
||||
|
@ -709,12 +720,8 @@ server_input_global_request(int type, u_int32_t seq, void *ctxt)
|
|||
|
||||
/* -R style forwarding */
|
||||
if (strcmp(rtype, "tcpip-forward") == 0) {
|
||||
struct passwd *pw;
|
||||
struct Forward fwd;
|
||||
|
||||
pw = the_authctxt->pw;
|
||||
if (pw == NULL || !the_authctxt->valid)
|
||||
fatal("server_input_global_request: no/invalid user");
|
||||
memset(&fwd, 0, sizeof(fwd));
|
||||
fwd.listen_host = packet_get_string(NULL);
|
||||
fwd.listen_port = (u_short)packet_get_int();
|
||||
|
@ -762,9 +769,10 @@ server_input_global_request(int type, u_int32_t seq, void *ctxt)
|
|||
/* check permissions */
|
||||
if ((options.allow_streamlocal_forwarding & FORWARD_REMOTE) == 0
|
||||
|| no_port_forwarding_flag || options.disable_forwarding ||
|
||||
!use_privsep) {
|
||||
(pw->pw_uid != 0 && !use_privsep)) {
|
||||
success = 0;
|
||||
packet_send_debug("Server has disabled port forwarding.");
|
||||
packet_send_debug("Server has disabled "
|
||||
"streamlocal forwarding.");
|
||||
} else {
|
||||
/* Start listening on the socket */
|
||||
success = channel_setup_remote_fwd_listener(
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: ssh-keyscan.c,v 1.106 2016/05/02 10:26:04 djm Exp $ */
|
||||
/* $OpenBSD: ssh-keyscan.c,v 1.107 2017/01/06 03:41:58 djm Exp $ */
|
||||
/*
|
||||
* Copyright 1995, 1996 by David Mazieres <dm@lcs.mit.edu>.
|
||||
*
|
||||
|
@ -752,10 +752,13 @@ main(int argc, char **argv)
|
|||
tname = strtok(optarg, ",");
|
||||
while (tname) {
|
||||
int type = sshkey_type_from_name(tname);
|
||||
|
||||
switch (type) {
|
||||
#ifdef WITH_SSH1
|
||||
case KEY_RSA1:
|
||||
get_keytypes |= KT_RSA1;
|
||||
break;
|
||||
#endif
|
||||
case KEY_DSA:
|
||||
get_keytypes |= KT_DSA;
|
||||
break;
|
||||
|
@ -769,7 +772,8 @@ main(int argc, char **argv)
|
|||
get_keytypes |= KT_ED25519;
|
||||
break;
|
||||
case KEY_UNSPEC:
|
||||
fatal("unknown key type %s", tname);
|
||||
default:
|
||||
fatal("Unknown key type \"%s\"", tname);
|
||||
}
|
||||
tname = strtok(NULL, ",");
|
||||
}
|
||||
|
|
28
ssh_config.5
28
ssh_config.5
|
@ -33,8 +33,8 @@
|
|||
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $OpenBSD: ssh_config.5,v 1.240 2016/10/15 19:56:25 jmc Exp $
|
||||
.Dd $Mdocdate: October 15 2016 $
|
||||
.\" $OpenBSD: ssh_config.5,v 1.241 2017/02/03 23:01:19 djm Exp $
|
||||
.Dd $Mdocdate: February 3 2017 $
|
||||
.Dt SSH_CONFIG 5
|
||||
.Os
|
||||
.Sh NAME
|
||||
|
@ -415,6 +415,10 @@ If the specified value begins with a
|
|||
.Sq +
|
||||
character, then the specified ciphers will be appended to the default set
|
||||
instead of replacing them.
|
||||
If the specified value begins with a
|
||||
.Sq -
|
||||
character, then the specified ciphers (including wildcards) will be removed
|
||||
from the default set instead of replacing them.
|
||||
.Pp
|
||||
The supported ciphers are:
|
||||
.Bd -literal -offset indent
|
||||
|
@ -784,6 +788,10 @@ Alternately if the specified value begins with a
|
|||
.Sq +
|
||||
character, then the specified key types will be appended to the default set
|
||||
instead of replacing them.
|
||||
If the specified value begins with a
|
||||
.Sq -
|
||||
character, then the specified key types (including wildcards) will be removed
|
||||
from the default set instead of replacing them.
|
||||
The default for this option is:
|
||||
.Bd -literal -offset 3n
|
||||
ecdsa-sha2-nistp256-cert-v01@openssh.com,
|
||||
|
@ -807,6 +815,10 @@ Alternately if the specified value begins with a
|
|||
.Sq +
|
||||
character, then the specified key types will be appended to the default set
|
||||
instead of replacing them.
|
||||
If the specified value begins with a
|
||||
.Sq -
|
||||
character, then the specified key types (including wildcards) will be removed
|
||||
from the default set instead of replacing them.
|
||||
The default for this option is:
|
||||
.Bd -literal -offset 3n
|
||||
ecdsa-sha2-nistp256-cert-v01@openssh.com,
|
||||
|
@ -1027,6 +1039,10 @@ Alternately if the specified value begins with a
|
|||
.Sq +
|
||||
character, then the specified methods will be appended to the default set
|
||||
instead of replacing them.
|
||||
If the specified value begins with a
|
||||
.Sq -
|
||||
character, then the specified methods (including wildcards) will be removed
|
||||
from the default set instead of replacing them.
|
||||
The default is:
|
||||
.Bd -literal -offset indent
|
||||
curve25519-sha256,curve25519-sha256@libssh.org,
|
||||
|
@ -1102,6 +1118,10 @@ If the specified value begins with a
|
|||
.Sq +
|
||||
character, then the specified algorithms will be appended to the default set
|
||||
instead of replacing them.
|
||||
If the specified value begins with a
|
||||
.Sq -
|
||||
character, then the specified algorithms (including wildcards) will be removed
|
||||
from the default set instead of replacing them.
|
||||
.Pp
|
||||
The algorithms that contain
|
||||
.Qq -etm
|
||||
|
@ -1264,6 +1284,10 @@ Alternately if the specified value begins with a
|
|||
.Sq +
|
||||
character, then the key types after it will be appended to the default
|
||||
instead of replacing it.
|
||||
If the specified value begins with a
|
||||
.Sq -
|
||||
character, then the specified key types (including wildcards) will be removed
|
||||
from the default set instead of replacing them.
|
||||
The default for this option is:
|
||||
.Bd -literal -offset 3n
|
||||
ecdsa-sha2-nistp256-cert-v01@openssh.com,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: sshconnect2.c,v 1.251 2016/12/04 23:54:02 djm Exp $ */
|
||||
/* $OpenBSD: sshconnect2.c,v 1.254 2017/02/03 02:56:00 dtucker Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2000 Markus Friedl. All rights reserved.
|
||||
* Copyright (c) 2008 Damien Miller. All rights reserved.
|
||||
|
@ -198,8 +198,8 @@ ssh_kex2(char *host, struct sockaddr *hostaddr, u_short port)
|
|||
}
|
||||
|
||||
if (options.rekey_limit || options.rekey_interval)
|
||||
packet_set_rekey_limits((u_int32_t)options.rekey_limit,
|
||||
(time_t)options.rekey_interval);
|
||||
packet_set_rekey_limits(options.rekey_limit,
|
||||
options.rekey_interval);
|
||||
|
||||
/* start key exchange */
|
||||
if ((r = kex_setup(active_state, myproposal)) != 0)
|
||||
|
@ -939,14 +939,14 @@ input_userauth_passwd_changereq(int type, u_int32_t seqnr, void *ctxt)
|
|||
Authctxt *authctxt = ctxt;
|
||||
char *info, *lang, *password = NULL, *retype = NULL;
|
||||
char prompt[150];
|
||||
const char *host = options.host_key_alias ? options.host_key_alias :
|
||||
authctxt->host;
|
||||
const char *host;
|
||||
|
||||
debug2("input_userauth_passwd_changereq");
|
||||
|
||||
if (authctxt == NULL)
|
||||
fatal("input_userauth_passwd_changereq: "
|
||||
"no authentication context");
|
||||
host = options.host_key_alias ? options.host_key_alias : authctxt->host;
|
||||
|
||||
info = packet_get_string(NULL);
|
||||
lang = packet_get_string(NULL);
|
||||
|
@ -1641,7 +1641,7 @@ ssh_keysign(struct sshkey *key, u_char **sigp, size_t *lenp,
|
|||
if ((b = sshbuf_new()) == NULL)
|
||||
fatal("%s: sshbuf_new failed", __func__);
|
||||
/* send # of sock, data to be signed */
|
||||
if ((r = sshbuf_put_u32(b, sock) != 0) ||
|
||||
if ((r = sshbuf_put_u32(b, sock)) != 0 ||
|
||||
(r = sshbuf_put_string(b, data, datalen)) != 0)
|
||||
fatal("%s: buffer error: %s", __func__, ssh_err(r));
|
||||
if (ssh_msg_send(to[1], version, b) == -1)
|
||||
|
|
6
sshd.8
6
sshd.8
|
@ -33,8 +33,8 @@
|
|||
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $OpenBSD: sshd.8,v 1.287 2016/11/30 02:57:40 djm Exp $
|
||||
.Dd $Mdocdate: November 30 2016 $
|
||||
.\" $OpenBSD: sshd.8,v 1.288 2017/01/30 23:27:39 dtucker Exp $
|
||||
.Dd $Mdocdate: January 30 2017 $
|
||||
.Dt SSHD 8
|
||||
.Os
|
||||
.Sh NAME
|
||||
|
@ -631,7 +631,7 @@ and
|
|||
files contain host public keys for all known hosts.
|
||||
The global file should
|
||||
be prepared by the administrator (optional), and the per-user file is
|
||||
maintained automatically: whenever the user connects from an unknown host,
|
||||
maintained automatically: whenever the user connects to an unknown host,
|
||||
its key is added to the per-user file.
|
||||
.Pp
|
||||
Each line in these files contains the following fields: markers (optional),
|
||||
|
|
4
sshd.c
4
sshd.c
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: sshd.c,v 1.480 2016/12/09 03:04:29 djm Exp $ */
|
||||
/* $OpenBSD: sshd.c,v 1.481 2017/02/03 02:56:00 dtucker Exp $ */
|
||||
/*
|
||||
* Author: Tatu Ylonen <ylo@cs.hut.fi>
|
||||
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
|
||||
|
@ -2261,7 +2261,7 @@ do_ssh2_kex(void)
|
|||
|
||||
if (options.rekey_limit || options.rekey_interval)
|
||||
packet_set_rekey_limits(options.rekey_limit,
|
||||
(time_t)options.rekey_interval);
|
||||
options.rekey_interval);
|
||||
|
||||
myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = compat_pkalg_proposal(
|
||||
list_hostkey_types());
|
||||
|
|
|
@ -33,8 +33,8 @@
|
|||
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $OpenBSD: sshd_config.5,v 1.239 2016/11/30 03:00:05 djm Exp $
|
||||
.Dd $Mdocdate: November 30 2016 $
|
||||
.\" $OpenBSD: sshd_config.5,v 1.242 2017/02/03 23:01:19 djm Exp $
|
||||
.Dd $Mdocdate: February 3 2017 $
|
||||
.Dt SSHD_CONFIG 5
|
||||
.Os
|
||||
.Sh NAME
|
||||
|
@ -437,6 +437,10 @@ If the specified value begins with a
|
|||
.Sq +
|
||||
character, then the specified ciphers will be appended to the default set
|
||||
instead of replacing them.
|
||||
If the specified value begins with a
|
||||
.Sq -
|
||||
character, then the specified ciphers (including wildcards) will be removed
|
||||
from the default set instead of replacing them.
|
||||
.Pp
|
||||
The supported ciphers are:
|
||||
.Pp
|
||||
|
@ -649,6 +653,10 @@ Alternately if the specified value begins with a
|
|||
.Sq +
|
||||
character, then the specified key types will be appended to the default set
|
||||
instead of replacing them.
|
||||
If the specified value begins with a
|
||||
.Sq -
|
||||
character, then the specified key types (including wildcards) will be removed
|
||||
from the default set instead of replacing them.
|
||||
The default for this option is:
|
||||
.Bd -literal -offset 3n
|
||||
ecdsa-sha2-nistp256-cert-v01@openssh.com,
|
||||
|
@ -843,6 +851,10 @@ Alternately if the specified value begins with a
|
|||
.Sq +
|
||||
character, then the specified methods will be appended to the default set
|
||||
instead of replacing them.
|
||||
If the specified value begins with a
|
||||
.Sq -
|
||||
character, then the specified methods (including wildcards) will be removed
|
||||
from the default set instead of replacing them.
|
||||
The supported algorithms are:
|
||||
.Pp
|
||||
.Bl -item -compact -offset indent
|
||||
|
@ -933,6 +945,10 @@ If the specified value begins with a
|
|||
.Sq +
|
||||
character, then the specified algorithms will be appended to the default set
|
||||
instead of replacing them.
|
||||
If the specified value begins with a
|
||||
.Sq -
|
||||
character, then the specified algorithms (including wildcards) will be removed
|
||||
from the default set instead of replacing them.
|
||||
.Pp
|
||||
The algorithms that contain
|
||||
.Qq -etm
|
||||
|
@ -1280,6 +1296,10 @@ Alternately if the specified value begins with a
|
|||
.Sq +
|
||||
character, then the specified key types will be appended to the default set
|
||||
instead of replacing them.
|
||||
If the specified value begins with a
|
||||
.Sq -
|
||||
character, then the specified key types (including wildcards) will be removed
|
||||
from the default set instead of replacing them.
|
||||
The default for this option is:
|
||||
.Bd -literal -offset 3n
|
||||
ecdsa-sha2-nistp256-cert-v01@openssh.com,
|
||||
|
@ -1644,13 +1664,13 @@ The username.
|
|||
.El
|
||||
.Pp
|
||||
.Cm AuthorizedKeysCommand
|
||||
accepts the tokens %%, %f, %h, %t, and %u.
|
||||
accepts the tokens %%, %f, %h, %k, %t, and %u.
|
||||
.Pp
|
||||
.Cm AuthorizedKeysFile
|
||||
accepts the tokens %%, %h, and %u.
|
||||
.Pp
|
||||
.Cm AuthorizedPrincipalsCommand
|
||||
accepts the tokens %%, %F, %f, %K, %k, %h, %i, %s, %T, %t, and %u.
|
||||
accepts the tokens %%, %F, %f, %h, %i, %K, %k, %s, %T, %t, and %u.
|
||||
.Pp
|
||||
.Cm AuthorizedPrincipalsFile
|
||||
accepts the tokens %%, %h, and %u.
|
||||
|
|
3
utf8.c
3
utf8.c
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: utf8.c,v 1.3 2016/05/30 12:57:21 schwarze Exp $ */
|
||||
/* $OpenBSD: utf8.c,v 1.4 2017/02/02 10:54:25 jsg Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
|
||||
*
|
||||
|
@ -122,6 +122,7 @@ vasnmprintf(char **str, size_t maxsz, int *wp, const char *fmt, va_list ap)
|
|||
sz = strlen(src) + 1;
|
||||
if ((dst = malloc(sz)) == NULL) {
|
||||
free(src);
|
||||
ret = -1;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue