xiaoxiang781216 commented on code in PR #3532:
URL: https://github.com/apache/nuttx-apps/pull/3532#discussion_r3456608256
##########
netutils/dropbear/patch/0003-guard-environ-declaration-for-nuttx.patch:
##########
@@ -0,0 +1,14 @@
+--- a/src/includes.h
++++ b/src/includes.h
+@@ -184,7 +184,11 @@ typedef u_int32_t uint32_t;
+ #include <dlfcn.h>
+ #endif
+
++#ifdef DROPBEAR_NUTTX
++/* NuttX provides environ as a macro in stdlib.h. */
++#else
+ extern char** environ;
Review Comment:
why not drop environ declaration directly and upstream to the community?
most implementation prototype in in unistd.h.
##########
netutils/dropbear/patch/0001-use-nuttx-unused-macro.patch:
##########
@@ -0,0 +1,291 @@
+--- a/src/chachapoly.c
++++ b/src/chachapoly.c
+@@ -43,11 +43,15 @@
+ const struct dropbear_cipher dropbear_chachapoly =
+ {&dummy, CHACHA20_KEY_LEN*2, CHACHA20_BLOCKSIZE};
+
+-static int dropbear_chachapoly_start(int UNUSED(cipher), const unsigned char*
UNUSED(IV),
Review Comment:
let's fix UNUSED macro by update the definition on nuttx git for gcc/clang
branch:
```
#define UNUSED(x) UNUSED_ ## x __attribute__((unused))
```
##########
netutils/dropbear/patch/0002-use-nuttx-ecdsa-hostkey-sign.patch:
##########
@@ -0,0 +1,103 @@
+--- a/src/ecdsa.c
++++ b/src/ecdsa.c
+@@ -4,6 +4,9 @@
+ #include "ecc.h"
+ #include "ecdsa.h"
+ #include "signkey.h"
++#ifdef DROPBEAR_NUTTX
++#include "nuttx_hostkey.h"
++#endif
+
+ #if DROPBEAR_ECDSA
+
+@@ -67,10 +70,14 @@
+ , bit_size);
+ }
+
++#ifdef DROPBEAR_NUTTX
Review Comment:
could you split the optimized change from basic porting to new pr?
##########
netutils/dropbear/patch/0004-fix-nuttx-compile-warnings.patch:
##########
@@ -0,0 +1,107 @@
+--- a/src/common-kex.c
++++ b/src/common-kex.c
+@@ -117,7 +117,7 @@ void send_msg_kexinit() {
+
+ }
+
+-static void switch_keys() {
++static void switch_keys(void) {
Review Comment:
remove this patch? already merge into the upstream
##########
netutils/dropbear/port/config.h:
##########
@@ -0,0 +1,20 @@
+/****************************************************************************
+ * apps/netutils/dropbear/port/config.h
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ****************************************************************************/
+
+#ifndef __APPS_NETUTILS_DROPBEAR_PORT_CONFIG_H
+#define __APPS_NETUTILS_DROPBEAR_PORT_CONFIG_H
+
+/* Dropbear looks for a file named config.h. Keep this wrapper name stable;
+ * NuttX-specific autoconf replacements live in nuttx_config.h.
+ */
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include "nuttx_config.h"
Review Comment:
why not move the content of nuttx_config.h into here and remove
nuttx_config.h
##########
netutils/dropbear/port/nuttx_compat.c:
##########
@@ -0,0 +1,78 @@
+/****************************************************************************
+ * apps/netutils/dropbear/port/nuttx_compat.c
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include "config.h"
+
+#include <sys/types.h>
+#include <errno.h>
+#include <grp.h>
+#include <unistd.h>
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static char g_dropbear_shell[] = "/bin/sh";
+static int g_shell_returned;
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+void dropbear_setusershell(void)
+{
+ g_shell_returned = 0;
+}
+
+FAR char *dropbear_getusershell(void)
+{
+ if (g_shell_returned == 0)
+ {
+ g_shell_returned = 1;
+ return g_dropbear_shell;
+ }
+
+ return NULL;
+}
+
+void dropbear_endusershell(void)
+{
+ g_shell_returned = 0;
+}
+
+int dropbear_getgroups(int size, gid_t list[])
Review Comment:
see https://github.com/apache/nuttx/pull/19182
##########
netutils/dropbear/patch/0006-use-nuttx-chachapoly-state.patch:
##########
@@ -0,0 +1,84 @@
+--- a/libtomcrypt/src/headers/tomcrypt_custom.h
++++ b/libtomcrypt/src/headers/tomcrypt_custom.h
+@@ -212,7 +212,9 @@
+ #define LTC_CAMELLIA
+
+ /* stream ciphers */
++#ifndef DROPBEAR_NUTTX_CHACHAPOLY
+ #define LTC_CHACHA
++#endif
+ #define LTC_RC4_STREAM
+ #define LTC_SOBER128_STREAM
+
+@@ -283,7 +285,9 @@
+ #define LTC_XCBC
+ #define LTC_F9_MODE
+ #define LTC_PELICAN
++#ifndef DROPBEAR_NUTTX_CHACHAPOLY
+ #define LTC_POLY1305
++#endif
+ #define LTC_BLAKE2SMAC
+ #define LTC_BLAKE2BMAC
+
+@@ -295,7 +299,9 @@
+ #define LTC_OCB3_MODE
+ #define LTC_CCM_MODE
+ #define LTC_GCM_MODE
++#ifndef DROPBEAR_NUTTX_CHACHAPOLY
+ #define LTC_CHACHA20POLY1305_MODE
++#endif
+
+ /* Use 64KiB tables */
+ #ifndef LTC_NO_TABLES
+@@ -323,7 +329,9 @@
+ #define LTC_RC4
+
+ /* The ChaCha20 stream cipher based PRNG */
++#ifndef DROPBEAR_NUTTX_CHACHAPOLY
+ #define LTC_CHACHA20_PRNG
++#endif
+
+ /* Fortuna PRNG */
+ #define LTC_FORTUNA
+--- a/libtomcrypt/src/headers/tomcrypt_mac.h
++++ b/libtomcrypt/src/headers/tomcrypt_mac.h
+@@ -113,6 +113,9 @@ void pmac_shift_xor(pmac_state *pmac);
+ #endif /* PMAC */
+
+ #ifdef LTC_POLY1305
++#ifdef DROPBEAR_NUTTX_CHACHAPOLY
Review Comment:
move to new pr
##########
netutils/dropbear/patch/0005-use-nuttx-sha256-hmac.patch:
##########
@@ -0,0 +1,45 @@
+--- a/libtomcrypt/src/headers/tomcrypt_hash.h
++++ b/libtomcrypt/src/headers/tomcrypt_hash.h
Review Comment:
move to new pr
##########
netutils/dropbear/port/nuttx_compat.c:
##########
@@ -0,0 +1,78 @@
+/****************************************************************************
+ * apps/netutils/dropbear/port/nuttx_compat.c
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include "config.h"
+
+#include <sys/types.h>
+#include <errno.h>
+#include <grp.h>
+#include <unistd.h>
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static char g_dropbear_shell[] = "/bin/sh";
+static int g_shell_returned;
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+void dropbear_setusershell(void)
Review Comment:
remove HAVE_GETUSERSHELL from config.h
##########
netutils/dropbear/patch/0007-use-nuttx-passwd-auth.patch:
##########
@@ -0,0 +1,87 @@
+--- a/src/svr-authpasswd.c
++++ b/src/svr-authpasswd.c
+@@ -33,6 +33,77 @@
+
+ #if DROPBEAR_SVR_PASSWORD_AUTH
+
++#if DROPBEAR_NUTTX_PASSWD
Review Comment:
move to new pr
##########
netutils/dropbear/dropbear_main.c:
##########
@@ -0,0 +1,305 @@
+/****************************************************************************
+ * apps/netutils/dropbear/dropbear_main.c
Review Comment:
why not use the implementation from dropbear directly?
##########
netutils/dropbear/port/localoptions.h:
##########
@@ -0,0 +1,21 @@
+/****************************************************************************
+ * apps/netutils/dropbear/port/localoptions.h
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ****************************************************************************/
+
+#ifndef __APPS_NETUTILS_DROPBEAR_PORT_LOCALOPTIONS_H
+#define __APPS_NETUTILS_DROPBEAR_PORT_LOCALOPTIONS_H
+
+/* Dropbear looks for a file named localoptions.h when
+ * LOCALOPTIONS_H_EXISTS is defined. Keep this wrapper name stable and place
+ * the NuttX-specific option choices in nuttx_localoptions.h.
+ */
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include "nuttx_localoptions.h"
Review Comment:
merge the content of nuttx_localoptions.h into here and remove
nuttx_localoptions.h
##########
netutils/dropbear/port/nuttx_compat.c:
##########
@@ -0,0 +1,78 @@
+/****************************************************************************
+ * apps/netutils/dropbear/port/nuttx_compat.c
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include "config.h"
+
+#include <sys/types.h>
+#include <errno.h>
+#include <grp.h>
+#include <unistd.h>
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static char g_dropbear_shell[] = "/bin/sh";
+static int g_shell_returned;
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+void dropbear_setusershell(void)
+{
+ g_shell_returned = 0;
+}
+
+FAR char *dropbear_getusershell(void)
+{
+ if (g_shell_returned == 0)
+ {
+ g_shell_returned = 1;
+ return g_dropbear_shell;
+ }
+
+ return NULL;
+}
+
+void dropbear_endusershell(void)
+{
+ g_shell_returned = 0;
+}
+
+int dropbear_getgroups(int size, gid_t list[])
+{
+ (void)size;
+ (void)list;
+
+ errno = ENOSYS;
+ return -1;
+}
+
+int link(FAR const char *path1, FAR const char *path2)
Review Comment:
why add the dummy implementation which already provide by nuttx kernel?
##########
netutils/dropbear/port/default_options_guard.h:
##########
@@ -0,0 +1,693 @@
+/****************************************************************************
+ * apps/netutils/dropbear/port/default_options_guard.h
Review Comment:
remove, should be generated by:
```
$(Q) sh $(DROPBEAR_UNPACKNAME)/src/ifndef_wrapper.sh \
< $(DROPBEAR_UNPACKNAME)/src/default_options.h > $@
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]