version 1.40.4.1, 2006/09/30 04:06:50 |
version 1.41, 2006/03/19 18:51:18 |
|
|
/* $OpenBSD$ */ |
|
/* |
/* |
* Copyright 2002 Niels Provos <provos@citi.umich.edu> |
* Copyright 2002 Niels Provos <provos@citi.umich.edu> |
* Copyright 2002 Markus Friedl <markus@openbsd.org> |
* Copyright 2002 Markus Friedl <markus@openbsd.org> |
|
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
*/ |
|
|
#include <sys/types.h> |
#include "includes.h" |
#include <sys/uio.h> |
|
|
|
#include <openssl/bn.h> |
#include <openssl/bn.h> |
#include <openssl/dh.h> |
#include <openssl/dh.h> |
|
|
#include <errno.h> |
|
#include <pwd.h> |
|
#include <signal.h> |
|
#include <stdio.h> |
|
#include <string.h> |
|
#include <unistd.h> |
|
|
|
#include "xmalloc.h" |
|
#include "ssh.h" |
#include "ssh.h" |
#include "dh.h" |
#include "dh.h" |
#include "buffer.h" |
|
#include "key.h" |
|
#include "cipher.h" |
|
#include "kex.h" |
#include "kex.h" |
#include "hostfile.h" |
|
#include "auth.h" |
#include "auth.h" |
#include "auth-options.h" |
#include "auth-options.h" |
|
#include "buffer.h" |
|
#include "bufaux.h" |
#include "packet.h" |
#include "packet.h" |
#include "mac.h" |
#include "mac.h" |
#include "log.h" |
#include "log.h" |
#include <zlib.h> |
#include "zlib.h" |
#include "monitor.h" |
#include "monitor.h" |
#ifdef GSSAPI |
|
#include "ssh-gss.h" |
|
#endif |
|
#include "monitor_wrap.h" |
#include "monitor_wrap.h" |
|
#include "xmalloc.h" |
#include "atomicio.h" |
#include "atomicio.h" |
#include "monitor_fdpass.h" |
#include "monitor_fdpass.h" |
#include "misc.h" |
#include "getput.h" |
|
|
|
#include "auth.h" |
#include "channels.h" |
#include "channels.h" |
#include "session.h" |
#include "session.h" |
|
|
|
#ifdef GSSAPI |
|
#include "ssh-gss.h" |
|
#endif |
|
|
/* Imports */ |
/* Imports */ |
extern int compat20; |
extern int compat20; |
extern Newkeys *newkeys[]; |
extern Newkeys *newkeys[]; |
|
|
|
|
debug3("%s entering: type %d", __func__, type); |
debug3("%s entering: type %d", __func__, type); |
|
|
put_u32(buf, mlen + 1); |
PUT_32BIT(buf, mlen + 1); |
buf[4] = (u_char) type; /* 1st byte of payload is mesg-type */ |
buf[4] = (u_char) type; /* 1st byte of payload is mesg-type */ |
if (atomicio(vwrite, sock, buf, sizeof(buf)) != sizeof(buf)) |
if (atomicio(vwrite, sock, buf, sizeof(buf)) != sizeof(buf)) |
fatal("%s: write: %s", __func__, strerror(errno)); |
fatal("%s: write: %s", __func__, strerror(errno)); |
|
|
cleanup_exit(255); |
cleanup_exit(255); |
fatal("%s: read: %s", __func__, strerror(errno)); |
fatal("%s: read: %s", __func__, strerror(errno)); |
} |
} |
msg_len = get_u32(buf); |
msg_len = GET_32BIT(buf); |
if (msg_len > 256 * 1024) |
if (msg_len > 256 * 1024) |
fatal("%s: read: bad msg_len %d", __func__, msg_len); |
fatal("%s: read: bad msg_len %d", __func__, msg_len); |
buffer_clear(m); |
buffer_clear(m); |
|
|
} |
} |
|
|
int |
int |
mm_pty_allocate(int *ptyfd, int *ttyfd, char *namebuf, size_t namebuflen) |
mm_pty_allocate(int *ptyfd, int *ttyfd, char *namebuf, int namebuflen) |
{ |
{ |
Buffer m; |
Buffer m; |
char *p, *msg; |
char *p, *msg; |
|
|
*name = xstrdup(""); |
*name = xstrdup(""); |
*infotxt = xstrdup(""); |
*infotxt = xstrdup(""); |
*numprompts = 1; |
*numprompts = 1; |
*prompts = xcalloc(*numprompts, sizeof(char *)); |
*prompts = xmalloc(*numprompts * sizeof(char *)); |
*echo_on = xcalloc(*numprompts, sizeof(u_int)); |
*echo_on = xmalloc(*numprompts * sizeof(u_int)); |
(*echo_on)[0] = 0; |
(*echo_on)[0] = 0; |
} |
} |
|
|
|
|
u_int *numprompts, char ***prompts, u_int **echo_on) |
u_int *numprompts, char ***prompts, u_int **echo_on) |
{ |
{ |
Buffer m; |
Buffer m; |
|
int len; |
u_int success; |
u_int success; |
char *challenge; |
char *p, *challenge; |
|
|
debug3("%s: entering", __func__); |
debug3("%s: entering", __func__); |
|
|
|
|
|
|
mm_chall_setup(name, infotxt, numprompts, prompts, echo_on); |
mm_chall_setup(name, infotxt, numprompts, prompts, echo_on); |
|
|
xasprintf(*prompts, "%s%s", challenge, SKEY_PROMPT); |
len = strlen(challenge) + strlen(SKEY_PROMPT) + 1; |
|
p = xmalloc(len); |
|
strlcpy(p, challenge, len); |
|
strlcat(p, SKEY_PROMPT, len); |
|
(*prompts)[0] = p; |
xfree(challenge); |
xfree(challenge); |
|
|
return (0); |
return (0); |