This is an automated email from the ASF dual-hosted git repository.

masayuki pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git

commit 58c3dbac95b34adf6c99854277ce4145a3606747
Author: Xiang Xiao <[email protected]>
AuthorDate: Mon Oct 17 04:06:07 2022 +0800

    Revert "netutils: Make telnetd_daemon() in public"
    
    This reverts commit 000d1455b49878d707ed94abea3f3f33120ce322.
---
 include/netutils/telnetd.h        |  31 ------------
 netutils/telnetd/Kconfig          |  23 +--------
 netutils/telnetd/telnetd_daemon.c | 100 ++++++++------------------------------
 3 files changed, 23 insertions(+), 131 deletions(-)

diff --git a/include/netutils/telnetd.h b/include/netutils/telnetd.h
index 5ccfcb720..11fb39f58 100644
--- a/include/netutils/telnetd.h
+++ b/include/netutils/telnetd.h
@@ -65,20 +65,6 @@ struct telnetd_config_s
                             * connection is accepted. */
 };
 
-/* This structure represents the overall state of one telnet daemon instance
- * (Yes, multiple telnet daemons are supported).
- */
-
-struct telnetd_s
-{
-  uint16_t              port;      /* The port to listen on (in network byte 
order) */
-  sa_family_t           family;    /* Address family */
-  uint8_t               priority;  /* The execution priority of the spawned 
task, */
-  size_t                stacksize; /* The stack size needed by the spawned 
task */
-  main_t                entry;     /* The entrypoint of the task to spawn when 
a new
-                                    * connection is accepted. */
-};
-
 /****************************************************************************
  * Public Function Prototypes
  ****************************************************************************/
@@ -91,23 +77,6 @@ extern "C"
 #define EXTERN extern
 #endif
 
-/****************************************************************************
- * Name: telnetd_daemon
- *
- * Description:
- *   This function is the Telnet daemon.  It does not return (unless an
- *   error occurs).
- *
- * Parameters:
- *   Standard task start up arguments.
- *
- * Return:
- *   Does not return unless an error occurs.
- *
- ****************************************************************************/
-
-int telnetd_daemon(int argc, FAR char *argv[]);
-
 /****************************************************************************
  * Name: telnetd_start
  *
diff --git a/netutils/telnetd/Kconfig b/netutils/telnetd/Kconfig
index 582dc5e76..eff726523 100644
--- a/netutils/telnetd/Kconfig
+++ b/netutils/telnetd/Kconfig
@@ -11,24 +11,5 @@ config NETUTILS_TELNETD
        ---help---
                Enable support for the Telnet daemon.
 
-config NETUTILS_TELNETD_USE_POSIX_SPAWNP
-       bool "Telnet daemon uses posix_spawnp"
-       default y if BUILD_KERNEL
-       default n if !BUILD_KERNEL
-       depends on NETUTILS_TELNETD
-       ---help---
-               Enable to use posix_spawnp instead of tak_create
-
-config NETUTILS_TELNETD_PATH
-       string "Telnetd path"
-       default "/bin/telnetd"
-       depends on NETUTILS_TELNETD_USE_POSIX_SPAWNP
-       ---help---
-               The path to the telnetd.
-
-config NETUTILS_TELNETD_SHELL_PATH
-       string "Telnetd shell path"
-       default "/bin/sh"
-       depends on NETUTILS_TELNETD_USE_POSIX_SPAWNP
-       ---help---
-               The path to the shell executable.
+if NETUTILS_TELNETD
+endif
diff --git a/netutils/telnetd/telnetd_daemon.c 
b/netutils/telnetd/telnetd_daemon.c
index d23e7b1e3..5a5d9b35f 100644
--- a/netutils/telnetd/telnetd_daemon.c
+++ b/netutils/telnetd/telnetd_daemon.c
@@ -41,7 +41,6 @@
 #include <assert.h>
 #include <errno.h>
 #include <debug.h>
-#include <spawn.h>
 
 #include <netinet/in.h>
 #include <arpa/inet.h>
@@ -55,12 +54,22 @@
  * Private Types
  ****************************************************************************/
 
-/****************************************************************************
- * Private Functions
- ****************************************************************************/
+/* This structure represents the overall state of one telnet daemon instance
+ * (Yes, multiple telnet daemons are supported).
+ */
+
+struct telnetd_s
+{
+  uint16_t              port;      /* The port to listen on (in network byte 
order) */
+  sa_family_t           family;    /* Address family */
+  uint8_t               priority;  /* The execution priority of the spawned 
task, */
+  size_t                stacksize; /* The stack size needed by the spawned 
task */
+  main_t                entry;     /* The entrypoint of the task to spawn when 
a new
+                                    * connection is accepted. */
+};
 
 /****************************************************************************
- * Public Functions
+ * Private Functions
  ****************************************************************************/
 
 /****************************************************************************
@@ -78,7 +87,7 @@
  *
  ****************************************************************************/
 
