mirror of
https://github.com/clearml/dropbear
synced 2025-05-31 02:18:13 +00:00
Make it compile, update for changes in channel structure.
--HG-- branch : agent-client extra : convert_revision : 84676a98a0848224078a716b1292744a34e9d80c
This commit is contained in:
parent
709a3e75cf
commit
c6582dbe37
@ -29,7 +29,8 @@ SVROBJS=svr-kex.o svr-algo.o svr-auth.o sshpty.o \
|
|||||||
|
|
||||||
CLIOBJS=cli-algo.o cli-main.o cli-auth.o cli-authpasswd.o cli-kex.o \
|
CLIOBJS=cli-algo.o cli-main.o cli-auth.o cli-authpasswd.o cli-kex.o \
|
||||||
cli-session.o cli-service.o cli-runopts.o cli-chansession.o \
|
cli-session.o cli-service.o cli-runopts.o cli-chansession.o \
|
||||||
cli-authpubkey.o cli-tcpfwd.o cli-channel.o cli-authinteract.o
|
cli-authpubkey.o cli-tcpfwd.o cli-channel.o cli-authinteract.o \
|
||||||
|
cli-agentfwd.o
|
||||||
|
|
||||||
CLISVROBJS=common-session.o packet.o common-algo.o common-kex.o \
|
CLISVROBJS=common-session.o packet.o common-algo.o common-kex.o \
|
||||||
common-channel.o common-chansession.o termcodes.o loginrec.o \
|
common-channel.o common-chansession.o termcodes.o loginrec.o \
|
||||||
|
@ -23,11 +23,11 @@
|
|||||||
* SOFTWARE. */
|
* SOFTWARE. */
|
||||||
#ifndef _AGENTFWD_H_
|
#ifndef _AGENTFWD_H_
|
||||||
#define _AGENTFWD_H_
|
#define _AGENTFWD_H_
|
||||||
#ifndef DISABLE_AGENTFWD
|
|
||||||
|
|
||||||
#include "includes.h"
|
#include "includes.h"
|
||||||
#include "chansession.h"
|
#include "chansession.h"
|
||||||
#include "channel.h"
|
#include "channel.h"
|
||||||
|
#include "auth.h"
|
||||||
|
|
||||||
/* An agent reply can be reasonably large, as it can
|
/* An agent reply can be reasonably large, as it can
|
||||||
* contain a list of all public keys held by the agent.
|
* contain a list of all public keys held by the agent.
|
||||||
@ -39,14 +39,13 @@ void agentsetauth(struct ChanSess *chansess);
|
|||||||
void agentcleanup(struct ChanSess * chansess);
|
void agentcleanup(struct ChanSess * chansess);
|
||||||
void agentset(struct ChanSess *chansess);
|
void agentset(struct ChanSess *chansess);
|
||||||
|
|
||||||
SignKeyList * load_agent_keys();
|
void load_agent_keys();
|
||||||
|
|
||||||
#ifdef __hpux
|
#ifdef __hpux
|
||||||
#define seteuid(a) setresuid(-1, (a), -1)
|
#define seteuid(a) setresuid(-1, (a), -1)
|
||||||
#define setegid(a) setresgid(-1, (a), -1)
|
#define setegid(a) setresgid(-1, (a), -1)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern const struct ChanSess chan_cli_agent;
|
extern const struct ChanType cli_chan_agent;
|
||||||
|
|
||||||
#endif /* DROPBEAR_AGENTFWD */
|
|
||||||
#endif /* _AGENTFWD_H_ */
|
#endif /* _AGENTFWD_H_ */
|
||||||
|
9
auth.h
9
auth.h
@ -26,6 +26,7 @@
|
|||||||
#define _AUTH_H_
|
#define _AUTH_H_
|
||||||
|
|
||||||
#include "includes.h"
|
#include "includes.h"
|
||||||
|
#include "signkey.h"
|
||||||
#include "chansession.h"
|
#include "chansession.h"
|
||||||
|
|
||||||
void svr_authinitialise();
|
void svr_authinitialise();
|
||||||
@ -124,8 +125,10 @@ struct AuthState {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* Sources for signing keys */
|
/* Sources for signing keys */
|
||||||
#define SIGNKEY_SOURCE_RAW_FILE 1
|
typedef enum {
|
||||||
#define SIGNKEY_SOURCE_AGENT 21
|
SIGNKEY_SOURCE_RAW_FILE,
|
||||||
|
SIGNKEY_SOURCE_AGENT,
|
||||||
|
} signkey_source;
|
||||||
|
|
||||||
struct SignKeyList;
|
struct SignKeyList;
|
||||||
/* A singly linked list of signing keys */
|
/* A singly linked list of signing keys */
|
||||||
@ -134,7 +137,7 @@ struct SignKeyList {
|
|||||||
sign_key *key;
|
sign_key *key;
|
||||||
int type; /* The type of key */
|
int type; /* The type of key */
|
||||||
struct SignKeyList *next;
|
struct SignKeyList *next;
|
||||||
int source;
|
signkey_source source;
|
||||||
char *filename;
|
char *filename;
|
||||||
/* the buffer? for encrypted keys, so we can later get
|
/* the buffer? for encrypted keys, so we can later get
|
||||||
* the private key portion */
|
* the private key portion */
|
||||||
|
@ -58,7 +58,7 @@ struct Channel {
|
|||||||
unsigned int recvmaxpacket, transmaxpacket;
|
unsigned int recvmaxpacket, transmaxpacket;
|
||||||
void* typedata; /* a pointer to type specific data */
|
void* typedata; /* a pointer to type specific data */
|
||||||
int writefd; /* read from wire, written to insecure side */
|
int writefd; /* read from wire, written to insecure side */
|
||||||
int readfd; /* read from insecure size, written to wire */
|
int readfd; /* read from insecure side, written to wire */
|
||||||
int errfd; /* used like writefd or readfd, depending if it's client or server.
|
int errfd; /* used like writefd or readfd, depending if it's client or server.
|
||||||
Doesn't exactly belong here, but is cleaner here */
|
Doesn't exactly belong here, but is cleaner here */
|
||||||
circbuffer *writebuf; /* data from the wire, for local consumption */
|
circbuffer *writebuf; /* data from the wire, for local consumption */
|
||||||
|
@ -60,7 +60,7 @@ struct ChanSess {
|
|||||||
unsigned char x11singleconn;
|
unsigned char x11singleconn;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef DISABLE_AGENTFWD
|
#ifdef ENABLE_SVR_AGENTFWD
|
||||||
struct Listener * agentlistener;
|
struct Listener * agentlistener;
|
||||||
char * agentfile;
|
char * agentfile;
|
||||||
char * agentdir;
|
char * agentdir;
|
||||||
|
@ -47,7 +47,7 @@
|
|||||||
|
|
||||||
static int new_agent_chan(struct Channel * channel);
|
static int new_agent_chan(struct Channel * channel);
|
||||||
|
|
||||||
const struct ChanType chan_cli_agent = {
|
const struct ChanType cli_chan_agent = {
|
||||||
0, /* sepfds */
|
0, /* sepfds */
|
||||||
"auth-agent@openssh.com",
|
"auth-agent@openssh.com",
|
||||||
new_agent_chan,
|
new_agent_chan,
|
||||||
@ -85,8 +85,8 @@ static int new_agent_chan(struct Channel * channel) {
|
|||||||
|
|
||||||
ses.maxfd = MAX(ses.maxfd, fd);
|
ses.maxfd = MAX(ses.maxfd, fd);
|
||||||
|
|
||||||
channel->infd = fd;
|
channel->readfd = fd;
|
||||||
channel->outfd = fd;
|
channel->writefd = fd;
|
||||||
|
|
||||||
// success
|
// success
|
||||||
return 0;
|
return 0;
|
||||||
@ -151,7 +151,7 @@ out:
|
|||||||
return inbuf;
|
return inbuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SignKeyList * agent_get_key_list(int fd)
|
static struct SignKeyList * agent_get_key_list(int fd)
|
||||||
{
|
{
|
||||||
buffer * inbuf = NULL;
|
buffer * inbuf = NULL;
|
||||||
unsigned int num = 0;
|
unsigned int num = 0;
|
||||||
@ -183,7 +183,7 @@ static SignKeyList * agent_get_key_list(int fd)
|
|||||||
num = buf_getint(inbuf);
|
num = buf_getint(inbuf);
|
||||||
for (i = 0; i < num; i++) {
|
for (i = 0; i < num; i++) {
|
||||||
sign_key * pubkey = NULL;
|
sign_key * pubkey = NULL;
|
||||||
char key_type = DROPBEAR_SIGNKEY_ANY;
|
int key_type = DROPBEAR_SIGNKEY_ANY;
|
||||||
struct SignKeyList *nextkey = NULL;
|
struct SignKeyList *nextkey = NULL;
|
||||||
|
|
||||||
nextkey = (struct SignKeyList*)m_malloc(sizeof(struct SignKeyList));
|
nextkey = (struct SignKeyList*)m_malloc(sizeof(struct SignKeyList));
|
||||||
@ -218,16 +218,15 @@ out:
|
|||||||
return retkey;
|
return retkey;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* return DROPBEAR_SUCCESS or DROPBEAR_FAILURE */
|
void load_agent_keys()
|
||||||
SignKeyList * load_agent_keys()
|
|
||||||
{
|
{
|
||||||
|
|
||||||
SignKeyList * ret_list;
|
struct SignKeyList * ret_list;
|
||||||
int fd;
|
int fd;
|
||||||
fd = connect_agent();
|
fd = connect_agent();
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
dropbear_log(LOG_INFO, "Failed to connect to agent");
|
dropbear_log(LOG_INFO, "Failed to connect to agent");
|
||||||
return NULL;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret_list = agent_get_key_list(fd);
|
ret_list = agent_get_key_list(fd);
|
||||||
|
@ -174,11 +174,11 @@ int cli_auth_pubkey() {
|
|||||||
|
|
||||||
TRACE(("enter cli_auth_pubkey"))
|
TRACE(("enter cli_auth_pubkey"))
|
||||||
|
|
||||||
if (cli_opts.pubkeys == NULL &&
|
if (cli_opts.privkeys == NULL &&
|
||||||
cli_opts.agent_fwd &&
|
cli_opts.agent_fwd &&
|
||||||
!cli_opts.agent_keys_loaded) {
|
!cli_opts.agent_keys_loaded) {
|
||||||
/* get the list of available keys from the agent */
|
/* get the list of available keys from the agent */
|
||||||
load_agent_keys(&cli_opts.pubkeys);
|
load_agent_keys(&cli_opts.privkeys);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cli_opts.privkeys != NULL) {
|
if (cli_opts.privkeys != NULL) {
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
#include "service.h"
|
#include "service.h"
|
||||||
#include "runopts.h"
|
#include "runopts.h"
|
||||||
#include "chansession.h"
|
#include "chansession.h"
|
||||||
|
#include "agentfwd.h"
|
||||||
|
|
||||||
static void cli_remoteclosed();
|
static void cli_remoteclosed();
|
||||||
static void cli_sessionloop();
|
static void cli_sessionloop();
|
||||||
|
7
dbutil.c
7
dbutil.c
@ -295,19 +295,16 @@ int dropbear_listen(const char* address, const char* port,
|
|||||||
return nsock;
|
return nsock;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Connect to a given unix socket. The socket is not non-blocking */
|
/* Connect to a given unix socket. The socket is blocking */
|
||||||
#ifdef ENABLE_CONNECT_UNIX
|
#ifdef ENABLE_CONNECT_UNIX
|
||||||
int connect_unix(const char* addr)
|
int connect_unix(const char* addr) {
|
||||||
{
|
|
||||||
struct sockaddr_un egdsock;
|
struct sockaddr_un egdsock;
|
||||||
int fd = -1;
|
int fd = -1;
|
||||||
|
|
||||||
memset((void*)&egdsock, 0x0, sizeof(egdsock));
|
memset((void*)&egdsock, 0x0, sizeof(egdsock));
|
||||||
egdsock.sun_family = AF_UNIX;
|
egdsock.sun_family = AF_UNIX;
|
||||||
strlcpy(egdsock.sun_path, addr, sizeof(egdsock.sun_path));
|
strlcpy(egdsock.sun_path, addr, sizeof(egdsock.sun_path));
|
||||||
|
|
||||||
fd = socket(PF_UNIX, SOCK_STREAM, 0);
|
fd = socket(PF_UNIX, SOCK_STREAM, 0);
|
||||||
|
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
11
session.h
11
session.h
@ -215,6 +215,17 @@ struct serversession {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct protocol {
|
||||||
|
int sock; /* read/write with this */
|
||||||
|
buffer * readbuf; /* Pending input data, should read a packet's worth */
|
||||||
|
struct Queue writequeue; /* A queue of output buffers to send */
|
||||||
|
void (*process)(); /* To be called after reading */
|
||||||
|
size_t (*bytes_to_read)();
|
||||||
|
void * state; /* protocol specific */
|
||||||
|
void (*protocol_closed)(); /* to be run when the sock gets closed */
|
||||||
|
void (*loop_handler)(); /* to run at end of each loop */
|
||||||
|
};
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
KEX_NOTHING,
|
KEX_NOTHING,
|
||||||
KEXINIT_RCVD,
|
KEXINIT_RCVD,
|
||||||
|
10
sysoptions.h
10
sysoptions.h
@ -146,10 +146,6 @@
|
|||||||
#define DISABLE_X11FWD
|
#define DISABLE_X11FWD
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef ENABLE_AGENTFWD
|
|
||||||
#define DISABLE_AGENTFWD
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(ENABLE_CLI_REMOTETCPFWD) || defined(ENABLE_CLI_LOCALTCPFWD)
|
#if defined(ENABLE_CLI_REMOTETCPFWD) || defined(ENABLE_CLI_LOCALTCPFWD)
|
||||||
#define ENABLE_CLI_ANYTCPFWD
|
#define ENABLE_CLI_ANYTCPFWD
|
||||||
#endif
|
#endif
|
||||||
@ -160,7 +156,7 @@
|
|||||||
|
|
||||||
#if defined(ENABLE_CLI_REMOTETCPFWD) || defined(ENABLE_CLI_LOCALTCPFWD) || \
|
#if defined(ENABLE_CLI_REMOTETCPFWD) || defined(ENABLE_CLI_LOCALTCPFWD) || \
|
||||||
defined(ENABLE_SVR_REMOTETCPFWD) || defined(ENABLE_SVR_LOCALTCPFWD) || \
|
defined(ENABLE_SVR_REMOTETCPFWD) || defined(ENABLE_SVR_LOCALTCPFWD) || \
|
||||||
defined(ENABLE_AGENTFWD) || defined(ENABLE_X11FWD)
|
defined(ENABLE_SVR_AGENTFWD) || defined(ENABLE_X11FWD)
|
||||||
#define USING_LISTENERS
|
#define USING_LISTENERS
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -168,6 +164,10 @@
|
|||||||
#define ENABLE_CLI_MULTIHOP
|
#define ENABLE_CLI_MULTIHOP
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(ENABLE_CLI_AGENTFWD) || defined(DROPBEAR_PRNGD_SOCKET)
|
||||||
|
#define ENABLE_CONNECT_UNIX
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(DROPBEAR_CLIENT) || defined(ENABLE_SVR_PUBKEY_AUTH)
|
#if defined(DROPBEAR_CLIENT) || defined(ENABLE_SVR_PUBKEY_AUTH)
|
||||||
#define DROPBEAR_KEY_LINES /* ie we're using authorized_keys or known_hosts */
|
#define DROPBEAR_KEY_LINES /* ie we're using authorized_keys or known_hosts */
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user