2018-08-28 10:47:58 +00:00
|
|
|
/* $OpenBSD: monitor_wrap.c,v 1.107 2018/07/20 03:46:34 djm Exp $ */
|
2002-06-23 14:01:54 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2002 Niels Provos <provos@citi.umich.edu>
|
|
|
|
* Copyright 2002 Markus Friedl <markus@openbsd.org>
|
|
|
|
* 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 ``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 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "includes.h"
|
2006-09-30 13:29:51 +00:00
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/uio.h>
|
|
|
|
|
|
|
|
#include <errno.h>
|
|
|
|
#include <pwd.h>
|
|
|
|
#include <signal.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <unistd.h>
|
2002-06-23 14:01:54 +00:00
|
|
|
|
2015-01-05 16:09:55 +00:00
|
|
|
#ifdef WITH_OPENSSL
|
2002-06-23 14:01:54 +00:00
|
|
|
#include <openssl/bn.h>
|
|
|
|
#include <openssl/dh.h>
|
2009-02-24 18:49:27 +00:00
|
|
|
#include <openssl/evp.h>
|
2015-01-05 16:09:55 +00:00
|
|
|
#endif
|
2002-06-23 14:01:54 +00:00
|
|
|
|
2008-07-23 09:33:08 +00:00
|
|
|
#include "openbsd-compat/sys-queue.h"
|
2006-09-30 13:29:51 +00:00
|
|
|
#include "xmalloc.h"
|
2002-06-23 14:01:54 +00:00
|
|
|
#include "ssh.h"
|
2015-01-05 16:09:55 +00:00
|
|
|
#ifdef WITH_OPENSSL
|
2002-06-23 14:01:54 +00:00
|
|
|
#include "dh.h"
|
2015-01-05 16:09:55 +00:00
|
|
|
#endif
|
2018-08-28 10:47:58 +00:00
|
|
|
#include "sshbuf.h"
|
|
|
|
#include "sshkey.h"
|
2006-09-30 13:29:51 +00:00
|
|
|
#include "cipher.h"
|
2002-06-23 14:01:54 +00:00
|
|
|
#include "kex.h"
|
2006-09-30 13:29:51 +00:00
|
|
|
#include "hostfile.h"
|
2002-06-23 14:01:54 +00:00
|
|
|
#include "auth.h"
|
2003-04-23 16:53:02 +00:00
|
|
|
#include "auth-options.h"
|
2002-06-23 14:01:54 +00:00
|
|
|
#include "packet.h"
|
|
|
|
#include "mac.h"
|
|
|
|
#include "log.h"
|
2017-01-31 12:29:48 +00:00
|
|
|
#include "auth-pam.h"
|
2002-06-23 14:01:54 +00:00
|
|
|
#include "monitor.h"
|
2006-09-30 13:29:51 +00:00
|
|
|
#ifdef GSSAPI
|
|
|
|
#include "ssh-gss.h"
|
|
|
|
#endif
|
2002-06-23 14:01:54 +00:00
|
|
|
#include "monitor_wrap.h"
|
|
|
|
#include "atomicio.h"
|
|
|
|
#include "monitor_fdpass.h"
|
2006-09-30 13:29:51 +00:00
|
|
|
#include "misc.h"
|
2002-06-23 14:01:54 +00:00
|
|
|
|
|
|
|
#include "channels.h"
|
|
|
|
#include "session.h"
|
2008-07-23 09:15:38 +00:00
|
|
|
#include "servconf.h"
|
2002-06-23 14:01:54 +00:00
|
|
|
|
2015-07-02 13:15:34 +00:00
|
|
|
#include "ssherr.h"
|
|
|
|
|
2002-06-23 14:01:54 +00:00
|
|
|
/* Imports */
|
|
|
|
extern struct monitor *pmonitor;
|
2018-08-28 10:47:58 +00:00
|
|
|
extern struct sshbuf *loginmsg;
|
2004-01-07 11:10:17 +00:00
|
|
|
extern ServerOptions options;
|
2002-06-23 14:01:54 +00:00
|
|
|
|
2011-09-28 08:14:41 +00:00
|
|
|
void
|
|
|
|
mm_log_handler(LogLevel level, const char *msg, void *ctx)
|
|
|
|
{
|
2018-08-28 10:47:58 +00:00
|
|
|
struct sshbuf *log_msg;
|
2011-09-28 08:14:41 +00:00
|
|
|
struct monitor *mon = (struct monitor *)ctx;
|
2018-08-28 10:47:58 +00:00
|
|
|
int r;
|
|
|
|
size_t len;
|
2011-09-28 08:14:41 +00:00
|
|
|
|
|
|
|
if (mon->m_log_sendfd == -1)
|
|
|
|
fatal("%s: no log channel", __func__);
|
|
|
|
|
2018-08-28 10:47:58 +00:00
|
|
|
if ((log_msg = sshbuf_new()) == NULL)
|
|
|
|
fatal("%s: sshbuf_new failed", __func__);
|
2011-09-28 08:14:41 +00:00
|
|
|
|
2018-08-28 10:47:58 +00:00
|
|
|
if ((r = sshbuf_put_u32(log_msg, 0)) != 0 || /* length; filled below */
|
|
|
|
(r = sshbuf_put_u32(log_msg, level)) != 0 ||
|
|
|
|
(r = sshbuf_put_cstring(log_msg, msg)) != 0)
|
|
|
|
fatal("%s: buffer error: %s", __func__, ssh_err(r));
|
|
|
|
if ((len = sshbuf_len(log_msg)) < 4 || len > 0xffffffff)
|
|
|
|
fatal("%s: bad length %zu", __func__, len);
|
|
|
|
POKE_U32(sshbuf_mutable_ptr(log_msg), len - 4);
|
|
|
|
if (atomicio(vwrite, mon->m_log_sendfd,
|
|
|
|
sshbuf_mutable_ptr(log_msg), len) != len)
|
2011-09-28 08:14:41 +00:00
|
|
|
fatal("%s: write: %s", __func__, strerror(errno));
|
2018-08-28 10:47:58 +00:00
|
|
|
sshbuf_free(log_msg);
|
2011-09-28 08:14:41 +00:00
|
|
|
}
|
|
|
|
|
2004-02-26 10:38:49 +00:00
|
|
|
int
|
|
|
|
mm_is_monitor(void)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* m_pid is only set in the privileged part, and
|
|
|
|
* points to the unprivileged child.
|
|
|
|
*/
|
|
|
|
return (pmonitor && pmonitor->m_pid > 0);
|
|
|
|
}
|
|
|
|
|
2002-06-23 14:01:54 +00:00
|
|
|
void
|
2018-08-28 10:47:58 +00:00
|
|
|
mm_request_send(int sock, enum monitor_reqtype type, struct sshbuf *m)
|
2002-06-23 14:01:54 +00:00
|
|
|
{
|
2018-08-28 10:47:58 +00:00
|
|
|
size_t mlen = sshbuf_len(m);
|
2002-10-29 09:43:00 +00:00
|
|
|
u_char buf[5];
|
2002-06-23 14:01:54 +00:00
|
|
|
|
|
|
|
debug3("%s entering: type %d", __func__, type);
|
|
|
|
|
2018-08-28 10:47:58 +00:00
|
|
|
if (mlen >= 0xffffffff)
|
|
|
|
fatal("%s: bad length %zu", __func__, mlen);
|
|
|
|
POKE_U32(buf, mlen + 1);
|
2002-06-23 14:01:54 +00:00
|
|
|
buf[4] = (u_char) type; /* 1st byte of payload is mesg-type */
|
2004-10-28 16:03:53 +00:00
|
|
|
if (atomicio(vwrite, sock, buf, sizeof(buf)) != sizeof(buf))
|
2005-09-03 06:59:33 +00:00
|
|
|
fatal("%s: write: %s", __func__, strerror(errno));
|
2018-08-28 10:47:58 +00:00
|
|
|
if (atomicio(vwrite, sock, sshbuf_mutable_ptr(m), mlen) != mlen)
|
2005-09-03 06:59:33 +00:00
|
|
|
fatal("%s: write: %s", __func__, strerror(errno));
|
2002-06-23 14:01:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2018-08-28 10:47:58 +00:00
|
|
|
mm_request_receive(int sock, struct sshbuf *m)
|
2002-06-23 14:01:54 +00:00
|
|
|
{
|
2018-08-28 10:47:58 +00:00
|
|
|
u_char buf[4], *p = NULL;
|
2002-06-23 14:01:54 +00:00
|
|
|
u_int msg_len;
|
2018-08-28 10:47:58 +00:00
|
|
|
int r;
|
2002-06-23 14:01:54 +00:00
|
|
|
|
|
|
|
debug3("%s entering", __func__);
|
|
|
|
|
2005-09-03 06:59:33 +00:00
|
|
|
if (atomicio(read, sock, buf, sizeof(buf)) != sizeof(buf)) {
|
2015-07-02 13:18:50 +00:00
|
|
|
if (errno == EPIPE)
|
2004-02-26 10:38:49 +00:00
|
|
|
cleanup_exit(255);
|
2005-09-03 06:59:33 +00:00
|
|
|
fatal("%s: read: %s", __func__, strerror(errno));
|
2002-06-23 14:01:54 +00:00
|
|
|
}
|
2018-08-28 10:47:58 +00:00
|
|
|
msg_len = PEEK_U32(buf);
|
2002-06-23 14:01:54 +00:00
|
|
|
if (msg_len > 256 * 1024)
|
|
|
|
fatal("%s: read: bad msg_len %d", __func__, msg_len);
|
2018-08-28 10:47:58 +00:00
|
|
|
sshbuf_reset(m);
|
|
|
|
if ((r = sshbuf_reserve(m, msg_len, &p)) != 0)
|
|
|
|
fatal("%s: buffer error: %s", __func__, ssh_err(r));
|
|
|
|
if (atomicio(read, sock, p, msg_len) != msg_len)
|
2005-09-03 06:59:33 +00:00
|
|
|
fatal("%s: read: %s", __func__, strerror(errno));
|
2002-06-23 14:01:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2018-08-28 10:47:58 +00:00
|
|
|
mm_request_receive_expect(int sock, enum monitor_reqtype type, struct sshbuf *m)
|
2002-06-23 14:01:54 +00:00
|
|
|
{
|
|
|
|
u_char rtype;
|
2018-08-28 10:47:58 +00:00
|
|
|
int r;
|
2002-06-23 14:01:54 +00:00
|
|
|
|
|
|
|
debug3("%s entering: type %d", __func__, type);
|
|
|
|
|
2004-10-28 16:03:53 +00:00
|
|
|
mm_request_receive(sock, m);
|
2018-08-28 10:47:58 +00:00
|
|
|
if ((r = sshbuf_get_u8(m, &rtype)) != 0)
|
|
|
|
fatal("%s: buffer error: %s", __func__, ssh_err(r));
|
2002-06-23 14:01:54 +00:00
|
|
|
if (rtype != type)
|
|
|
|
fatal("%s: read: rtype %d != type %d", __func__,
|
|
|
|
rtype, type);
|
|
|
|
}
|
|
|
|
|
2015-01-05 16:09:55 +00:00
|
|
|
#ifdef WITH_OPENSSL
|
2002-06-23 14:01:54 +00:00
|
|
|
DH *
|
|
|
|
mm_choose_dh(int min, int nbits, int max)
|
|
|
|
{
|
|
|
|
BIGNUM *p, *g;
|
2018-08-28 10:47:58 +00:00
|
|
|
int r;
|
|
|
|
u_char success = 0;
|
|
|
|
struct sshbuf *m;
|
2002-06-23 14:01:54 +00:00
|
|
|
|
2018-08-28 10:47:58 +00:00
|
|
|
if ((m = sshbuf_new()) == NULL)
|
|
|
|
fatal("%s: sshbuf_new failed", __func__);
|
|
|
|
if ((r = sshbuf_put_u32(m, min)) != 0 ||
|
|
|
|
(r = sshbuf_put_u32(m, nbits)) != 0 ||
|
|
|
|
(r = sshbuf_put_u32(m, max)) != 0)
|
|
|
|
fatal("%s: buffer error: %s", __func__, ssh_err(r));
|
2002-06-23 14:01:54 +00:00
|
|
|
|
2018-08-28 10:47:58 +00:00
|
|
|
mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_MODULI, m);
|
2002-06-23 14:01:54 +00:00
|
|
|
|
|
|
|
debug3("%s: waiting for MONITOR_ANS_MODULI", __func__);
|
2018-08-28 10:47:58 +00:00
|
|
|
mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_MODULI, m);
|
2002-06-23 14:01:54 +00:00
|
|
|
|
2018-08-28 10:47:58 +00:00
|
|
|
if ((r = sshbuf_get_u8(m, &success)) != 0)
|
|
|
|
fatal("%s: buffer error: %s", __func__, ssh_err(r));
|
2002-06-23 14:01:54 +00:00
|
|
|
if (success == 0)
|
|
|
|
fatal("%s: MONITOR_ANS_MODULI failed", __func__);
|
|
|
|
|
|
|
|
if ((p = BN_new()) == NULL)
|
|
|
|
fatal("%s: BN_new failed", __func__);
|
|
|
|
if ((g = BN_new()) == NULL)
|
|
|
|
fatal("%s: BN_new failed", __func__);
|
2018-08-28 10:47:58 +00:00
|
|
|
if ((r = sshbuf_get_bignum2(m, p)) != 0 ||
|
|
|
|
(r = sshbuf_get_bignum2(m, g)) != 0)
|
|
|
|
fatal("%s: buffer error: %s", __func__, ssh_err(r));
|
2002-06-23 14:01:54 +00:00
|
|
|
|
2018-08-28 10:47:58 +00:00
|
|
|
debug3("%s: remaining %zu", __func__, sshbuf_len(m));
|
|
|
|
sshbuf_free(m);
|
2002-06-23 14:01:54 +00:00
|
|
|
|
|
|
|
return (dh_new_group(g, p));
|
|
|
|
}
|
2015-01-05 16:09:55 +00:00
|
|
|
#endif
|
2002-06-23 14:01:54 +00:00
|
|
|
|
|
|
|
int
|
2018-08-28 10:47:58 +00:00
|
|
|
mm_sshkey_sign(struct sshkey *key, u_char **sigp, size_t *lenp,
|
|
|
|
const u_char *data, size_t datalen, const char *hostkey_alg, u_int compat)
|
2002-06-23 14:01:54 +00:00
|
|
|
{
|
2015-07-02 13:15:34 +00:00
|
|
|
struct kex *kex = *pmonitor->m_pkex;
|
2018-08-28 10:47:58 +00:00
|
|
|
struct sshbuf *m;
|
|
|
|
u_int ndx = kex->host_key_index(key, 0, active_state);
|
|
|
|
int r;
|
2002-06-23 14:01:54 +00:00
|
|
|
|
|
|
|
debug3("%s entering", __func__);
|
|
|
|
|
2018-08-28 10:47:58 +00:00
|
|
|
if ((m = sshbuf_new()) == NULL)
|
|
|
|
fatal("%s: sshbuf_new failed", __func__);
|
|
|
|
if ((r = sshbuf_put_u32(m, ndx)) != 0 ||
|
|
|
|
(r = sshbuf_put_string(m, data, datalen)) != 0 ||
|
|
|
|
(r = sshbuf_put_cstring(m, hostkey_alg)) != 0 ||
|
|
|
|
(r = sshbuf_put_u32(m, compat)) != 0)
|
|
|
|
fatal("%s: buffer error: %s", __func__, ssh_err(r));
|
2002-06-23 14:01:54 +00:00
|
|
|
|
2018-08-28 10:47:58 +00:00
|
|
|
mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_SIGN, m);
|
2002-06-23 14:01:54 +00:00
|
|
|
|
|
|
|
debug3("%s: waiting for MONITOR_ANS_SIGN", __func__);
|
2018-08-28 10:47:58 +00:00
|
|
|
mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_SIGN, m);
|
|
|
|
if ((r = sshbuf_get_string(m, sigp, lenp)) != 0)
|
|
|
|
fatal("%s: buffer error: %s", __func__, ssh_err(r));
|
|
|
|
sshbuf_free(m);
|
2002-06-23 14:01:54 +00:00
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct passwd *
|
2004-10-28 16:03:53 +00:00
|
|
|
mm_getpwnamallow(const char *username)
|
2002-06-23 14:01:54 +00:00
|
|
|
{
|
2018-05-06 12:24:45 +00:00
|
|
|
struct ssh *ssh = active_state; /* XXX */
|
2018-08-28 10:47:58 +00:00
|
|
|
struct sshbuf *m;
|
2002-06-23 14:01:54 +00:00
|
|
|
struct passwd *pw;
|
2018-08-28 10:47:58 +00:00
|
|
|
size_t len;
|
|
|
|
u_int i;
|
2008-07-23 09:15:38 +00:00
|
|
|
ServerOptions *newopts;
|
2018-08-28 10:47:58 +00:00
|
|
|
int r;
|
|
|
|
u_char ok;
|
|
|
|
const u_char *p;
|
2002-06-23 14:01:54 +00:00
|
|
|
|
|
|
|
debug3("%s entering", __func__);
|
|
|
|
|
2018-08-28 10:47:58 +00:00
|
|
|
if ((m = sshbuf_new()) == NULL)
|
|
|
|
fatal("%s: sshbuf_new failed", __func__);
|
|
|
|
if ((r = sshbuf_put_cstring(m, username)) != 0)
|
|
|
|
fatal("%s: buffer error: %s", __func__, ssh_err(r));
|
2002-06-23 14:01:54 +00:00
|
|
|
|
2018-08-28 10:47:58 +00:00
|
|
|
mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_PWNAM, m);
|
2002-06-23 14:01:54 +00:00
|
|
|
|
|
|
|
debug3("%s: waiting for MONITOR_ANS_PWNAM", __func__);
|
2018-08-28 10:47:58 +00:00
|
|
|
mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_PWNAM, m);
|
2002-06-23 14:01:54 +00:00
|
|
|
|
2018-08-28 10:47:58 +00:00
|
|
|
if ((r = sshbuf_get_u8(m, &ok)) != 0)
|
|
|
|
fatal("%s: buffer error: %s", __func__, ssh_err(r));
|
|
|
|
if (ok == 0) {
|
2008-07-23 09:28:49 +00:00
|
|
|
pw = NULL;
|
|
|
|
goto out;
|
2002-06-23 14:01:54 +00:00
|
|
|
}
|
2018-08-28 10:47:58 +00:00
|
|
|
|
|
|
|
/* XXX don't like passing struct passwd like this */
|
|
|
|
pw = xcalloc(sizeof(*pw), 1);
|
|
|
|
if ((r = sshbuf_get_string_direct(m, &p, &len)) != 0)
|
|
|
|
fatal("%s: buffer error: %s", __func__, ssh_err(r));
|
|
|
|
if (len != sizeof(*pw))
|
2002-06-23 14:01:54 +00:00
|
|
|
fatal("%s: struct passwd size mismatch", __func__);
|
2018-08-28 10:47:58 +00:00
|
|
|
memcpy(pw, p, sizeof(*pw));
|
|
|
|
|
|
|
|
if ((r = sshbuf_get_cstring(m, &pw->pw_name, NULL)) != 0 ||
|
|
|
|
(r = sshbuf_get_cstring(m, &pw->pw_passwd, NULL)) != 0 ||
|
2013-09-18 17:27:38 +00:00
|
|
|
#ifdef HAVE_STRUCT_PASSWD_PW_GECOS
|
2018-08-28 10:47:58 +00:00
|
|
|
(r = sshbuf_get_cstring(m, &pw->pw_gecos, NULL)) != 0 ||
|
2013-09-18 17:27:38 +00:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_STRUCT_PASSWD_PW_CLASS
|
2018-08-28 10:47:58 +00:00
|
|
|
(r = sshbuf_get_cstring(m, &pw->pw_class, NULL)) != 0 ||
|
2002-06-27 22:31:32 +00:00
|
|
|
#endif
|
2018-08-28 10:47:58 +00:00
|
|
|
(r = sshbuf_get_cstring(m, &pw->pw_dir, NULL)) != 0 ||
|
|
|
|
(r = sshbuf_get_cstring(m, &pw->pw_shell, NULL)) != 0)
|
|
|
|
fatal("%s: buffer error: %s", __func__, ssh_err(r));
|
2008-07-23 09:15:38 +00:00
|
|
|
|
2008-07-23 09:28:49 +00:00
|
|
|
out:
|
2008-07-23 09:15:38 +00:00
|
|
|
/* copy options block as a Match directive may have changed some */
|
2018-08-28 10:47:58 +00:00
|
|
|
if ((r = sshbuf_get_string_direct(m, &p, &len)) != 0)
|
|
|
|
fatal("%s: buffer error: %s", __func__, ssh_err(r));
|
2008-07-23 09:15:38 +00:00
|
|
|
if (len != sizeof(*newopts))
|
|
|
|
fatal("%s: option block size mismatch", __func__);
|
2018-08-28 10:47:58 +00:00
|
|
|
newopts = xcalloc(sizeof(*newopts), 1);
|
|
|
|
memcpy(newopts, p, sizeof(*newopts));
|
2011-09-28 08:14:41 +00:00
|
|
|
|
|
|
|
#define M_CP_STROPT(x) do { \
|
2018-08-28 10:47:58 +00:00
|
|
|
if (newopts->x != NULL) { \
|
|
|
|
if ((r = sshbuf_get_cstring(m, \
|
|
|
|
&newopts->x, NULL)) != 0) \
|
|
|
|
fatal("%s: buffer error: %s", \
|
|
|
|
__func__, ssh_err(r)); \
|
|
|
|
} \
|
2011-09-28 08:14:41 +00:00
|
|
|
} while (0)
|
|
|
|
#define M_CP_STRARRAYOPT(x, nx) do { \
|
2018-05-06 12:24:45 +00:00
|
|
|
newopts->x = newopts->nx == 0 ? \
|
|
|
|
NULL : xcalloc(newopts->nx, sizeof(*newopts->x)); \
|
2018-08-28 10:47:58 +00:00
|
|
|
for (i = 0; i < newopts->nx; i++) { \
|
|
|
|
if ((r = sshbuf_get_cstring(m, \
|
|
|
|
&newopts->x[i], NULL)) != 0) \
|
|
|
|
fatal("%s: buffer error: %s", \
|
|
|
|
__func__, ssh_err(r)); \
|
|
|
|
} \
|
2018-05-06 12:24:45 +00:00
|
|
|
} while (0)
|
2011-09-28 08:14:41 +00:00
|
|
|
/* See comment in servconf.h */
|
|
|
|
COPY_MATCH_STRING_OPTS();
|
|
|
|
#undef M_CP_STROPT
|
|
|
|
#undef M_CP_STRARRAYOPT
|
|
|
|
|
2008-07-23 09:15:38 +00:00
|
|
|
copy_set_server_options(&options, newopts, 1);
|
2018-05-06 12:24:45 +00:00
|
|
|
log_change_level(options.log_level);
|
|
|
|
process_permitopen(ssh, &options);
|
2013-09-18 17:27:38 +00:00
|
|
|
free(newopts);
|
2008-07-23 09:15:38 +00:00
|
|
|
|
2018-08-28 10:47:58 +00:00
|
|
|
sshbuf_free(m);
|
2002-06-23 14:01:54 +00:00
|
|
|
|
|
|
|
return (pw);
|
|
|
|
}
|
|
|
|
|
2004-02-26 10:38:49 +00:00
|
|
|
char *
|
|
|
|
mm_auth2_read_banner(void)
|
2002-06-23 14:01:54 +00:00
|
|
|
{
|
2018-08-28 10:47:58 +00:00
|
|
|
struct sshbuf *m;
|
2002-06-23 14:01:54 +00:00
|
|
|
char *banner;
|
2018-08-28 10:47:58 +00:00
|
|
|
int r;
|
2002-06-23 14:01:54 +00:00
|
|
|
|
|
|
|
debug3("%s entering", __func__);
|
|
|
|
|
2018-08-28 10:47:58 +00:00
|
|
|
if ((m = sshbuf_new()) == NULL)
|
|
|
|
fatal("%s: sshbuf_new failed", __func__);
|
|
|
|
mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_AUTH2_READ_BANNER, m);
|
|
|
|
sshbuf_reset(m);
|
2002-06-23 14:01:54 +00:00
|
|
|
|
2004-02-26 10:38:49 +00:00
|
|
|
mm_request_receive_expect(pmonitor->m_recvfd,
|
2018-08-28 10:47:58 +00:00
|
|
|
MONITOR_ANS_AUTH2_READ_BANNER, m);
|
|
|
|
if ((r = sshbuf_get_cstring(m, &banner, NULL)) != 0)
|
|
|
|
fatal("%s: buffer error: %s", __func__, ssh_err(r));
|
|
|
|
sshbuf_free(m);
|
2002-06-23 14:01:54 +00:00
|
|
|
|
2004-02-26 10:38:49 +00:00
|
|
|
/* treat empty banner as missing banner */
|
|
|
|
if (strlen(banner) == 0) {
|
2013-09-18 17:27:38 +00:00
|
|
|
free(banner);
|
2004-02-26 10:38:49 +00:00
|
|
|
banner = NULL;
|
|
|
|
}
|
2002-06-23 14:01:54 +00:00
|
|
|
return (banner);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Inform the privileged process about service and style */
|
|
|
|
|
|
|
|
void
|
|
|
|
mm_inform_authserv(char *service, char *style)
|
|
|
|
{
|
2018-08-28 10:47:58 +00:00
|
|
|
struct sshbuf *m;
|
|
|
|
int r;
|
2002-06-23 14:01:54 +00:00
|
|
|
|
|
|
|
debug3("%s entering", __func__);
|
|
|
|
|
2018-08-28 10:47:58 +00:00
|
|
|
if ((m = sshbuf_new()) == NULL)
|
|
|
|
fatal("%s: sshbuf_new failed", __func__);
|
|
|
|
if ((r = sshbuf_put_cstring(m, service)) != 0 ||
|
|
|
|
(r = sshbuf_put_cstring(m, style ? style : "")) != 0)
|
|
|
|
fatal("%s: buffer error: %s", __func__, ssh_err(r));
|
2002-06-23 14:01:54 +00:00
|
|
|
|
2018-08-28 10:47:58 +00:00
|
|
|
mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_AUTHSERV, m);
|
2002-06-23 14:01:54 +00:00
|
|
|
|
2018-08-28 10:47:58 +00:00
|
|
|
sshbuf_free(m);
|
2002-06-23 14:01:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Do the password authentication */
|
|
|
|
int
|
2018-05-06 12:27:04 +00:00
|
|
|
mm_auth_password(struct ssh *ssh, char *password)
|
2002-06-23 14:01:54 +00:00
|
|
|
{
|
2018-08-28 10:47:58 +00:00
|
|
|
struct sshbuf *m;
|
|
|
|
int r, authenticated = 0;
|
|
|
|
#ifdef USE_PAM
|
|
|
|
u_int maxtries = 0;
|
|
|
|
#endif
|
2002-06-23 14:01:54 +00:00
|
|
|
|
|
|
|
debug3("%s entering", __func__);
|
|
|
|
|
2018-08-28 10:47:58 +00:00
|
|
|
if ((m = sshbuf_new()) == NULL)
|
|
|
|
fatal("%s: sshbuf_new failed", __func__);
|
|
|
|
if ((r = sshbuf_put_cstring(m, password)) != 0)
|
|
|
|
fatal("%s: buffer error: %s", __func__, ssh_err(r));
|
|
|
|
mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_AUTHPASSWORD, m);
|
2002-06-23 14:01:54 +00:00
|
|
|
|
|
|
|
debug3("%s: waiting for MONITOR_ANS_AUTHPASSWORD", __func__);
|
2018-08-28 10:47:58 +00:00
|
|
|
mm_request_receive_expect(pmonitor->m_recvfd,
|
|
|
|
MONITOR_ANS_AUTHPASSWORD, m);
|
2002-06-23 14:01:54 +00:00
|
|
|
|
2018-08-28 10:47:58 +00:00
|
|
|
if ((r = sshbuf_get_u32(m, &authenticated)) != 0)
|
|
|
|
fatal("%s: buffer error: %s", __func__, ssh_err(r));
|
2017-01-31 12:29:48 +00:00
|
|
|
#ifdef USE_PAM
|
2018-08-28 10:47:58 +00:00
|
|
|
if ((r = sshbuf_get_u32(m, &maxtries)) != 0)
|
|
|
|
fatal("%s: buffer error: %s", __func__, ssh_err(r));
|
|
|
|
if (maxtries > INT_MAX)
|
|
|
|
fatal("%s: bad maxtries %u", __func__, maxtries);
|
|
|
|
sshpam_set_maxtries_reached(maxtries);
|
2017-01-31 12:29:48 +00:00
|
|
|
#endif
|
2002-06-23 14:01:54 +00:00
|
|
|
|
2018-08-28 10:47:58 +00:00
|
|
|
sshbuf_free(m);
|
2002-06-23 14:01:54 +00:00
|
|
|
|
|
|
|
debug3("%s: user %sauthenticated",
|
|
|
|
__func__, authenticated ? "" : "not ");
|
|
|
|
return (authenticated);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2018-05-06 12:27:04 +00:00
|
|
|
mm_user_key_allowed(struct ssh *ssh, struct passwd *pw, struct sshkey *key,
|
|
|
|
int pubkey_auth_attempt, struct sshauthopt **authoptp)
|
2002-06-23 14:01:54 +00:00
|
|
|
{
|
2015-07-02 13:18:50 +00:00
|
|
|
return (mm_key_allowed(MM_USERKEY, NULL, NULL, key,
|
2018-05-06 12:27:04 +00:00
|
|
|
pubkey_auth_attempt, authoptp));
|
2002-06-23 14:01:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2017-01-31 12:29:48 +00:00
|
|
|
mm_hostbased_key_allowed(struct passwd *pw, const char *user, const char *host,
|
2018-05-06 12:24:45 +00:00
|
|
|
struct sshkey *key)
|
2002-06-23 14:01:54 +00:00
|
|
|
{
|
2018-05-06 12:27:04 +00:00
|
|
|
return (mm_key_allowed(MM_HOSTKEY, user, host, key, 0, NULL));
|
2002-06-23 14:01:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2017-01-31 12:29:48 +00:00
|
|
|
mm_key_allowed(enum mm_keytype type, const char *user, const char *host,
|
2018-05-06 12:27:04 +00:00
|
|
|
struct sshkey *key, int pubkey_auth_attempt, struct sshauthopt **authoptp)
|
2002-06-23 14:01:54 +00:00
|
|
|
{
|
2018-08-28 10:47:58 +00:00
|
|
|
struct sshbuf *m;
|
2018-05-06 12:27:04 +00:00
|
|
|
int r, allowed = 0;
|
|
|
|
struct sshauthopt *opts = NULL;
|
2002-06-23 14:01:54 +00:00
|
|
|
|
|
|
|
debug3("%s entering", __func__);
|
|
|
|
|
2018-05-06 12:27:04 +00:00
|
|
|
if (authoptp != NULL)
|
|
|
|
*authoptp = NULL;
|
|
|
|
|
2018-08-28 10:47:58 +00:00
|
|
|
if ((m = sshbuf_new()) == NULL)
|
|
|
|
fatal("%s: sshbuf_new failed", __func__);
|
|
|
|
if ((r = sshbuf_put_u32(m, type)) != 0 ||
|
|
|
|
(r = sshbuf_put_cstring(m, user ? user : "")) != 0 ||
|
|
|
|
(r = sshbuf_put_cstring(m, host ? host : "")) != 0 ||
|
|
|
|
(r = sshkey_puts(key, m)) != 0 ||
|
|
|
|
(r = sshbuf_put_u32(m, pubkey_auth_attempt)) != 0)
|
|
|
|
fatal("%s: buffer error: %s", __func__, ssh_err(r));
|
2002-06-23 14:01:54 +00:00
|
|
|
|
2018-08-28 10:47:58 +00:00
|
|
|
mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_KEYALLOWED, m);
|
2002-06-23 14:01:54 +00:00
|
|
|
|
|
|
|
debug3("%s: waiting for MONITOR_ANS_KEYALLOWED", __func__);
|
2018-05-06 12:27:04 +00:00
|
|
|
mm_request_receive_expect(pmonitor->m_recvfd,
|
2018-08-28 10:47:58 +00:00
|
|
|
MONITOR_ANS_KEYALLOWED, m);
|
2002-06-23 14:01:54 +00:00
|
|
|
|
2018-08-28 10:47:58 +00:00
|
|
|
if ((r = sshbuf_get_u32(m, &allowed)) != 0)
|
|
|
|
fatal("%s: buffer error: %s", __func__, ssh_err(r));
|
2018-05-06 12:27:04 +00:00
|
|
|
if (allowed && type == MM_USERKEY) {
|
2018-08-28 10:47:58 +00:00
|
|
|
if ((r = sshauthopt_deserialise(m, &opts)) != 0)
|
2018-05-06 12:27:04 +00:00
|
|
|
fatal("%s: sshauthopt_deserialise: %s",
|
|
|
|
__func__, ssh_err(r));
|
|
|
|
}
|
2018-08-28 10:47:58 +00:00
|
|
|
sshbuf_free(m);
|
2002-06-23 14:01:54 +00:00
|
|
|
|
2018-05-06 12:27:04 +00:00
|
|
|
if (authoptp != NULL) {
|
|
|
|
*authoptp = opts;
|
|
|
|
opts = NULL;
|
|
|
|
}
|
|
|
|
sshauthopt_free(opts);
|
|
|
|
|
|
|
|
return allowed;
|
2002-06-23 14:01:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This key verify needs to send the key type along, because the
|
|
|
|
* privileged parent makes the decision if the key is allowed
|
|
|
|
* for authentication.
|
|
|
|
*/
|
|
|
|
|
|
|
|
int
|
2018-05-06 12:24:45 +00:00
|
|
|
mm_sshkey_verify(const struct sshkey *key, const u_char *sig, size_t siglen,
|
2018-05-06 12:27:04 +00:00
|
|
|
const u_char *data, size_t datalen, const char *sigalg, u_int compat)
|
2002-06-23 14:01:54 +00:00
|
|
|
{
|
2018-08-28 10:47:58 +00:00
|
|
|
struct sshbuf *m;
|
2018-05-06 12:24:45 +00:00
|
|
|
u_int encoded_ret = 0;
|
2018-08-28 10:47:58 +00:00
|
|
|
int r;
|
2002-06-23 14:01:54 +00:00
|
|
|
|
|
|
|
debug3("%s entering", __func__);
|
|
|
|
|
|
|
|
|
2018-08-28 10:47:58 +00:00
|
|
|
if ((m = sshbuf_new()) == NULL)
|
|
|
|
fatal("%s: sshbuf_new failed", __func__);
|
|
|
|
if ((r = sshkey_puts(key, m)) != 0 ||
|
|
|
|
(r = sshbuf_put_string(m, sig, siglen)) != 0 ||
|
|
|
|
(r = sshbuf_put_string(m, data, datalen)) != 0 ||
|
|
|
|
(r = sshbuf_put_cstring(m, sigalg == NULL ? "" : sigalg)) != 0)
|
|
|
|
fatal("%s: buffer error: %s", __func__, ssh_err(r));
|
2002-06-23 14:01:54 +00:00
|
|
|
|
2018-08-28 10:47:58 +00:00
|
|
|
mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_KEYVERIFY, m);
|
2002-06-23 14:01:54 +00:00
|
|
|
|
|
|
|
debug3("%s: waiting for MONITOR_ANS_KEYVERIFY", __func__);
|
2018-08-28 10:47:58 +00:00
|
|
|
mm_request_receive_expect(pmonitor->m_recvfd,
|
|
|
|
MONITOR_ANS_KEYVERIFY, m);
|
2002-06-23 14:01:54 +00:00
|
|
|
|
2018-08-28 10:47:58 +00:00
|
|
|
if ((r = sshbuf_get_u32(m, &encoded_ret)) != 0)
|
|
|
|
fatal("%s: buffer error: %s", __func__, ssh_err(r));
|
2002-06-23 14:01:54 +00:00
|
|
|
|
2018-08-28 10:47:58 +00:00
|
|
|
sshbuf_free(m);
|
2002-06-23 14:01:54 +00:00
|
|
|
|
2018-05-06 12:24:45 +00:00
|
|
|
if (encoded_ret != 0)
|
|
|
|
return SSH_ERR_SIGNATURE_INVALID;
|
|
|
|
return 0;
|
2002-06-23 14:01:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-10-28 16:03:53 +00:00
|
|
|
mm_send_keystate(struct monitor *monitor)
|
2002-06-23 14:01:54 +00:00
|
|
|
{
|
2015-07-02 13:15:34 +00:00
|
|
|
struct ssh *ssh = active_state; /* XXX */
|
|
|
|
struct sshbuf *m;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
if ((m = sshbuf_new()) == NULL)
|
|
|
|
fatal("%s: sshbuf_new failed", __func__);
|
|
|
|
if ((r = ssh_packet_get_state(ssh, m)) != 0)
|
|
|
|
fatal("%s: get_state failed: %s",
|
|
|
|
__func__, ssh_err(r));
|
|
|
|
mm_request_send(monitor->m_recvfd, MONITOR_REQ_KEYEXPORT, m);
|
2002-06-23 14:01:54 +00:00
|
|
|
debug3("%s: Finished sending state", __func__);
|
2015-07-02 13:15:34 +00:00
|
|
|
sshbuf_free(m);
|
2002-06-23 14:01:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2006-09-30 13:29:51 +00:00
|
|
|
mm_pty_allocate(int *ptyfd, int *ttyfd, char *namebuf, size_t namebuflen)
|
2002-06-23 14:01:54 +00:00
|
|
|
{
|
2018-08-28 10:47:58 +00:00
|
|
|
struct sshbuf *m;
|
2004-10-28 16:03:53 +00:00
|
|
|
char *p, *msg;
|
2018-08-28 10:47:58 +00:00
|
|
|
int success = 0, tmp1 = -1, tmp2 = -1, r;
|
2008-07-23 09:33:08 +00:00
|
|
|
|
|
|
|
/* Kludge: ensure there are fds free to receive the pty/tty */
|
|
|
|
if ((tmp1 = dup(pmonitor->m_recvfd)) == -1 ||
|
|
|
|
(tmp2 = dup(pmonitor->m_recvfd)) == -1) {
|
|
|
|
error("%s: cannot allocate fds for pty", __func__);
|
|
|
|
if (tmp1 > 0)
|
|
|
|
close(tmp1);
|
|
|
|
if (tmp2 > 0)
|
|
|
|
close(tmp2);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
close(tmp1);
|
|
|
|
close(tmp2);
|
2002-06-23 14:01:54 +00:00
|
|
|
|
2018-08-28 10:47:58 +00:00
|
|
|
if ((m = sshbuf_new()) == NULL)
|
|
|
|
fatal("%s: sshbuf_new failed", __func__);
|
|
|
|
mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_PTY, m);
|
2002-06-23 14:01:54 +00:00
|
|
|
|
|
|
|
debug3("%s: waiting for MONITOR_ANS_PTY", __func__);
|
2018-08-28 10:47:58 +00:00
|
|
|
mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_PTY, m);
|
2002-06-23 14:01:54 +00:00
|
|
|
|
2018-08-28 10:47:58 +00:00
|
|
|
if ((r = sshbuf_get_u32(m, &success)) != 0)
|
|
|
|
fatal("%s: buffer error: %s", __func__, ssh_err(r));
|
2002-06-23 14:01:54 +00:00
|
|
|
if (success == 0) {
|
|
|
|
debug3("%s: pty alloc failed", __func__);
|
2018-08-28 10:47:58 +00:00
|
|
|
sshbuf_free(m);
|
2002-06-23 14:01:54 +00:00
|
|
|
return (0);
|
|
|
|
}
|
2018-08-28 10:47:58 +00:00
|
|
|
if ((r = sshbuf_get_cstring(m, &p, NULL)) != 0 ||
|
|
|
|
(r = sshbuf_get_cstring(m, &msg, NULL)) != 0)
|
|
|
|
fatal("%s: buffer error: %s", __func__, ssh_err(r));
|
|
|
|
sshbuf_free(m);
|
2002-06-23 14:01:54 +00:00
|
|
|
|
|
|
|
strlcpy(namebuf, p, namebuflen); /* Possible truncation */
|
2013-09-18 17:27:38 +00:00
|
|
|
free(p);
|
2002-06-23 14:01:54 +00:00
|
|
|
|
2018-08-28 10:47:58 +00:00
|
|
|
if ((r = sshbuf_put(loginmsg, msg, strlen(msg))) != 0)
|
|
|
|
fatal("%s: buffer error: %s", __func__, ssh_err(r));
|
2013-09-18 17:27:38 +00:00
|
|
|
free(msg);
|
2004-10-28 16:03:53 +00:00
|
|
|
|
2008-07-23 09:28:49 +00:00
|
|
|
if ((*ptyfd = mm_receive_fd(pmonitor->m_recvfd)) == -1 ||
|
|
|
|
(*ttyfd = mm_receive_fd(pmonitor->m_recvfd)) == -1)
|
|
|
|
fatal("%s: receive fds failed", __func__);
|
2002-06-23 14:01:54 +00:00
|
|
|
|
|
|
|
/* Success */
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-02-26 10:38:49 +00:00
|
|
|
mm_session_pty_cleanup2(Session *s)
|
2002-06-23 14:01:54 +00:00
|
|
|
{
|
2018-08-28 10:47:58 +00:00
|
|
|
struct sshbuf *m;
|
|
|
|
int r;
|
2002-06-23 14:01:54 +00:00
|
|
|
|
|
|
|
if (s->ttyfd == -1)
|
|
|
|
return;
|
2018-08-28 10:47:58 +00:00
|
|
|
if ((m = sshbuf_new()) == NULL)
|
|
|
|
fatal("%s: sshbuf_new failed", __func__);
|
|
|
|
if ((r = sshbuf_put_cstring(m, s->tty)) != 0)
|
|
|
|
fatal("%s: buffer error: %s", __func__, ssh_err(r));
|
|
|
|
mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_PTYCLEANUP, m);
|
|
|
|
sshbuf_free(m);
|
2002-06-23 14:01:54 +00:00
|
|
|
|
|
|
|
/* closed dup'ed master */
|
2008-07-23 09:33:08 +00:00
|
|
|
if (s->ptymaster != -1 && close(s->ptymaster) < 0)
|
|
|
|
error("close(s->ptymaster/%d): %s",
|
|
|
|
s->ptymaster, strerror(errno));
|
2002-06-23 14:01:54 +00:00
|
|
|
|
|
|
|
/* unlink pty from session */
|
|
|
|
s->ttyfd = -1;
|
|
|
|
}
|
|
|
|
|
2002-06-27 22:31:32 +00:00
|
|
|
#ifdef USE_PAM
|
|
|
|
void
|
2004-04-20 09:35:04 +00:00
|
|
|
mm_start_pam(Authctxt *authctxt)
|
2002-06-27 22:31:32 +00:00
|
|
|
{
|
2018-08-28 10:47:58 +00:00
|
|
|
struct sshbuf *m;
|
2002-06-27 22:31:32 +00:00
|
|
|
|
|
|
|
debug3("%s entering", __func__);
|
2004-01-07 11:10:17 +00:00
|
|
|
if (!options.use_pam)
|
|
|
|
fatal("UsePAM=no, but ended up in %s anyway", __func__);
|
2018-08-28 10:47:58 +00:00
|
|
|
if ((m = sshbuf_new()) == NULL)
|
|
|
|
fatal("%s: sshbuf_new failed", __func__);
|
|
|
|
mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_PAM_START, m);
|
2002-06-27 22:31:32 +00:00
|
|
|
|
2018-08-28 10:47:58 +00:00
|
|
|
sshbuf_free(m);
|
2002-06-27 22:31:32 +00:00
|
|
|
}
|
2004-01-07 11:10:17 +00:00
|
|
|
|
|
|
|
u_int
|
|
|
|
mm_do_pam_account(void)
|
|
|
|
{
|
2018-08-28 10:47:58 +00:00
|
|
|
struct sshbuf *m;
|
2004-01-07 11:10:17 +00:00
|
|
|
u_int ret;
|
2005-06-05 15:40:50 +00:00
|
|
|
char *msg;
|
2018-08-28 10:47:58 +00:00
|
|
|
size_t msglen;
|
|
|
|
int r;
|
2004-01-07 11:10:17 +00:00
|
|
|
|
|
|
|
debug3("%s entering", __func__);
|
|
|
|
if (!options.use_pam)
|
|
|
|
fatal("UsePAM=no, but ended up in %s anyway", __func__);
|
|
|
|
|
2018-08-28 10:47:58 +00:00
|
|
|
if ((m = sshbuf_new()) == NULL)
|
|
|
|
fatal("%s: sshbuf_new failed", __func__);
|
|
|
|
mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_PAM_ACCOUNT, m);
|
2004-01-07 11:10:17 +00:00
|
|
|
|
2004-02-26 10:38:49 +00:00
|
|
|
mm_request_receive_expect(pmonitor->m_recvfd,
|
2018-08-28 10:47:58 +00:00
|
|
|
MONITOR_ANS_PAM_ACCOUNT, m);
|
|
|
|
if ((r = sshbuf_get_u32(m, &ret)) != 0 ||
|
|
|
|
(r = sshbuf_get_cstring(m, &msg, &msglen)) != 0 ||
|
|
|
|
(r = sshbuf_put(loginmsg, msg, msglen)) != 0)
|
|
|
|
fatal("%s: buffer error: %s", __func__, ssh_err(r));
|
2004-01-07 11:10:17 +00:00
|
|
|
|
2018-08-28 10:47:58 +00:00
|
|
|
free(msg);
|
|
|
|
sshbuf_free(m);
|
2004-02-26 10:38:49 +00:00
|
|
|
|
2004-01-07 11:10:17 +00:00
|
|
|
debug3("%s returning %d", __func__, ret);
|
|
|
|
|
|
|
|
return (ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
void *
|
|
|
|
mm_sshpam_init_ctx(Authctxt *authctxt)
|
|
|
|
{
|
2018-08-28 10:47:58 +00:00
|
|
|
struct sshbuf *m;
|
|
|
|
int r, success;
|
2004-01-07 11:10:17 +00:00
|
|
|
|
|
|
|
debug3("%s", __func__);
|
2018-08-28 10:47:58 +00:00
|
|
|
if ((m = sshbuf_new()) == NULL)
|
|
|
|
fatal("%s: sshbuf_new failed", __func__);
|
|
|
|
mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_PAM_INIT_CTX, m);
|
2004-01-07 11:10:17 +00:00
|
|
|
debug3("%s: waiting for MONITOR_ANS_PAM_INIT_CTX", __func__);
|
2018-08-28 10:47:58 +00:00
|
|
|
mm_request_receive_expect(pmonitor->m_recvfd,
|
|
|
|
MONITOR_ANS_PAM_INIT_CTX, m);
|
|
|
|
if ((r = sshbuf_get_u32(m, &success)) != 0)
|
|
|
|
fatal("%s: buffer error: %s", __func__, ssh_err(r));
|
2004-01-07 11:10:17 +00:00
|
|
|
if (success == 0) {
|
|
|
|
debug3("%s: pam_init_ctx failed", __func__);
|
2018-08-28 10:47:58 +00:00
|
|
|
sshbuf_free(m);
|
2004-01-07 11:10:17 +00:00
|
|
|
return (NULL);
|
|
|
|
}
|
2018-08-28 10:47:58 +00:00
|
|
|
sshbuf_free(m);
|
2004-01-07 11:10:17 +00:00
|
|
|
return (authctxt);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
mm_sshpam_query(void *ctx, char **name, char **info,
|
|
|
|
u_int *num, char ***prompts, u_int **echo_on)
|
|
|
|
{
|
2018-08-28 10:47:58 +00:00
|
|
|
struct sshbuf *m;
|
|
|
|
u_int i, n;
|
|
|
|
int r, ret;
|
2004-01-07 11:10:17 +00:00
|
|
|
|
|
|
|
debug3("%s", __func__);
|
2018-08-28 10:47:58 +00:00
|
|
|
if ((m = sshbuf_new()) == NULL)
|
|
|
|
fatal("%s: sshbuf_new failed", __func__);
|
|
|
|
mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_PAM_QUERY, m);
|
2004-01-07 11:10:17 +00:00
|
|
|
debug3("%s: waiting for MONITOR_ANS_PAM_QUERY", __func__);
|
2018-08-28 10:47:58 +00:00
|
|
|
mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_PAM_QUERY, m);
|
|
|
|
if ((r = sshbuf_get_u32(m, &ret)) != 0 ||
|
|
|
|
(r = sshbuf_get_cstring(m, name, NULL)) != 0 ||
|
|
|
|
(r = sshbuf_get_cstring(m, info, NULL)) != 0 ||
|
|
|
|
(r = sshbuf_get_u32(m, &n)) != 0 ||
|
|
|
|
(r = sshbuf_get_u32(m, num)) != 0)
|
|
|
|
fatal("%s: buffer error: %s", __func__, ssh_err(r));
|
2004-01-07 11:10:17 +00:00
|
|
|
debug3("%s: pam_query returned %d", __func__, ret);
|
2018-08-28 10:47:58 +00:00
|
|
|
sshpam_set_maxtries_reached(n);
|
2006-09-30 13:29:51 +00:00
|
|
|
if (*num > PAM_MAX_NUM_MSG)
|
2018-08-28 10:47:58 +00:00
|
|
|
fatal("%s: received %u PAM messages, expected <= %u",
|
2006-09-30 13:29:51 +00:00
|
|
|
__func__, *num, PAM_MAX_NUM_MSG);
|
|
|
|
*prompts = xcalloc((*num + 1), sizeof(char *));
|
|
|
|
*echo_on = xcalloc((*num + 1), sizeof(u_int));
|
2004-01-07 11:10:17 +00:00
|
|
|
for (i = 0; i < *num; ++i) {
|
2018-08-28 10:47:58 +00:00
|
|
|
if ((r = sshbuf_get_cstring(m, &((*prompts)[i]), NULL)) != 0 ||
|
|
|
|
(r = sshbuf_get_u32(m, &((*echo_on)[i]))) != 0)
|
|
|
|
fatal("%s: buffer error: %s", __func__, ssh_err(r));
|
2004-01-07 11:10:17 +00:00
|
|
|
}
|
2018-08-28 10:47:58 +00:00
|
|
|
sshbuf_free(m);
|
2004-01-07 11:10:17 +00:00
|
|
|
return (ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
mm_sshpam_respond(void *ctx, u_int num, char **resp)
|
|
|
|
{
|
2018-08-28 10:47:58 +00:00
|
|
|
struct sshbuf *m;
|
|
|
|
u_int n, i;
|
|
|
|
int r, ret;
|
2004-01-07 11:10:17 +00:00
|
|
|
|
|
|
|
debug3("%s", __func__);
|
2018-08-28 10:47:58 +00:00
|
|
|
if ((m = sshbuf_new()) == NULL)
|
|
|
|
fatal("%s: sshbuf_new failed", __func__);
|
|
|
|
if ((r = sshbuf_put_u32(m, num)) != 0)
|
|
|
|
fatal("%s: buffer error: %s", __func__, ssh_err(r));
|
|
|
|
for (i = 0; i < num; ++i) {
|
|
|
|
if ((r = sshbuf_put_cstring(m, resp[i])) != 0)
|
|
|
|
fatal("%s: buffer error: %s", __func__, ssh_err(r));
|
|
|
|
}
|
|
|
|
mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_PAM_RESPOND, m);
|
2004-01-07 11:10:17 +00:00
|
|
|
debug3("%s: waiting for MONITOR_ANS_PAM_RESPOND", __func__);
|
2018-08-28 10:47:58 +00:00
|
|
|
mm_request_receive_expect(pmonitor->m_recvfd,
|
|
|
|
MONITOR_ANS_PAM_RESPOND, m);
|
|
|
|
if ((r = sshbuf_get_u32(m, &n)) != 0)
|
|
|
|
fatal("%s: buffer error: %s", __func__, ssh_err(r));
|
|
|
|
ret = (int)n; /* XXX */
|
2004-01-07 11:10:17 +00:00
|
|
|
debug3("%s: pam_respond returned %d", __func__, ret);
|
2018-08-28 10:47:58 +00:00
|
|
|
sshbuf_free(m);
|
2004-01-07 11:10:17 +00:00
|
|
|
return (ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
mm_sshpam_free_ctx(void *ctxtp)
|
|
|
|
{
|
2018-08-28 10:47:58 +00:00
|
|
|
struct sshbuf *m;
|
2004-01-07 11:10:17 +00:00
|
|
|
|
|
|
|
debug3("%s", __func__);
|
2018-08-28 10:47:58 +00:00
|
|
|
if ((m = sshbuf_new()) == NULL)
|
|
|
|
fatal("%s: sshbuf_new failed", __func__);
|
|
|
|
mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_PAM_FREE_CTX, m);
|
2004-01-07 11:10:17 +00:00
|
|
|
debug3("%s: waiting for MONITOR_ANS_PAM_FREE_CTX", __func__);
|
2018-08-28 10:47:58 +00:00
|
|
|
mm_request_receive_expect(pmonitor->m_recvfd,
|
|
|
|
MONITOR_ANS_PAM_FREE_CTX, m);
|
|
|
|
sshbuf_free(m);
|
2004-01-07 11:10:17 +00:00
|
|
|
}
|
2002-06-27 22:31:32 +00:00
|
|
|
#endif /* USE_PAM */
|
|
|
|
|
2002-06-23 14:01:54 +00:00
|
|
|
/* Request process termination */
|
|
|
|
|
|
|
|
void
|
|
|
|
mm_terminate(void)
|
|
|
|
{
|
2018-08-28 10:47:58 +00:00
|
|
|
struct sshbuf *m;
|
2002-06-23 14:01:54 +00:00
|
|
|
|
2018-08-28 10:47:58 +00:00
|
|
|
if ((m = sshbuf_new()) == NULL)
|
|
|
|
fatal("%s: sshbuf_new failed", __func__);
|
|
|
|
mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_TERM, m);
|
|
|
|
sshbuf_free(m);
|
2002-06-23 14:01:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
mm_chall_setup(char **name, char **infotxt, u_int *numprompts,
|
|
|
|
char ***prompts, u_int **echo_on)
|
|
|
|
{
|
|
|
|
*name = xstrdup("");
|
|
|
|
*infotxt = xstrdup("");
|
|
|
|
*numprompts = 1;
|
2006-09-30 13:29:51 +00:00
|
|
|
*prompts = xcalloc(*numprompts, sizeof(char *));
|
|
|
|
*echo_on = xcalloc(*numprompts, sizeof(u_int));
|
2002-06-23 14:01:54 +00:00
|
|
|
(*echo_on)[0] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
mm_bsdauth_query(void *ctx, char **name, char **infotxt,
|
|
|
|
u_int *numprompts, char ***prompts, u_int **echo_on)
|
|
|
|
{
|
2018-08-28 10:47:58 +00:00
|
|
|
struct sshbuf *m;
|
2003-04-23 16:53:02 +00:00
|
|
|
u_int success;
|
2002-06-23 14:01:54 +00:00
|
|
|
char *challenge;
|
2018-08-28 10:47:58 +00:00
|
|
|
int r;
|
2002-06-23 14:01:54 +00:00
|
|
|
|
|
|
|
debug3("%s: entering", __func__);
|
|
|
|
|
2018-08-28 10:47:58 +00:00
|
|
|
if ((m = sshbuf_new()) == NULL)
|
|
|
|
fatal("%s: sshbuf_new failed", __func__);
|
|
|
|
mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_BSDAUTHQUERY, m);
|
2002-06-23 14:01:54 +00:00
|
|
|
|
2018-08-28 10:47:58 +00:00
|
|
|
mm_request_receive_expect(pmonitor->m_recvfd,
|
|
|
|
MONITOR_ANS_BSDAUTHQUERY, m);
|
|
|
|
if ((r = sshbuf_get_u32(m, &success)) != 0)
|
|
|
|
fatal("%s: buffer error: %s", __func__, ssh_err(r));
|
2003-04-23 16:53:02 +00:00
|
|
|
if (success == 0) {
|
2002-06-23 14:01:54 +00:00
|
|
|
debug3("%s: no challenge", __func__);
|
2018-08-28 10:47:58 +00:00
|
|
|
sshbuf_free(m);
|
2002-06-23 14:01:54 +00:00
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the challenge, and format the response */
|
2018-08-28 10:47:58 +00:00
|
|
|
if ((r = sshbuf_get_cstring(m, &challenge, NULL)) != 0)
|
|
|
|
fatal("%s: buffer error: %s", __func__, ssh_err(r));
|
|
|
|
sshbuf_free(m);
|
2002-06-23 14:01:54 +00:00
|
|
|
|
|
|
|
mm_chall_setup(name, infotxt, numprompts, prompts, echo_on);
|
|
|
|
(*prompts)[0] = challenge;
|
|
|
|
|
|
|
|
debug3("%s: received challenge: %s", __func__, challenge);
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
mm_bsdauth_respond(void *ctx, u_int numresponses, char **responses)
|
|
|
|
{
|
2018-08-28 10:47:58 +00:00
|
|
|
struct sshbuf *m;
|
|
|
|
int r, authok;
|
2002-06-23 14:01:54 +00:00
|
|
|
|
|
|
|
debug3("%s: entering", __func__);
|
|
|
|
if (numresponses != 1)
|
|
|
|
return (-1);
|
|
|
|
|
2018-08-28 10:47:58 +00:00
|
|
|
if ((m = sshbuf_new()) == NULL)
|
|
|
|
fatal("%s: sshbuf_new failed", __func__);
|
|
|
|
if ((r = sshbuf_put_cstring(m, responses[0])) != 0)
|
|
|
|
fatal("%s: buffer error: %s", __func__, ssh_err(r));
|
|
|
|
mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_BSDAUTHRESPOND, m);
|
2002-06-23 14:01:54 +00:00
|
|
|
|
|
|
|
mm_request_receive_expect(pmonitor->m_recvfd,
|
2018-08-28 10:47:58 +00:00
|
|
|
MONITOR_ANS_BSDAUTHRESPOND, m);
|
2002-06-23 14:01:54 +00:00
|
|
|
|
2018-08-28 10:47:58 +00:00
|
|
|
if ((r = sshbuf_get_u32(m, &authok)) != 0)
|
|
|
|
fatal("%s: buffer error: %s", __func__, ssh_err(r));
|
|
|
|
sshbuf_free(m);
|
2002-06-23 14:01:54 +00:00
|
|
|
|
|
|
|
return ((authok == 0) ? -1 : 0);
|
|
|
|
}
|
|
|
|
|
2005-06-05 15:40:50 +00:00
|
|
|
#ifdef SSH_AUDIT_EVENTS
|
|
|
|
void
|
|
|
|
mm_audit_event(ssh_audit_event_t event)
|
|
|
|
{
|
2018-08-28 10:47:58 +00:00
|
|
|
struct sshbuf *m;
|
|
|
|
int r;
|
2005-06-05 15:40:50 +00:00
|
|
|
|
|
|
|
debug3("%s entering", __func__);
|
|
|
|
|
2018-08-28 10:47:58 +00:00
|
|
|
if ((m = sshbuf_new()) == NULL)
|
|
|
|
fatal("%s: sshbuf_new failed", __func__);
|
|
|
|
if ((r = sshbuf_put_u32(m, event)) != 0)
|
|
|
|
fatal("%s: buffer error: %s", __func__, ssh_err(r));
|
2005-06-05 15:40:50 +00:00
|
|
|
|
2018-08-28 10:47:58 +00:00
|
|
|
mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_AUDIT_EVENT, m);
|
|
|
|
sshbuf_free(m);
|
2005-06-05 15:40:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
mm_audit_run_command(const char *command)
|
|
|
|
{
|
2018-08-28 10:47:58 +00:00
|
|
|
struct sshbuf *m;
|
|
|
|
int r;
|
2005-06-05 15:40:50 +00:00
|
|
|
|
|
|
|
debug3("%s entering command %s", __func__, command);
|
|
|
|
|
2018-08-28 10:47:58 +00:00
|
|
|
if ((m = sshbuf_new()) == NULL)
|
|
|
|
fatal("%s: sshbuf_new failed", __func__);
|
|
|
|
if ((r = sshbuf_put_cstring(m, command)) != 0)
|
|
|
|
fatal("%s: buffer error: %s", __func__, ssh_err(r));
|
2005-06-05 15:40:50 +00:00
|
|
|
|
2018-08-28 10:47:58 +00:00
|
|
|
mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_AUDIT_COMMAND, m);
|
|
|
|
sshbuf_free(m);
|
2005-06-05 15:40:50 +00:00
|
|
|
}
|
|
|
|
#endif /* SSH_AUDIT_EVENTS */
|
|
|
|
|
2004-01-07 11:10:17 +00:00
|
|
|
#ifdef GSSAPI
|
|
|
|
OM_uint32
|
2004-10-28 16:03:53 +00:00
|
|
|
mm_ssh_gssapi_server_ctx(Gssctxt **ctx, gss_OID goid)
|
2002-10-29 09:43:00 +00:00
|
|
|
{
|
2018-08-28 10:47:58 +00:00
|
|
|
struct sshbuf *m;
|
2004-01-07 11:10:17 +00:00
|
|
|
OM_uint32 major;
|
2018-08-28 10:47:58 +00:00
|
|
|
int r;
|
2002-10-29 09:43:00 +00:00
|
|
|
|
2004-01-07 11:10:17 +00:00
|
|
|
/* Client doesn't get to see the context */
|
|
|
|
*ctx = NULL;
|
2002-10-29 09:43:00 +00:00
|
|
|
|
2018-08-28 10:47:58 +00:00
|
|
|
if ((m = sshbuf_new()) == NULL)
|
|
|
|
fatal("%s: sshbuf_new failed", __func__);
|
|
|
|
if ((r = sshbuf_put_string(m, goid->elements, goid->length)) != 0)
|
|
|
|
fatal("%s: buffer error: %s", __func__, ssh_err(r));
|
2002-10-29 09:43:00 +00:00
|
|
|
|
2018-08-28 10:47:58 +00:00
|
|
|
mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_GSSSETUP, m);
|
|
|
|
mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_GSSSETUP, m);
|
2004-01-07 11:10:17 +00:00
|
|
|
|
2018-08-28 10:47:58 +00:00
|
|
|
if ((r = sshbuf_get_u32(m, &major)) != 0)
|
|
|
|
fatal("%s: buffer error: %s", __func__, ssh_err(r));
|
2002-10-29 09:43:00 +00:00
|
|
|
|
2018-08-28 10:47:58 +00:00
|
|
|
sshbuf_free(m);
|
2004-01-07 11:10:17 +00:00
|
|
|
return (major);
|
2002-10-29 09:43:00 +00:00
|
|
|
}
|
|
|
|
|
2004-01-07 11:10:17 +00:00
|
|
|
OM_uint32
|
|
|
|
mm_ssh_gssapi_accept_ctx(Gssctxt *ctx, gss_buffer_desc *in,
|
2018-08-28 10:47:58 +00:00
|
|
|
gss_buffer_desc *out, OM_uint32 *flagsp)
|
2002-10-29 09:43:00 +00:00
|
|
|
{
|
2018-08-28 10:47:58 +00:00
|
|
|
struct sshbuf *m;
|
2004-01-07 11:10:17 +00:00
|
|
|
OM_uint32 major;
|
2018-08-28 10:47:58 +00:00
|
|
|
u_int flags;
|
|
|
|
int r;
|
2002-10-29 09:43:00 +00:00
|
|
|
|
2018-08-28 10:47:58 +00:00
|
|
|
if ((m = sshbuf_new()) == NULL)
|
|
|
|
fatal("%s: sshbuf_new failed", __func__);
|
|
|
|
if ((r = sshbuf_put_string(m, in->value, in->length)) != 0)
|
|
|
|
fatal("%s: buffer error: %s", __func__, ssh_err(r));
|
|
|
|
|
|
|
|
mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_GSSSTEP, m);
|
|
|
|
mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_GSSSTEP, m);
|
|
|
|
|
|
|
|
if ((r = sshbuf_get_u32(m, &major)) != 0 ||
|
|
|
|
(r = ssh_gssapi_get_buffer_desc(m, out)) != 0)
|
|
|
|
fatal("%s: buffer error: %s", __func__, ssh_err(r));
|
|
|
|
if (flagsp != NULL) {
|
|
|
|
if ((r = sshbuf_get_u32(m, &flags)) != 0)
|
|
|
|
fatal("%s: buffer error: %s", __func__, ssh_err(r));
|
|
|
|
*flagsp = flags;
|
|
|
|
}
|
2002-10-29 09:43:00 +00:00
|
|
|
|
2018-08-28 10:47:58 +00:00
|
|
|
sshbuf_free(m);
|
2004-01-07 11:10:17 +00:00
|
|
|
|
|
|
|
return (major);
|
|
|
|
}
|
|
|
|
|
2004-02-26 10:38:49 +00:00
|
|
|
OM_uint32
|
|
|
|
mm_ssh_gssapi_checkmic(Gssctxt *ctx, gss_buffer_t gssbuf, gss_buffer_t gssmic)
|
|
|
|
{
|
2018-08-28 10:47:58 +00:00
|
|
|
struct sshbuf *m;
|
2004-02-26 10:38:49 +00:00
|
|
|
OM_uint32 major;
|
2018-08-28 10:47:58 +00:00
|
|
|
int r;
|
2004-02-26 10:38:49 +00:00
|
|
|
|
2018-08-28 10:47:58 +00:00
|
|
|
if ((m = sshbuf_new()) == NULL)
|
|
|
|
fatal("%s: sshbuf_new failed", __func__);
|
|
|
|
if ((r = sshbuf_put_string(m, gssbuf->value, gssbuf->length)) != 0 ||
|
|
|
|
(r = sshbuf_put_string(m, gssmic->value, gssmic->length)) != 0)
|
|
|
|
fatal("%s: buffer error: %s", __func__, ssh_err(r));
|
2004-02-26 10:38:49 +00:00
|
|
|
|
2018-08-28 10:47:58 +00:00
|
|
|
mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_GSSCHECKMIC, m);
|
|
|
|
mm_request_receive_expect(pmonitor->m_recvfd,
|
|
|
|
MONITOR_ANS_GSSCHECKMIC, m);
|
2004-02-26 10:38:49 +00:00
|
|
|
|
2018-08-28 10:47:58 +00:00
|
|
|
if ((r = sshbuf_get_u32(m, &major)) != 0)
|
|
|
|
fatal("%s: buffer error: %s", __func__, ssh_err(r));
|
|
|
|
sshbuf_free(m);
|
2004-02-26 10:38:49 +00:00
|
|
|
return(major);
|
|
|
|
}
|
|
|
|
|
2004-01-07 11:10:17 +00:00
|
|
|
int
|
|
|
|
mm_ssh_gssapi_userok(char *user)
|
|
|
|
{
|
2018-08-28 10:47:58 +00:00
|
|
|
struct sshbuf *m;
|
|
|
|
int r, authenticated = 0;
|
2004-01-07 11:10:17 +00:00
|
|
|
|
2018-08-28 10:47:58 +00:00
|
|
|
if ((m = sshbuf_new()) == NULL)
|
|
|
|
fatal("%s: sshbuf_new failed", __func__);
|
2004-01-07 11:10:17 +00:00
|
|
|
|
2018-08-28 10:47:58 +00:00
|
|
|
mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_GSSUSEROK, m);
|
|
|
|
mm_request_receive_expect(pmonitor->m_recvfd,
|
|
|
|
MONITOR_ANS_GSSUSEROK, m);
|
2004-01-07 11:10:17 +00:00
|
|
|
|
2018-08-28 10:47:58 +00:00
|
|
|
if ((r = sshbuf_get_u32(m, &authenticated)) != 0)
|
|
|
|
fatal("%s: buffer error: %s", __func__, ssh_err(r));
|
2002-10-29 09:43:00 +00:00
|
|
|
|
2018-08-28 10:47:58 +00:00
|
|
|
sshbuf_free(m);
|
2004-01-07 11:10:17 +00:00
|
|
|
debug3("%s: user %sauthenticated",__func__, authenticated ? "" : "not ");
|
|
|
|
return (authenticated);
|
2002-10-29 09:43:00 +00:00
|
|
|
}
|
2004-01-07 11:10:17 +00:00
|
|
|
#endif /* GSSAPI */
|