From 5a1f42ba07dfc4744b6ddbad4e589e0983cc43bb Mon Sep 17 00:00:00 2001 From: Jacob Barthelmeh Date: Tue, 16 Aug 2022 13:28:06 -0600 Subject: [PATCH] update copyright, wrap isspace, fix formating --- apps/wolfsshd/auth.c | 5 +-- apps/wolfsshd/auth.h | 2 +- apps/wolfsshd/configuration.c | 8 ++--- apps/wolfsshd/configuration.h | 2 +- apps/wolfsshd/wolfsshd.c | 61 +++-------------------------------- configure.ac | 2 +- wolfssh/port.h | 9 ++++++ 7 files changed, 23 insertions(+), 66 deletions(-) diff --git a/apps/wolfsshd/auth.c b/apps/wolfsshd/auth.c index 607b2034..3befdbeb 100644 --- a/apps/wolfsshd/auth.c +++ b/apps/wolfsshd/auth.c @@ -1,6 +1,6 @@ /* auth.c * - * Copyright (C) 2014-2021 wolfSSL Inc. + * Copyright (C) 2014-2022 wolfSSL Inc. * * This file is part of wolfSSH. * @@ -601,7 +601,8 @@ static int RequestAuthentication(const char* usr, int type, const byte* data, /* temporarily elevate permissions */ if (ret == WOLFSSH_USERAUTH_SUCCESS && wolfSSHD_AuthRaisePermissions(auth) != WS_SUCCESS) { - wolfSSH_Log(WS_LOG_ERROR, "[SSHD] Failure to raise permissions for auth"); + wolfSSH_Log(WS_LOG_ERROR, + "[SSHD] Failure to raise permissions for auth"); ret = WOLFSSH_USERAUTH_FAILURE; } diff --git a/apps/wolfsshd/auth.h b/apps/wolfsshd/auth.h index 42dc9af5..01e41106 100644 --- a/apps/wolfsshd/auth.h +++ b/apps/wolfsshd/auth.h @@ -1,6 +1,6 @@ /* auth.h * - * Copyright (C) 2014-2021 wolfSSL Inc. + * Copyright (C) 2014-2022 wolfSSL Inc. * * This file is part of wolfSSH. * diff --git a/apps/wolfsshd/configuration.c b/apps/wolfsshd/configuration.c index b556868e..695f40b2 100644 --- a/apps/wolfsshd/configuration.c +++ b/apps/wolfsshd/configuration.c @@ -1,6 +1,6 @@ /* configuration.c * - * Copyright (C) 2014-2021 wolfSSL Inc. + * Copyright (C) 2014-2022 wolfSSL Inc. * * This file is part of wolfSSH. * @@ -445,7 +445,7 @@ static int HandleInclude(WOLFSSHD_CONFIG *conf, const char *value) /* Ignore trailing whitespace */ ptr = value + WSTRLEN(value) - 1; while (ptr != value) { - if (!isspace(*ptr)) { + if (!WISSPACE(*ptr)) { ptr--; } else { @@ -649,12 +649,12 @@ static int CountWhitespace(const char* in, int inSz, byte inv) if (in != NULL) { for (; i < inSz; ++i) { if (inv) { - if (isspace(in[i])) { + if (WISSPACE(in[i])) { break; } } else { - if (!isspace(in[i])) { + if (!WISSPACE(in[i])) { break; } } diff --git a/apps/wolfsshd/configuration.h b/apps/wolfsshd/configuration.h index 952a1f87..3d352408 100644 --- a/apps/wolfsshd/configuration.h +++ b/apps/wolfsshd/configuration.h @@ -1,6 +1,6 @@ /* configuration.h * - * Copyright (C) 2014-2021 wolfSSL Inc. + * Copyright (C) 2014-2022 wolfSSL Inc. * * This file is part of wolfSSH. * diff --git a/apps/wolfsshd/wolfsshd.c b/apps/wolfsshd/wolfsshd.c index 136a9a43..a2d265df 100644 --- a/apps/wolfsshd/wolfsshd.c +++ b/apps/wolfsshd/wolfsshd.c @@ -1,6 +1,6 @@ /* wolfsshd.c * - * Copyright (C) 2014-2021 wolfSSL Inc. + * Copyright (C) 2014-2022 wolfSSL Inc. * * This file is part of wolfSSH. * @@ -143,7 +143,8 @@ static void ShowUsage(void) { printf("wolfsshd %s\n", LIBWOLFSSH_VERSION_STRING); printf(" -? display this help and exit\n"); - printf(" -f Configuration file to use, default is /etc/ssh/sshd_config\n"); + printf(" -f Configuration file to use, default is " + "/etc/ssh/sshd_config\n"); printf(" -p Port number to listen on\n"); printf(" -d Turn on debug mode\n"); printf(" -D Run in foreground (do not detach)\n"); @@ -271,61 +272,7 @@ static int SetupCTX(WOLFSSHD_CONFIG* conf, WOLFSSH_CTX** ctx) } } - /* Load in host public key */ -// { -// if (userPubKey) { -// byte* userBuf = NULL; -// word32 userBufSz = 0; -// -// /* get the files size */ -// load_file(userPubKey, NULL, &userBufSz); -// -// /* create temp buffer and load in file */ -// if (userBufSz == 0) { -// fprintf(stderr, "Couldn't find size of file %s.\n", userPubKey); -// WEXIT(EXIT_FAILURE); -// } -// -// userBuf = (byte*)WMALLOC(userBufSz, NULL, 0); -// if (userBuf == NULL) { -// fprintf(stderr, "WMALLOC failed\n"); -// WEXIT(EXIT_FAILURE); -// } -// load_file(userPubKey, userBuf, &userBufSz); -// LoadPublicKeyBuffer(userBuf, userBufSz, &pwMapList); -// } -// -// bufSz = (word32)WSTRLEN(samplePasswordBuffer); -// WMEMCPY(keyLoadBuf, samplePasswordBuffer, bufSz); -// keyLoadBuf[bufSz] = 0; -// LoadPasswordBuffer(keyLoadBuf, bufSz, &pwMapList); -// -// if (userEcc) { -// #ifndef WOLFSSH_NO_ECC -// bufName = samplePublicKeyEccBuffer; -// #endif -// } -// else { -// #ifndef WOLFSSH_NO_RSA -// bufName = samplePublicKeyRsaBuffer; -// #endif -// } -// if (bufName != NULL) { -// bufSz = (word32)WSTRLEN(bufName); -// WMEMCPY(keyLoadBuf, bufName, bufSz); -// keyLoadBuf[bufSz] = 0; -// LoadPublicKeyBuffer(keyLoadBuf, bufSz, &pwMapList); -// } -// -// bufSz = (word32)WSTRLEN(sampleNoneBuffer); -// WMEMCPY(keyLoadBuf, sampleNoneBuffer, bufSz); -// keyLoadBuf[bufSz] = 0; -// LoadNoneBuffer(keyLoadBuf, bufSz, &pwMapList); -// -// #ifdef WOLFSSH_SMALL_STACK -// WFREE(keyLoadBuf, NULL, 0); -// #endif -// } + /* @TODO Load in host public key */ /* Set allowed connection type, i.e. public key / password */ diff --git a/configure.ac b/configure.ac index 7b11c829..8f052afb 100644 --- a/configure.ac +++ b/configure.ac @@ -223,7 +223,7 @@ AS_IF([test "x$ENABLED_DISTRO" = "xyes"], AS_IF([test "x$ENABLED_ALL" = "xyes"], [ENABLED_KEYGEN=yes; ENABLED_SCP=yes; ENABLED_SFTP=yes; ENABLED_FWD=yes; ENABLED_SHELL=yes; ENABLED_AGENT=yes; ENABLED_SSHD=yes]) AS_IF([test "x$ENABLED_SSHD" = "xyes"], - [ENABLED_SHELL=yes;]) + [ENABLED_SHELL=yes]) # Set the defined flags for the code. AS_IF([test "x$ENABLED_INLINE" = "xno"], diff --git a/wolfssh/port.h b/wolfssh/port.h index 7efb1e25..c89cffdd 100644 --- a/wolfssh/port.h +++ b/wolfssh/port.h @@ -41,6 +41,15 @@ extern "C" { /* This value needs to stay in sync with the actual value of DYNTYPE_STRING * from internal.h. */ +#ifdef WOLFSSH_SSHD + /* uses isspace (not always available from wolfSSL) */ + #ifdef XISSPACE + #define WISSPACE XISSPACE + #else + #define WISSPACE isspace + #endif +#endif + /* setup memory handling */ #ifndef WMALLOC_USER #ifdef WOLFSSL_USER_SETTINGS