-int telnetd_daemon(int argc, FAR char *argv[])
+static int telnetd_daemon(int argc, FAR char *argv[])
 {
   UNUSED(argc);
 
@@ -94,11 +103,6 @@ int telnetd_daemon(int argc, FAR char *argv[])
 #endif
   } addr;
 
-#ifdef CONFIG_NETUTILS_TELNETD_USE_POSIX_SPAWNP
-  posix_spawn_file_actions_t file_actions;
-  posix_spawnattr_t attr;
-  FAR char *argv1[2];
-#endif
   struct telnet_session_s session;
 #ifdef CONFIG_NET_SOLINGER
   struct linger ling;
@@ -314,29 +318,6 @@ int telnetd_daemon(int argc, FAR char *argv[])
           close(drvrfd);
         }
 
-#ifdef CONFIG_NETUTILS_TELNETD_USE_POSIX_SPAWNP
-      posix_spawn_file_actions_init(&file_actions);
-      ret = posix_spawnattr_init(&attr);
-
-      if (ret < 0)
-        {
-          nerr("ERROR in posix_spawnattr_init(): %d\n", errno);
-          goto errout_with_socket;
-        }
-
-      argv1[0] = CONFIG_NETUTILS_TELNETD_SHELL_PATH;
-      argv1[1] = NULL;
-
-      ret = posix_spawnp(&pid,
-                         CONFIG_NETUTILS_TELNETD_SHELL_PATH,
-                         &file_actions, &attr, argv1, NULL);
-
-      if (ret < 0)
-        {
-          nerr("ERROR in posix_spawnp(): %d\n", errno);
-          goto errout_with_attrs;
-        }
-#else
       /* Create a task to handle the connection.  The created task
        * will inherit the new stdin, stdout, and stderr.
        */
@@ -349,7 +330,6 @@ int telnetd_daemon(int argc, FAR char *argv[])
           nerr("ERROR: Failed start the telnet session: %d\n", errno);
           goto errout_with_socket;
         }
-#endif
 
       /* Forget about the connection. */
 
@@ -361,11 +341,6 @@ int telnetd_daemon(int argc, FAR char *argv[])
 errout_with_acceptsd:
   close(acceptsd);
 
-#ifdef CONFIG_NETUTILS_TELNETD_USE_POSIX_SPAWNP
-errout_with_attrs:
-  posix_spawnattr_destroy(&attr);
-#endif
-
 errout_with_socket:
   close(listensd);
 errout_with_daemon:
@@ -373,6 +348,10 @@ errout_with_daemon:
   return 1;
 }
 
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
 /****************************************************************************
  * Name: telnetd_start
  *
@@ -394,46 +373,10 @@ errout_with_daemon:
 
 int telnetd_start(FAR struct telnetd_config_s *config)
 {
-  FAR char *argv[2];
-  pid_t pid;
-
-#ifdef CONFIG_NETUTILS_TELNETD_USE_POSIX_SPAWNP
-  posix_spawn_file_actions_t file_actions;
-  posix_spawnattr_t attr;
-  int ret = 0;
-
-  posix_spawn_file_actions_init(&file_actions);
-  ret = posix_spawnattr_init(&attr);
-
-  if (ret < 0)
-    {
-      nerr("ERROR in posix_spawnattr_init(): %d\n", errno);
-      pid = -1;
-      goto errout;
-    }
-
-  argv[0] = CONFIG_NETUTILS_TELNETD_PATH;
-  argv[1] = NULL;
-
-  ret = posix_spawnp(&pid,
-                     CONFIG_NETUTILS_TELNETD_PATH,
-                     &file_actions, &attr, argv, NULL);
-
-  if (ret < 0)
-    {
-      nerr("ERROR in posix_spawnp(): %d\n", errno);
-      pid = -1;
-      goto errout_with_attrs;
-    }
-
-errout_with_attrs:
-  posix_spawnattr_destroy(&attr);
-
-errout:
-  return pid;
-#else
   FAR struct telnetd_s *daemon;
+  FAR char *argv[2];
   char arg0[sizeof("0x1234567812345678")];
+  pid_t pid;
 
   /* Allocate a state structure for the new daemon */
 
@@ -470,5 +413,4 @@ errout:
   /* Return success */
 
   return pid;
-#endif
 }

Reply via email to