MFhead@r322057
This commit is contained in:
commit
7921075587
File diff suppressed because it is too large
Load Diff
@ -1,3 +1,4 @@
|
||||
1. Prerequisites
|
||||
----------------
|
||||
|
||||
A C compiler. Any C89 or better compiler should work. Where supported,
|
||||
@ -243,7 +244,7 @@ manually using the following commands:
|
||||
|
||||
ssh-keygen -t [type] -f /etc/ssh/ssh_host_key -N ""
|
||||
|
||||
for each of the types you wish to generate (rsa, dsa or ecdsaa) or
|
||||
for each of the types you wish to generate (rsa, dsa or ecdsa) or
|
||||
|
||||
ssh-keygen -A
|
||||
|
||||
|
@ -236,6 +236,8 @@ clean: regressclean
|
||||
rm -f regress/unittests/sshkey/test_sshkey
|
||||
rm -f regress/unittests/bitmap/*.o
|
||||
rm -f regress/unittests/bitmap/test_bitmap
|
||||
rm -f regress/unittests/conversion/*.o
|
||||
rm -f regress/unittests/conversion/test_conversion
|
||||
rm -f regress/unittests/hostkeys/*.o
|
||||
rm -f regress/unittests/hostkeys/test_hostkeys
|
||||
rm -f regress/unittests/kex/*.o
|
||||
@ -262,6 +264,8 @@ distclean: regressclean
|
||||
rm -f regress/unittests/sshkey/test_sshkey
|
||||
rm -f regress/unittests/bitmap/*.o
|
||||
rm -f regress/unittests/bitmap/test_bitmap
|
||||
rm -f regress/unittests/conversion/*.o
|
||||
rm -f regress/unittests/conversion/test_conversion
|
||||
rm -f regress/unittests/hostkeys/*.o
|
||||
rm -f regress/unittests/hostkeys/test_hostkeys
|
||||
rm -f regress/unittests/kex/*.o
|
||||
@ -426,6 +430,8 @@ regress-prep:
|
||||
mkdir -p `pwd`/regress/unittests/sshkey
|
||||
[ -d `pwd`/regress/unittests/bitmap ] || \
|
||||
mkdir -p `pwd`/regress/unittests/bitmap
|
||||
[ -d `pwd`/regress/unittests/conversion ] || \
|
||||
mkdir -p `pwd`/regress/unittests/conversion
|
||||
[ -d `pwd`/regress/unittests/hostkeys ] || \
|
||||
mkdir -p `pwd`/regress/unittests/hostkeys
|
||||
[ -d `pwd`/regress/unittests/kex ] || \
|
||||
@ -503,6 +509,16 @@ regress/unittests/bitmap/test_bitmap$(EXEEXT): ${UNITTESTS_TEST_BITMAP_OBJS} \
|
||||
regress/unittests/test_helper/libtest_helper.a \
|
||||
-lssh -lopenbsd-compat -lssh -lopenbsd-compat $(LIBS)
|
||||
|
||||
UNITTESTS_TEST_CONVERSION_OBJS=\
|
||||
regress/unittests/conversion/tests.o
|
||||
|
||||
regress/unittests/conversion/test_conversion$(EXEEXT): \
|
||||
${UNITTESTS_TEST_CONVERSION_OBJS} \
|
||||
regress/unittests/test_helper/libtest_helper.a libssh.a
|
||||
$(LD) -o $@ $(LDFLAGS) $(UNITTESTS_TEST_CONVERSION_OBJS) \
|
||||
regress/unittests/test_helper/libtest_helper.a \
|
||||
-lssh -lopenbsd-compat -lssh -lopenbsd-compat $(LIBS)
|
||||
|
||||
UNITTESTS_TEST_KEX_OBJS=\
|
||||
regress/unittests/kex/tests.o \
|
||||
regress/unittests/kex/test_kex.o
|
||||
@ -558,13 +574,14 @@ regress-binaries: regress/modpipe$(EXEEXT) \
|
||||
regress/unittests/sshbuf/test_sshbuf$(EXEEXT) \
|
||||
regress/unittests/sshkey/test_sshkey$(EXEEXT) \
|
||||
regress/unittests/bitmap/test_bitmap$(EXEEXT) \
|
||||
regress/unittests/conversion/test_conversion$(EXEEXT) \
|
||||
regress/unittests/hostkeys/test_hostkeys$(EXEEXT) \
|
||||
regress/unittests/kex/test_kex$(EXEEXT) \
|
||||
regress/unittests/match/test_match$(EXEEXT) \
|
||||
regress/unittests/utf8/test_utf8$(EXEEXT) \
|
||||
regress/misc/kexfuzz/kexfuzz$(EXEEXT)
|
||||
|
||||
tests interop-tests t-exec: regress-prep regress-binaries $(TARGETS)
|
||||
tests interop-tests t-exec unit: regress-prep regress-binaries $(TARGETS)
|
||||
BUILDDIR=`pwd`; \
|
||||
TEST_SSH_SCP="$${BUILDDIR}/scp"; \
|
||||
TEST_SSH_SSH="$${BUILDDIR}/ssh"; \
|
||||
|
@ -1,4 +1,4 @@
|
||||
See https://www.openssh.com/releasenotes.html#7.4p1 for the release notes.
|
||||
See https://www.openssh.com/releasenotes.html#7.5p1 for the release notes.
|
||||
|
||||
Please read https://www.openssh.com/report.html for bug reporting
|
||||
instructions and note that we do not use Github for bug reporting or
|
||||
|
@ -833,6 +833,8 @@ fake_password(const char *wire_password)
|
||||
fatal("%s: password length too long: %zu", __func__, l);
|
||||
|
||||
ret = malloc(l + 1);
|
||||
if (ret == NULL)
|
||||
return NULL;
|
||||
for (i = 0; i < l; i++)
|
||||
ret[i] = junk[i % (sizeof(junk) - 1)];
|
||||
ret[i] = '\0';
|
||||
|
@ -1,448 +0,0 @@
|
||||
/* $OpenBSD: auth1.c,v 1.82 2014/07/15 15:54:14 millert Exp $ */
|
||||
/*
|
||||
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
|
||||
* All rights reserved
|
||||
*
|
||||
* As far as I am concerned, the code I have written for this software
|
||||
* can be used freely for any purpose. Any derived versions of this
|
||||
* software must be clearly marked as such, and if the derived work is
|
||||
* incompatible with the protocol description in the RFC file, it must be
|
||||
* called by a name other than "ssh" or "Secure Shell".
|
||||
*/
|
||||
|
||||
#include "includes.h"
|
||||
|
||||
#ifdef WITH_SSH1
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <pwd.h>
|
||||
|
||||
#include "openbsd-compat/sys-queue.h"
|
||||
#include "xmalloc.h"
|
||||
#include "rsa.h"
|
||||
#include "ssh1.h"
|
||||
#include "packet.h"
|
||||
#include "buffer.h"
|
||||
#include "log.h"
|
||||
#include "misc.h"
|
||||
#include "servconf.h"
|
||||
#include "compat.h"
|
||||
#include "key.h"
|
||||
#include "hostfile.h"
|
||||
#include "auth.h"
|
||||
#include "channels.h"
|
||||
#include "session.h"
|
||||
#include "uidswap.h"
|
||||
#ifdef GSSAPI
|
||||
#include "ssh-gss.h"
|
||||
#endif
|
||||
#include "monitor_wrap.h"
|
||||
#include "buffer.h"
|
||||
#include "blacklist_client.h"
|
||||
|
||||
/* import */
|
||||
extern ServerOptions options;
|
||||
extern Buffer loginmsg;
|
||||
|
||||
static int auth1_process_password(Authctxt *);
|
||||
static int auth1_process_rsa(Authctxt *);
|
||||
static int auth1_process_rhosts_rsa(Authctxt *);
|
||||
static int auth1_process_tis_challenge(Authctxt *);
|
||||
static int auth1_process_tis_response(Authctxt *);
|
||||
|
||||
static char *client_user = NULL; /* Used to fill in remote user for PAM */
|
||||
|
||||
struct AuthMethod1 {
|
||||
int type;
|
||||
char *name;
|
||||
int *enabled;
|
||||
int (*method)(Authctxt *);
|
||||
};
|
||||
|
||||
const struct AuthMethod1 auth1_methods[] = {
|
||||
{
|
||||
SSH_CMSG_AUTH_PASSWORD, "password",
|
||||
&options.password_authentication, auth1_process_password
|
||||
},
|
||||
{
|
||||
SSH_CMSG_AUTH_RSA, "rsa",
|
||||
&options.rsa_authentication, auth1_process_rsa
|
||||
},
|
||||
{
|
||||
SSH_CMSG_AUTH_RHOSTS_RSA, "rhosts-rsa",
|
||||
&options.rhosts_rsa_authentication, auth1_process_rhosts_rsa
|
||||
},
|
||||
{
|
||||
SSH_CMSG_AUTH_TIS, "challenge-response",
|
||||
&options.challenge_response_authentication,
|
||||
auth1_process_tis_challenge
|
||||
},
|
||||
{
|
||||
SSH_CMSG_AUTH_TIS_RESPONSE, "challenge-response",
|
||||
&options.challenge_response_authentication,
|
||||
auth1_process_tis_response
|
||||
},
|
||||
{ -1, NULL, NULL, NULL}
|
||||
};
|
||||
|
||||
static const struct AuthMethod1
|
||||
*lookup_authmethod1(int type)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; auth1_methods[i].name != NULL; i++)
|
||||
if (auth1_methods[i].type == type)
|
||||
return (&(auth1_methods[i]));
|
||||
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
static char *
|
||||
get_authname(int type)
|
||||
{
|
||||
const struct AuthMethod1 *a;
|
||||
static char buf[64];
|
||||
|
||||
if ((a = lookup_authmethod1(type)) != NULL)
|
||||
return (a->name);
|
||||
snprintf(buf, sizeof(buf), "bad-auth-msg-%d", type);
|
||||
return (buf);
|
||||
}
|
||||
|
||||
/*ARGSUSED*/
|
||||
static int
|
||||
auth1_process_password(Authctxt *authctxt)
|
||||
{
|
||||
int authenticated = 0;
|
||||
char *password;
|
||||
u_int dlen;
|
||||
|
||||
/*
|
||||
* Read user password. It is in plain text, but was
|
||||
* transmitted over the encrypted channel so it is
|
||||
* not visible to an outside observer.
|
||||
*/
|
||||
password = packet_get_string(&dlen);
|
||||
packet_check_eom();
|
||||
|
||||
/* Try authentication with the password. */
|
||||
authenticated = PRIVSEP(auth_password(authctxt, password));
|
||||
|
||||
explicit_bzero(password, dlen);
|
||||
free(password);
|
||||
|
||||
return (authenticated);
|
||||
}
|
||||
|
||||
/*ARGSUSED*/
|
||||
static int
|
||||
auth1_process_rsa(Authctxt *authctxt)
|
||||
{
|
||||
int authenticated = 0;
|
||||
BIGNUM *n;
|
||||
|
||||
/* RSA authentication requested. */
|
||||
if ((n = BN_new()) == NULL)
|
||||
fatal("do_authloop: BN_new failed");
|
||||
packet_get_bignum(n);
|
||||
packet_check_eom();
|
||||
authenticated = auth_rsa(authctxt, n);
|
||||
BN_clear_free(n);
|
||||
|
||||
return (authenticated);
|
||||
}
|
||||
|
||||
/*ARGSUSED*/
|
||||
static int
|
||||
auth1_process_rhosts_rsa(Authctxt *authctxt)
|
||||
{
|
||||
int keybits, authenticated = 0;
|
||||
u_int bits;
|
||||
Key *client_host_key;
|
||||
u_int ulen;
|
||||
|
||||
/*
|
||||
* Get client user name. Note that we just have to
|
||||
* trust the client; root on the client machine can
|
||||
* claim to be any user.
|
||||
*/
|
||||
client_user = packet_get_cstring(&ulen);
|
||||
|
||||
/* Get the client host key. */
|
||||
client_host_key = key_new(KEY_RSA1);
|
||||
bits = packet_get_int();
|
||||
packet_get_bignum(client_host_key->rsa->e);
|
||||
packet_get_bignum(client_host_key->rsa->n);
|
||||
|
||||
keybits = BN_num_bits(client_host_key->rsa->n);
|
||||
if (keybits < 0 || bits != (u_int)keybits) {
|
||||
verbose("Warning: keysize mismatch for client_host_key: "
|
||||
"actual %d, announced %d",
|
||||
BN_num_bits(client_host_key->rsa->n), bits);
|
||||
}
|
||||
packet_check_eom();
|
||||
|
||||
authenticated = auth_rhosts_rsa(authctxt, client_user,
|
||||
client_host_key);
|
||||
key_free(client_host_key);
|
||||
|
||||
auth_info(authctxt, "ruser %.100s", client_user);
|
||||
|
||||
return (authenticated);
|
||||
}
|
||||
|
||||
/*ARGSUSED*/
|
||||
static int
|
||||
auth1_process_tis_challenge(Authctxt *authctxt)
|
||||
{
|
||||
char *challenge;
|
||||
|
||||
if ((challenge = get_challenge(authctxt)) == NULL)
|
||||
return (0);
|
||||
|
||||
debug("sending challenge '%s'", challenge);
|
||||
packet_start(SSH_SMSG_AUTH_TIS_CHALLENGE);
|
||||
packet_put_cstring(challenge);
|
||||
free(challenge);
|
||||
packet_send();
|
||||
packet_write_wait();
|
||||
|
||||
return (-1);
|
||||
}
|
||||
|
||||
/*ARGSUSED*/
|
||||
static int
|
||||
auth1_process_tis_response(Authctxt *authctxt)
|
||||
{
|
||||
int authenticated = 0;
|
||||
char *response;
|
||||
u_int dlen;
|
||||
|
||||
response = packet_get_string(&dlen);
|
||||
packet_check_eom();
|
||||
authenticated = verify_response(authctxt, response);
|
||||
explicit_bzero(response, dlen);
|
||||
free(response);
|
||||
|
||||
return (authenticated);
|
||||
}
|
||||
|
||||
/*
|
||||
* read packets, try to authenticate the user and
|
||||
* return only if authentication is successful
|
||||
*/
|
||||
static void
|
||||
do_authloop(Authctxt *authctxt)
|
||||
{
|
||||
int authenticated = 0;
|
||||
int prev = 0, type = 0;
|
||||
const struct AuthMethod1 *meth;
|
||||
|
||||
debug("Attempting authentication for %s%.100s.",
|
||||
authctxt->valid ? "" : "invalid user ", authctxt->user);
|
||||
|
||||
/* If the user has no password, accept authentication immediately. */
|
||||
if (options.permit_empty_passwd && options.password_authentication &&
|
||||
#ifdef KRB5
|
||||
(!options.kerberos_authentication || options.kerberos_or_local_passwd) &&
|
||||
#endif
|
||||
PRIVSEP(auth_password(authctxt, ""))) {
|
||||
#ifdef USE_PAM
|
||||
if (options.use_pam && (PRIVSEP(do_pam_account())))
|
||||
#endif
|
||||
{
|
||||
auth_log(authctxt, 1, 0, "without authentication",
|
||||
NULL);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Indicate that authentication is needed. */
|
||||
packet_start(SSH_SMSG_FAILURE);
|
||||
packet_send();
|
||||
packet_write_wait();
|
||||
|
||||
for (;;) {
|
||||
/* default to fail */
|
||||
authenticated = 0;
|
||||
|
||||
|
||||
/* Get a packet from the client. */
|
||||
prev = type;
|
||||
type = packet_read();
|
||||
|
||||
/*
|
||||
* If we started challenge-response authentication but the
|
||||
* next packet is not a response to our challenge, release
|
||||
* the resources allocated by get_challenge() (which would
|
||||
* normally have been released by verify_response() had we
|
||||
* received such a response)
|
||||
*/
|
||||
if (prev == SSH_CMSG_AUTH_TIS &&
|
||||
type != SSH_CMSG_AUTH_TIS_RESPONSE)
|
||||
abandon_challenge_response(authctxt);
|
||||
|
||||
if (authctxt->failures >= options.max_authtries)
|
||||
goto skip;
|
||||
if ((meth = lookup_authmethod1(type)) == NULL) {
|
||||
logit("Unknown message during authentication: "
|
||||
"type %d", type);
|
||||
goto skip;
|
||||
}
|
||||
|
||||
if (!*(meth->enabled)) {
|
||||
verbose("%s authentication disabled.", meth->name);
|
||||
goto skip;
|
||||
}
|
||||
|
||||
authenticated = meth->method(authctxt);
|
||||
if (authenticated == -1)
|
||||
continue; /* "postponed" */
|
||||
|
||||
#ifdef BSD_AUTH
|
||||
if (authctxt->as) {
|
||||
auth_close(authctxt->as);
|
||||
authctxt->as = NULL;
|
||||
}
|
||||
#endif
|
||||
if (!authctxt->valid && authenticated)
|
||||
fatal("INTERNAL ERROR: authenticated invalid user %s",
|
||||
authctxt->user);
|
||||
|
||||
#ifdef _UNICOS
|
||||
if (authenticated && cray_access_denied(authctxt->user)) {
|
||||
authenticated = 0;
|
||||
fatal("Access denied for user %s.",authctxt->user);
|
||||
}
|
||||
#endif /* _UNICOS */
|
||||
|
||||
#ifndef HAVE_CYGWIN
|
||||
/* Special handling for root */
|
||||
if (authenticated && authctxt->pw->pw_uid == 0 &&
|
||||
!auth_root_allowed(meth->name)) {
|
||||
authenticated = 0;
|
||||
# ifdef SSH_AUDIT_EVENTS
|
||||
PRIVSEP(audit_event(SSH_LOGIN_ROOT_DENIED));
|
||||
# endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef USE_PAM
|
||||
if (options.use_pam && authenticated &&
|
||||
!PRIVSEP(do_pam_account())) {
|
||||
char *msg;
|
||||
size_t len;
|
||||
|
||||
BLACKLIST_NOTIFY(BLACKLIST_AUTH_FAIL, "ssh");
|
||||
error("Access denied for user %s by PAM account "
|
||||
"configuration", authctxt->user);
|
||||
len = buffer_len(&loginmsg);
|
||||
buffer_append(&loginmsg, "\0", 1);
|
||||
msg = buffer_ptr(&loginmsg);
|
||||
/* strip trailing newlines */
|
||||
if (len > 0)
|
||||
while (len > 0 && msg[--len] == '\n')
|
||||
msg[len] = '\0';
|
||||
else
|
||||
msg = "Access denied.";
|
||||
packet_disconnect("%s", msg);
|
||||
}
|
||||
#endif
|
||||
|
||||
skip:
|
||||
/* Log before sending the reply */
|
||||
auth_log(authctxt, authenticated, 0, get_authname(type), NULL);
|
||||
|
||||
free(client_user);
|
||||
client_user = NULL;
|
||||
|
||||
if (authenticated)
|
||||
return;
|
||||
|
||||
BLACKLIST_NOTIFY(BLACKLIST_AUTH_FAIL, "ssh");
|
||||
if (++authctxt->failures >= options.max_authtries) {
|
||||
#ifdef SSH_AUDIT_EVENTS
|
||||
PRIVSEP(audit_event(SSH_LOGIN_EXCEED_MAXTRIES));
|
||||
#endif
|
||||
auth_maxtries_exceeded(authctxt);
|
||||
}
|
||||
|
||||
packet_start(SSH_SMSG_FAILURE);
|
||||
packet_send();
|
||||
packet_write_wait();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Performs authentication of an incoming connection. Session key has already
|
||||
* been exchanged and encryption is enabled.
|
||||
*/
|
||||
void
|
||||
do_authentication(Authctxt *authctxt)
|
||||
{
|
||||
u_int ulen;
|
||||
char *user, *style = NULL;
|
||||
|
||||
/* Get the name of the user that we wish to log in as. */
|
||||
packet_read_expect(SSH_CMSG_USER);
|
||||
|
||||
/* Get the user name. */
|
||||
user = packet_get_cstring(&ulen);
|
||||
packet_check_eom();
|
||||
|
||||
if ((style = strchr(user, ':')) != NULL)
|
||||
*style++ = '\0';
|
||||
|
||||
authctxt->user = user;
|
||||
authctxt->style = style;
|
||||
|
||||
/* Verify that the user is a valid user. */
|
||||
if ((authctxt->pw = PRIVSEP(getpwnamallow(user))) != NULL)
|
||||
authctxt->valid = 1;
|
||||
else {
|
||||
debug("do_authentication: invalid user %s", user);
|
||||
authctxt->pw = fakepw();
|
||||
BLACKLIST_NOTIFY(BLACKLIST_BAD_USER, user);
|
||||
}
|
||||
|
||||
/* Configuration may have changed as a result of Match */
|
||||
if (options.num_auth_methods != 0)
|
||||
fatal("AuthenticationMethods is not supported with SSH "
|
||||
"protocol 1");
|
||||
|
||||
setproctitle("%s%s", authctxt->valid ? user : "unknown",
|
||||
use_privsep ? " [net]" : "");
|
||||
|
||||
#ifdef USE_PAM
|
||||
if (options.use_pam)
|
||||
PRIVSEP(start_pam(authctxt));
|
||||
#endif
|
||||
|
||||
/*
|
||||
* If we are not running as root, the user must have the same uid as
|
||||
* the server.
|
||||
*/
|
||||
#ifndef HAVE_CYGWIN
|
||||
if (!use_privsep && getuid() != 0 && authctxt->pw &&
|
||||
authctxt->pw->pw_uid != getuid())
|
||||
packet_disconnect("Cannot change user when server not running as root.");
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Loop until the user has been authenticated or the connection is
|
||||
* closed, do_authloop() returns only if authentication is successful
|
||||
*/
|
||||
do_authloop(authctxt);
|
||||
|
||||
/* The user has been authenticated and accepted. */
|
||||
packet_start(SSH_SMSG_SUCCESS);
|
||||
packet_send();
|
||||
packet_write_wait();
|
||||
}
|
||||
|
||||
#endif /* WITH_SSH1 */
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: auth2-pubkey.c,v 1.60 2016/11/30 02:57:40 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.
|
||||
*
|
||||
@ -564,9 +564,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++)
|
||||
;
|
||||
@ -599,11 +602,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
|
||||
@ -727,6 +731,9 @@ match_principals_command(struct passwd *user_pw, const struct sshkey *key)
|
||||
|
||||
ok = process_principals(f, NULL, pw, cert);
|
||||
|
||||
fclose(f);
|
||||
f = NULL;
|
||||
|
||||
if (exited_cleanly(pid, "AuthorizedPrincipalsCommand", command) != 0)
|
||||
goto out;
|
||||
|
||||
@ -768,6 +775,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);
|
||||
@ -854,7 +864,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)
|
||||
@ -1050,6 +1060,9 @@ user_key_command_allowed2(struct passwd *user_pw, Key *key)
|
||||
|
||||
ok = check_authkeys_file(f, options.authorized_keys_command, key, pw);
|
||||
|
||||
fclose(f);
|
||||
f = NULL;
|
||||
|
||||
if (exited_cleanly(pid, "AuthorizedKeysCommand", command) != 0)
|
||||
goto out;
|
||||
|
||||
|
@ -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.
|
||||
*
|
||||
@ -214,15 +214,16 @@ 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;
|
||||
int authenticated = 0;
|
||||
#ifdef HAVE_LOGIN_CAP
|
||||
struct ssh *ssh = active_state; /* XXX */
|
||||
login_cap_t *lc;
|
||||
const char *from_host, *from_ip;
|
||||
#endif
|
||||
|
||||
if (authctxt == NULL)
|
||||
fatal("input_userauth_request: no authctxt");
|
||||
|
||||
@ -241,9 +242,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));
|
||||
@ -253,6 +255,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);
|
||||
@ -320,6 +324,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;
|
||||
|
||||
@ -381,6 +386,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 */
|
||||
|
@ -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
|
||||
@ -3065,7 +3065,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) {
|
||||
@ -4026,9 +4026,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;
|
||||
@ -4069,7 +4073,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;
|
||||
@ -4092,6 +4101,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.
|
||||
@ -4136,7 +4152,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;
|
||||
|
||||
@ -4161,9 +4178,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. */
|
||||
@ -4354,6 +4373,33 @@ connect_local_xsocket(u_int dnr)
|
||||
return connect_local_xsocket_path(buf);
|
||||
}
|
||||
|
||||
#ifdef __APPLE__
|
||||
static int
|
||||
is_path_to_xsocket(const char *display, char *path, size_t pathlen)
|
||||
{
|
||||
struct stat sbuf;
|
||||
|
||||
if (strlcpy(path, display, pathlen) >= pathlen) {
|
||||
error("%s: display path too long", __func__);
|
||||
return 0;
|
||||
}
|
||||
if (display[0] != '/')
|
||||
return 0;
|
||||
if (stat(path, &sbuf) == 0) {
|
||||
return 1;
|
||||
} else {
|
||||
char *dot = strrchr(path, '.');
|
||||
if (dot != NULL) {
|
||||
*dot = '\0';
|
||||
if (stat(path, &sbuf) == 0) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
int
|
||||
x11_connect_display(void)
|
||||
{
|
||||
@ -4375,15 +4421,22 @@ x11_connect_display(void)
|
||||
* connection to the real X server.
|
||||
*/
|
||||
|
||||
/* Check if the display is from launchd. */
|
||||
#ifdef __APPLE__
|
||||
if (strncmp(display, "/tmp/launch", 11) == 0) {
|
||||
sock = connect_local_xsocket_path(display);
|
||||
if (sock < 0)
|
||||
return -1;
|
||||
/* Check if display is a path to a socket (as set by launchd). */
|
||||
{
|
||||
char path[PATH_MAX];
|
||||
|
||||
/* OK, we now have a connection to the display. */
|
||||
return sock;
|
||||
if (is_path_to_xsocket(display, path, sizeof(path))) {
|
||||
debug("x11_connect_display: $DISPLAY is launchd");
|
||||
|
||||
/* Create a socket. */
|
||||
sock = connect_local_xsocket_path(path);
|
||||
if (sock < 0)
|
||||
return -1;
|
||||
|
||||
/* OK, we now have a connection to the display. */
|
||||
return sock;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
/*
|
||||
|
@ -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.291 2017/03/10 05:01:13 djm 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.");
|
||||
@ -2390,6 +2390,26 @@ client_global_hostkeys_private_confirm(int type, u_int32_t seq, void *_ctx)
|
||||
hostkeys_update_ctx_free(ctx);
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns non-zero if the key is accepted by HostkeyAlgorithms.
|
||||
* Made slightly less trivial by the multiple RSA signature algorithm names.
|
||||
*/
|
||||
static int
|
||||
key_accepted_by_hostkeyalgs(const struct sshkey *key)
|
||||
{
|
||||
const char *ktype = sshkey_ssh_name(key);
|
||||
const char *hostkeyalgs = options.hostkeyalgorithms != NULL ?
|
||||
options.hostkeyalgorithms : KEX_DEFAULT_PK_ALG;
|
||||
|
||||
if (key == NULL || key->type == KEY_UNSPEC)
|
||||
return 0;
|
||||
if (key->type == KEY_RSA &&
|
||||
(match_pattern_list("rsa-sha2-256", hostkeyalgs, 0) == 1 ||
|
||||
match_pattern_list("rsa-sha2-512", hostkeyalgs, 0) == 1))
|
||||
return 1;
|
||||
return match_pattern_list(ktype, hostkeyalgs, 0) == 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Handle hostkeys-00@openssh.com global request to inform the client of all
|
||||
* the server's hostkeys. The keys are checked against the user's
|
||||
@ -2436,10 +2456,7 @@ client_input_hostkeys(void)
|
||||
sshkey_type(key), fp);
|
||||
free(fp);
|
||||
|
||||
/* Check that the key is accepted in HostkeyAlgorithms */
|
||||
if (match_pattern_list(sshkey_ssh_name(key),
|
||||
options.hostkeyalgorithms ? options.hostkeyalgorithms :
|
||||
KEX_DEFAULT_PK_ALG, 0) != 1) {
|
||||
if (!key_accepted_by_hostkeyalgs(key)) {
|
||||
debug3("%s: %s key not permitted by HostkeyAlgorithms",
|
||||
__func__, sshkey_ssh_name(key));
|
||||
continue;
|
||||
|
@ -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')
|
||||
|
@ -737,6 +737,9 @@
|
||||
/* Define to 1 if you have the <linux/seccomp.h> header file. */
|
||||
/* #undef HAVE_LINUX_SECCOMP_H */
|
||||
|
||||
/* Define to 1 if you have the `llabs' function. */
|
||||
#define HAVE_LLABS 1
|
||||
|
||||
/* Define to 1 if you have the <locale.h> header file. */
|
||||
#define HAVE_LOCALE_H 1
|
||||
|
||||
@ -786,7 +789,7 @@
|
||||
#define HAVE_MEMORY_H 1
|
||||
|
||||
/* Define to 1 if you have the `memset_s' function. */
|
||||
/* #undef HAVE_MEMSET_S */
|
||||
#define HAVE_MEMSET_S 1
|
||||
|
||||
/* Define to 1 if you have the `mkdtemp' function. */
|
||||
#define HAVE_MKDTEMP 1
|
||||
|
@ -747,6 +747,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], ["!"],
|
||||
@ -1523,7 +1526,6 @@ int deny_severity = 0, allow_severity = 0;
|
||||
TCPW_MSG="yes"
|
||||
], [
|
||||
AC_MSG_ERROR([*** libwrap missing])
|
||||
|
||||
])
|
||||
LIBS="$saved_LIBS"
|
||||
fi
|
||||
@ -1534,36 +1536,47 @@ int deny_severity = 0, allow_severity = 0;
|
||||
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"
|
||||
@ -1766,6 +1779,7 @@ AC_CHECK_FUNCS([ \
|
||||
inet_ntoa \
|
||||
inet_ntop \
|
||||
innetgr \
|
||||
llabs \
|
||||
login_getcapbool \
|
||||
md5_crypt \
|
||||
memmove \
|
||||
@ -1834,11 +1848,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])
|
||||
@ -2583,8 +2594,8 @@ if test "x$openssl" = "xyes" ; then
|
||||
ssl_library_ver=`cat conftest.ssllibver`
|
||||
# Check version is supported.
|
||||
case "$ssl_library_ver" in
|
||||
0090[[0-7]]*|009080[[0-5]]*)
|
||||
AC_MSG_ERROR([OpenSSL >= 0.9.8f required (have "$ssl_library_ver")])
|
||||
10000*|0*)
|
||||
AC_MSG_ERROR([OpenSSL >= 1.0.1 required (have "$ssl_library_ver")])
|
||||
;;
|
||||
*) ;;
|
||||
esac
|
||||
@ -5147,6 +5158,7 @@ echo " S/KEY support: $SKEY_MSG"
|
||||
echo " TCP Wrappers support: $TCPW_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"
|
||||
|
@ -63,7 +63,6 @@ sshd_config_configured=no
|
||||
port_number=22
|
||||
service_name=sshd
|
||||
strictmodes=yes
|
||||
privsep_used=yes
|
||||
cygwin_value=""
|
||||
user_account=
|
||||
password_value=
|
||||
@ -140,33 +139,21 @@ sshd_strictmodes() {
|
||||
|
||||
# ======================================================================
|
||||
# Routine: sshd_privsep
|
||||
# MODIFIES: privsep_used
|
||||
# Try to create ssshd user account
|
||||
# ======================================================================
|
||||
sshd_privsep() {
|
||||
local ret=0
|
||||
|
||||
if [ "${sshd_config_configured}" != "yes" ]
|
||||
then
|
||||
echo
|
||||
csih_inform "Privilege separation is set to 'sandbox' by default since"
|
||||
csih_inform "OpenSSH 6.1. This is unsupported by Cygwin and has to be set"
|
||||
csih_inform "to 'yes' or 'no'."
|
||||
csih_inform "However, using privilege separation requires a non-privileged account"
|
||||
csih_inform "called 'sshd'."
|
||||
csih_inform "For more info on privilege separation read /usr/share/doc/openssh/README.privsep."
|
||||
if csih_request "Should privilege separation be used?"
|
||||
if ! csih_create_unprivileged_user sshd
|
||||
then
|
||||
privsep_used=yes
|
||||
if ! csih_create_unprivileged_user sshd
|
||||
then
|
||||
csih_error_recoverable "Couldn't create user 'sshd'!"
|
||||
csih_error_recoverable "Privilege separation set to 'no' again!"
|
||||
csih_error_recoverable "Check your ${SYSCONFDIR}/sshd_config file!"
|
||||
let ++ret
|
||||
privsep_used=no
|
||||
fi
|
||||
else
|
||||
privsep_used=no
|
||||
csih_error_recoverable "Could not create user 'sshd'!"
|
||||
csih_error_recoverable "You will not be able to run an sshd service"
|
||||
csih_error_recoverable "under a privileged account successfully."
|
||||
csih_error_recoverable "Make sure to create a non-privileged user 'sshd'"
|
||||
csih_error_recoverable "manually before trying to run the service!"
|
||||
let ++ret
|
||||
fi
|
||||
fi
|
||||
return $ret
|
||||
@ -202,18 +189,6 @@ sshd_config_tweak() {
|
||||
let ++ret
|
||||
fi
|
||||
fi
|
||||
if [ "${sshd_config_configured}" != "yes" ]
|
||||
then
|
||||
/usr/bin/sed -i -e "
|
||||
s/^#\?UsePrivilegeSeparation .*/UsePrivilegeSeparation ${privsep_used}/" \
|
||||
${SYSCONFDIR}/sshd_config
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
csih_warning "Setting privilege separation failed!"
|
||||
csih_warning "Check your ${SYSCONFDIR}/sshd_config file!"
|
||||
let ++ret
|
||||
fi
|
||||
fi
|
||||
return $ret
|
||||
} # --- End of sshd_config_tweak --- #
|
||||
|
||||
@ -693,7 +668,7 @@ then
|
||||
fi
|
||||
fi
|
||||
|
||||
# handle sshd_config (and privsep)
|
||||
# handle sshd_config
|
||||
csih_install_config "${SYSCONFDIR}/sshd_config" "${SYSCONFDIR}/defaults" || let ++warning_cnt
|
||||
if ! /usr/bin/cmp "${SYSCONFDIR}/sshd_config" "${SYSCONFDIR}/defaults/${SYSCONFDIR}/sshd_config" >/dev/null 2>&1
|
||||
then
|
||||
|
@ -1,4 +1,4 @@
|
||||
%define ver 7.4p1
|
||||
%define ver 7.5p1
|
||||
%define rel 1
|
||||
|
||||
# OpenSSH privilege separation requires a user & group ID
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
Summary: OpenSSH, a free Secure Shell (SSH) protocol implementation
|
||||
Name: openssh
|
||||
Version: 7.4p1
|
||||
Version: 7.5p1
|
||||
URL: https://www.openssh.com/
|
||||
Release: 1
|
||||
Source0: openssh-%{version}.tar.gz
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: digest-openssl.c,v 1.5 2014/12/21 22:27:56 djm Exp $ */
|
||||
/* $OpenBSD: digest-openssl.c,v 1.6 2017/03/10 02:59:51 dtucker Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2013 Damien Miller <djm@mindrot.org>
|
||||
*
|
||||
@ -158,7 +158,7 @@ ssh_digest_final(struct ssh_digest_ctx *ctx, u_char *d, size_t dlen)
|
||||
const struct ssh_digest *digest = ssh_digest_by_alg(ctx->alg);
|
||||
u_int l = dlen;
|
||||
|
||||
if (dlen > UINT_MAX)
|
||||
if (digest == NULL || dlen > UINT_MAX)
|
||||
return SSH_ERR_INVALID_ARGUMENT;
|
||||
if (dlen < digest->digest_len) /* No truncation allowed */
|
||||
return SSH_ERR_INVALID_ARGUMENT;
|
||||
|
@ -12,7 +12,7 @@ configure_args="
|
||||
--with-libedit
|
||||
--with-ssl-engine
|
||||
--without-xauth
|
||||
"
|
||||
"
|
||||
|
||||
set -e
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: hostfile.c,v 1.67 2016/09/17 18:00:27 tedu Exp $ */
|
||||
/* $OpenBSD: hostfile.c,v 1.68 2017/03/10 04:26:06 djm Exp $ */
|
||||
/*
|
||||
* Author: Tatu Ylonen <ylo@cs.hut.fi>
|
||||
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
|
||||
@ -419,19 +419,24 @@ write_host_entry(FILE *f, const char *host, const char *ip,
|
||||
const struct sshkey *key, int store_hash)
|
||||
{
|
||||
int r, success = 0;
|
||||
char *hashed_host = NULL;
|
||||
char *hashed_host = NULL, *lhost;
|
||||
|
||||
lhost = xstrdup(host);
|
||||
lowercase(lhost);
|
||||
|
||||
if (store_hash) {
|
||||
if ((hashed_host = host_hash(host, NULL, 0)) == NULL) {
|
||||
if ((hashed_host = host_hash(lhost, NULL, 0)) == NULL) {
|
||||
error("%s: host_hash failed", __func__);
|
||||
free(lhost);
|
||||
return 0;
|
||||
}
|
||||
fprintf(f, "%s ", hashed_host);
|
||||
} else if (ip != NULL)
|
||||
fprintf(f, "%s,%s ", host, ip);
|
||||
else
|
||||
fprintf(f, "%s ", host);
|
||||
|
||||
fprintf(f, "%s,%s ", lhost, ip);
|
||||
else {
|
||||
fprintf(f, "%s ", lhost);
|
||||
}
|
||||
free(lhost);
|
||||
if ((r = sshkey_write(key, f)) == 0)
|
||||
success = 1;
|
||||
else
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: kex.c,v 1.127 2016/10/10 19:28:48 markus Exp $ */
|
||||
/* $OpenBSD: kex.c,v 1.131 2017/03/15 07:07:39 markus Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2000, 2001 Markus Friedl. All rights reserved.
|
||||
*
|
||||
@ -178,7 +178,7 @@ kex_names_valid(const char *names)
|
||||
char *
|
||||
kex_names_cat(const char *a, const char *b)
|
||||
{
|
||||
char *ret = NULL, *tmp = NULL, *cp, *p;
|
||||
char *ret = NULL, *tmp = NULL, *cp, *p, *m;
|
||||
size_t len;
|
||||
|
||||
if (a == NULL || *a == '\0')
|
||||
@ -195,8 +195,10 @@ kex_names_cat(const char *a, const char *b)
|
||||
}
|
||||
strlcpy(ret, a, len);
|
||||
for ((p = strsep(&cp, ",")); p && *p != '\0'; (p = strsep(&cp, ","))) {
|
||||
if (match_list(ret, p, NULL) != NULL)
|
||||
if ((m = match_list(ret, p, NULL)) != NULL) {
|
||||
free(m);
|
||||
continue; /* Algorithm already present */
|
||||
}
|
||||
if (strlcat(ret, ",", len) >= len ||
|
||||
strlcat(ret, p, len) >= len) {
|
||||
free(tmp);
|
||||
@ -211,7 +213,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 +225,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;
|
||||
}
|
||||
|
||||
@ -334,7 +341,6 @@ kex_reset_dispatch(struct ssh *ssh)
|
||||
{
|
||||
ssh_dispatch_range(ssh, SSH2_MSG_TRANSPORT_MIN,
|
||||
SSH2_MSG_TRANSPORT_MAX, &kex_protocol_error);
|
||||
ssh_dispatch_set(ssh, SSH2_MSG_KEXINIT, &kex_input_kexinit);
|
||||
}
|
||||
|
||||
static int
|
||||
@ -343,7 +349,7 @@ kex_send_ext_info(struct ssh *ssh)
|
||||
int r;
|
||||
char *algs;
|
||||
|
||||
if ((algs = sshkey_alg_list(0, 1, ',')) == NULL)
|
||||
if ((algs = sshkey_alg_list(0, 1, 1, ',')) == NULL)
|
||||
return SSH_ERR_ALLOC_FAIL;
|
||||
if ((r = sshpkt_start(ssh, SSH2_MSG_EXT_INFO)) != 0 ||
|
||||
(r = sshpkt_put_u32(ssh, 1)) != 0 ||
|
||||
@ -424,6 +430,7 @@ kex_input_newkeys(int type, u_int32_t seq, void *ctxt)
|
||||
|
||||
debug("SSH2_MSG_NEWKEYS received");
|
||||
ssh_dispatch_set(ssh, SSH2_MSG_NEWKEYS, &kex_protocol_error);
|
||||
ssh_dispatch_set(ssh, SSH2_MSG_KEXINIT, &kex_input_kexinit);
|
||||
if ((r = sshpkt_get_end(ssh)) != 0)
|
||||
return r;
|
||||
if ((r = ssh_set_newkeys(ssh, MODE_IN)) != 0)
|
||||
@ -538,6 +545,7 @@ kex_new(struct ssh *ssh, char *proposal[PROPOSAL_MAX], struct kex **kexp)
|
||||
goto out;
|
||||
kex->done = 0;
|
||||
kex_reset_dispatch(ssh);
|
||||
ssh_dispatch_set(ssh, SSH2_MSG_KEXINIT, &kex_input_kexinit);
|
||||
r = 0;
|
||||
*kexp = kex;
|
||||
out:
|
||||
@ -646,8 +654,10 @@ choose_enc(struct sshenc *enc, char *client, char *server)
|
||||
|
||||
if (name == NULL)
|
||||
return SSH_ERR_NO_CIPHER_ALG_MATCH;
|
||||
if ((enc->cipher = cipher_by_name(name)) == NULL)
|
||||
if ((enc->cipher = cipher_by_name(name)) == NULL) {
|
||||
free(name);
|
||||
return SSH_ERR_INTERNAL_ERROR;
|
||||
}
|
||||
enc->name = name;
|
||||
enc->enabled = 0;
|
||||
enc->iv = NULL;
|
||||
@ -665,8 +675,10 @@ choose_mac(struct ssh *ssh, struct sshmac *mac, char *client, char *server)
|
||||
|
||||
if (name == NULL)
|
||||
return SSH_ERR_NO_MAC_ALG_MATCH;
|
||||
if (mac_setup(mac, name) < 0)
|
||||
if (mac_setup(mac, name) < 0) {
|
||||
free(name);
|
||||
return SSH_ERR_INTERNAL_ERROR;
|
||||
}
|
||||
/* truncate the key */
|
||||
if (ssh->compat & SSH_BUG_HMAC)
|
||||
mac->key_len = 16;
|
||||
@ -690,6 +702,7 @@ choose_comp(struct sshcomp *comp, char *client, char *server)
|
||||
} else if (strcmp(name, "none") == 0) {
|
||||
comp->type = COMP_NONE;
|
||||
} else {
|
||||
free(name);
|
||||
return SSH_ERR_INTERNAL_ERROR;
|
||||
}
|
||||
comp->name = name;
|
||||
|
@ -14,7 +14,7 @@
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $OpenBSD: krl.c,v 1.38 2016/09/12 01:22:38 deraadt Exp $ */
|
||||
/* $OpenBSD: krl.c,v 1.39 2017/03/10 07:18:32 dtucker Exp $ */
|
||||
|
||||
#include "includes.h"
|
||||
|
||||
@ -1089,7 +1089,7 @@ ssh_krl_from_blob(struct sshbuf *buf, struct ssh_krl **krlp,
|
||||
break;
|
||||
case KRL_SECTION_SIGNATURE:
|
||||
/* Handled above, but still need to stay in synch */
|
||||
sshbuf_reset(sect);
|
||||
sshbuf_free(sect);
|
||||
sect = NULL;
|
||||
if ((r = sshbuf_skip_string(copy)) != 0)
|
||||
goto out;
|
||||
@ -1288,7 +1288,8 @@ ssh_krl_file_contains_key(const char *path, const struct sshkey *key)
|
||||
debug2("%s: checking KRL %s", __func__, path);
|
||||
r = ssh_krl_check_key(krl, key);
|
||||
out:
|
||||
close(fd);
|
||||
if (fd != -1)
|
||||
close(fd);
|
||||
sshbuf_free(krlbuf);
|
||||
ssh_krl_free(krl);
|
||||
if (r != 0)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: log.c,v 1.48 2016/07/15 05:01:58 dtucker Exp $ */
|
||||
/* $OpenBSD: log.c,v 1.49 2017/03/10 03:15:58 djm Exp $ */
|
||||
/*
|
||||
* Author: Tatu Ylonen <ylo@cs.hut.fi>
|
||||
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
|
||||
@ -453,7 +453,8 @@ do_log(LogLevel level, const char *fmt, va_list args)
|
||||
tmp_handler(level, fmtbuf, log_handler_ctx);
|
||||
log_handler = tmp_handler;
|
||||
} else if (log_on_stderr) {
|
||||
snprintf(msgbuf, sizeof msgbuf, "%s\r\n", fmtbuf);
|
||||
snprintf(msgbuf, sizeof msgbuf, "%.*s\r\n",
|
||||
(int)sizeof msgbuf - 3, fmtbuf);
|
||||
(void)write(log_stderr_fd, msgbuf, strlen(msgbuf));
|
||||
} else {
|
||||
#if defined(HAVE_OPENLOG_R) && defined(SYSLOG_DATA_INIT)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: match.c,v 1.33 2016/11/06 05:46:37 djm Exp $ */
|
||||
/* $OpenBSD: match.c,v 1.37 2017/03/10 04:24:55 djm Exp $ */
|
||||
/*
|
||||
* Author: Tatu Ylonen <ylo@cs.hut.fi>
|
||||
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
|
||||
@ -42,9 +42,11 @@
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "xmalloc.h"
|
||||
#include "match.h"
|
||||
#include "misc.h"
|
||||
|
||||
/*
|
||||
* Returns true if the given string matches the pattern (which may contain ?
|
||||
@ -145,7 +147,7 @@ match_pattern_list(const char *string, const char *pattern, int dolower)
|
||||
if (subi >= sizeof(sub) - 1)
|
||||
return 0;
|
||||
|
||||
/* If the subpattern was terminated by a comma, skip the comma. */
|
||||
/* If the subpattern was terminated by a comma, then skip it. */
|
||||
if (i < len && pattern[i] == ',')
|
||||
i++;
|
||||
|
||||
@ -177,7 +179,13 @@ match_pattern_list(const char *string, const char *pattern, int dolower)
|
||||
int
|
||||
match_hostname(const char *host, const char *pattern)
|
||||
{
|
||||
return match_pattern_list(host, pattern, 1);
|
||||
char *hostcopy = xstrdup(host);
|
||||
int r;
|
||||
|
||||
lowercase(hostcopy);
|
||||
r = match_pattern_list(hostcopy, pattern, 1);
|
||||
free(hostcopy);
|
||||
return r;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -284,3 +292,35 @@ 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) {
|
||||
free(orig_prop);
|
||||
free(fix_prop);
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -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: misc.c,v 1.107 2016/11/30 00:28:31 dtucker Exp $ */
|
||||
/* $OpenBSD: misc.c,v 1.109 2017/03/14 00:55:37 dtucker Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2000 Markus Friedl. All rights reserved.
|
||||
* Copyright (c) 2005,2006 Damien Miller. All rights reserved.
|
||||
@ -307,7 +307,7 @@ a2tun(const char *s, int *remote)
|
||||
long
|
||||
convtime(const char *s)
|
||||
{
|
||||
long total, secs;
|
||||
long total, secs, multiplier = 1;
|
||||
const char *p;
|
||||
char *endp;
|
||||
|
||||
@ -334,23 +334,28 @@ convtime(const char *s)
|
||||
break;
|
||||
case 'm':
|
||||
case 'M':
|
||||
secs *= MINUTES;
|
||||
multiplier = MINUTES;
|
||||
break;
|
||||
case 'h':
|
||||
case 'H':
|
||||
secs *= HOURS;
|
||||
multiplier = HOURS;
|
||||
break;
|
||||
case 'd':
|
||||
case 'D':
|
||||
secs *= DAYS;
|
||||
multiplier = DAYS;
|
||||
break;
|
||||
case 'w':
|
||||
case 'W':
|
||||
secs *= WEEKS;
|
||||
multiplier = WEEKS;
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
if (secs >= LONG_MAX / multiplier)
|
||||
return -1;
|
||||
secs *= multiplier;
|
||||
if (total >= LONG_MAX - secs)
|
||||
return -1;
|
||||
total += secs;
|
||||
if (total < 0)
|
||||
return -1;
|
||||
|
@ -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 { \
|
||||
|
@ -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>
|
||||
*
|
||||
@ -2162,7 +2162,6 @@ int
|
||||
muxclient(const char *path)
|
||||
{
|
||||
struct sockaddr_un addr;
|
||||
socklen_t sun_len;
|
||||
int sock;
|
||||
u_int pid;
|
||||
|
||||
@ -2186,8 +2185,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))
|
||||
@ -2197,7 +2194,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:
|
||||
|
@ -301,3 +301,11 @@ mbtowc(wchar_t *pwc, const char *s, size_t n)
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_LLABS
|
||||
long long
|
||||
llabs(long long j)
|
||||
{
|
||||
return (j < 0 ? -j : j);
|
||||
}
|
||||
#endif
|
||||
|
@ -135,4 +135,8 @@ void errx(int, const char *, ...) __attribute__((format(printf, 2, 3)));
|
||||
void warn(const char *, ...) __attribute__((format(printf, 1, 2)));
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_LLABS
|
||||
long long llabs(long long);
|
||||
#endif
|
||||
|
||||
#endif /* _BSD_MISC_H */
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: fmt_scaled.c,v 1.9 2007/03/20 03:42:52 tedu Exp $ */
|
||||
/* $OpenBSD: fmt_scaled.c,v 1.13 2017/03/11 23:37:23 djm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001, 2002, 2003 Ian F. Darwin. All rights reserved.
|
||||
@ -69,7 +69,7 @@ static long long scale_factors[] = {
|
||||
|
||||
#define MAX_DIGITS (SCALE_LENGTH * 3) /* XXX strlen(sprintf("%lld", -1)? */
|
||||
|
||||
/** Convert the given input string "scaled" into numeric in "result".
|
||||
/* Convert the given input string "scaled" into numeric in "result".
|
||||
* Return 0 on success, -1 and errno set on error.
|
||||
*/
|
||||
int
|
||||
@ -81,7 +81,7 @@ scan_scaled(char *scaled, long long *result)
|
||||
long long scale_fact = 1, whole = 0, fpart = 0;
|
||||
|
||||
/* Skip leading whitespace */
|
||||
while (isascii(*p) && isspace(*p))
|
||||
while (isascii((unsigned char)*p) && isspace((unsigned char)*p))
|
||||
++p;
|
||||
|
||||
/* Then at most one leading + or - */
|
||||
@ -108,7 +108,8 @@ scan_scaled(char *scaled, long long *result)
|
||||
* (but note that E for Exa might look like e to some!).
|
||||
* Advance 'p' to end, to get scale factor.
|
||||
*/
|
||||
for (; isascii(*p) && (isdigit(*p) || *p=='.'); ++p) {
|
||||
for (; isascii((unsigned char)*p) &&
|
||||
(isdigit((unsigned char)*p) || *p=='.'); ++p) {
|
||||
if (*p == '.') {
|
||||
if (fract_digits > 0) { /* oops, more than one '.' */
|
||||
errno = EINVAL;
|
||||
@ -124,6 +125,10 @@ scan_scaled(char *scaled, long long *result)
|
||||
/* ignore extra fractional digits */
|
||||
continue;
|
||||
fract_digits++; /* for later scaling */
|
||||
if (fpart >= LLONG_MAX / 10) {
|
||||
errno = ERANGE;
|
||||
return -1;
|
||||
}
|
||||
fpart *= 10;
|
||||
fpart += i;
|
||||
} else { /* normal digit */
|
||||
@ -131,6 +136,10 @@ scan_scaled(char *scaled, long long *result)
|
||||
errno = ERANGE;
|
||||
return -1;
|
||||
}
|
||||
if (whole >= LLONG_MAX / 10) {
|
||||
errno = ERANGE;
|
||||
return -1;
|
||||
}
|
||||
whole *= 10;
|
||||
whole += i;
|
||||
}
|
||||
@ -150,17 +159,22 @@ scan_scaled(char *scaled, long long *result)
|
||||
/* Validate scale factor, and scale whole and fraction by it. */
|
||||
for (i = 0; i < SCALE_LENGTH; i++) {
|
||||
|
||||
/** Are we there yet? */
|
||||
/* Are we there yet? */
|
||||
if (*p == scale_chars[i] ||
|
||||
*p == tolower(scale_chars[i])) {
|
||||
*p == tolower((unsigned char)scale_chars[i])) {
|
||||
|
||||
/* If it ends with alphanumerics after the scale char, bad. */
|
||||
if (isalnum(*(p+1))) {
|
||||
if (isalnum((unsigned char)*(p+1))) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
scale_fact = scale_factors[i];
|
||||
|
||||
if (whole >= LLONG_MAX / scale_fact) {
|
||||
errno = ERANGE;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* scale whole part */
|
||||
whole *= scale_fact;
|
||||
|
||||
@ -181,7 +195,9 @@ scan_scaled(char *scaled, long long *result)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
errno = ERANGE;
|
||||
|
||||
/* Invalid unit or character */
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -196,7 +212,7 @@ fmt_scaled(long long number, char *result)
|
||||
unsigned int i;
|
||||
unit_type unit = NONE;
|
||||
|
||||
abval = (number < 0LL) ? -number : number; /* no long long_abs yet */
|
||||
abval = llabs(number);
|
||||
|
||||
/* Not every negative long long has a positive representation.
|
||||
* Also check for numbers that are just too darned big to format
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: packet.c,v 1.243 2016/10/11 21:47:45 djm Exp $ */
|
||||
/* $OpenBSD: packet.c,v 1.247 2017/03/11 13:07:35 markus Exp $ */
|
||||
/*
|
||||
* Author: Tatu Ylonen <ylo@cs.hut.fi>
|
||||
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
|
||||
@ -354,6 +354,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)
|
||||
{
|
||||
@ -1051,7 +1070,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 */
|
||||
@ -1449,8 +1468,10 @@ ssh_packet_read_seqnr(struct ssh *ssh, u_char *typep, u_int32_t *seqnr_p)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (r == 0)
|
||||
return SSH_ERR_CONN_TIMEOUT;
|
||||
if (r == 0) {
|
||||
r = SSH_ERR_CONN_TIMEOUT;
|
||||
goto out;
|
||||
}
|
||||
/* Read data from the socket. */
|
||||
len = read(state->connection_in, buf, sizeof(buf));
|
||||
if (len == 0) {
|
||||
@ -1831,11 +1852,11 @@ ssh_packet_read_poll2(struct ssh *ssh, u_char *typep, u_int32_t *seqnr_p)
|
||||
if (r != SSH_ERR_MAC_INVALID)
|
||||
goto out;
|
||||
logit("Corrupted MAC on input.");
|
||||
if (need > PACKET_MAX_SIZE)
|
||||
if (need + block_size > PACKET_MAX_SIZE)
|
||||
return SSH_ERR_INTERNAL_ERROR;
|
||||
return ssh_packet_start_discard(ssh, enc, mac,
|
||||
sshbuf_len(state->incoming_packet),
|
||||
PACKET_MAX_SIZE - need);
|
||||
PACKET_MAX_SIZE - need - block_size);
|
||||
}
|
||||
/* Remove MAC from input buffer */
|
||||
DBG(debug("MAC #%d ok", state->p_read.seqnr));
|
||||
@ -2076,27 +2097,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:
|
||||
@ -2105,17 +2135,16 @@ sshpkt_fatal(struct ssh *ssh, const char *tag, int r)
|
||||
case SSH_ERR_NO_HOSTKEY_ALG_MATCH:
|
||||
if (ssh && ssh->kex && ssh->kex->failed_choice) {
|
||||
BLACKLIST_NOTIFY(BLACKLIST_AUTH_FAIL, "ssh");
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
@ -2128,7 +2157,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;
|
||||
@ -2141,12 +2170,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
|
||||
@ -2399,10 +2429,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;
|
||||
}
|
||||
|
@ -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 *);
|
||||
|
@ -167,15 +167,6 @@
|
||||
#define _PATH_LS "ls"
|
||||
#endif
|
||||
|
||||
/* path to login program */
|
||||
#ifndef LOGIN_PROGRAM
|
||||
# ifdef LOGIN_PROGRAM_FALLBACK
|
||||
# define LOGIN_PROGRAM LOGIN_PROGRAM_FALLBACK
|
||||
# else
|
||||
# define LOGIN_PROGRAM "/usr/bin/login"
|
||||
# endif
|
||||
#endif /* LOGIN_PROGRAM */
|
||||
|
||||
/* Askpass program define */
|
||||
#ifndef ASKPASS_PROGRAM
|
||||
#define ASKPASS_PROGRAM "/usr/lib/ssh/ssh-askpass"
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: readconf.c,v 1.262 2016/10/25 04:08:13 jsg Exp $ */
|
||||
/* $OpenBSD: readconf.c,v 1.270 2017/03/10 04:27:32 djm Exp $ */
|
||||
/*
|
||||
* Author: Tatu Ylonen <ylo@cs.hut.fi>
|
||||
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
|
||||
@ -95,7 +95,7 @@ __RCSID("$FreeBSD$");
|
||||
|
||||
Host books.com
|
||||
RemoteForward 9999 shadows.cs.hut.fi:9999
|
||||
Cipher 3des
|
||||
Ciphers 3des-cbc
|
||||
|
||||
Host fascist.blob.com
|
||||
Port 23123
|
||||
@ -110,7 +110,7 @@ __RCSID("$FreeBSD$");
|
||||
PublicKeyAuthentication no
|
||||
|
||||
Host *.su
|
||||
Cipher none
|
||||
Ciphers aes128-ctr
|
||||
PasswordAuthentication no
|
||||
|
||||
Host vpn.fake.com
|
||||
@ -183,6 +183,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 },
|
||||
@ -191,30 +229,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 },
|
||||
@ -236,15 +259,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 },
|
||||
@ -253,13 +273,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 },
|
||||
@ -280,7 +293,6 @@ static struct {
|
||||
{ "localcommand", oLocalCommand },
|
||||
{ "permitlocalcommand", oPermitLocalCommand },
|
||||
{ "visualhostkey", oVisualHostKey },
|
||||
{ "useroaming", oDeprecated },
|
||||
{ "kexalgorithms", oKexAlgorithms },
|
||||
{ "ipqos", oIPQoS },
|
||||
{ "requesttty", oRequestTTY },
|
||||
@ -841,11 +853,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';
|
||||
}
|
||||
@ -1193,7 +1205,7 @@ process_config_line_depth(Options *options, struct passwd *pw, const char *host,
|
||||
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)
|
||||
@ -1204,7 +1216,7 @@ process_config_line_depth(Options *options, struct passwd *pw, const char *host,
|
||||
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)
|
||||
@ -1216,7 +1228,8 @@ process_config_line_depth(Options *options, struct passwd *pw, const char *host,
|
||||
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)
|
||||
@ -1230,7 +1243,8 @@ process_config_line_depth(Options *options, struct passwd *pw, const char *host,
|
||||
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)
|
||||
@ -1497,6 +1511,7 @@ process_config_line_depth(Options *options, struct passwd *pw, const char *host,
|
||||
if (r == GLOB_NOMATCH) {
|
||||
debug("%.200s line %d: include %s matched no "
|
||||
"files",filename, linenum, arg2);
|
||||
free(arg2);
|
||||
continue;
|
||||
} else if (r != 0 || gl.gl_pathc < 0)
|
||||
fatal("%.200s line %d: glob failed for %s.",
|
||||
@ -1513,6 +1528,11 @@ process_config_line_depth(Options *options, struct passwd *pw, const char *host,
|
||||
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.
|
||||
@ -1727,7 +1747,7 @@ read_config_file_depth(const char *filename, struct passwd *pw,
|
||||
int flags, int *activep, int depth)
|
||||
{
|
||||
FILE *f;
|
||||
char line[1024];
|
||||
char line[4096];
|
||||
int linenum;
|
||||
int bad_options = 0;
|
||||
|
||||
@ -1757,6 +1777,8 @@ read_config_file_depth(const char *filename, struct passwd *pw,
|
||||
while (fgets(line, sizeof(line), f)) {
|
||||
/* Update line number counter. */
|
||||
linenum++;
|
||||
if (strlen(line) == sizeof(line) - 1)
|
||||
fatal("%s line %d too long", filename, linenum);
|
||||
if (process_config_line_depth(options, pw, host, original_host,
|
||||
line, filename, linenum, activep, flags, depth) != 0)
|
||||
bad_options++;
|
||||
@ -2482,10 +2504,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));
|
||||
@ -2558,8 +2580,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);
|
||||
@ -2571,7 +2595,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);
|
||||
@ -2591,7 +2617,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);
|
||||
|
@ -222,6 +222,7 @@ unit:
|
||||
$$V ${.OBJDIR}/unittests/sshkey/test_sshkey \
|
||||
-d ${.CURDIR}/unittests/sshkey/testdata ; \
|
||||
$$V ${.OBJDIR}/unittests/bitmap/test_bitmap ; \
|
||||
$$V ${.OBJDIR}/unittests/conversion/test_conversion ; \
|
||||
$$V ${.OBJDIR}/unittests/kex/test_kex ; \
|
||||
$$V ${.OBJDIR}/unittests/hostkeys/test_hostkeys \
|
||||
-d ${.CURDIR}/unittests/hostkeys/testdata ; \
|
||||
|
@ -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
|
||||
|
@ -4,7 +4,7 @@
|
||||
tid="AllowUsers/DenyUsers"
|
||||
|
||||
me="$LOGNAME"
|
||||
if [ "x$me" == "x" ]; then
|
||||
if [ "x$me" = "x" ]; then
|
||||
me=`whoami`
|
||||
fi
|
||||
other="nobody"
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $OpenBSD: cert-file.sh,v 1.4 2016/12/16 02:48:55 djm Exp $
|
||||
# $OpenBSD: cert-file.sh,v 1.5 2017/03/11 23:44:16 djm Exp $
|
||||
# Placed in the Public Domain.
|
||||
|
||||
tid="ssh with certificates"
|
||||
@ -17,24 +17,59 @@ ${SSHKEYGEN} -q -N '' -t ed25519 -f $OBJ/user_key1 || \
|
||||
fatal "ssh-keygen failed"
|
||||
${SSHKEYGEN} -q -N '' -t ed25519 -f $OBJ/user_key2 || \
|
||||
fatal "ssh-keygen failed"
|
||||
${SSHKEYGEN} -q -N '' -t ed25519 -f $OBJ/user_key3 || \
|
||||
fatal "ssh-keygen failed"
|
||||
${SSHKEYGEN} -q -N '' -t ed25519 -f $OBJ/user_key4 || \
|
||||
fatal "ssh-keygen failed"
|
||||
${SSHKEYGEN} -q -N '' -t ed25519 -f $OBJ/user_key5 || \
|
||||
fatal "ssh-keygen failed"
|
||||
|
||||
# Move the certificate to a different address to better control
|
||||
# when it is offered.
|
||||
${SSHKEYGEN} -q -s $OBJ/user_ca_key1 -I "regress user key for $USER" \
|
||||
-z $$ -n ${USER} $OBJ/user_key1 ||
|
||||
fail "couldn't sign user_key1 with user_ca_key1"
|
||||
fatal "couldn't sign user_key1 with user_ca_key1"
|
||||
mv $OBJ/user_key1-cert.pub $OBJ/cert_user_key1_1.pub
|
||||
${SSHKEYGEN} -q -s $OBJ/user_ca_key2 -I "regress user key for $USER" \
|
||||
-z $$ -n ${USER} $OBJ/user_key1 ||
|
||||
fail "couldn't sign user_key1 with user_ca_key2"
|
||||
fatal "couldn't sign user_key1 with user_ca_key2"
|
||||
mv $OBJ/user_key1-cert.pub $OBJ/cert_user_key1_2.pub
|
||||
${SSHKEYGEN} -q -s $OBJ/user_ca_key1 -I "regress user key for $USER" \
|
||||
-z $$ -n ${USER} $OBJ/user_key3 ||
|
||||
fatal "couldn't sign user_key3 with user_ca_key1"
|
||||
rm $OBJ/user_key3.pub # to test use of private key w/o public half.
|
||||
${SSHKEYGEN} -q -s $OBJ/user_ca_key1 -I "regress user key for $USER" \
|
||||
-z $$ -n ${USER} $OBJ/user_key4 ||
|
||||
fatal "couldn't sign user_key4 with user_ca_key1"
|
||||
rm $OBJ/user_key4 $OBJ/user_key4.pub # to test no matching pub/private key case.
|
||||
|
||||
trace 'try with identity files'
|
||||
opts="-F $OBJ/ssh_proxy -oIdentitiesOnly=yes"
|
||||
opts2="$opts -i $OBJ/user_key1 -i $OBJ/user_key2"
|
||||
echo "cert-authority $(cat $OBJ/user_ca_key1.pub)" > $OBJ/authorized_keys_$USER
|
||||
|
||||
# Make a clean config that doesn't have any pre-added identities.
|
||||
cat $OBJ/ssh_proxy | grep -v IdentityFile > $OBJ/no_identity_config
|
||||
|
||||
# XXX: verify that certificate used was what we expect. Needs exposure of
|
||||
# keys via enviornment variable or similar.
|
||||
|
||||
for p in ${SSH_PROTOCOLS}; do
|
||||
# Key with no .pub should work - finding the equivalent *-cert.pub.
|
||||
verbose "protocol $p: identity cert with no plain public file"
|
||||
${SSH} -F $OBJ/no_identity_config -oIdentitiesOnly=yes \
|
||||
-i $OBJ/user_key3 somehost exit 5$p
|
||||
[ $? -ne 5$p ] && fail "ssh failed"
|
||||
|
||||
# CertificateFile matching private key with no .pub file should work.
|
||||
verbose "protocol $p: CertificateFile with no plain public file"
|
||||
${SSH} -F $OBJ/no_identity_config -oIdentitiesOnly=yes \
|
||||
-oCertificateFile=$OBJ/user_key3-cert.pub \
|
||||
-i $OBJ/user_key3 somehost exit 5$p
|
||||
[ $? -ne 5$p ] && fail "ssh failed"
|
||||
|
||||
# Just keys should fail
|
||||
verbose "protocol $p: plain keys"
|
||||
${SSH} $opts2 somehost exit 5$p
|
||||
r=$?
|
||||
if [ $r -eq 5$p ]; then
|
||||
@ -42,6 +77,7 @@ for p in ${SSH_PROTOCOLS}; do
|
||||
fi
|
||||
|
||||
# Keys with untrusted cert should fail.
|
||||
verbose "protocol $p: untrusted cert"
|
||||
opts3="$opts2 -oCertificateFile=$OBJ/cert_user_key1_2.pub"
|
||||
${SSH} $opts3 somehost exit 5$p
|
||||
r=$?
|
||||
@ -50,6 +86,7 @@ for p in ${SSH_PROTOCOLS}; do
|
||||
fi
|
||||
|
||||
# Good cert with bad key should fail.
|
||||
verbose "protocol $p: good cert, bad key"
|
||||
opts3="$opts -i $OBJ/user_key2"
|
||||
opts3="$opts3 -oCertificateFile=$OBJ/cert_user_key1_1.pub"
|
||||
${SSH} $opts3 somehost exit 5$p
|
||||
@ -59,6 +96,7 @@ for p in ${SSH_PROTOCOLS}; do
|
||||
fi
|
||||
|
||||
# Keys with one trusted cert, should succeed.
|
||||
verbose "protocol $p: single trusted"
|
||||
opts3="$opts2 -oCertificateFile=$OBJ/cert_user_key1_1.pub"
|
||||
${SSH} $opts3 somehost exit 5$p
|
||||
r=$?
|
||||
@ -67,6 +105,7 @@ for p in ${SSH_PROTOCOLS}; do
|
||||
fi
|
||||
|
||||
# Multiple certs and keys, with one trusted cert, should succeed.
|
||||
verbose "protocol $p: multiple trusted"
|
||||
opts3="$opts2 -oCertificateFile=$OBJ/cert_user_key1_2.pub"
|
||||
opts3="$opts3 -oCertificateFile=$OBJ/cert_user_key1_1.pub"
|
||||
${SSH} $opts3 somehost exit 5$p
|
||||
@ -74,14 +113,6 @@ for p in ${SSH_PROTOCOLS}; do
|
||||
if [ $r -ne 5$p ]; then
|
||||
fail "ssh failed with multiple certs in protocol $p"
|
||||
fi
|
||||
|
||||
#Keys with trusted certificate specified in config options, should succeed.
|
||||
opts3="$opts2 -oCertificateFile=$OBJ/cert_user_key1_1.pub"
|
||||
${SSH} $opts3 somehost exit 5$p
|
||||
r=$?
|
||||
if [ $r -ne 5$p ]; then
|
||||
fail "ssh failed with trusted cert in config in protocol $p"
|
||||
fi
|
||||
done
|
||||
|
||||
#next, using an agent in combination with the keys
|
||||
|
@ -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"
|
||||
@ -10,8 +10,7 @@ start_sshd
|
||||
base=33
|
||||
last=$PORT
|
||||
fwd=""
|
||||
CTL=$OBJ/ctl-sock
|
||||
rm -f $CTL
|
||||
CTL=/tmp/openssh.regress.ctl-sock.$$
|
||||
|
||||
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: test-exec.sh,v 1.58 2016/12/16 01:06:27 dtucker Exp $
|
||||
# $OpenBSD: test-exec.sh,v 1.59 2017/02/07 23:03:11 dtucker Exp $
|
||||
# Placed in the Public Domain.
|
||||
|
||||
#SUDO=sudo
|
||||
@ -444,12 +444,10 @@ Host *
|
||||
User $USER
|
||||
GlobalKnownHostsFile $OBJ/known_hosts
|
||||
UserKnownHostsFile $OBJ/known_hosts
|
||||
RSAAuthentication yes
|
||||
PubkeyAuthentication yes
|
||||
ChallengeResponseAuthentication no
|
||||
HostbasedAuthentication no
|
||||
PasswordAuthentication no
|
||||
RhostsRSAAuthentication no
|
||||
BatchMode yes
|
||||
StrictHostKeyChecking yes
|
||||
LogLevel DEBUG3
|
||||
|
@ -1,5 +1,6 @@
|
||||
# $OpenBSD: Makefile,v 1.7 2016/08/19 06:44:13 djm Exp $
|
||||
REGRESS_FAIL_EARLY= yes
|
||||
SUBDIR= test_helper sshbuf sshkey bitmap kex hostkeys utf8 match
|
||||
# $OpenBSD: Makefile,v 1.9 2017/03/14 01:20:29 dtucker Exp $
|
||||
|
||||
REGRESS_FAIL_EARLY?= yes
|
||||
SUBDIR= test_helper sshbuf sshkey bitmap kex hostkeys utf8 match conversion
|
||||
|
||||
.include <bsd.subdir.mk>
|
||||
|
10
crypto/openssh/regress/unittests/conversion/Makefile
Normal file
10
crypto/openssh/regress/unittests/conversion/Makefile
Normal file
@ -0,0 +1,10 @@
|
||||
# $OpenBSD: Makefile,v 1.1 2017/03/14 01:20:29 dtucker Exp $
|
||||
|
||||
PROG=test_conversion
|
||||
SRCS=tests.c
|
||||
REGRESS_TARGETS=run-regress-${PROG}
|
||||
|
||||
run-regress-${PROG}: ${PROG}
|
||||
env ${TEST_ENV} ./${PROG}
|
||||
|
||||
.include <bsd.regress.mk>
|
51
crypto/openssh/regress/unittests/conversion/tests.c
Normal file
51
crypto/openssh/regress/unittests/conversion/tests.c
Normal file
@ -0,0 +1,51 @@
|
||||
/* $OpenBSD: tests.c,v 1.1 2017/03/14 01:20:29 dtucker Exp $ */
|
||||
/*
|
||||
* Regress test for conversions
|
||||
*
|
||||
* Placed in the public domain
|
||||
*/
|
||||
|
||||
#include "includes.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#include <stdio.h>
|
||||
#ifdef HAVE_STDINT_H
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "../test_helper/test_helper.h"
|
||||
|
||||
#include "misc.h"
|
||||
|
||||
void
|
||||
tests(void)
|
||||
{
|
||||
char buf[1024];
|
||||
|
||||
TEST_START("conversion_convtime");
|
||||
ASSERT_LONG_EQ(convtime("0"), 0);
|
||||
ASSERT_LONG_EQ(convtime("1"), 1);
|
||||
ASSERT_LONG_EQ(convtime("1S"), 1);
|
||||
/* from the examples in the comment above the function */
|
||||
ASSERT_LONG_EQ(convtime("90m"), 5400);
|
||||
ASSERT_LONG_EQ(convtime("1h30m"), 5400);
|
||||
ASSERT_LONG_EQ(convtime("2d"), 172800);
|
||||
ASSERT_LONG_EQ(convtime("1w"), 604800);
|
||||
|
||||
/* negative time is not allowed */
|
||||
ASSERT_LONG_EQ(convtime("-7"), -1);
|
||||
ASSERT_LONG_EQ(convtime("-9d"), -1);
|
||||
|
||||
/* overflow */
|
||||
snprintf(buf, sizeof buf, "%llu", (unsigned long long)LONG_MAX + 1);
|
||||
ASSERT_LONG_EQ(convtime(buf), -1);
|
||||
|
||||
/* overflow with multiplier */
|
||||
snprintf(buf, sizeof buf, "%lluM", (unsigned long long)LONG_MAX/60 + 1);
|
||||
ASSERT_LONG_EQ(convtime(buf), -1);
|
||||
ASSERT_LONG_EQ(convtime("1000000000000000000000w"), -1);
|
||||
TEST_DONE();
|
||||
}
|
@ -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 *);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: test_helper.c,v 1.6 2015/03/03 20:42:49 djm Exp $ */
|
||||
/* $OpenBSD: test_helper.c,v 1.7 2017/03/14 01:10:07 dtucker Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2011 Damien Miller <djm@mindrot.org>
|
||||
*
|
||||
@ -441,6 +441,17 @@ assert_u_int(const char *file, int line, const char *a1, const char *a2,
|
||||
test_die();
|
||||
}
|
||||
|
||||
void
|
||||
assert_long(const char *file, int line, const char *a1, const char *a2,
|
||||
long aa1, long aa2, enum test_predicate pred)
|
||||
{
|
||||
TEST_CHECK(aa1, aa2, pred);
|
||||
test_header(file, line, a1, a2, "LONG", pred);
|
||||
fprintf(stderr, "%12s = %ld / 0x%lx\n", a1, aa1, aa1);
|
||||
fprintf(stderr, "%12s = %ld / 0x%lx\n", a2, aa2, aa2);
|
||||
test_die();
|
||||
}
|
||||
|
||||
void
|
||||
assert_long_long(const char *file, int line, const char *a1, const char *a2,
|
||||
long long aa1, long long aa2, enum test_predicate pred)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: test_helper.h,v 1.6 2015/01/18 19:52:44 djm Exp $ */
|
||||
/* $OpenBSD: test_helper.h,v 1.7 2017/03/14 01:10:07 dtucker Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2011 Damien Miller <djm@mindrot.org>
|
||||
*
|
||||
@ -67,6 +67,9 @@ void assert_size_t(const char *file, int line,
|
||||
void assert_u_int(const char *file, int line,
|
||||
const char *a1, const char *a2,
|
||||
u_int aa1, u_int aa2, enum test_predicate pred);
|
||||
void assert_long(const char *file, int line,
|
||||
const char *a1, const char *a2,
|
||||
long aa1, long aa2, enum test_predicate pred);
|
||||
void assert_long_long(const char *file, int line,
|
||||
const char *a1, const char *a2,
|
||||
long long aa1, long long aa2, enum test_predicate pred);
|
||||
@ -110,6 +113,8 @@ void assert_u64(const char *file, int line,
|
||||
assert_size_t(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_EQ)
|
||||
#define ASSERT_U_INT_EQ(a1, a2) \
|
||||
assert_u_int(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_EQ)
|
||||
#define ASSERT_LONG_EQ(a1, a2) \
|
||||
assert_long(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_EQ)
|
||||
#define ASSERT_LONG_LONG_EQ(a1, a2) \
|
||||
assert_long_long(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_EQ)
|
||||
#define ASSERT_CHAR_EQ(a1, a2) \
|
||||
@ -139,6 +144,8 @@ void assert_u64(const char *file, int line,
|
||||
assert_size_t(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_NE)
|
||||
#define ASSERT_U_INT_NE(a1, a2) \
|
||||
assert_u_int(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_NE)
|
||||
#define ASSERT_LONG_NE(a1, a2) \
|
||||
assert_long(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_NE)
|
||||
#define ASSERT_LONG_LONG_NE(a1, a2) \
|
||||
assert_long_long(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_NE)
|
||||
#define ASSERT_CHAR_NE(a1, a2) \
|
||||
@ -166,6 +173,8 @@ void assert_u64(const char *file, int line,
|
||||
assert_size_t(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_LT)
|
||||
#define ASSERT_U_INT_LT(a1, a2) \
|
||||
assert_u_int(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_LT)
|
||||
#define ASSERT_LONG_LT(a1, a2) \
|
||||
assert_long(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_LT)
|
||||
#define ASSERT_LONG_LONG_LT(a1, a2) \
|
||||
assert_long_long(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_LT)
|
||||
#define ASSERT_CHAR_LT(a1, a2) \
|
||||
@ -193,6 +202,8 @@ void assert_u64(const char *file, int line,
|
||||
assert_size_t(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_LE)
|
||||
#define ASSERT_U_INT_LE(a1, a2) \
|
||||
assert_u_int(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_LE)
|
||||
#define ASSERT_LONG_LE(a1, a2) \
|
||||
assert_long(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_LE)
|
||||
#define ASSERT_LONG_LONG_LE(a1, a2) \
|
||||
assert_long_long(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_LE)
|
||||
#define ASSERT_CHAR_LE(a1, a2) \
|
||||
@ -220,6 +231,8 @@ void assert_u64(const char *file, int line,
|
||||
assert_size_t(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_GT)
|
||||
#define ASSERT_U_INT_GT(a1, a2) \
|
||||
assert_u_int(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_GT)
|
||||
#define ASSERT_LONG_GT(a1, a2) \
|
||||
assert_long(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_GT)
|
||||
#define ASSERT_LONG_LONG_GT(a1, a2) \
|
||||
assert_long_long(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_GT)
|
||||
#define ASSERT_CHAR_GT(a1, a2) \
|
||||
@ -247,6 +260,8 @@ void assert_u64(const char *file, int line,
|
||||
assert_size_t(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_GE)
|
||||
#define ASSERT_U_INT_GE(a1, a2) \
|
||||
assert_u_int(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_GE)
|
||||
#define ASSERT_LONG_GE(a1, a2) \
|
||||
assert_long(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_GE)
|
||||
#define ASSERT_LONG_LONG_GE(a1, a2) \
|
||||
assert_long_long(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_GE)
|
||||
#define ASSERT_CHAR_GE(a1, a2) \
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: tests.c,v 1.3 2016/12/19 04:55:18 djm Exp $ */
|
||||
/* $OpenBSD: tests.c,v 1.4 2017/02/19 00:11:29 djm Exp $ */
|
||||
/*
|
||||
* Regress test for the utf8.h *mprintf() API
|
||||
*
|
||||
@ -15,10 +15,7 @@
|
||||
|
||||
#include "utf8.h"
|
||||
|
||||
void badarg(void);
|
||||
void one(const char *, const char *, int, int, int, const char *);
|
||||
|
||||
void
|
||||
static void
|
||||
badarg(void)
|
||||
{
|
||||
char buf[16];
|
||||
@ -33,8 +30,8 @@ badarg(void)
|
||||
TEST_DONE();
|
||||
}
|
||||
|
||||
void
|
||||
one(const char *name, const char *mbs, int width,
|
||||
static void
|
||||
one(int utf8, const char *name, const char *mbs, int width,
|
||||
int wantwidth, int wantlen, const char *wants)
|
||||
{
|
||||
char buf[16];
|
||||
@ -43,7 +40,7 @@ one(const char *name, const char *mbs, int width,
|
||||
|
||||
if (wantlen == -2)
|
||||
wantlen = strlen(wants);
|
||||
(void)strlcpy(buf, "utf8_", sizeof(buf));
|
||||
(void)strlcpy(buf, utf8 ? "utf8_" : "c_", sizeof(buf));
|
||||
(void)strlcat(buf, name, sizeof(buf));
|
||||
TEST_START(buf);
|
||||
wp = wantwidth == -2 ? NULL : &width;
|
||||
@ -65,19 +62,41 @@ tests(void)
|
||||
TEST_DONE();
|
||||
|
||||
badarg();
|
||||
one("empty", "", 2, 0, 0, "");
|
||||
one("ascii", "x", -2, -2, -2, "x");
|
||||
one("newline", "a\nb", -2, -2, -2, "a\nb");
|
||||
one("cr", "a\rb", -2, -2, -2, "a\rb");
|
||||
one("tab", "a\tb", -2, -2, -2, "a\tb");
|
||||
one("esc", "\033x", -2, -2, -2, "\\033x");
|
||||
one("inv_badbyte", "\377x", -2, -2, -2, "\\377x");
|
||||
one("inv_nocont", "\341x", -2, -2, -2, "\\341x");
|
||||
one("inv_nolead", "a\200b", -2, -2, -2, "a\\200b");
|
||||
one("sz_ascii", "1234567890123456", -2, -2, 16, "123456789012345");
|
||||
one("sz_esc", "123456789012\033", -2, -2, 16, "123456789012");
|
||||
one("width_ascii", "123", 2, 2, -1, "12");
|
||||
one("width_double", "a\343\201\201", 2, 1, -1, "a");
|
||||
one("double_fit", "a\343\201\201", 3, 3, 4, "a\343\201\201");
|
||||
one("double_spc", "a\343\201\201", 4, 3, 4, "a\343\201\201");
|
||||
one(1, "empty", "", 2, 0, 0, "");
|
||||
one(1, "ascii", "x", -2, -2, -2, "x");
|
||||
one(1, "newline", "a\nb", -2, -2, -2, "a\nb");
|
||||
one(1, "cr", "a\rb", -2, -2, -2, "a\rb");
|
||||
one(1, "tab", "a\tb", -2, -2, -2, "a\tb");
|
||||
one(1, "esc", "\033x", -2, -2, -2, "\\033x");
|
||||
one(1, "inv_badbyte", "\377x", -2, -2, -2, "\\377x");
|
||||
one(1, "inv_nocont", "\341x", -2, -2, -2, "\\341x");
|
||||
one(1, "inv_nolead", "a\200b", -2, -2, -2, "a\\200b");
|
||||
one(1, "sz_ascii", "1234567890123456", -2, -2, 16, "123456789012345");
|
||||
one(1, "sz_esc", "123456789012\033", -2, -2, 16, "123456789012");
|
||||
one(1, "width_ascii", "123", 2, 2, -1, "12");
|
||||
one(1, "width_double", "a\343\201\201", 2, 1, -1, "a");
|
||||
one(1, "double_fit", "a\343\201\201", 3, 3, 4, "a\343\201\201");
|
||||
one(1, "double_spc", "a\343\201\201", 4, 3, 4, "a\343\201\201");
|
||||
|
||||
TEST_START("C_setlocale");
|
||||
loc = setlocale(LC_CTYPE, "C");
|
||||
ASSERT_PTR_NE(loc, NULL);
|
||||
TEST_DONE();
|
||||
|
||||
badarg();
|
||||
one(0, "empty", "", 2, 0, 0, "");
|
||||
one(0, "ascii", "x", -2, -2, -2, "x");
|
||||
one(0, "newline", "a\nb", -2, -2, -2, "a\nb");
|
||||
one(0, "cr", "a\rb", -2, -2, -2, "a\rb");
|
||||
one(0, "tab", "a\tb", -2, -2, -2, "a\tb");
|
||||
one(0, "esc", "\033x", -2, -2, -2, "\\033x");
|
||||
one(0, "inv_badbyte", "\377x", -2, -2, -2, "\\377x");
|
||||
one(0, "inv_nocont", "\341x", -2, -2, -2, "\\341x");
|
||||
one(0, "inv_nolead", "a\200b", -2, -2, -2, "a\\200b");
|
||||
one(0, "sz_ascii", "1234567890123456", -2, -2, 16, "123456789012345");
|
||||
one(0, "sz_esc", "123456789012\033", -2, -2, 16, "123456789012");
|
||||
one(0, "width_ascii", "123", 2, 2, -1, "12");
|
||||
one(0, "width_double", "a\343\201\201", 2, 1, -1, "a");
|
||||
one(0, "double_fit", "a\343\201\201", 7, 5, -1, "a\\343");
|
||||
one(0, "double_spc", "a\343\201\201", 13, 13, 13, "a\\343\\201\\201");
|
||||
}
|
||||
|
@ -73,19 +73,35 @@
|
||||
# define SECCOMP_FILTER_FAIL SECCOMP_RET_TRAP
|
||||
#endif /* SANDBOX_SECCOMP_FILTER_DEBUG */
|
||||
|
||||
#if __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
# define ARG_LO_OFFSET 0
|
||||
# define ARG_HI_OFFSET sizeof(uint32_t)
|
||||
#elif __BYTE_ORDER == __BIG_ENDIAN
|
||||
# define ARG_LO_OFFSET sizeof(uint32_t)
|
||||
# define ARG_HI_OFFSET 0
|
||||
#else
|
||||
#error "Unknown endianness"
|
||||
#endif
|
||||
|
||||
/* Simple helpers to avoid manual errors (but larger BPF programs). */
|
||||
#define SC_DENY(_nr, _errno) \
|
||||
BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, __NR_ ## _nr, 0, 1), \
|
||||
BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, (_nr), 0, 1), \
|
||||
BPF_STMT(BPF_RET+BPF_K, SECCOMP_RET_ERRNO|(_errno))
|
||||
#define SC_ALLOW(_nr) \
|
||||
BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, __NR_ ## _nr, 0, 1), \
|
||||
BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, (_nr), 0, 1), \
|
||||
BPF_STMT(BPF_RET+BPF_K, SECCOMP_RET_ALLOW)
|
||||
#define SC_ALLOW_ARG(_nr, _arg_nr, _arg_val) \
|
||||
BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, __NR_ ## _nr, 0, 4), \
|
||||
/* load first syscall argument */ \
|
||||
BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, (_nr), 0, 6), \
|
||||
/* load and test first syscall argument, low word */ \
|
||||
BPF_STMT(BPF_LD+BPF_W+BPF_ABS, \
|
||||
offsetof(struct seccomp_data, args[(_arg_nr)])), \
|
||||
BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, (_arg_val), 0, 1), \
|
||||
offsetof(struct seccomp_data, args[(_arg_nr)]) + ARG_LO_OFFSET), \
|
||||
BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, \
|
||||
((_arg_val) & 0xFFFFFFFF), 0, 3), \
|
||||
/* load and test first syscall argument, high word */ \
|
||||
BPF_STMT(BPF_LD+BPF_W+BPF_ABS, \
|
||||
offsetof(struct seccomp_data, args[(_arg_nr)]) + ARG_HI_OFFSET), \
|
||||
BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, \
|
||||
(((uint32_t)((uint64_t)(_arg_val) >> 32)) & 0xFFFFFFFF), 0, 1), \
|
||||
BPF_STMT(BPF_RET+BPF_K, SECCOMP_RET_ALLOW), \
|
||||
/* reload syscall number; all rules expect it in accumulator */ \
|
||||
BPF_STMT(BPF_LD+BPF_W+BPF_ABS, \
|
||||
@ -104,108 +120,122 @@ static const struct sock_filter preauth_insns[] = {
|
||||
|
||||
/* Syscalls to non-fatally deny */
|
||||
#ifdef __NR_lstat
|
||||
SC_DENY(lstat, EACCES),
|
||||
SC_DENY(__NR_lstat, EACCES),
|
||||
#endif
|
||||
#ifdef __NR_lstat64
|
||||
SC_DENY(lstat64, EACCES),
|
||||
SC_DENY(__NR_lstat64, EACCES),
|
||||
#endif
|
||||
#ifdef __NR_fstat
|
||||
SC_DENY(fstat, EACCES),
|
||||
SC_DENY(__NR_fstat, EACCES),
|
||||
#endif
|
||||
#ifdef __NR_fstat64
|
||||
SC_DENY(fstat64, EACCES),
|
||||
SC_DENY(__NR_fstat64, EACCES),
|
||||
#endif
|
||||
#ifdef __NR_open
|
||||
SC_DENY(open, EACCES),
|
||||
SC_DENY(__NR_open, EACCES),
|
||||
#endif
|
||||
#ifdef __NR_openat
|
||||
SC_DENY(openat, EACCES),
|
||||
SC_DENY(__NR_openat, EACCES),
|
||||
#endif
|
||||
#ifdef __NR_newfstatat
|
||||
SC_DENY(newfstatat, EACCES),
|
||||
SC_DENY(__NR_newfstatat, EACCES),
|
||||
#endif
|
||||
#ifdef __NR_stat
|
||||
SC_DENY(stat, EACCES),
|
||||
SC_DENY(__NR_stat, EACCES),
|
||||
#endif
|
||||
#ifdef __NR_stat64
|
||||
SC_DENY(stat64, EACCES),
|
||||
SC_DENY(__NR_stat64, EACCES),
|
||||
#endif
|
||||
|
||||
/* Syscalls to permit */
|
||||
#ifdef __NR_brk
|
||||
SC_ALLOW(brk),
|
||||
SC_ALLOW(__NR_brk),
|
||||
#endif
|
||||
#ifdef __NR_clock_gettime
|
||||
SC_ALLOW(clock_gettime),
|
||||
SC_ALLOW(__NR_clock_gettime),
|
||||
#endif
|
||||
#ifdef __NR_close
|
||||
SC_ALLOW(close),
|
||||
SC_ALLOW(__NR_close),
|
||||
#endif
|
||||
#ifdef __NR_exit
|
||||
SC_ALLOW(exit),
|
||||
SC_ALLOW(__NR_exit),
|
||||
#endif
|
||||
#ifdef __NR_exit_group
|
||||
SC_ALLOW(exit_group),
|
||||
SC_ALLOW(__NR_exit_group),
|
||||
#endif
|
||||
#ifdef __NR_getpgid
|
||||
SC_ALLOW(getpgid),
|
||||
SC_ALLOW(__NR_getpgid),
|
||||
#endif
|
||||
#ifdef __NR_getpid
|
||||
SC_ALLOW(getpid),
|
||||
SC_ALLOW(__NR_getpid),
|
||||
#endif
|
||||
#ifdef __NR_getrandom
|
||||
SC_ALLOW(getrandom),
|
||||
SC_ALLOW(__NR_getrandom),
|
||||
#endif
|
||||
#ifdef __NR_gettimeofday
|
||||
SC_ALLOW(gettimeofday),
|
||||
SC_ALLOW(__NR_gettimeofday),
|
||||
#endif
|
||||
#ifdef __NR_madvise
|
||||
SC_ALLOW(madvise),
|
||||
SC_ALLOW(__NR_madvise),
|
||||
#endif
|
||||
#ifdef __NR_mmap
|
||||
SC_ALLOW(mmap),
|
||||
SC_ALLOW(__NR_mmap),
|
||||
#endif
|
||||
#ifdef __NR_mmap2
|
||||
SC_ALLOW(mmap2),
|
||||
SC_ALLOW(__NR_mmap2),
|
||||
#endif
|
||||
#ifdef __NR_mremap
|
||||
SC_ALLOW(mremap),
|
||||
SC_ALLOW(__NR_mremap),
|
||||
#endif
|
||||
#ifdef __NR_munmap
|
||||
SC_ALLOW(munmap),
|
||||
SC_ALLOW(__NR_munmap),
|
||||
#endif
|
||||
#ifdef __NR__newselect
|
||||
SC_ALLOW(_newselect),
|
||||
SC_ALLOW(__NR__newselect),
|
||||
#endif
|
||||
#ifdef __NR_poll
|
||||
SC_ALLOW(poll),
|
||||
SC_ALLOW(__NR_poll),
|
||||
#endif
|
||||
#ifdef __NR_pselect6
|
||||
SC_ALLOW(pselect6),
|
||||
SC_ALLOW(__NR_pselect6),
|
||||
#endif
|
||||
#ifdef __NR_read
|
||||
SC_ALLOW(read),
|
||||
SC_ALLOW(__NR_read),
|
||||
#endif
|
||||
#ifdef __NR_rt_sigprocmask
|
||||
SC_ALLOW(rt_sigprocmask),
|
||||
SC_ALLOW(__NR_rt_sigprocmask),
|
||||
#endif
|
||||
#ifdef __NR_select
|
||||
SC_ALLOW(select),
|
||||
SC_ALLOW(__NR_select),
|
||||
#endif
|
||||
#ifdef __NR_shutdown
|
||||
SC_ALLOW(shutdown),
|
||||
SC_ALLOW(__NR_shutdown),
|
||||
#endif
|
||||
#ifdef __NR_sigprocmask
|
||||
SC_ALLOW(sigprocmask),
|
||||
SC_ALLOW(__NR_sigprocmask),
|
||||
#endif
|
||||
#ifdef __NR_time
|
||||
SC_ALLOW(time),
|
||||
SC_ALLOW(__NR_time),
|
||||
#endif
|
||||
#ifdef __NR_write
|
||||
SC_ALLOW(write),
|
||||
SC_ALLOW(__NR_write),
|
||||
#endif
|
||||
#ifdef __NR_socketcall
|
||||
SC_ALLOW_ARG(socketcall, 0, SYS_SHUTDOWN),
|
||||
SC_ALLOW_ARG(__NR_socketcall, 0, SYS_SHUTDOWN),
|
||||
#endif
|
||||
#if defined(__NR_ioctl) && defined(__s390__)
|
||||
/* Allow ioctls for ICA crypto card on s390 */
|
||||
SC_ALLOW_ARG(__NR_ioctl, 1, Z90STAT_STATUS_MASK),
|
||||
SC_ALLOW_ARG(__NR_ioctl, 1, ICARSAMODEXPO),
|
||||
SC_ALLOW_ARG(__NR_ioctl, 1, ICARSACRT),
|
||||
#endif
|
||||
#if defined(__x86_64__) && defined(__ILP32__) && defined(__X32_SYSCALL_BIT)
|
||||
/*
|
||||
* On Linux x32, the clock_gettime VDSO falls back to the
|
||||
* x86-64 syscall under some circumstances, e.g.
|
||||
* https://bugs.debian.org/849923
|
||||
*/
|
||||
SC_ALLOW(__NR_clock_gettime & ~__X32_SYSCALL_BIT);
|
||||
#endif
|
||||
|
||||
/* Default deny */
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
/* $OpenBSD: servconf.c,v 1.301 2016/11/30 03:00:05 djm Exp $ */
|
||||
/* $OpenBSD: servconf.c,v 1.306 2017/03/14 07:19:07 djm Exp $ */
|
||||
/*
|
||||
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
|
||||
* All rights reserved
|
||||
@ -279,7 +279,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 = 0;
|
||||
if (options->kbd_interactive_authentication == -1)
|
||||
@ -547,7 +547,7 @@ static struct {
|
||||
{ "clientalivecountmax", sClientAliveCountMax, SSHCFG_ALL },
|
||||
{ "authorizedkeysfile", sAuthorizedKeysFile, SSHCFG_ALL },
|
||||
{ "authorizedkeysfile2", sDeprecated, SSHCFG_ALL },
|
||||
{ "useprivilegeseparation", sUsePrivilegeSeparation, SSHCFG_GLOBAL},
|
||||
{ "useprivilegeseparation", sDeprecated, SSHCFG_GLOBAL},
|
||||
{ "acceptenv", sAcceptEnv, SSHCFG_ALL },
|
||||
{ "permittunnel", sPermitTunnel, SSHCFG_ALL },
|
||||
{ "permittty", sPermitTTY, SSHCFG_ALL },
|
||||
@ -983,6 +983,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;
|
||||
@ -1185,7 +1194,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)
|
||||
@ -1381,11 +1391,6 @@ process_server_config_line(ServerOptions *options, char *line,
|
||||
intptr = &options->disable_forwarding;
|
||||
goto parse_flag;
|
||||
|
||||
case sUsePrivilegeSeparation:
|
||||
intptr = &use_privsep;
|
||||
multistate_ptr = multistate_privsep;
|
||||
goto parse_multistate;
|
||||
|
||||
case sAllowUsers:
|
||||
while ((arg = strdelim(&cp)) && *arg != '\0') {
|
||||
if (options->num_allow_users >= MAX_ALLOW_USERS)
|
||||
@ -1444,7 +1449,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)
|
||||
@ -1455,7 +1460,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)
|
||||
@ -1467,7 +1472,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)
|
||||
@ -2117,8 +2123,6 @@ fmt_intarg(ServerOpCodes code, int val)
|
||||
return fmt_multistate_int(val, multistate_gatewayports);
|
||||
case sCompression:
|
||||
return fmt_multistate_int(val, multistate_compression);
|
||||
case sUsePrivilegeSeparation:
|
||||
return fmt_multistate_int(val, multistate_privsep);
|
||||
case sAllowTcpForwarding:
|
||||
return fmt_multistate_int(val, multistate_tcpfwd);
|
||||
case sAllowStreamLocalForwarding:
|
||||
@ -2169,8 +2173,6 @@ dump_cfg_fmtint(ServerOpCodes code, int val)
|
||||
static void
|
||||
dump_cfg_string(ServerOpCodes code, const char *val)
|
||||
{
|
||||
if (val == NULL)
|
||||
return;
|
||||
printf("%s %s\n", lookup_opcode_name(code),
|
||||
val == NULL ? "none" : val);
|
||||
}
|
||||
@ -2296,7 +2298,6 @@ dump_config(ServerOptions *o)
|
||||
dump_cfg_fmtint(sDisableForwarding, o->disable_forwarding);
|
||||
dump_cfg_fmtint(sAllowStreamLocalForwarding, o->allow_streamlocal_forwarding);
|
||||
dump_cfg_fmtint(sStreamLocalBindUnlink, o->fwd_opts.streamlocal_bind_unlink);
|
||||
dump_cfg_fmtint(sUsePrivilegeSeparation, use_privsep);
|
||||
dump_cfg_fmtint(sFingerprintHash, o->fingerprint_hash);
|
||||
dump_cfg_fmtint(sUseBlacklist, o->use_blacklist);
|
||||
|
||||
|
@ -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(
|
||||
|
@ -1261,7 +1261,8 @@ static void
|
||||
do_nologin(struct passwd *pw)
|
||||
{
|
||||
FILE *f = NULL;
|
||||
char buf[1024], *nl, *def_nl = _PATH_NOLOGIN;
|
||||
const char *nl;
|
||||
char buf[1024], *def_nl = _PATH_NOLOGIN;
|
||||
struct stat sb;
|
||||
|
||||
#ifdef HAVE_LOGIN_CAP
|
||||
@ -1273,11 +1274,8 @@ do_nologin(struct passwd *pw)
|
||||
return;
|
||||
nl = def_nl;
|
||||
#endif
|
||||
if (stat(nl, &sb) == -1) {
|
||||
if (nl != def_nl)
|
||||
free(nl);
|
||||
if (stat(nl, &sb) == -1)
|
||||
return;
|
||||
}
|
||||
|
||||
/* /etc/nologin exists. Print its contents if we can and exit. */
|
||||
logit("User %.100s not allowed because %s exists", pw->pw_name, nl);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: sftp-client.c,v 1.125 2016/09/12 01:22:38 deraadt Exp $ */
|
||||
/* $OpenBSD: sftp-client.c,v 1.126 2017/01/03 05:46:51 djm Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org>
|
||||
*
|
||||
@ -67,6 +67,13 @@ extern int showprogress;
|
||||
/* Maximum depth to descend in directory trees */
|
||||
#define MAX_DIR_DEPTH 64
|
||||
|
||||
/* Directory separator characters */
|
||||
#ifdef HAVE_CYGWIN
|
||||
# define SFTP_DIRECTORY_CHARS "/\\"
|
||||
#else /* HAVE_CYGWIN */
|
||||
# define SFTP_DIRECTORY_CHARS "/"
|
||||
#endif /* HAVE_CYGWIN */
|
||||
|
||||
struct sftp_conn {
|
||||
int fd_in;
|
||||
int fd_out;
|
||||
@ -587,6 +594,8 @@ do_lsreaddir(struct sftp_conn *conn, const char *path, int print_flag,
|
||||
|
||||
if ((r = sshbuf_get_u32(msg, &count)) != 0)
|
||||
fatal("%s: buffer error: %s", __func__, ssh_err(r));
|
||||
if (count > SSHBUF_SIZE_MAX)
|
||||
fatal("%s: nonsensical number of entries", __func__);
|
||||
if (count == 0)
|
||||
break;
|
||||
debug3("Received %d SSH2_FXP_NAME responses", count);
|
||||
@ -617,7 +626,7 @@ do_lsreaddir(struct sftp_conn *conn, const char *path, int print_flag,
|
||||
* These can be used to attack recursive ops
|
||||
* (e.g. send '../../../../etc/passwd')
|
||||
*/
|
||||
if (strchr(filename, '/') != NULL) {
|
||||
if (strpbrk(filename, SFTP_DIRECTORY_CHARS) != NULL) {
|
||||
error("Server sent suspect path \"%s\" "
|
||||
"during readdir of \"%s\"", filename, path);
|
||||
} else if (dir) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: sftp.c,v 1.177 2016/10/18 12:41:22 millert Exp $ */
|
||||
/* $OpenBSD: sftp.c,v 1.178 2017/02/15 01:46:47 djm Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org>
|
||||
*
|
||||
@ -969,23 +969,34 @@ static int
|
||||
do_df(struct sftp_conn *conn, const char *path, int hflag, int iflag)
|
||||
{
|
||||
struct sftp_statvfs st;
|
||||
char s_used[FMT_SCALED_STRSIZE];
|
||||
char s_avail[FMT_SCALED_STRSIZE];
|
||||
char s_root[FMT_SCALED_STRSIZE];
|
||||
char s_total[FMT_SCALED_STRSIZE];
|
||||
unsigned long long ffree;
|
||||
char s_used[FMT_SCALED_STRSIZE], s_avail[FMT_SCALED_STRSIZE];
|
||||
char s_root[FMT_SCALED_STRSIZE], s_total[FMT_SCALED_STRSIZE];
|
||||
char s_icapacity[16], s_dcapacity[16];
|
||||
|
||||
if (do_statvfs(conn, path, &st, 1) == -1)
|
||||
return -1;
|
||||
if (st.f_files == 0)
|
||||
strlcpy(s_icapacity, "ERR", sizeof(s_icapacity));
|
||||
else {
|
||||
snprintf(s_icapacity, sizeof(s_icapacity), "%3llu%%",
|
||||
(unsigned long long)(100 * (st.f_files - st.f_ffree) /
|
||||
st.f_files));
|
||||
}
|
||||
if (st.f_blocks == 0)
|
||||
strlcpy(s_dcapacity, "ERR", sizeof(s_dcapacity));
|
||||
else {
|
||||
snprintf(s_dcapacity, sizeof(s_dcapacity), "%3llu%%",
|
||||
(unsigned long long)(100 * (st.f_blocks - st.f_bfree) /
|
||||
st.f_blocks));
|
||||
}
|
||||
if (iflag) {
|
||||
ffree = st.f_files ? (100 * (st.f_files - st.f_ffree) / st.f_files) : 0;
|
||||
printf(" Inodes Used Avail "
|
||||
"(root) %%Capacity\n");
|
||||
printf("%11llu %11llu %11llu %11llu %3llu%%\n",
|
||||
printf("%11llu %11llu %11llu %11llu %s\n",
|
||||
(unsigned long long)st.f_files,
|
||||
(unsigned long long)(st.f_files - st.f_ffree),
|
||||
(unsigned long long)st.f_favail,
|
||||
(unsigned long long)st.f_ffree, ffree);
|
||||
(unsigned long long)st.f_ffree, s_icapacity);
|
||||
} else if (hflag) {
|
||||
strlcpy(s_used, "error", sizeof(s_used));
|
||||
strlcpy(s_avail, "error", sizeof(s_avail));
|
||||
@ -996,21 +1007,18 @@ do_df(struct sftp_conn *conn, const char *path, int hflag, int iflag)
|
||||
fmt_scaled(st.f_bfree * st.f_frsize, s_root);
|
||||
fmt_scaled(st.f_blocks * st.f_frsize, s_total);
|
||||
printf(" Size Used Avail (root) %%Capacity\n");
|
||||
printf("%7sB %7sB %7sB %7sB %3llu%%\n",
|
||||
s_total, s_used, s_avail, s_root,
|
||||
(unsigned long long)(100 * (st.f_blocks - st.f_bfree) /
|
||||
st.f_blocks));
|
||||
printf("%7sB %7sB %7sB %7sB %s\n",
|
||||
s_total, s_used, s_avail, s_root, s_dcapacity);
|
||||
} else {
|
||||
printf(" Size Used Avail "
|
||||
"(root) %%Capacity\n");
|
||||
printf("%12llu %12llu %12llu %12llu %3llu%%\n",
|
||||
printf("%12llu %12llu %12llu %12llu %s\n",
|
||||
(unsigned long long)(st.f_frsize * st.f_blocks / 1024),
|
||||
(unsigned long long)(st.f_frsize *
|
||||
(st.f_blocks - st.f_bfree) / 1024),
|
||||
(unsigned long long)(st.f_frsize * st.f_bavail / 1024),
|
||||
(unsigned long long)(st.f_frsize * st.f_bfree / 1024),
|
||||
(unsigned long long)(100 * (st.f_blocks - st.f_bfree) /
|
||||
st.f_blocks));
|
||||
s_dcapacity);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: ssh-agent.c,v 1.215 2016/11/30 03:07:37 djm Exp $ */
|
||||
/* $OpenBSD: ssh-agent.c,v 1.218 2017/03/15 03:52:30 deraadt Exp $ */
|
||||
/*
|
||||
* Author: Tatu Ylonen <ylo@cs.hut.fi>
|
||||
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
|
||||
@ -90,7 +90,7 @@ __RCSID("$FreeBSD$");
|
||||
#endif
|
||||
|
||||
#ifndef DEFAULT_PKCS11_WHITELIST
|
||||
# define DEFAULT_PKCS11_WHITELIST "/usr/lib/*,/usr/local/lib/*"
|
||||
# define DEFAULT_PKCS11_WHITELIST "/usr/lib*/*,/usr/local/lib*/*"
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
@ -841,7 +841,7 @@ process_add_smartcard_key(SocketEntry *e)
|
||||
static void
|
||||
process_remove_smartcard_key(SocketEntry *e)
|
||||
{
|
||||
char *provider = NULL, *pin = NULL;
|
||||
char *provider = NULL, *pin = NULL, canonical_provider[PATH_MAX];
|
||||
int r, version, success = 0;
|
||||
Identity *id, *nxt;
|
||||
Idtab *tab;
|
||||
@ -851,6 +851,13 @@ process_remove_smartcard_key(SocketEntry *e)
|
||||
fatal("%s: buffer error: %s", __func__, ssh_err(r));
|
||||
free(pin);
|
||||
|
||||
if (realpath(provider, canonical_provider) == NULL) {
|
||||
verbose("failed PKCS#11 add of \"%.100s\": realpath: %s",
|
||||
provider, strerror(errno));
|
||||
goto send;
|
||||
}
|
||||
|
||||
debug("%s: remove %.100s", __func__, canonical_provider);
|
||||
for (version = 1; version < 3; version++) {
|
||||
tab = idtab_lookup(version);
|
||||
for (id = TAILQ_FIRST(&tab->idlist); id; id = nxt) {
|
||||
@ -858,18 +865,19 @@ process_remove_smartcard_key(SocketEntry *e)
|
||||
/* Skip file--based keys */
|
||||
if (id->provider == NULL)
|
||||
continue;
|
||||
if (!strcmp(provider, id->provider)) {
|
||||
if (!strcmp(canonical_provider, id->provider)) {
|
||||
TAILQ_REMOVE(&tab->idlist, id, next);
|
||||
free_identity(id);
|
||||
tab->nentries--;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pkcs11_del_provider(provider) == 0)
|
||||
if (pkcs11_del_provider(canonical_provider) == 0)
|
||||
success = 1;
|
||||
else
|
||||
error("process_remove_smartcard_key:"
|
||||
" pkcs11_del_provider failed");
|
||||
send:
|
||||
free(provider);
|
||||
send_status(e, success);
|
||||
}
|
||||
@ -1214,10 +1222,9 @@ static void
|
||||
usage(void)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"usage: ssh-agent [-c | -s] [-Dd] [-a bind_address] [-E fingerprint_hash]\n"
|
||||
"usage: ssh-agent [-c | -s] [-Ddx] [-a bind_address] [-E fingerprint_hash]\n"
|
||||
" [-P pkcs11_whitelist] [-t life] [command [arg ...]]\n"
|
||||
" ssh-agent [-c | -s] -k\n");
|
||||
fprintf(stderr, " -x Exit when the last client disconnects.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: ssh-keygen.c,v 1.292 2016/09/12 03:29:16 dtucker Exp $ */
|
||||
/* $OpenBSD: ssh-keygen.c,v 1.299 2017/03/10 04:26:06 djm Exp $ */
|
||||
/*
|
||||
* Author: Tatu Ylonen <ylo@cs.hut.fi>
|
||||
* Copyright (c) 1994 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
|
||||
@ -37,6 +37,7 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <limits.h>
|
||||
#include <locale.h>
|
||||
|
||||
#include "xmalloc.h"
|
||||
#include "sshkey.h"
|
||||
@ -57,6 +58,7 @@
|
||||
#include "atomicio.h"
|
||||
#include "krl.h"
|
||||
#include "digest.h"
|
||||
#include "utf8.h"
|
||||
|
||||
#ifdef WITH_OPENSSL
|
||||
# define DEFAULT_KEY_TYPE_NAME "rsa"
|
||||
@ -843,7 +845,7 @@ fingerprint_one_key(const struct sshkey *public, const char *comment)
|
||||
ra = sshkey_fingerprint(public, fingerprint_hash, SSH_FP_RANDOMART);
|
||||
if (fp == NULL || ra == NULL)
|
||||
fatal("%s: sshkey_fingerprint failed", __func__);
|
||||
printf("%u %s %s (%s)\n", sshkey_size(public), fp,
|
||||
mprintf("%u %s %s (%s)\n", sshkey_size(public), fp,
|
||||
comment ? comment : "no comment", sshkey_type(public));
|
||||
if (log_level >= SYSLOG_LEVEL_VERBOSE)
|
||||
printf("%s\n", ra);
|
||||
@ -1082,6 +1084,7 @@ known_hosts_hash(struct hostkey_foreach_line *l, void *_ctx)
|
||||
struct known_hosts_ctx *ctx = (struct known_hosts_ctx *)_ctx;
|
||||
char *hashed, *cp, *hosts, *ohosts;
|
||||
int has_wild = l->hosts && strcspn(l->hosts, "*?!") != strlen(l->hosts);
|
||||
int was_hashed = l->hosts && l->hosts[0] == HASH_DELIM;
|
||||
|
||||
switch (l->status) {
|
||||
case HKF_STATUS_OK:
|
||||
@ -1090,11 +1093,10 @@ known_hosts_hash(struct hostkey_foreach_line *l, void *_ctx)
|
||||
* Don't hash hosts already already hashed, with wildcard
|
||||
* characters or a CA/revocation marker.
|
||||
*/
|
||||
if ((l->match & HKF_MATCH_HOST_HASHED) != 0 ||
|
||||
has_wild || l->marker != MRK_NONE) {
|
||||
if (was_hashed || has_wild || l->marker != MRK_NONE) {
|
||||
fprintf(ctx->out, "%s\n", l->line);
|
||||
if (has_wild && !find_host) {
|
||||
logit("%s:%ld: ignoring host name "
|
||||
logit("%s:%lu: ignoring host name "
|
||||
"with wildcard: %.64s", l->path,
|
||||
l->linenum, l->hosts);
|
||||
}
|
||||
@ -1106,6 +1108,7 @@ known_hosts_hash(struct hostkey_foreach_line *l, void *_ctx)
|
||||
*/
|
||||
ohosts = hosts = xstrdup(l->hosts);
|
||||
while ((cp = strsep(&hosts, ",")) != NULL && *cp != '\0') {
|
||||
lowercase(cp);
|
||||
if ((hashed = host_hash(cp, NULL, 0)) == NULL)
|
||||
fatal("hash_host failed");
|
||||
fprintf(ctx->out, "%s %s\n", hashed, l->rawkey);
|
||||
@ -1116,7 +1119,7 @@ known_hosts_hash(struct hostkey_foreach_line *l, void *_ctx)
|
||||
case HKF_STATUS_INVALID:
|
||||
/* Retain invalid lines, but mark file as invalid. */
|
||||
ctx->invalid = 1;
|
||||
logit("%s:%ld: invalid line", l->path, l->linenum);
|
||||
logit("%s:%lu: invalid line", l->path, l->linenum);
|
||||
/* FALLTHROUGH */
|
||||
default:
|
||||
fprintf(ctx->out, "%s\n", l->line);
|
||||
@ -1150,14 +1153,14 @@ known_hosts_find_delete(struct hostkey_foreach_line *l, void *_ctx)
|
||||
*/
|
||||
ctx->found_key = 1;
|
||||
if (!quiet)
|
||||
printf("# Host %s found: line %ld\n",
|
||||
printf("# Host %s found: line %lu\n",
|
||||
ctx->host, l->linenum);
|
||||
}
|
||||
return 0;
|
||||
} else if (find_host) {
|
||||
ctx->found_key = 1;
|
||||
if (!quiet) {
|
||||
printf("# Host %s found: line %ld %s\n",
|
||||
printf("# Host %s found: line %lu %s\n",
|
||||
ctx->host,
|
||||
l->linenum, l->marker == MRK_CA ? "CA" :
|
||||
(l->marker == MRK_REVOKE ? "REVOKED" : ""));
|
||||
@ -1166,7 +1169,7 @@ known_hosts_find_delete(struct hostkey_foreach_line *l, void *_ctx)
|
||||
known_hosts_hash(l, ctx);
|
||||
else if (print_fingerprint) {
|
||||
fp = sshkey_fingerprint(l->key, fptype, rep);
|
||||
printf("%s %s %s %s\n", ctx->host,
|
||||
mprintf("%s %s %s %s\n", ctx->host,
|
||||
sshkey_type(l->key), fp, l->comment);
|
||||
free(fp);
|
||||
} else
|
||||
@ -1177,7 +1180,7 @@ known_hosts_find_delete(struct hostkey_foreach_line *l, void *_ctx)
|
||||
/* Retain non-matching hosts when deleting */
|
||||
if (l->status == HKF_STATUS_INVALID) {
|
||||
ctx->invalid = 1;
|
||||
logit("%s:%ld: invalid line", l->path, l->linenum);
|
||||
logit("%s:%lu: invalid line", l->path, l->linenum);
|
||||
}
|
||||
fprintf(ctx->out, "%s\n", l->line);
|
||||
}
|
||||
@ -1317,7 +1320,7 @@ do_change_passphrase(struct passwd *pw)
|
||||
fatal("Failed to load key %s: %s", identity_file, ssh_err(r));
|
||||
}
|
||||
if (comment)
|
||||
printf("Key has comment '%s'\n", comment);
|
||||
mprintf("Key has comment '%s'\n", comment);
|
||||
|
||||
/* Ask the new passphrase (twice). */
|
||||
if (identity_new_passphrase) {
|
||||
@ -1441,7 +1444,10 @@ do_change_comment(struct passwd *pw)
|
||||
sshkey_free(private);
|
||||
exit(1);
|
||||
}
|
||||
printf("Key now has comment '%s'\n", comment);
|
||||
if (comment)
|
||||
printf("Key now has comment '%s'\n", comment);
|
||||
else
|
||||
printf("Key now has no comment\n");
|
||||
|
||||
if (identity_comment) {
|
||||
strlcpy(new_comment, identity_comment, sizeof(new_comment));
|
||||
@ -2203,11 +2209,17 @@ do_check_krl(struct passwd *pw, int argc, char **argv)
|
||||
exit(ret);
|
||||
}
|
||||
|
||||
#ifdef WITH_SSH1
|
||||
# define RSA1_USAGE " | rsa1"
|
||||
#else
|
||||
# define RSA1_USAGE ""
|
||||
#endif
|
||||
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"usage: ssh-keygen [-q] [-b bits] [-t dsa | ecdsa | ed25519 | rsa | rsa1]\n"
|
||||
"usage: ssh-keygen [-q] [-b bits] [-t dsa | ecdsa | ed25519 | rsa%s]\n"
|
||||
" [-N new_passphrase] [-C comment] [-f output_keyfile]\n"
|
||||
" ssh-keygen -p [-P old_passphrase] [-N new_passphrase] [-f keyfile]\n"
|
||||
" ssh-keygen -i [-m key_format] [-f input_keyfile]\n"
|
||||
@ -2215,7 +2227,7 @@ usage(void)
|
||||
" ssh-keygen -y [-f input_keyfile]\n"
|
||||
" ssh-keygen -c [-P passphrase] [-C comment] [-f keyfile]\n"
|
||||
" ssh-keygen -l [-v] [-E fingerprint_hash] [-f input_keyfile]\n"
|
||||
" ssh-keygen -B [-f input_keyfile]\n");
|
||||
" ssh-keygen -B [-f input_keyfile]\n", RSA1_USAGE);
|
||||
#ifdef ENABLE_PKCS11
|
||||
fprintf(stderr,
|
||||
" ssh-keygen -D pkcs11\n");
|
||||
@ -2280,6 +2292,8 @@ main(int argc, char **argv)
|
||||
|
||||
seed_rng();
|
||||
|
||||
msetlocale();
|
||||
|
||||
/* we need this for the home * directory. */
|
||||
pw = getpwuid(getuid());
|
||||
if (!pw)
|
||||
|
@ -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.109 2017/03/10 04:26:06 djm Exp $ */
|
||||
/*
|
||||
* Copyright 1995, 1996 by David Mazieres <dm@lcs.mit.edu>.
|
||||
*
|
||||
@ -321,16 +321,18 @@ keygrab_ssh2(con *c)
|
||||
}
|
||||
|
||||
static void
|
||||
keyprint_one(char *host, struct sshkey *key)
|
||||
keyprint_one(const char *host, struct sshkey *key)
|
||||
{
|
||||
char *hostport;
|
||||
|
||||
if (hash_hosts && (host = host_hash(host, NULL, 0)) == NULL)
|
||||
fatal("host_hash failed");
|
||||
const char *known_host, *hashed;
|
||||
|
||||
hostport = put_host_port(host, ssh_port);
|
||||
lowercase(hostport);
|
||||
if (hash_hosts && (hashed = host_hash(host, NULL, 0)) == NULL)
|
||||
fatal("host_hash failed");
|
||||
known_host = hash_hosts ? hashed : hostport;
|
||||
if (!get_cert)
|
||||
fprintf(stdout, "%s ", hostport);
|
||||
fprintf(stdout, "%s ", known_host);
|
||||
sshkey_write(key, stdout);
|
||||
fputs("\n", stdout);
|
||||
free(hostport);
|
||||
@ -752,10 +754,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 +774,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, ",");
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: ssh.c,v 1.448 2016/12/06 07:48:01 djm Exp $ */
|
||||
/* $OpenBSD: ssh.c,v 1.451 2017/03/10 04:07:20 djm Exp $ */
|
||||
/*
|
||||
* Author: Tatu Ylonen <ylo@cs.hut.fi>
|
||||
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
|
||||
@ -685,11 +685,11 @@ main(int ac, char **av)
|
||||
else if (strcmp(optarg, "kex") == 0)
|
||||
cp = kex_alg_list('\n');
|
||||
else if (strcmp(optarg, "key") == 0)
|
||||
cp = sshkey_alg_list(0, 0, '\n');
|
||||
cp = sshkey_alg_list(0, 0, 0, '\n');
|
||||
else if (strcmp(optarg, "key-cert") == 0)
|
||||
cp = sshkey_alg_list(1, 0, '\n');
|
||||
cp = sshkey_alg_list(1, 0, 0, '\n');
|
||||
else if (strcmp(optarg, "key-plain") == 0)
|
||||
cp = sshkey_alg_list(0, 1, '\n');
|
||||
cp = sshkey_alg_list(0, 1, 0, '\n');
|
||||
else if (strcmp(optarg, "protocol-version") == 0) {
|
||||
#ifdef WITH_SSH1
|
||||
cp = xstrdup("1\n2");
|
||||
@ -1099,7 +1099,7 @@ main(int ac, char **av)
|
||||
options.proxy_use_fdpass = 0;
|
||||
snprintf(port_s, sizeof(port_s), "%d", options.jump_port);
|
||||
xasprintf(&options.proxy_command,
|
||||
"ssh%s%s%s%s%s%s%s%s%s%.*s -W %%h:%%p %s",
|
||||
"ssh%s%s%s%s%s%s%s%s%s%.*s -W '[%%h]:%%p' %s",
|
||||
/* Optional "-l user" argument if jump_user set */
|
||||
options.jump_user == NULL ? "" : " -l ",
|
||||
options.jump_user == NULL ? "" : options.jump_user,
|
||||
|
@ -50,4 +50,4 @@
|
||||
# ProxyCommand ssh -q -W %h:%p gateway.example.com
|
||||
# RekeyLimit 1G 1h
|
||||
# VerifyHostKeyDNS yes
|
||||
# VersionAddendum FreeBSD-20170305
|
||||
# VersionAddendum FreeBSD-20170804
|
||||
|
@ -33,9 +33,9 @@
|
||||
.\" (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 $
|
||||
.\" $OpenBSD: ssh_config.5,v 1.242 2017/02/27 14:30:33 jmc Exp $
|
||||
.\" $FreeBSD$
|
||||
.Dd $Mdocdate: October 15 2016 $
|
||||
.Dd $Mdocdate: February 27 2017 $
|
||||
.Dt SSH_CONFIG 5
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -417,6 +417,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
|
||||
@ -786,6 +790,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,
|
||||
@ -809,6 +817,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,
|
||||
@ -1029,6 +1041,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,
|
||||
@ -1104,6 +1120,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
|
||||
@ -1129,7 +1149,7 @@ However, this option disables host authentication for localhost.
|
||||
The argument to this keyword must be
|
||||
.Cm yes
|
||||
or
|
||||
.Cm no .
|
||||
.Cm no
|
||||
(the default).
|
||||
.It Cm NumberOfPasswordPrompts
|
||||
Specifies the number of password prompts before giving up.
|
||||
@ -1266,6 +1286,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,
|
||||
@ -1650,7 +1674,7 @@ in
|
||||
Specifies a string to append to the regular version string to identify
|
||||
OS- or site-specific modifications.
|
||||
The default is
|
||||
.Dq FreeBSD-20170305 .
|
||||
.Dq FreeBSD-20170804 .
|
||||
The value
|
||||
.Cm none
|
||||
may be used to disable this.
|
||||
|
@ -40,7 +40,6 @@
|
||||
#define addr_match_cidr_list Fssh_addr_match_cidr_list
|
||||
#define addr_match_list Fssh_addr_match_list
|
||||
#define addr_netmatch Fssh_addr_netmatch
|
||||
#define addr_pton Fssh_addr_pton
|
||||
#define addr_pton_cidr Fssh_addr_pton_cidr
|
||||
#define ask_permission Fssh_ask_permission
|
||||
#define atomicio Fssh_atomicio
|
||||
@ -51,9 +50,10 @@
|
||||
#define bandwidth_limit Fssh_bandwidth_limit
|
||||
#define bandwidth_limit_init Fssh_bandwidth_limit_init
|
||||
#define barrett_reduce Fssh_barrett_reduce
|
||||
#define baud_to_speed Fssh_baud_to_speed
|
||||
#define bcrypt_hash Fssh_bcrypt_hash
|
||||
#define bcrypt_pbkdf Fssh_bcrypt_pbkdf
|
||||
#define bf_ssh1_cipher Fssh_bf_ssh1_cipher
|
||||
#define bind_permitted Fssh_bind_permitted
|
||||
#define bitmap_clear_bit Fssh_bitmap_clear_bit
|
||||
#define bitmap_free Fssh_bitmap_free
|
||||
#define bitmap_from_string Fssh_bitmap_from_string
|
||||
@ -110,7 +110,6 @@
|
||||
#define buffer_put_short Fssh_buffer_put_short
|
||||
#define buffer_put_string Fssh_buffer_put_string
|
||||
#define cert_free Fssh_cert_free
|
||||
#define cert_new Fssh_cert_new
|
||||
#define chacha_encrypt_bytes Fssh_chacha_encrypt_bytes
|
||||
#define chacha_ivsetup Fssh_chacha_ivsetup
|
||||
#define chacha_keysetup Fssh_chacha_keysetup
|
||||
@ -126,7 +125,6 @@
|
||||
#define chan_rcvd_oclose Fssh_chan_rcvd_oclose
|
||||
#define chan_read_failed Fssh_chan_read_failed
|
||||
#define chan_send_eof2 Fssh_chan_send_eof2
|
||||
#define chan_send_ieof1 Fssh_chan_send_ieof1
|
||||
#define chan_send_oclose1 Fssh_chan_send_oclose1
|
||||
#define chan_shutdown_read Fssh_chan_shutdown_read
|
||||
#define chan_shutdown_write Fssh_chan_shutdown_write
|
||||
@ -135,6 +133,7 @@
|
||||
#define channel_add_permitted_opens Fssh_channel_add_permitted_opens
|
||||
#define channel_after_select Fssh_channel_after_select
|
||||
#define channel_by_id Fssh_channel_by_id
|
||||
#define channel_by_remote_id Fssh_channel_by_remote_id
|
||||
#define channel_cancel_cleanup Fssh_channel_cancel_cleanup
|
||||
#define channel_cancel_lport_listener Fssh_channel_cancel_lport_listener
|
||||
#define channel_cancel_rport_listener Fssh_channel_cancel_rport_listener
|
||||
@ -162,7 +161,6 @@
|
||||
#define channel_input_oclose Fssh_channel_input_oclose
|
||||
#define channel_input_open_confirmation Fssh_channel_input_open_confirmation
|
||||
#define channel_input_open_failure Fssh_channel_input_open_failure
|
||||
#define channel_input_port_forward_request Fssh_channel_input_port_forward_request
|
||||
#define channel_input_port_open Fssh_channel_input_port_open
|
||||
#define channel_input_status_confirm Fssh_channel_input_status_confirm
|
||||
#define channel_input_window_adjust Fssh_channel_input_window_adjust
|
||||
@ -192,6 +190,8 @@
|
||||
#define channel_pre_x11_open_13 Fssh_channel_pre_x11_open_13
|
||||
#define channel_prepare_select Fssh_channel_prepare_select
|
||||
#define channel_print_adm_permitted_opens Fssh_channel_print_adm_permitted_opens
|
||||
#define channel_proxy_downstream Fssh_channel_proxy_downstream
|
||||
#define channel_proxy_upstream Fssh_channel_proxy_upstream
|
||||
#define channel_register_cleanup Fssh_channel_register_cleanup
|
||||
#define channel_register_fds Fssh_channel_register_fds
|
||||
#define channel_register_filter Fssh_channel_register_filter
|
||||
@ -223,8 +223,10 @@
|
||||
#define cipher_blocksize Fssh_cipher_blocksize
|
||||
#define cipher_by_name Fssh_cipher_by_name
|
||||
#define cipher_by_number Fssh_cipher_by_number
|
||||
#define cipher_cleanup Fssh_cipher_cleanup
|
||||
#define cipher_crypt Fssh_cipher_crypt
|
||||
#define cipher_ctx_get_number Fssh_cipher_ctx_get_number
|
||||
#define cipher_ctx_is_plaintext Fssh_cipher_ctx_is_plaintext
|
||||
#define cipher_free Fssh_cipher_free
|
||||
#define cipher_get_keycontext Fssh_cipher_get_keycontext
|
||||
#define cipher_get_keyiv Fssh_cipher_get_keyiv
|
||||
#define cipher_get_keyiv_len Fssh_cipher_get_keyiv_len
|
||||
@ -254,7 +256,7 @@
|
||||
#define compat_pkalg_proposal Fssh_compat_pkalg_proposal
|
||||
#define compress_buffer Fssh_compress_buffer
|
||||
#define connect_next Fssh_connect_next
|
||||
#define connect_to Fssh_connect_to
|
||||
#define connect_to_reason Fssh_connect_to_reason
|
||||
#define convtime Fssh_convtime
|
||||
#define crypto_hash_sha512 Fssh_crypto_hash_sha512
|
||||
#define crypto_hashblocks_sha512 Fssh_crypto_hashblocks_sha512
|
||||
@ -299,6 +301,7 @@
|
||||
#define crypto_sign_ed25519_ref_shortsc25519_from16bytes Fssh_crypto_sign_ed25519_ref_shortsc25519_from16bytes
|
||||
#define crypto_sign_ed25519_ref_unpackneg_vartime Fssh_crypto_sign_ed25519_ref_unpackneg_vartime
|
||||
#define crypto_verify_32 Fssh_crypto_verify_32
|
||||
#define daemonized Fssh_daemonized
|
||||
#define dbl_p1p1 Fssh_dbl_p1p1
|
||||
#define deattack_init Fssh_deattack_init
|
||||
#define debug Fssh_debug
|
||||
@ -325,11 +328,8 @@
|
||||
#define enable_compat13 Fssh_enable_compat13
|
||||
#define enable_compat20 Fssh_enable_compat20
|
||||
#define error Fssh_error
|
||||
#define evp_ssh1_3des Fssh_evp_ssh1_3des
|
||||
#define evp_ssh1_bf Fssh_evp_ssh1_bf
|
||||
#define export_dns_rr Fssh_export_dns_rr
|
||||
#define fatal Fssh_fatal
|
||||
#define filter_proposal Fssh_filter_proposal
|
||||
#define fingerprint_b64 Fssh_fingerprint_b64
|
||||
#define fingerprint_hex Fssh_fingerprint_hex
|
||||
#define fmprintf Fssh_fmprintf
|
||||
@ -412,7 +412,6 @@
|
||||
#define kexgex_hash Fssh_kexgex_hash
|
||||
#define kexgex_server Fssh_kexgex_server
|
||||
#define key_add_private Fssh_key_add_private
|
||||
#define key_alg_list Fssh_key_alg_list
|
||||
#define key_cert_check_authority Fssh_key_cert_check_authority
|
||||
#define key_cert_copy Fssh_key_cert_copy
|
||||
#define key_certify Fssh_key_certify
|
||||
@ -461,10 +460,10 @@
|
||||
#define mac_setup Fssh_mac_setup
|
||||
#define mac_valid Fssh_mac_valid
|
||||
#define match Fssh_match
|
||||
#define match_filter_list Fssh_match_filter_list
|
||||
#define match_host_and_ip Fssh_match_host_and_ip
|
||||
#define match_hostname Fssh_match_hostname
|
||||
#define match_list Fssh_match_list
|
||||
#define match_maybe_hashed Fssh_match_maybe_hashed
|
||||
#define match_pattern Fssh_match_pattern
|
||||
#define match_pattern_list Fssh_match_pattern_list
|
||||
#define match_user Fssh_match_user
|
||||
@ -478,7 +477,7 @@
|
||||
#define mprintf Fssh_mprintf
|
||||
#define ms_subtract_diff Fssh_ms_subtract_diff
|
||||
#define ms_to_timeval Fssh_ms_to_timeval
|
||||
#define mult Fssh_mult
|
||||
#define msetlocale Fssh_msetlocale
|
||||
#define mysignal Fssh_mysignal
|
||||
#define newkeys_from_blob Fssh_newkeys_from_blob
|
||||
#define newkeys_to_blob Fssh_newkeys_to_blob
|
||||
@ -509,7 +508,6 @@
|
||||
#define pkcs11_find Fssh_pkcs11_find
|
||||
#define pkcs11_init Fssh_pkcs11_init
|
||||
#define pkcs11_provider_finalize Fssh_pkcs11_provider_finalize
|
||||
#define pkcs11_provider_unref Fssh_pkcs11_provider_unref
|
||||
#define pkcs11_rsa_finish Fssh_pkcs11_rsa_finish
|
||||
#define pkcs11_rsa_private_decrypt Fssh_pkcs11_rsa_private_decrypt
|
||||
#define pkcs11_rsa_private_encrypt Fssh_pkcs11_rsa_private_encrypt
|
||||
@ -526,7 +524,6 @@
|
||||
#define port_open_helper Fssh_port_open_helper
|
||||
#define prime_test Fssh_prime_test
|
||||
#define proto_spec Fssh_proto_spec
|
||||
#define put_bitmap Fssh_put_bitmap
|
||||
#define put_host_port Fssh_put_host_port
|
||||
#define put_u16 Fssh_put_u16
|
||||
#define put_u32 Fssh_put_u32
|
||||
@ -537,6 +534,7 @@
|
||||
#define read_keyfile_line Fssh_read_keyfile_line
|
||||
#define read_mux Fssh_read_mux
|
||||
#define read_passphrase Fssh_read_passphrase
|
||||
#define recip Fssh_recip
|
||||
#define record_hostkey Fssh_record_hostkey
|
||||
#define reduce_add_sub Fssh_reduce_add_sub
|
||||
#define refresh_progress_meter Fssh_refresh_progress_meter
|
||||
@ -563,11 +561,7 @@
|
||||
#define sigdie Fssh_sigdie
|
||||
#define snmprintf Fssh_snmprintf
|
||||
#define sock_set_v6only Fssh_sock_set_v6only
|
||||
#define square Fssh_square
|
||||
#define ssh1_3des_cbc Fssh_ssh1_3des_cbc
|
||||
#define ssh1_3des_cleanup Fssh_ssh1_3des_cleanup
|
||||
#define ssh1_3des_init Fssh_ssh1_3des_init
|
||||
#define ssh1_3des_iv Fssh_ssh1_3des_iv
|
||||
#define speed_to_baud Fssh_speed_to_baud
|
||||
#define ssh_OpenSSL_add_all_algorithms Fssh_ssh_OpenSSL_add_all_algorithms
|
||||
#define ssh_add_hostkey Fssh_ssh_add_hostkey
|
||||
#define ssh_add_identity_constrained Fssh_ssh_add_identity_constrained
|
||||
@ -656,6 +650,7 @@
|
||||
#define ssh_packet_get_int Fssh_ssh_packet_get_int
|
||||
#define ssh_packet_get_int64 Fssh_ssh_packet_get_int64
|
||||
#define ssh_packet_get_maxsize Fssh_ssh_packet_get_maxsize
|
||||
#define ssh_packet_get_mux Fssh_ssh_packet_get_mux
|
||||
#define ssh_packet_get_output Fssh_ssh_packet_get_output
|
||||
#define ssh_packet_get_protocol_flags Fssh_ssh_packet_get_protocol_flags
|
||||
#define ssh_packet_get_rekey_timeout Fssh_ssh_packet_get_rekey_timeout
|
||||
@ -666,6 +661,7 @@
|
||||
#define ssh_packet_inc_alive_timeouts Fssh_ssh_packet_inc_alive_timeouts
|
||||
#define ssh_packet_is_interactive Fssh_ssh_packet_is_interactive
|
||||
#define ssh_packet_is_rekeying Fssh_ssh_packet_is_rekeying
|
||||
#define ssh_packet_log_type Fssh_ssh_packet_log_type
|
||||
#define ssh_packet_need_rekeying Fssh_ssh_packet_need_rekeying
|
||||
#define ssh_packet_next Fssh_ssh_packet_next
|
||||
#define ssh_packet_not_very_much_data_to_write Fssh_ssh_packet_not_very_much_data_to_write
|
||||
@ -695,11 +691,13 @@
|
||||
#define ssh_packet_send_ignore Fssh_ssh_packet_send_ignore
|
||||
#define ssh_packet_set_alive_timeouts Fssh_ssh_packet_set_alive_timeouts
|
||||
#define ssh_packet_set_authenticated Fssh_ssh_packet_set_authenticated
|
||||
#define ssh_packet_set_compress_hooks Fssh_ssh_packet_set_compress_hooks
|
||||
#define ssh_packet_set_connection Fssh_ssh_packet_set_connection
|
||||
#define ssh_packet_set_encryption_key Fssh_ssh_packet_set_encryption_key
|
||||
#define ssh_packet_set_input_hook Fssh_ssh_packet_set_input_hook
|
||||
#define ssh_packet_set_interactive Fssh_ssh_packet_set_interactive
|
||||
#define ssh_packet_set_log_preamble Fssh_ssh_packet_set_log_preamble
|
||||
#define ssh_packet_set_maxsize Fssh_ssh_packet_set_maxsize
|
||||
#define ssh_packet_set_mux Fssh_ssh_packet_set_mux
|
||||
#define ssh_packet_set_nonblocking Fssh_ssh_packet_set_nonblocking
|
||||
#define ssh_packet_set_protocol_flags Fssh_ssh_packet_set_protocol_flags
|
||||
#define ssh_packet_set_rekey_limits Fssh_ssh_packet_set_rekey_limits
|
||||
@ -725,6 +723,7 @@
|
||||
#define ssh_set_verify_host_key_callback Fssh_ssh_set_verify_host_key_callback
|
||||
#define ssh_update_card Fssh_ssh_update_card
|
||||
#define sshbuf_alloc Fssh_sshbuf_alloc
|
||||
#define sshbuf_allocate Fssh_sshbuf_allocate
|
||||
#define sshbuf_avail Fssh_sshbuf_avail
|
||||
#define sshbuf_b64tod Fssh_sshbuf_b64tod
|
||||
#define sshbuf_check_reserve Fssh_sshbuf_check_reserve
|
||||
@ -783,6 +782,7 @@
|
||||
#define sshbuf_set_max_size Fssh_sshbuf_set_max_size
|
||||
#define sshbuf_set_parent Fssh_sshbuf_set_parent
|
||||
#define sshkey_add_private Fssh_sshkey_add_private
|
||||
#define sshkey_alg_list Fssh_sshkey_alg_list
|
||||
#define sshkey_cert_check_authority Fssh_sshkey_cert_check_authority
|
||||
#define sshkey_cert_copy Fssh_sshkey_cert_copy
|
||||
#define sshkey_cert_type Fssh_sshkey_cert_type
|
||||
@ -925,6 +925,5 @@
|
||||
#define xcalloc Fssh_xcalloc
|
||||
#define xcrypt Fssh_xcrypt
|
||||
#define xmalloc Fssh_xmalloc
|
||||
#define xmmap Fssh_xmmap
|
||||
#define xreallocarray Fssh_xreallocarray
|
||||
#define xstrdup Fssh_xstrdup
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: sshconnect.c,v 1.272 2016/09/12 01:22:38 deraadt Exp $ */
|
||||
/* $OpenBSD: sshconnect.c,v 1.273 2017/03/10 03:22:40 dtucker Exp $ */
|
||||
/*
|
||||
* Author: Tatu Ylonen <ylo@cs.hut.fi>
|
||||
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
|
||||
@ -1533,6 +1533,7 @@ maybe_add_key_to_agent(char *authfile, Key *private, char *comment,
|
||||
if (options.add_keys_to_agent == 2 &&
|
||||
!ask_permission("Add key %s (%s) to agent?", authfile, comment)) {
|
||||
debug3("user denied adding this key");
|
||||
close(auth_sock);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1541,4 +1542,5 @@ maybe_add_key_to_agent(char *authfile, Key *private, char *comment,
|
||||
debug("identity added to agent: %s", authfile);
|
||||
else
|
||||
debug("could not add identity to agent: %s (%d)", authfile, r);
|
||||
close(auth_sock);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: sshconnect1.c,v 1.79 2016/09/19 07:52:42 natano Exp $ */
|
||||
/* $OpenBSD: sshconnect1.c,v 1.80 2017/03/10 03:53:11 dtucker Exp $ */
|
||||
/*
|
||||
* Author: Tatu Ylonen <ylo@cs.hut.fi>
|
||||
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
|
||||
@ -520,7 +520,8 @@ ssh_kex(char *host, struct sockaddr *hostaddr)
|
||||
cookie[i] = packet_get_char();
|
||||
|
||||
/* Get the public key. */
|
||||
server_key = key_new(KEY_RSA1);
|
||||
if ((server_key = key_new(KEY_RSA1)) == NULL)
|
||||
fatal("%s: key_new(KEY_RSA1) failed", __func__);
|
||||
bits = packet_get_int();
|
||||
packet_get_bignum(server_key->rsa->e);
|
||||
packet_get_bignum(server_key->rsa->n);
|
||||
@ -532,7 +533,8 @@ ssh_kex(char *host, struct sockaddr *hostaddr)
|
||||
logit("Warning: This may be due to an old implementation of ssh.");
|
||||
}
|
||||
/* Get the host key. */
|
||||
host_key = key_new(KEY_RSA1);
|
||||
if ((host_key = key_new(KEY_RSA1)) == NULL)
|
||||
fatal("%s: key_new(KEY_RSA1) failed", __func__);
|
||||
bits = packet_get_int();
|
||||
packet_get_bignum(host_key->rsa->e);
|
||||
packet_get_bignum(host_key->rsa->n);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: sshconnect2.c,v 1.251 2016/12/04 23:54:02 djm Exp $ */
|
||||
/* $OpenBSD: sshconnect2.c,v 1.255 2017/03/11 23:40:26 djm Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2000 Markus Friedl. All rights reserved.
|
||||
* Copyright (c) 2008 Damien Miller. All rights reserved.
|
||||
@ -193,8 +193,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)
|
||||
@ -934,14 +934,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);
|
||||
@ -996,11 +996,11 @@ input_userauth_passwd_changereq(int type, u_int32_t seqnr, void *ctxt)
|
||||
}
|
||||
|
||||
static const char *
|
||||
identity_sign_encode(struct identity *id)
|
||||
key_sign_encode(const struct sshkey *key)
|
||||
{
|
||||
struct ssh *ssh = active_state;
|
||||
|
||||
if (id->key->type == KEY_RSA) {
|
||||
if (key->type == KEY_RSA) {
|
||||
switch (ssh->kex->rsa_sha2) {
|
||||
case 256:
|
||||
return "rsa-sha2-256";
|
||||
@ -1008,7 +1008,7 @@ identity_sign_encode(struct identity *id)
|
||||
return "rsa-sha2-512";
|
||||
}
|
||||
}
|
||||
return key_ssh_name(id->key);
|
||||
return key_ssh_name(key);
|
||||
}
|
||||
|
||||
static int
|
||||
@ -1017,30 +1017,49 @@ identity_sign(struct identity *id, u_char **sigp, size_t *lenp,
|
||||
{
|
||||
Key *prv;
|
||||
int ret;
|
||||
const char *alg;
|
||||
|
||||
alg = identity_sign_encode(id);
|
||||
|
||||
/* the agent supports this key */
|
||||
if (id->agent_fd != -1)
|
||||
if (id->key != NULL && id->agent_fd != -1)
|
||||
return ssh_agent_sign(id->agent_fd, id->key, sigp, lenp,
|
||||
data, datalen, alg, compat);
|
||||
data, datalen, key_sign_encode(id->key), compat);
|
||||
|
||||
/*
|
||||
* we have already loaded the private key or
|
||||
* the private key is stored in external hardware
|
||||
*/
|
||||
if (id->isprivate || (id->key->flags & SSHKEY_FLAG_EXT))
|
||||
return (sshkey_sign(id->key, sigp, lenp, data, datalen, alg,
|
||||
compat));
|
||||
if (id->key != NULL &&
|
||||
(id->isprivate || (id->key->flags & SSHKEY_FLAG_EXT)))
|
||||
return (sshkey_sign(id->key, sigp, lenp, data, datalen,
|
||||
key_sign_encode(id->key), compat));
|
||||
|
||||
/* load the private key from the file */
|
||||
if ((prv = load_identity_file(id)) == NULL)
|
||||
return SSH_ERR_KEY_NOT_FOUND;
|
||||
ret = sshkey_sign(prv, sigp, lenp, data, datalen, alg, compat);
|
||||
ret = sshkey_sign(prv, sigp, lenp, data, datalen,
|
||||
key_sign_encode(prv), compat);
|
||||
sshkey_free(prv);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
static int
|
||||
id_filename_matches(Identity *id, Identity *private_id)
|
||||
{
|
||||
const char *suffixes[] = { ".pub", "-cert.pub", NULL };
|
||||
size_t len = strlen(id->filename), plen = strlen(private_id->filename);
|
||||
size_t i, slen;
|
||||
|
||||
if (strcmp(id->filename, private_id->filename) == 0)
|
||||
return 1;
|
||||
for (i = 0; suffixes[i]; i++) {
|
||||
slen = strlen(suffixes[i]);
|
||||
if (len > slen && plen == len - slen &&
|
||||
strcmp(id->filename + (len - slen), suffixes[i]) == 0 &&
|
||||
memcmp(id->filename, private_id->filename, plen) == 0)
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
sign_and_send_pubkey(Authctxt *authctxt, Identity *id)
|
||||
{
|
||||
@ -1083,7 +1102,7 @@ sign_and_send_pubkey(Authctxt *authctxt, Identity *id)
|
||||
} else {
|
||||
buffer_put_cstring(&b, authctxt->method->name);
|
||||
buffer_put_char(&b, have_sig);
|
||||
buffer_put_cstring(&b, identity_sign_encode(id));
|
||||
buffer_put_cstring(&b, key_sign_encode(id->key));
|
||||
}
|
||||
buffer_put_string(&b, blob, bloblen);
|
||||
|
||||
@ -1103,6 +1122,24 @@ sign_and_send_pubkey(Authctxt *authctxt, Identity *id)
|
||||
break;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Exact key matches are preferred, but also allow
|
||||
* filename matches for non-PKCS#11/agent keys that
|
||||
* didn't load public keys. This supports the case
|
||||
* of keeping just a private key file and public
|
||||
* certificate on disk.
|
||||
*/
|
||||
if (!matched && !id->isprivate && id->agent_fd == -1 &&
|
||||
(id->key->flags & SSHKEY_FLAG_EXT) == 0) {
|
||||
TAILQ_FOREACH(private_id, &authctxt->keys, next) {
|
||||
if (private_id->key == NULL &&
|
||||
id_filename_matches(id, private_id)) {
|
||||
id = private_id;
|
||||
matched = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (matched) {
|
||||
debug2("%s: using private key \"%s\"%s for "
|
||||
"certificate", __func__, id->filename,
|
||||
@ -1181,7 +1218,7 @@ send_pubkey_test(Authctxt *authctxt, Identity *id)
|
||||
packet_put_cstring(authctxt->method->name);
|
||||
packet_put_char(have_sig);
|
||||
if (!(datafellows & SSH_BUG_PKAUTH))
|
||||
packet_put_cstring(identity_sign_encode(id));
|
||||
packet_put_cstring(key_sign_encode(id->key));
|
||||
packet_put_string(blob, bloblen);
|
||||
free(blob);
|
||||
packet_send();
|
||||
@ -1632,7 +1669,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)
|
||||
|
@ -33,9 +33,9 @@
|
||||
.\" (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 $
|
||||
.\" $OpenBSD: sshd.8,v 1.288 2017/01/30 23:27:39 dtucker Exp $
|
||||
.\" $FreeBSD$
|
||||
.Dd $Mdocdate: November 30 2016 $
|
||||
.Dd $Mdocdate: January 30 2017 $
|
||||
.Dt SSHD 8
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -634,7 +634,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),
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: sshd.c,v 1.480 2016/12/09 03:04:29 djm Exp $ */
|
||||
/* $OpenBSD: sshd.c,v 1.485 2017/03/15 03:52:30 deraadt Exp $ */
|
||||
/*
|
||||
* Author: Tatu Ylonen <ylo@cs.hut.fi>
|
||||
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
|
||||
@ -383,14 +383,14 @@ sshd_exchange_identification(struct ssh *ssh, int sock_in, int sock_out)
|
||||
{
|
||||
u_int i;
|
||||
int remote_major, remote_minor;
|
||||
char *s, *newline = "\n";
|
||||
char *s;
|
||||
char buf[256]; /* Must not be larger than remote_version. */
|
||||
char remote_version[256]; /* Must be at least as big as buf. */
|
||||
|
||||
xasprintf(&server_version_string, "SSH-%d.%d-%.100s%s%s%s",
|
||||
xasprintf(&server_version_string, "SSH-%d.%d-%.100s%s%s\r\n",
|
||||
PROTOCOL_MAJOR_2, PROTOCOL_MINOR_2, SSH_VERSION,
|
||||
*options.version_addendum == '\0' ? "" : " ",
|
||||
options.version_addendum, newline);
|
||||
options.version_addendum);
|
||||
|
||||
/* Send our protocol version identification. */
|
||||
if (atomicio(vwrite, sock_out, server_version_string,
|
||||
@ -1068,6 +1068,11 @@ server_listen(void)
|
||||
close(listen_sock);
|
||||
continue;
|
||||
}
|
||||
if (fcntl(listen_sock, F_SETFD, FD_CLOEXEC) == -1) {
|
||||
verbose("socket: CLOEXEC: %s", strerror(errno));
|
||||
close(listen_sock);
|
||||
continue;
|
||||
}
|
||||
/*
|
||||
* Set socket options.
|
||||
* Allow local port reuse in TIME_WAIT.
|
||||
@ -1696,6 +1701,15 @@ main(int ac, char **av)
|
||||
continue;
|
||||
key = key_load_private(options.host_key_files[i], "", NULL);
|
||||
pubkey = key_load_public(options.host_key_files[i], NULL);
|
||||
|
||||
if ((pubkey != NULL && pubkey->type == KEY_RSA1) ||
|
||||
(key != NULL && key->type == KEY_RSA1)) {
|
||||
verbose("Ignoring RSA1 key %s",
|
||||
options.host_key_files[i]);
|
||||
key_free(key);
|
||||
key_free(pubkey);
|
||||
continue;
|
||||
}
|
||||
if (pubkey == NULL && key != NULL)
|
||||
pubkey = key_demote(key);
|
||||
sensitive_data.host_keys[i] = key;
|
||||
@ -2227,7 +2241,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());
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $OpenBSD: sshd_config,v 1.100 2016/08/15 12:32:04 naddy Exp $
|
||||
# $OpenBSD: sshd_config,v 1.101 2017/03/14 07:19:07 djm Exp $
|
||||
# $FreeBSD$
|
||||
|
||||
# This is the sshd server system-wide configuration file. See
|
||||
@ -42,7 +42,8 @@
|
||||
#PubkeyAuthentication yes
|
||||
|
||||
# The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2
|
||||
#AuthorizedKeysFile .ssh/authorized_keys .ssh/authorized_keys2
|
||||
# but this is overridden so installations will only check .ssh/authorized_keys
|
||||
AuthorizedKeysFile .ssh/authorized_keys
|
||||
|
||||
#AuthorizedPrincipalsFile none
|
||||
|
||||
@ -95,7 +96,6 @@
|
||||
#PrintMotd yes
|
||||
#PrintLastLog yes
|
||||
#TCPKeepAlive yes
|
||||
#UsePrivilegeSeparation sandbox
|
||||
#PermitUserEnvironment no
|
||||
#Compression delayed
|
||||
#ClientAliveInterval 0
|
||||
@ -106,7 +106,7 @@
|
||||
#PermitTunnel no
|
||||
#ChrootDirectory none
|
||||
#UseBlacklist no
|
||||
#VersionAddendum FreeBSD-20170305
|
||||
#VersionAddendum FreeBSD-20170804
|
||||
|
||||
# no default banner path
|
||||
#Banner none
|
||||
|
@ -33,9 +33,9 @@
|
||||
.\" (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 $
|
||||
.\" $OpenBSD: sshd_config.5,v 1.243 2017/03/14 07:19:07 djm Exp $
|
||||
.\" $FreeBSD$
|
||||
.Dd $Mdocdate: November 30 2016 $
|
||||
.Dd $Mdocdate: March 14 2017 $
|
||||
.Dt SSHD_CONFIG 5
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -438,6 +438,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
|
||||
@ -651,6 +655,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,
|
||||
@ -845,6 +853,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
|
||||
@ -935,6 +947,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
|
||||
@ -1291,6 +1307,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,
|
||||
@ -1496,33 +1516,11 @@ is enabled, you will not be able to run
|
||||
as a non-root user.
|
||||
The default is
|
||||
.Cm yes .
|
||||
.It Cm UsePrivilegeSeparation
|
||||
Specifies whether
|
||||
.Xr sshd 8
|
||||
separates privileges by creating an unprivileged child process
|
||||
to deal with incoming network traffic.
|
||||
After successful authentication, another process will be created that has
|
||||
the privilege of the authenticated user.
|
||||
The goal of privilege separation is to prevent privilege
|
||||
escalation by containing any corruption within the unprivileged processes.
|
||||
The argument must be
|
||||
.Cm yes ,
|
||||
.Cm no ,
|
||||
or
|
||||
.Cm sandbox .
|
||||
If
|
||||
.Cm UsePrivilegeSeparation
|
||||
is set to
|
||||
.Cm sandbox
|
||||
then the pre-authentication unprivileged process is subject to additional
|
||||
restrictions.
|
||||
The default is
|
||||
.Cm sandbox .
|
||||
.It Cm VersionAddendum
|
||||
Optionally specifies additional text to append to the SSH protocol banner
|
||||
sent by the server upon connection.
|
||||
The default is
|
||||
.Qq FreeBSD-20170305 .
|
||||
.Qq FreeBSD-20170804 .
|
||||
The value
|
||||
.Cm none
|
||||
may be used to disable this.
|
||||
@ -1669,13 +1667,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.
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: sshkey.c,v 1.41 2016/10/24 01:09:17 dtucker Exp $ */
|
||||
/* $OpenBSD: sshkey.c,v 1.45 2017/03/10 04:07:20 djm Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2000, 2001 Markus Friedl. All rights reserved.
|
||||
* Copyright (c) 2008 Alexander von Gernler. All rights reserved.
|
||||
@ -89,7 +89,9 @@ static const struct keytype keytypes[] = {
|
||||
{ "ssh-ed25519-cert-v01@openssh.com", "ED25519-CERT",
|
||||
KEY_ED25519_CERT, 0, 1, 0 },
|
||||
#ifdef WITH_OPENSSL
|
||||
# ifdef WITH_SSH1
|
||||
{ NULL, "RSA1", KEY_RSA1, 0, 0, 0 },
|
||||
# endif
|
||||
{ "ssh-rsa", "RSA", KEY_RSA, 0, 0, 0 },
|
||||
{ "rsa-sha2-256", "RSA", KEY_RSA, 0, 0, 1 },
|
||||
{ "rsa-sha2-512", "RSA", KEY_RSA, 0, 0, 1 },
|
||||
@ -195,14 +197,16 @@ sshkey_ecdsa_nid_from_name(const char *name)
|
||||
}
|
||||
|
||||
char *
|
||||
sshkey_alg_list(int certs_only, int plain_only, char sep)
|
||||
sshkey_alg_list(int certs_only, int plain_only, int include_sigonly, char sep)
|
||||
{
|
||||
char *tmp, *ret = NULL;
|
||||
size_t nlen, rlen = 0;
|
||||
const struct keytype *kt;
|
||||
|
||||
for (kt = keytypes; kt->type != -1; kt++) {
|
||||
if (kt->name == NULL || kt->sigonly)
|
||||
if (kt->name == NULL)
|
||||
continue;
|
||||
if (!include_sigonly && kt->sigonly)
|
||||
continue;
|
||||
if ((certs_only && !kt->cert) || (plain_only && kt->cert))
|
||||
continue;
|
||||
@ -1237,6 +1241,9 @@ sshkey_read(struct sshkey *ret, char **cpp)
|
||||
u_long bits;
|
||||
#endif /* WITH_SSH1 */
|
||||
|
||||
if (ret == NULL)
|
||||
return SSH_ERR_INVALID_ARGUMENT;
|
||||
|
||||
cp = *cpp;
|
||||
|
||||
switch (ret->type) {
|
||||
@ -3786,7 +3793,46 @@ sshkey_parse_private_pem_fileblob(struct sshbuf *blob, int type,
|
||||
|
||||
if ((pk = PEM_read_bio_PrivateKey(bio, NULL, NULL,
|
||||
(char *)passphrase)) == NULL) {
|
||||
r = SSH_ERR_KEY_WRONG_PASSPHRASE;
|
||||
unsigned long pem_err = ERR_peek_last_error();
|
||||
int pem_reason = ERR_GET_REASON(pem_err);
|
||||
|
||||
/*
|
||||
* Translate OpenSSL error codes to determine whether
|
||||
* passphrase is required/incorrect.
|
||||
*/
|
||||
switch (ERR_GET_LIB(pem_err)) {
|
||||
case ERR_LIB_PEM:
|
||||
switch (pem_reason) {
|
||||
case PEM_R_BAD_PASSWORD_READ:
|
||||
case PEM_R_PROBLEMS_GETTING_PASSWORD:
|
||||
case PEM_R_BAD_DECRYPT:
|
||||
r = SSH_ERR_KEY_WRONG_PASSPHRASE;
|
||||
goto out;
|
||||
default:
|
||||
r = SSH_ERR_INVALID_FORMAT;
|
||||
goto out;
|
||||
}
|
||||
case ERR_LIB_EVP:
|
||||
switch (pem_reason) {
|
||||
case EVP_R_BAD_DECRYPT:
|
||||
r = SSH_ERR_KEY_WRONG_PASSPHRASE;
|
||||
goto out;
|
||||
case EVP_R_BN_DECODE_ERROR:
|
||||
case EVP_R_DECODE_ERROR:
|
||||
#ifdef EVP_R_PRIVATE_KEY_DECODE_ERROR
|
||||
case EVP_R_PRIVATE_KEY_DECODE_ERROR:
|
||||
#endif
|
||||
r = SSH_ERR_INVALID_FORMAT;
|
||||
goto out;
|
||||
default:
|
||||
r = SSH_ERR_LIBCRYPTO_ERROR;
|
||||
goto out;
|
||||
}
|
||||
case ERR_LIB_ASN1:
|
||||
r = SSH_ERR_INVALID_FORMAT;
|
||||
goto out;
|
||||
}
|
||||
r = SSH_ERR_LIBCRYPTO_ERROR;
|
||||
goto out;
|
||||
}
|
||||
if (pk->type == EVP_PKEY_RSA &&
|
||||
@ -3860,6 +3906,8 @@ int
|
||||
sshkey_parse_private_fileblob_type(struct sshbuf *blob, int type,
|
||||
const char *passphrase, struct sshkey **keyp, char **commentp)
|
||||
{
|
||||
int r = SSH_ERR_INTERNAL_ERROR;
|
||||
|
||||
if (keyp != NULL)
|
||||
*keyp = NULL;
|
||||
if (commentp != NULL)
|
||||
@ -3882,9 +3930,11 @@ sshkey_parse_private_fileblob_type(struct sshbuf *blob, int type,
|
||||
return sshkey_parse_private2(blob, type, passphrase,
|
||||
keyp, commentp);
|
||||
case KEY_UNSPEC:
|
||||
if (sshkey_parse_private2(blob, type, passphrase, keyp,
|
||||
commentp) == 0)
|
||||
return 0;
|
||||
r = sshkey_parse_private2(blob, type, passphrase, keyp,
|
||||
commentp);
|
||||
/* Do not fallback to PEM parser if only passphrase is wrong. */
|
||||
if (r == 0 || r == SSH_ERR_KEY_WRONG_PASSPHRASE)
|
||||
return r;
|
||||
#ifdef WITH_OPENSSL
|
||||
return sshkey_parse_private_pem_fileblob(blob, type,
|
||||
passphrase, keyp);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: sshkey.h,v 1.14 2016/09/12 23:31:27 djm Exp $ */
|
||||
/* $OpenBSD: sshkey.h,v 1.15 2017/03/10 04:07:20 djm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2000, 2001 Markus Friedl. All rights reserved.
|
||||
@ -156,7 +156,7 @@ int sshkey_ec_validate_private(const EC_KEY *);
|
||||
const char *sshkey_ssh_name(const struct sshkey *);
|
||||
const char *sshkey_ssh_name_plain(const struct sshkey *);
|
||||
int sshkey_names_valid2(const char *, int);
|
||||
char *sshkey_alg_list(int, int, char);
|
||||
char *sshkey_alg_list(int, int, int, char);
|
||||
|
||||
int sshkey_from_blob(const u_char *, size_t, struct sshkey **);
|
||||
int sshkey_fromb(struct sshbuf *, struct sshkey **);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: utf8.c,v 1.3 2016/05/30 12:57:21 schwarze Exp $ */
|
||||
/* $OpenBSD: utf8.c,v 1.5 2017/02/19 00:10:57 djm Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
|
||||
*
|
||||
@ -60,7 +60,8 @@ dangerous_locale(void) {
|
||||
char *loc;
|
||||
|
||||
loc = nl_langinfo(CODESET);
|
||||
return strcmp(loc, "US-ASCII") && strcmp(loc, "UTF-8");
|
||||
return strcmp(loc, "US-ASCII") != 0 && strcmp(loc, "UTF-8") != 0 &&
|
||||
strcmp(loc, "ANSI_X3.4-1968") != 0 && strcmp(loc, "646") != 0;
|
||||
}
|
||||
|
||||
static int
|
||||
@ -116,6 +117,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;
|
||||
}
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
/* $OpenBSD: version.h,v 1.78 2016/12/19 04:55:51 djm Exp $ */
|
||||
/* $OpenBSD: version.h,v 1.79 2017/03/20 01:18:59 djm Exp $ */
|
||||
/* $FreeBSD$ */
|
||||
|
||||
#define SSH_VERSION "OpenSSH_7.4"
|
||||
#define SSH_VERSION "OpenSSH_7.5"
|
||||
|
||||
#define SSH_PORTABLE "p1"
|
||||
#define SSH_RELEASE SSH_VERSION SSH_PORTABLE
|
||||
|
||||
#define SSH_VERSION_FREEBSD "FreeBSD-20170305"
|
||||
#define SSH_VERSION_FREEBSD "FreeBSD-20170804"
|
||||
|
||||
#ifdef WITH_OPENSSL
|
||||
#define OPENSSL_VERSION SSLeay_version(SSLEAY_VERSION)
|
||||
|
@ -41,7 +41,7 @@ SRCS+= ntoh.c
|
||||
.PATH: ${LIBC_SRC}/string
|
||||
SRCS+= bcmp.c bcopy.c bzero.c ffs.c fls.c \
|
||||
memccpy.c memchr.c memcmp.c memcpy.c memmove.c memset.c \
|
||||
qdivrem.c strcat.c strchr.c strcmp.c strcpy.c \
|
||||
qdivrem.c strcat.c strchr.c strcmp.c strcpy.c stpcpy.c stpncpy.c \
|
||||
strcspn.c strlcat.c strlcpy.c strlen.c strncat.c strncmp.c strncpy.c \
|
||||
strpbrk.c strrchr.c strsep.c strspn.c strstr.c strtok.c swab.c
|
||||
.if ${MACHINE_CPUARCH} == "arm"
|
||||
|
@ -35,6 +35,7 @@ MAN+= expand_number.3 flopen.3 fparseln.3 hexdump.3 \
|
||||
property.3 pty.3 quotafile.3 realhostname.3 realhostname_sa.3 \
|
||||
_secure_path.3 trimdomain.3 uucplock.3 pw_util.3
|
||||
MAN+= login.conf.5
|
||||
MLINKS+=flopen.3 flopenat.3
|
||||
MLINKS+=kld.3 kld_isloaded.3 kld.3 kld_load.3
|
||||
MLINKS+=login_auth.3 auth_cat.3 login_auth.3 auth_checknologin.3
|
||||
MLINKS+=login_cap.3 login_close.3 login_cap.3 login_getcapbool.3 \
|
||||
|
@ -25,11 +25,12 @@
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd June 6, 2009
|
||||
.Dd July 28, 2017
|
||||
.Dt FLOPEN 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm flopen
|
||||
.Nm flopen ,
|
||||
.Nm flopenat
|
||||
.Nd "Reliably open and lock a file"
|
||||
.Sh LIBRARY
|
||||
.Lb libutil
|
||||
@ -40,6 +41,10 @@
|
||||
.Fn flopen "const char *path" "int flags"
|
||||
.Ft int
|
||||
.Fn flopen "const char *path" "int flags" "mode_t mode"
|
||||
.Ft int
|
||||
.Fn flopenat "int fd" "const char *path" "int flags"
|
||||
.Ft int
|
||||
.Fn flopenat "int fd" "const char *path" "int flags" "mode_t mode"
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Fn flopen
|
||||
@ -79,6 +84,27 @@ argument is required if
|
||||
.Va flags
|
||||
includes
|
||||
.Dv O_CREAT .
|
||||
.Pp
|
||||
The
|
||||
.Fn flopenat
|
||||
function is equivalent to the
|
||||
.Fn flopen
|
||||
function except in the case where the
|
||||
.Fa path
|
||||
specifies a relative path.
|
||||
In this case the file to be opened is determined relative to the directory
|
||||
associated with the file descriptor
|
||||
.Fa fd
|
||||
instead of the current working directory.
|
||||
If
|
||||
.Fn flopenat
|
||||
is passed the special value
|
||||
.Dv AT_FDCWD
|
||||
in the
|
||||
.Fa fd
|
||||
parameter, the current working directory is used
|
||||
and the behavior is identical to a call to
|
||||
.Fn flopen .
|
||||
.Sh RETURN VALUES
|
||||
If successful,
|
||||
.Fn flopen
|
||||
|
@ -45,8 +45,8 @@ __FBSDID("$FreeBSD$");
|
||||
* code's apparent simplicity; there would be no need for this function if it
|
||||
* was easy to get right.
|
||||
*/
|
||||
int
|
||||
flopen(const char *path, int flags, ...)
|
||||
static int
|
||||
vflopenat(int dirfd, const char *path, int flags, va_list ap)
|
||||
{
|
||||
int fd, operation, serrno, trunc;
|
||||
struct stat sb, fsb;
|
||||
@ -58,11 +58,7 @@ flopen(const char *path, int flags, ...)
|
||||
|
||||
mode = 0;
|
||||
if (flags & O_CREAT) {
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, flags);
|
||||
mode = (mode_t)va_arg(ap, int); /* mode_t promoted to int */
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
operation = LOCK_EX;
|
||||
@ -73,7 +69,7 @@ flopen(const char *path, int flags, ...)
|
||||
flags &= ~O_TRUNC;
|
||||
|
||||
for (;;) {
|
||||
if ((fd = open(path, flags, mode)) == -1)
|
||||
if ((fd = openat(dirfd, path, flags, mode)) == -1)
|
||||
/* non-existent or no access */
|
||||
return (-1);
|
||||
if (flock(fd, operation) == -1) {
|
||||
@ -83,7 +79,7 @@ flopen(const char *path, int flags, ...)
|
||||
errno = serrno;
|
||||
return (-1);
|
||||
}
|
||||
if (stat(path, &sb) == -1) {
|
||||
if (fstatat(dirfd, path, &sb, 0) == -1) {
|
||||
/* disappeared from under our feet */
|
||||
(void)close(fd);
|
||||
continue;
|
||||
@ -123,3 +119,27 @@ flopen(const char *path, int flags, ...)
|
||||
return (fd);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
flopen(const char *path, int flags, ...)
|
||||
{
|
||||
va_list ap;
|
||||
int ret;
|
||||
|
||||
va_start(ap, flags);
|
||||
ret = vflopenat(AT_FDCWD, path, flags, ap);
|
||||
va_end(ap);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
int
|
||||
flopenat(int dirfd, const char *path, int flags, ...)
|
||||
{
|
||||
va_list ap;
|
||||
int ret;
|
||||
|
||||
va_start(ap, flags);
|
||||
ret = vflopenat(dirfd, path, flags, ap);
|
||||
va_end(ap);
|
||||
return (ret);
|
||||
}
|
||||
|
@ -93,6 +93,7 @@ int expand_number(const char *_buf, uint64_t *_num);
|
||||
int extattr_namespace_to_string(int _attrnamespace, char **_string);
|
||||
int extattr_string_to_namespace(const char *_string, int *_attrnamespace);
|
||||
int flopen(const char *_path, int _flags, ...);
|
||||
int flopenat(int _dirfd, const char *_path, int _flags, ...);
|
||||
int forkpty(int *_amaster, char *_name,
|
||||
struct termios *_termp, struct winsize *_winp);
|
||||
void hexdump(const void *_ptr, int _length, const char *_hdr, int _flags);
|
||||
|
@ -29,7 +29,7 @@
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd January 15, 2017
|
||||
.Dd August 3, 2017
|
||||
.Dt EHCI 4
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -69,16 +69,6 @@ but can be noticed since
|
||||
.Tn USB
|
||||
2.0 devices plugged in to the same
|
||||
connector appear to connect to different USB buses.
|
||||
.Sh SEE ALSO
|
||||
.Xr ohci 4 ,
|
||||
.Xr uhci 4 ,
|
||||
.Xr usb 4 ,
|
||||
.Xr xhci 4
|
||||
.Sh HISTORY
|
||||
The
|
||||
.Nm
|
||||
device driver first appeared in
|
||||
.Fx 5.1 .
|
||||
.Sh LOADER TUNABLES
|
||||
When the kernel has been compiled with
|
||||
.Cd options USB_DEBUG ,
|
||||
@ -98,4 +88,27 @@ The default value is 0 (off).
|
||||
.It Va hw.usb.ehci.no_hs
|
||||
This tunable disables USB devices to attach like HIGH-speed ones and will force all attached devices to attach to the FULL- or LOW-speed companion controller.
|
||||
The default value is 0 (off).
|
||||
.Sh MIB Variables
|
||||
The
|
||||
.Nm
|
||||
driver exposes the following variables in the
|
||||
.Va hw.usb.ehci
|
||||
branch of the
|
||||
.Xr sysctl 3
|
||||
MIB:
|
||||
.Bl -tag -width ".Va debug"
|
||||
.It Va debug
|
||||
Debug output level, where 0 is debugging disabled and larger values increase
|
||||
debug message verbosity.
|
||||
Default is 0.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr ohci 4 ,
|
||||
.Xr uhci 4 ,
|
||||
.Xr usb 4 ,
|
||||
.Xr xhci 4
|
||||
.Sh HISTORY
|
||||
The
|
||||
.Nm
|
||||
device driver first appeared in
|
||||
.Fx 5.1 .
|
||||
|
@ -24,7 +24,7 @@
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd June 23, 2005
|
||||
.Dd August 3, 2017
|
||||
.Dt OHCI 4
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -59,6 +59,19 @@ NVIDIA nForce3
|
||||
.It
|
||||
Sun PCIO-2 (RIO USB)
|
||||
.El
|
||||
.Sh MIB Variables
|
||||
The
|
||||
.Nm
|
||||
driver exposes the following variables in the
|
||||
.Va hw.usb.ohci
|
||||
branch of the
|
||||
.Xr sysctl 3
|
||||
MIB:
|
||||
.Bl -tag -width ".Va debug"
|
||||
.It Va debug
|
||||
Debug output level, where 0 is debugging disabled and larger values increase
|
||||
debug message verbosity.
|
||||
Default is 0.
|
||||
.Sh SEE ALSO
|
||||
.Xr ehci 4 ,
|
||||
.Xr uhci 4 ,
|
||||
|
@ -29,7 +29,7 @@
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd April 26, 2017
|
||||
.Dd August 3, 2017
|
||||
.Dt UCOM 4
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -63,6 +63,21 @@ This means that normal programs such as
|
||||
or
|
||||
.Xr ppp 8
|
||||
can be used to access the device.
|
||||
.Sh MIB Variables
|
||||
The
|
||||
.Nm
|
||||
driver exposes the following variables in the
|
||||
.Va hw.usb.ucom
|
||||
branch of the
|
||||
.Xr sysctl 3
|
||||
MIB:
|
||||
.Bl -tag -width ".Va pps_mode"
|
||||
.It Va debug
|
||||
Debug output level, where 0 is debugging disabled and larger values increase
|
||||
debug message verbosity.
|
||||
Default is 0.
|
||||
.It Va pps_mode
|
||||
Enables and configure PPS capture mode as described below.
|
||||
.Sh Pulse Per Second (PPS) Timing Interface
|
||||
The
|
||||
.Nm
|
||||
|
@ -29,7 +29,7 @@
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd May 16, 2014
|
||||
.Dd August 3, 2017
|
||||
.Dt UGEN 4
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -291,6 +291,19 @@ and
|
||||
.Va alt_index
|
||||
should be set to
|
||||
.Dv USB_CURRENT_ALT_INDEX .
|
||||
.Sh MIB Variables
|
||||
The
|
||||
.Nm
|
||||
driver exposes the following variables in the
|
||||
.Va hw.usb.ugen
|
||||
branch of the
|
||||
.Xr sysctl 3
|
||||
MIB:
|
||||
.Bl -tag -width ".Va debug"
|
||||
.It Va debug
|
||||
Debug output level, where 0 is debugging disabled and larger values increase
|
||||
debug message verbosity.
|
||||
Default is 0.
|
||||
.Sh FILES
|
||||
.Bl -tag -width ".Pa /dev/ugen Ns Ar N Ns Pa \&. Ns Ar E" -compact
|
||||
.It Pa /dev/ugen Ns Ar N Ns Pa \&. Ns Ar E
|
||||
|
@ -24,7 +24,7 @@
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd April 20, 2005
|
||||
.Dd August 3, 2017
|
||||
.Dt UHCI 4
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -49,6 +49,19 @@ Intel 82371SB (PIIX3)
|
||||
.It
|
||||
VIA 83C572
|
||||
.El
|
||||
.Sh MIB Variables
|
||||
The
|
||||
.Nm
|
||||
driver exposes the following variables in the
|
||||
.Va hw.usb.uhci
|
||||
branch of the
|
||||
.Xr sysctl 3
|
||||
MIB:
|
||||
.Bl -tag -width ".Va debug"
|
||||
.It Va debug
|
||||
Debug output level, where 0 is debugging disabled and larger values increase
|
||||
debug message verbosity.
|
||||
Default is 0.
|
||||
.Sh SEE ALSO
|
||||
.Xr ehci 4 ,
|
||||
.Xr ohci 4 ,
|
||||
|
@ -29,7 +29,7 @@
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd November 22, 2006
|
||||
.Dd August 3, 2017
|
||||
.Dt UHID 4
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -127,6 +127,19 @@ Use
|
||||
to send data to the device.
|
||||
Data should be written in chunks of the
|
||||
size prescribed by the report descriptor.
|
||||
.Sh MIB Variables
|
||||
The
|
||||
.Nm
|
||||
driver exposes the following variables in the
|
||||
.Va hw.usb.uhid
|
||||
branch of the
|
||||
.Xr sysctl 3
|
||||
MIB:
|
||||
.Bl -tag -width ".Va debug"
|
||||
.It Va debug
|
||||
Debug output level, where 0 is debugging disabled and larger values increase
|
||||
debug message verbosity.
|
||||
Default is 0.
|
||||
.Sh FILES
|
||||
.Bl -tag -width ".Pa /dev/uhid?"
|
||||
.It Pa /dev/uhid?
|
||||
|
@ -24,7 +24,7 @@
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd November 22, 2006
|
||||
.Dd August 3, 2017
|
||||
.Dt UKBD 4
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -136,6 +136,19 @@ or
|
||||
Do not allow the user to change the keymap.
|
||||
Note that these options also affect the AT keyboard driver,
|
||||
.Xr atkbd 4 .
|
||||
.Sh MIB Variables
|
||||
The
|
||||
.Nm
|
||||
driver exposes the following variables in the
|
||||
.Va hw.usb.ukbd
|
||||
branch of the
|
||||
.Xr sysctl 3
|
||||
MIB:
|
||||
.Bl -tag -width ".Va debug"
|
||||
.It Va debug
|
||||
Debug output level, where 0 is debugging disabled and larger values increase
|
||||
debug message verbosity.
|
||||
Default is 0.
|
||||
.Sh FILES
|
||||
.Bl -tag -width ".Pa /dev/kbd*" -compact
|
||||
.It Pa /dev/kbd*
|
||||
|
@ -24,7 +24,7 @@
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd November 27, 2006
|
||||
.Dd August 3, 2017
|
||||
.Dt UMS 4
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -64,6 +64,19 @@ type device.
|
||||
See
|
||||
.Xr moused 8
|
||||
for an explanation of these mouse types.
|
||||
.Sh MIB Variables
|
||||
The
|
||||
.Nm
|
||||
driver exposes the following variables in the
|
||||
.Va hw.usb.ums
|
||||
branch of the
|
||||
.Xr sysctl 3
|
||||
MIB:
|
||||
.Bl -tag -width ".Va debug"
|
||||
.It Va debug
|
||||
Debug output level, where 0 is debugging disabled and larger values increase
|
||||
debug message verbosity.
|
||||
Default is 0.
|
||||
.Sh FILES
|
||||
.Bl -tag -width /dev/ums0 -compact
|
||||
.It Pa /dev/ums0
|
||||
|
@ -29,7 +29,7 @@
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd April 26, 2017
|
||||
.Dd August 3, 2017
|
||||
.Dt UPLCOM 4
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -180,6 +180,19 @@ YC-Cable USB-Serial Adapter
|
||||
.It
|
||||
Zeagle N2iTion3 Diving Computer
|
||||
.El
|
||||
.Sh MIB Variables
|
||||
The
|
||||
.Nm
|
||||
driver exposes the following variables in the
|
||||
.Va hw.usb.uplcom
|
||||
branch of the
|
||||
.Xr sysctl 3
|
||||
MIB:
|
||||
.Bl -tag -width ".Va debug"
|
||||
.It Va debug
|
||||
Debug output level, where 0 is debugging disabled and larger values increase
|
||||
debug message verbosity.
|
||||
Default is 0.
|
||||
.Sh FILES
|
||||
.Bl -tag -width "/dev/ttyU*.init" -compact
|
||||
.It Pa /dev/ttyU*
|
||||
|
@ -24,7 +24,7 @@
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd April 29, 2017
|
||||
.Dd August 3, 2017
|
||||
.Dt USB 4
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -131,6 +131,19 @@ Any interface specific driver can attach to the device.
|
||||
.It
|
||||
If none is found, generic interface class drivers can attach.
|
||||
.El
|
||||
.Sh MIB Variables
|
||||
The
|
||||
.Nm
|
||||
driver exposes the following variables in the
|
||||
.Va hw.usb
|
||||
branch of the
|
||||
.Xr sysctl 3
|
||||
MIB:
|
||||
.Bl -tag -width ".Va debug"
|
||||
.It Va debug
|
||||
Debug output level, where 0 is debugging disabled and larger values increase
|
||||
debug message verbosity.
|
||||
Default is 0.
|
||||
.Sh SEE ALSO
|
||||
The
|
||||
.Tn USB
|
||||
|
@ -24,7 +24,7 @@
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd May 17, 2011
|
||||
.Dd August 3, 2017
|
||||
.Dt XHCI 4
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -56,6 +56,19 @@ driver supports
|
||||
.Tn XHCI
|
||||
compatible controllers having PCI class 12 (serial bus),
|
||||
subclass 3 (USB) and programming interface 48 (XHCI).
|
||||
.Sh MIB Variables
|
||||
The
|
||||
.Nm
|
||||
driver exposes the following variables in the
|
||||
.Va hw.usb.xhci
|
||||
branch of the
|
||||
.Xr sysctl 3
|
||||
MIB:
|
||||
.Bl -tag -width ".Va debug"
|
||||
.It Va debug
|
||||
Debug output level, where 0 is debugging disabled and larger values increase
|
||||
debug message verbosity.
|
||||
Default is 0.
|
||||
.Sh SEE ALSO
|
||||
.Xr ehci 4 ,
|
||||
.Xr ohci 4 ,
|
||||
|
@ -63,7 +63,7 @@ breakpoint(void)
|
||||
__asm __volatile("int $3");
|
||||
}
|
||||
|
||||
static __inline u_int
|
||||
static __inline __pure2 u_int
|
||||
bsfl(u_int mask)
|
||||
{
|
||||
u_int result;
|
||||
@ -72,7 +72,7 @@ bsfl(u_int mask)
|
||||
return (result);
|
||||
}
|
||||
|
||||
static __inline u_long
|
||||
static __inline __pure2 u_long
|
||||
bsfq(u_long mask)
|
||||
{
|
||||
u_long result;
|
||||
@ -81,7 +81,7 @@ bsfq(u_long mask)
|
||||
return (result);
|
||||
}
|
||||
|
||||
static __inline u_int
|
||||
static __inline __pure2 u_int
|
||||
bsrl(u_int mask)
|
||||
{
|
||||
u_int result;
|
||||
@ -90,7 +90,7 @@ bsrl(u_int mask)
|
||||
return (result);
|
||||
}
|
||||
|
||||
static __inline u_long
|
||||
static __inline __pure2 u_long
|
||||
bsrq(u_long mask)
|
||||
{
|
||||
u_long result;
|
||||
@ -155,7 +155,7 @@ enable_intr(void)
|
||||
|
||||
#define HAVE_INLINE_FFSL
|
||||
|
||||
static __inline int
|
||||
static __inline __pure2 int
|
||||
ffsl(long mask)
|
||||
{
|
||||
return (mask == 0 ? mask : (int)bsfq((u_long)mask) + 1);
|
||||
@ -163,7 +163,7 @@ ffsl(long mask)
|
||||
|
||||
#define HAVE_INLINE_FFSLL
|
||||
|
||||
static __inline int
|
||||
static __inline __pure2 int
|
||||
ffsll(long long mask)
|
||||
{
|
||||
return (ffsl((long)mask));
|
||||
@ -171,7 +171,7 @@ ffsll(long long mask)
|
||||
|
||||
#define HAVE_INLINE_FLS
|
||||
|
||||
static __inline int
|
||||
static __inline __pure2 int
|
||||
fls(int mask)
|
||||
{
|
||||
return (mask == 0 ? mask : (int)bsrl((u_int)mask) + 1);
|
||||
@ -179,7 +179,7 @@ fls(int mask)
|
||||
|
||||
#define HAVE_INLINE_FLSL
|
||||
|
||||
static __inline int
|
||||
static __inline __pure2 int
|
||||
flsl(long mask)
|
||||
{
|
||||
return (mask == 0 ? mask : (int)bsrq((u_long)mask) + 1);
|
||||
@ -187,7 +187,7 @@ flsl(long mask)
|
||||
|
||||
#define HAVE_INLINE_FLSLL
|
||||
|
||||
static __inline int
|
||||
static __inline __pure2 int
|
||||
flsll(long long mask)
|
||||
{
|
||||
return (flsl((long)mask));
|
||||
|
@ -47,7 +47,6 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/rman.h>
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
#include <dev/iicbus/iicbus.h>
|
||||
#include <dev/iicbus/iiconf.h>
|
||||
|
||||
#include <dev/gpio/gpiobusvar.h>
|
||||
@ -59,7 +58,6 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
#include <arm/allwinner/axp209reg.h>
|
||||
|
||||
#include "iicbus_if.h"
|
||||
#include "gpio_if.h"
|
||||
#include "regdev_if.h"
|
||||
|
||||
@ -602,7 +600,6 @@ enum AXP2XX_TYPE {
|
||||
|
||||
struct axp2xx_softc {
|
||||
device_t dev;
|
||||
uint32_t addr;
|
||||
struct resource * res[1];
|
||||
void * intrcookie;
|
||||
struct intr_config_hook intr_hook;
|
||||
@ -641,57 +638,15 @@ static struct resource_spec axp_res_spec[] = {
|
||||
static int
|
||||
axp2xx_read(device_t dev, uint8_t reg, uint8_t *data, uint8_t size)
|
||||
{
|
||||
struct axp2xx_softc *sc = device_get_softc(dev);
|
||||
struct iic_msg msg[2];
|
||||
|
||||
msg[0].slave = sc->addr;
|
||||
msg[0].flags = IIC_M_WR;
|
||||
msg[0].len = 1;
|
||||
msg[0].buf = ®
|
||||
|
||||
msg[1].slave = sc->addr;
|
||||
msg[1].flags = IIC_M_RD;
|
||||
msg[1].len = size;
|
||||
msg[1].buf = data;
|
||||
|
||||
return (iicbus_transfer(dev, msg, 2));
|
||||
return (iicdev_readfrom(dev, reg, data, size, IIC_INTRWAIT));
|
||||
}
|
||||
|
||||
static int
|
||||
axp2xx_write(device_t dev, uint8_t reg, uint8_t data)
|
||||
{
|
||||
uint8_t buffer[2];
|
||||
struct axp2xx_softc *sc = device_get_softc(dev);
|
||||
struct iic_msg msg[2];
|
||||
int nmsgs = 0;
|
||||
|
||||
if (sc->type == AXP209) {
|
||||
buffer[0] = reg;
|
||||
buffer[1] = data;
|
||||
|
||||
msg[0].slave = sc->addr;
|
||||
msg[0].flags = IIC_M_WR;
|
||||
msg[0].len = 2;
|
||||
msg[0].buf = buffer;
|
||||
|
||||
nmsgs = 1;
|
||||
}
|
||||
else if (sc->type == AXP221) {
|
||||
msg[0].slave = sc->addr;
|
||||
msg[0].flags = IIC_M_WR;
|
||||
msg[0].len = 1;
|
||||
msg[0].buf = ®
|
||||
|
||||
msg[1].slave = sc->addr;
|
||||
msg[1].flags = IIC_M_WR;
|
||||
msg[1].len = 1;
|
||||
msg[1].buf = &data;
|
||||
nmsgs = 2;
|
||||
}
|
||||
else
|
||||
return (EINVAL);
|
||||
|
||||
return (iicbus_transfer(dev, msg, nmsgs));
|
||||
return (iicdev_writeto(dev, reg, &data, sizeof(data), IIC_INTRWAIT));
|
||||
}
|
||||
|
||||
static int
|
||||
@ -1239,7 +1194,6 @@ axp2xx_start(void *pdev)
|
||||
dev = pdev;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
sc->addr = iicbus_get_addr(dev);
|
||||
sc->dev = dev;
|
||||
|
||||
if (bootverbose) {
|
||||
@ -1451,4 +1405,4 @@ EARLY_DRIVER_MODULE(ofw_gpiobus, axp2xx_pmu, ofw_gpiobus_driver,
|
||||
DRIVER_MODULE(gpioc, axp2xx_pmu, gpioc_driver, gpioc_devclass,
|
||||
0, 0);
|
||||
MODULE_VERSION(axp2xx, 1);
|
||||
MODULE_DEPEND(axp2xx, iicbus, 1, 1, 1);
|
||||
MODULE_DEPEND(axp2xx, iicbus, IICBUS_MINVER, IICBUS_PREFVER, IICBUS_MAXVER);
|
||||
|
40
sys/arm/conf/GENERIC-NODEBUG
Normal file
40
sys/arm/conf/GENERIC-NODEBUG
Normal file
@ -0,0 +1,40 @@
|
||||
#
|
||||
# GENERIC-NODEBUG -- WITNESS and INVARIANTS free kernel configuration file
|
||||
# for FreeBSD/arm
|
||||
#
|
||||
# This configuration file removes several debugging options, including
|
||||
# WITNESS and INVARIANTS checking, which are known to have significant
|
||||
# performance impact on running systems. When benchmarking new features
|
||||
# this kernel should be used instead of the standard GENERIC.
|
||||
# This kernel configuration should never appear outside of the HEAD
|
||||
# of the FreeBSD tree.
|
||||
#
|
||||
# For more information on this file, please read the config(5) manual page,
|
||||
# and/or the handbook section on Kernel Configuration Files:
|
||||
#
|
||||
# http://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html
|
||||
#
|
||||
# The handbook is also available locally in /usr/share/doc/handbook
|
||||
# if you've installed the doc distribution, otherwise always see the
|
||||
# FreeBSD World Wide Web server (http://www.FreeBSD.org/) for the
|
||||
# latest information.
|
||||
#
|
||||
# An exhaustive list of options and more detailed explanations of the
|
||||
# device lines is also present in the ../../conf/NOTES and NOTES files.
|
||||
# If you are in doubt as to the purpose or necessity of a line, check first
|
||||
# in NOTES.
|
||||
#
|
||||
# $FreeBSD$
|
||||
|
||||
include GENERIC
|
||||
|
||||
ident GENERIC-NODEBUG
|
||||
|
||||
nooptions INVARIANTS
|
||||
nooptions INVARIANT_SUPPORT
|
||||
nooptions WITNESS
|
||||
nooptions WITNESS_SKIPSPIN
|
||||
nooptions BUF_TRACKING
|
||||
nooptions DEADLKRES
|
||||
nooptions FULL_BUF_TRACKING
|
||||
|
@ -69,6 +69,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include "gic_v3_reg.h"
|
||||
#include "gic_v3_var.h"
|
||||
|
||||
static bus_get_domain_t gic_v3_get_domain;
|
||||
static bus_read_ivar_t gic_v3_read_ivar;
|
||||
|
||||
static pic_disable_intr_t gic_v3_disable_intr;
|
||||
@ -97,6 +98,7 @@ static device_method_t gic_v3_methods[] = {
|
||||
DEVMETHOD(device_detach, gic_v3_detach),
|
||||
|
||||
/* Bus interface */
|
||||
DEVMETHOD(bus_get_domain, gic_v3_get_domain),
|
||||
DEVMETHOD(bus_read_ivar, gic_v3_read_ivar),
|
||||
|
||||
/* Interrupt controller interface */
|
||||
@ -350,6 +352,19 @@ gic_v3_detach(device_t dev)
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
gic_v3_get_domain(device_t dev, device_t child, int *domain)
|
||||
{
|
||||
struct gic_v3_devinfo *di;
|
||||
|
||||
di = device_get_ivars(child);
|
||||
if (di->gic_domain < 0)
|
||||
return (ENOENT);
|
||||
|
||||
*domain = di->gic_domain;
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
gic_v3_read_ivar(device_t dev, device_t child, int which, uintptr_t *result)
|
||||
{
|
||||
|
@ -186,6 +186,7 @@ gic_v3_fdt_attach(device_t dev)
|
||||
|
||||
/* OFW bus interface */
|
||||
struct gic_v3_ofw_devinfo {
|
||||
struct gic_v3_devinfo di_gic_dinfo;
|
||||
struct ofw_bus_devinfo di_dinfo;
|
||||
struct resource_list di_rl;
|
||||
};
|
||||
@ -281,6 +282,14 @@ gic_v3_ofw_bus_attach(device_t dev)
|
||||
for (node = OF_child(parent); node > 0; node = OF_peer(node)) {
|
||||
/* Allocate and populate devinfo. */
|
||||
di = malloc(sizeof(*di), M_GIC_V3, M_WAITOK | M_ZERO);
|
||||
|
||||
/* Read the numa node, or -1 if there is none */
|
||||
if (OF_getencprop(node, "numa-node-id",
|
||||
&di->di_gic_dinfo.gic_domain,
|
||||
sizeof(di->di_gic_dinfo.gic_domain)) <= 0) {
|
||||
di->di_gic_dinfo.gic_domain = -1;
|
||||
}
|
||||
|
||||
if (ofw_bus_gen_setup_devinfo(&di->di_dinfo, node)) {
|
||||
if (bootverbose) {
|
||||
device_printf(dev,
|
||||
|
@ -82,6 +82,11 @@ struct gic_v3_softc {
|
||||
struct gic_v3_irqsrc *gic_irqs;
|
||||
};
|
||||
|
||||
|
||||
struct gic_v3_devinfo {
|
||||
int gic_domain;
|
||||
};
|
||||
|
||||
#define GIC_INTR_ISRC(sc, irq) (&sc->gic_irqs[irq].gi_isrc)
|
||||
|
||||
MALLOC_DECLARE(M_GIC_V3);
|
||||
|
@ -576,6 +576,12 @@ its_init_cpu(device_t dev, struct gicv3_its_softc *sc)
|
||||
uint64_t xbaser, tmp;
|
||||
uint32_t ctlr;
|
||||
u_int cpuid;
|
||||
int domain;
|
||||
|
||||
if (bus_get_domain(dev, &domain) == 0) {
|
||||
if (PCPU_GET(domain) != domain)
|
||||
return (0);
|
||||
}
|
||||
|
||||
gicv3 = device_get_parent(dev);
|
||||
cpuid = PCPU_GET(cpuid);
|
||||
|
@ -67,6 +67,7 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
#ifdef FDT
|
||||
#include <dev/ofw/openfirm.h>
|
||||
#include <dev/ofw/ofw_bus.h>
|
||||
#include <dev/ofw/ofw_cpu.h>
|
||||
#endif
|
||||
|
||||
@ -197,6 +198,10 @@ arm64_cpu_attach(device_t dev)
|
||||
/* Set the device to start it later */
|
||||
cpu_list[cpuid] = dev;
|
||||
|
||||
/* Try to read the numa node of this cpu */
|
||||
OF_getencprop(ofw_bus_get_node(dev), "numa-node-id",
|
||||
&__pcpu[cpuid].pc_domain, sizeof(__pcpu[cpuid].pc_domain));
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
38
sys/boot/efi/include/efi_driver_utils.h
Normal file
38
sys/boot/efi/include/efi_driver_utils.h
Normal file
@ -0,0 +1,38 @@
|
||||
/*-
|
||||
* Copyright (c) 2017 Eric McCorkle
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef _EFI_DRIVER_UTILS_H_
|
||||
#define _EFI_DRIVER_UTILS_H_
|
||||
|
||||
#include <efi.h>
|
||||
#include <efiprot.h>
|
||||
|
||||
extern EFI_STATUS install_driver(EFI_DRIVER_BINDING *driver);
|
||||
extern EFI_STATUS connect_controllers(EFI_GUID *filter);
|
||||
|
||||
#endif
|
45
sys/boot/efi/include/efi_drivers.h
Normal file
45
sys/boot/efi/include/efi_drivers.h
Normal file
@ -0,0 +1,45 @@
|
||||
/*-
|
||||
* Copyright (c) 2016 Eric McCorkle
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef _EFI_DRIVERS_H_
|
||||
#define _EFI_DRIVERS_H_
|
||||
|
||||
#include <bootstrap.h>
|
||||
|
||||
typedef struct efi_driver_t {
|
||||
const char *name;
|
||||
void (*init)(void);
|
||||
} efi_driver_t;
|
||||
|
||||
extern struct devsw efipart_dev;
|
||||
extern int efipart_getdesc(struct devdesc *dev, char **out);
|
||||
|
||||
/* EFI drivers. */
|
||||
extern const efi_driver_t fs_driver;
|
||||
|
||||
#endif
|
@ -64,6 +64,11 @@ pdinfo_list_t *efiblk_get_pdinfo_list(struct devsw *dev);
|
||||
|
||||
void *efi_get_table(EFI_GUID *tbl);
|
||||
|
||||
int efi_getdev(void **vdev, const char *devspec, const char **path);
|
||||
char *efi_fmtdev(void *vdev);
|
||||
int efi_setcurrdev(struct env_var *ev, int flags, const void *value);
|
||||
|
||||
|
||||
int efi_register_handles(struct devsw *, EFI_HANDLE *, EFI_HANDLE *, int);
|
||||
EFI_HANDLE efi_find_handle(struct devsw *, int);
|
||||
int efi_handle_lookup(EFI_HANDLE, struct devsw **, int *, uint64_t *);
|
||||
@ -79,6 +84,7 @@ CHAR16 *efi_devpath_name(EFI_DEVICE_PATH *);
|
||||
void efi_free_devpath_name(CHAR16 *);
|
||||
|
||||
int efi_status_to_errno(EFI_STATUS);
|
||||
EFI_STATUS errno_to_efi_status(int errno);
|
||||
|
||||
void efi_time_init(void);
|
||||
void efi_time_fini(void);
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user