Fixed some issues with NO_WOLFSSH_SERVER builds. wolfSSH proper still

has the server code, but the wolfSFTP code excludes the server side.
pull/134/head
John Safranek 2019-01-09 13:14:25 -08:00
parent 8ec417b97b
commit 42675723e2
5 changed files with 107 additions and 101 deletions

View File

@ -179,13 +179,16 @@ static int ssh_worker(thread_ctx_t* threadCtx) {
* returns 0 on success
*/
static int sftp_worker(thread_ctx_t* threadCtx) {
int ret;
int ret = 0;
(void)threadCtx;
#ifndef NO_WOLFSSH_SERVER
do {
ret = wolfSSH_SFTP_read(threadCtx->ssh);
} while (ret != WS_FATAL_ERROR);
#endif
return 0;
return ret;
}
#endif

View File

@ -7353,7 +7353,8 @@ int SendChannelSuccess(WOLFSSH* ssh, word32 channelId, int success)
}
#if defined(WOLFSSH_SFTP) || defined(WOLFSSH_SCP)
#if (defined(WOLFSSH_SFTP) || defined(WOLFSSH_SCP)) && \
!defined(NO_WOLFSSH_SERVER)
/* cleans up absolute path */
void clean_path(char* path)
{

View File

@ -407,7 +407,7 @@ int wolfSSH_accept(WOLFSSH* ssh)
#endif
ssh->acceptState = ACCEPT_CLIENT_SESSION_ESTABLISHED;
WLOG(WS_LOG_DEBUG, acceptState, "CLIENT_SESSION_ESTABLISHED");
#ifdef WOLFSSH_SFTP
#if defined(WOLFSSH_SFTP) && !defined(NO_WOLFSSH_SERVER)
{
const char* cmd = wolfSSH_GetSessionCommand(ssh);
if (cmd != NULL &&
@ -416,7 +416,7 @@ int wolfSSH_accept(WOLFSSH* ssh)
return wolfSSH_SFTP_accept(ssh);
}
}
#endif /* WOLFSSH_SFTP*/
#endif /* WOLFSSH_SFTP and !NO_WOLFSSH_SERVER */
break;
#ifdef WOLFSSH_SCP

View File

@ -342,10 +342,6 @@ typedef struct WS_SFTP_RENAME_STATE {
static int SendPacketType(WOLFSSH* ssh, byte type, byte* buf, word32 bufSz);
static int SFTP_ParseAtributes_buffer(WOLFSSH* ssh, WS_SFTP_FILEATRB* atr,
byte* buf, word32* idx, word32 maxIdx);
static int SFTP_GetAttributes(const char* fileName, WS_SFTP_FILEATRB* atr,
byte link);
static int SFTP_GetAttributes_Handle(WOLFSSH* ssh, byte* handle, int handleSz,
WS_SFTP_FILEATRB* atr);
static WS_SFTPNAME* wolfSSH_SFTPNAME_new(void* heap);
@ -522,7 +518,102 @@ static int SFTP_SetHeader(WOLFSSH* ssh, word32 reqId, byte type, word32 len,
}
/* returns the size of buffer needed to hold attributes */
static int SFTP_AtributesSz(WOLFSSH* ssh, WS_SFTP_FILEATRB* atr)
{
word32 sz = 0;
(void)ssh;
sz += UINT32_SZ; /* flag */
/* check if size attribute present */
if (atr->flags & WOLFSSH_FILEATRB_SIZE) {
sz += UINT32_SZ * 2;
}
/* check if uid and gid attribute present */
if (atr->flags & WOLFSSH_FILEATRB_UIDGID) {
sz += UINT32_SZ * 2;
}
/* check if permissions attribute present */
if (atr->flags & WOLFSSH_FILEATRB_PERM) {
sz += UINT32_SZ;
}
/* check if time attribute present */
if (atr->flags & WOLFSSH_FILEATRB_TIME) {
sz += UINT32_SZ * 2;
}
/* check if extended attributes are present */
if (atr->flags & WOLFSSH_FILEATRB_EXT) {
sz += UINT32_SZ;
/* @TODO handle extended attributes */
}
return sz;
}
/* set attributes in buffer
*
* returns WS_SUCCESS on success
*/
static int SFTP_SetAttributes(WOLFSSH* ssh, byte* buf, word32 bufSz,
WS_SFTP_FILEATRB* atr)
{
word32 idx = 0;
(void)ssh;
(void)bufSz;
/* get flags */
c32toa(atr->flags, buf); idx += UINT32_SZ;
/* check if size attribute present */
if (atr->flags & WOLFSSH_FILEATRB_SIZE) {
c32toa((word32)(atr->sz << 32), buf + idx); idx += UINT32_SZ;
c32toa((word32)(atr->sz & 0xFFFFFFFF), buf + idx); idx += UINT32_SZ;
}
/* check if uid and gid attribute present */
if (atr->flags & WOLFSSH_FILEATRB_UIDGID) {
c32toa(atr->uid, buf + idx); idx += UINT32_SZ;
c32toa(atr->gid, buf + idx); idx += UINT32_SZ;
}
/* check if permissions attribute present */
if (atr->flags & WOLFSSH_FILEATRB_PERM) {
c32toa(atr->per, buf + idx); idx += UINT32_SZ;
}
/* check if time attribute present */
if (atr->flags & WOLFSSH_FILEATRB_TIME) {
c32toa(atr->atime, buf + idx); idx += UINT32_SZ;
c32toa(atr->mtime, buf + idx); idx += UINT32_SZ;
}
/* check if extended attributes are present */
if (atr->flags & WOLFSSH_FILEATRB_EXT) {
/* @TODO handle attribute extensions */
c32toa(atr->extCount, buf + idx);
}
return WS_SUCCESS;
}
#ifndef NO_WOLFSSH_SERVER
static int SFTP_GetAttributes(const char* fileName, WS_SFTP_FILEATRB* atr,
byte link);
static int SFTP_GetAttributes_Handle(WOLFSSH* ssh, byte* handle, int handleSz,
WS_SFTP_FILEATRB* atr);
/* unique from other packets because the request ID is not also sent.
*
* returns WS_SUCCESS on success
@ -646,95 +737,6 @@ int wolfSSH_SFTP_accept(WOLFSSH* ssh)
return ret;
}
/* returns the size of buffer needed to hold attributes */
static int SFTP_AtributesSz(WOLFSSH* ssh, WS_SFTP_FILEATRB* atr)
{
word32 sz = 0;
(void)ssh;
sz += UINT32_SZ; /* flag */
/* check if size attribute present */
if (atr->flags & WOLFSSH_FILEATRB_SIZE) {
sz += UINT32_SZ * 2;
}
/* check if uid and gid attribute present */
if (atr->flags & WOLFSSH_FILEATRB_UIDGID) {
sz += UINT32_SZ * 2;
}
/* check if permissions attribute present */
if (atr->flags & WOLFSSH_FILEATRB_PERM) {
sz += UINT32_SZ;
}
/* check if time attribute present */
if (atr->flags & WOLFSSH_FILEATRB_TIME) {
sz += UINT32_SZ * 2;
}
/* check if extended attributes are present */
if (atr->flags & WOLFSSH_FILEATRB_EXT) {
sz += UINT32_SZ;
/* @TODO handle extended attributes */
}
return sz;
}
/* set attributes in buffer
*
* returns WS_SUCCESS on success
*/
static int SFTP_SetAttributes(WOLFSSH* ssh, byte* buf, word32 bufSz,
WS_SFTP_FILEATRB* atr)
{
word32 idx = 0;
(void)ssh;
(void)bufSz;
/* get flags */
c32toa(atr->flags, buf); idx += UINT32_SZ;
/* check if size attribute present */
if (atr->flags & WOLFSSH_FILEATRB_SIZE) {
c32toa((word32)(atr->sz << 32), buf + idx); idx += UINT32_SZ;
c32toa((word32)(atr->sz & 0xFFFFFFFF), buf + idx); idx += UINT32_SZ;
}
/* check if uid and gid attribute present */
if (atr->flags & WOLFSSH_FILEATRB_UIDGID) {
c32toa(atr->uid, buf + idx); idx += UINT32_SZ;
c32toa(atr->gid, buf + idx); idx += UINT32_SZ;
}
/* check if permissions attribute present */
if (atr->flags & WOLFSSH_FILEATRB_PERM) {
c32toa(atr->per, buf + idx); idx += UINT32_SZ;
}
/* check if time attribute present */
if (atr->flags & WOLFSSH_FILEATRB_TIME) {
c32toa(atr->atime, buf + idx); idx += UINT32_SZ;
c32toa(atr->mtime, buf + idx); idx += UINT32_SZ;
}
/* check if extended attributes are present */
if (atr->flags & WOLFSSH_FILEATRB_EXT) {
/* @TODO handle attribute extensions */
c32toa(atr->extCount, buf + idx);
}
return WS_SUCCESS;
}
/* returns WS_SUCCESS on success */
static int wolfSSH_SFTP_RecvRealPath(WOLFSSH* ssh, int reqId, int maxSz)
{

View File

@ -55,6 +55,8 @@ char* myoptarg = NULL;
#endif /* NO_TESTSUITE_MAIN_DRIVER */
#if !defined(NO_WOLFSSH_SERVER) && !defined(NO_WOLFSSH_CLIENT)
static int tsClientUserAuth(byte authType, WS_UserAuthData* authData, void* ctx)
{
static char password[] = "upthehill";
@ -68,8 +70,6 @@ static int tsClientUserAuth(byte authType, WS_UserAuthData* authData, void* ctx)
}
#if !defined(NO_WOLFSSH_SERVER) && !defined(NO_WOLFSSH_CLIENT)
#define NUMARGS 5
#define ARGLEN 32
@ -147,7 +147,7 @@ int TestsuiteTest(int argc, char** argv)
#else /* !NO_WOLFSSH_SERVER && !NO_WOLFSSH_CLIENT */
int TestsuiteTest(int argc, char** argv)
{
(void)argc;
(void)argv;
return EXIT_SUCCESS;