monitor_wrap.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* 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
*
* 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"
RCSID("$OpenBSD: monitor_wrap.c,v 1.19 2002/09/26 11:38:43 markus Exp $");
#pragma ident "%Z%%M% %I% %E% SMI"
#include "ssh.h"
#include "dh.h"
#include "kex.h"
#include "auth.h"
#include "buffer.h"
#include "bufaux.h"
#include "packet.h"
#include "mac.h"
#include "log.h"
#include "zlib.h"
#include "monitor.h"
#include "monitor_wrap.h"
#include "xmalloc.h"
#include "atomicio.h"
#include "monitor_fdpass.h"
#include "getput.h"
#include "auth.h"
#include "channels.h"
#include "session.h"
#ifdef GSSAPI
#include "ssh-gss.h"
#endif
/* Imports */
extern int compat20;
extern z_stream incoming_stream;
extern z_stream outgoing_stream;
void
{
}
void
{
if (res == 0)
}
buffer_clear(m);
}
void
{
mm_request_receive(socket, m);
rtype = buffer_get_char(m);
}
DH *
{
BIGNUM *p, *g;
int success = 0;
Buffer m;
buffer_init(&m);
buffer_put_int(&m, min);
buffer_put_int(&m, nbits);
buffer_put_int(&m, max);
success = buffer_get_char(&m);
if (success == 0)
buffer_get_bignum2(&m, p);
buffer_get_bignum2(&m, g);
buffer_free(&m);
return (dh_new_group(g, p));
}
int
{
Buffer m;
buffer_init(&m);
buffer_free(&m);
return (0);
}
struct passwd *
mm_getpwnamallow(const char *login)
{
Buffer m;
buffer_init(&m);
buffer_put_cstring(&m, login);
if (buffer_get_char(&m) == 0) {
buffer_free(&m);
return (NULL);
}
#ifdef HAVE_PW_CLASS_IN_PASSWD
#endif
buffer_free(&m);
return (pw);
}
char *mm_auth2_read_banner(void)
{
Buffer m;
char *banner;
buffer_init(&m);
buffer_clear(&m);
buffer_free(&m);
return (banner);
}
/* Inform the privileged process about service and style */
void
{
Buffer m;
buffer_init(&m);
buffer_put_cstring(&m, service);
buffer_free(&m);
}
/* Do the password authentication */
int
{
Buffer m;
int authenticated = 0;
buffer_init(&m);
buffer_put_cstring(&m, password);
authenticated = buffer_get_int(&m);
buffer_free(&m);
debug3("%s: user %sauthenticated",
return (authenticated);
}
int
{
}
int
{
}
int
{
int ret;
return (ret);
}
static void
mm_send_debug(Buffer *m)
{
char *msg;
while (buffer_len(m)) {
}
}
int
{
Buffer m;
int allowed = 0;
/* Convert the key to a blob and the pass it over */
return (0);
buffer_init(&m);
buffer_put_int(&m, type);
allowed = buffer_get_int(&m);
/* Send potential debug messages */
mm_send_debug(&m);
buffer_free(&m);
return (allowed);
}
/*
* 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
{
Buffer m;
int verified = 0;
/* Convert the key to a blob and the pass it over */
return (0);
buffer_init(&m);
verified = buffer_get_int(&m);
buffer_free(&m);
return (verified);
}
/* Export key state after authentication */
Newkeys *
{
Buffer b;
#ifdef DEBUG_PK
#endif
buffer_init(&b);
/* Enc structure */
/* Mac structure */
/* Comp structure */
len = buffer_len(&b);
if (len != 0)
buffer_free(&b);
return (newkey);
}
int
{
Buffer b;
int len;
return 0;
}
buffer_init(&b);
/* Enc structure */
/* The cipher struct is constant and shared, you export pointer */
/* Mac structure */
/* Comp structure */
len = buffer_len(&b);
}
buffer_free(&b);
return len;
}
static void
{
}
void
{
Buffer m;
buffer_init(&m);
if (!compat20) {
buffer_put_int(&m, packet_get_ssh1_cipher());
goto skip;
} else {
/* Kex for rekeying */
}
debug3("%s: Sending new keys: %p %p",
/* Keys from Kex */
skip:
/* More key context */
buffer_put_string(&m, p, plen);
xfree(p);
buffer_put_string(&m, p, plen);
xfree(p);
/* Compression state */
/* Network I/O buffers */
buffer_free(&m);
}
int
{
Buffer m;
char *p;
int success = 0;
buffer_init(&m);
success = buffer_get_int(&m);
if (success == 0) {
buffer_free(&m);
return (0);
}
p = buffer_get_string(&m, NULL);
buffer_free(&m);
xfree(p);
/* Success */
return (1);
}
void
mm_session_pty_cleanup2(void *session)
{
Buffer m;
if (s->ttyfd == -1)
return;
buffer_init(&m);
buffer_put_cstring(&m, s->tty);
buffer_free(&m);
/* closed dup'ed master */
/* unlink pty from session */
s->ttyfd = -1;
}
#ifdef USE_PAM
void
mm_start_pam(char *user)
{
Buffer m;
buffer_init(&m);
buffer_put_cstring(&m, user);
buffer_free(&m);
}
#endif /* USE_PAM */
/* Request process termination */
void
mm_terminate(void)
{
Buffer m;
buffer_init(&m);
buffer_free(&m);
}
int
{
int rsafail;
Buffer m;
buffer_init(&m);
buffer_put_bignum2(&m, num);
rsafail = buffer_get_int(&m);
buffer_get_bignum2(&m, num);
buffer_free(&m);
return (rsafail);
}
static void
{
*numprompts = 1;
(*echo_on)[0] = 0;
}
int
{
Buffer m;
int res;
char *challenge;
buffer_init(&m);
&m);
res = buffer_get_int(&m);
if (res == -1) {
buffer_free(&m);
return (-1);
}
/* Get the challenge, and format the response */
buffer_free(&m);
return (0);
}
int
{
Buffer m;
int authok;
if (numresponses != 1)
return (-1);
buffer_init(&m);
buffer_put_cstring(&m, responses[0]);
authok = buffer_get_int(&m);
buffer_free(&m);
return ((authok == 0) ? -1 : 0);
}
int
{
Buffer m;
char *p, *challenge;
buffer_init(&m);
&m);
res = buffer_get_int(&m);
if (res == -1) {
buffer_free(&m);
return (-1);
}
/* Get the challenge, and format the response */
buffer_free(&m);
(*prompts)[0] = p;
return (0);
}
int
{
Buffer m;
int authok;
if (numresponses != 1)
return (-1);
buffer_init(&m);
buffer_put_cstring(&m, responses[0]);
MONITOR_ANS_SKEYRESPOND, &m);
authok = buffer_get_int(&m);
buffer_free(&m);
return ((authok == 0) ? -1 : 0);
}
void
{
Buffer m;
int i;
buffer_init(&m);
for (i = 0; i < 16; i++)
buffer_put_char(&m, session_id[i]);
buffer_free(&m);
}
int
{
Buffer m;
int allowed = 0;
buffer_init(&m);
buffer_put_bignum2(&m, client_n);
allowed = buffer_get_int(&m);
}
mm_send_debug(&m);
buffer_free(&m);
return (allowed);
}
BIGNUM *
{
Buffer m;
buffer_init(&m);
buffer_get_bignum2(&m, challenge);
buffer_free(&m);
return (challenge);
}
int
{
Buffer m;
int success = 0;
buffer_init(&m);
success = buffer_get_int(&m);
buffer_free(&m);
return (success);
}
#ifdef KRB4
int
{
Buffer m;
int success = 0;
char *p;
buffer_init(&m);
success = buffer_get_int(&m);
if (success) {
p = buffer_get_string(&m, &rlen);
if (rlen >= MAX_KTXT_LEN)
xfree(p);
}
buffer_free(&m);
return (success);
}
#endif
#ifdef KRB5
int
{
Buffer m;
int success;
buffer_init(&m);
success = buffer_get_int(&m);
if (success) {
} else {
}
buffer_free(&m);
return (success);
}
#endif
#ifdef GSSAPI
Buffer m;
/* Client doesn't get to see the context */
buffer_init(&m);
major=buffer_get_int(&m);
buffer_free(&m);
return(major);
}
gss_buffer_t out) {
Buffer m;
buffer_init(&m);
major=buffer_get_int(&m);
buffer_free(&m);
return(major);
}
int
Buffer m;
int authenticated = 0;
buffer_init(&m);
&m);
authenticated = buffer_get_int(&m);
buffer_free(&m);
return(authenticated);
}
Buffer m;
buffer_init(&m);
major=buffer_get_int(&m);
buffer_free(&m);
return(major);
}
char *
Buffer m;
char *errstr;
buffer_init(&m);
maj = buffer_get_int(&m);
min = buffer_get_int(&m);
buffer_free(&m);
return(errstr);
}
{
Buffer m;
int count;
buffer_init(&m);
&m);
major=buffer_get_int(&m);
count=buffer_get_int(&m);
while(count-->0) {
}
buffer_free(&m);
return(major);
}
int
mm_ssh_gssapi_localname(char **lname)
{
Buffer m;
buffer_init(&m);
&m);
buffer_free(&m);
if (lname[0] == '\0') {
} else {
}
return(0);
}
#endif /* GSSAPI */