You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2022/08/09 15:17:30 UTC

[incubator-nuttx-apps] branch master updated (167c551e8 -> 41fe4f177)

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

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


    from 167c551e8 wamr: Add a new option to enable semaphore support
     new 000d1455b netutils: Make telnetd_daemon() in public
     new 3f70a78dd nshlib: Make nsh_telnetmain() in public
     new a86315050 system: telnetd: Add telnetd app
     new 41fe4f177 system:nsh : Apply CONFIG_NSH_DISABLE_TELNETSTART to nsh_main.c

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 include/netutils/telnetd.h                         |  31 +++++++
 include/nshlib/nshlib.h                            |  21 +++++
 netutils/telnetd/Kconfig                           |  23 ++++-
 netutils/telnetd/telnetd_daemon.c                  | 100 ++++++++++++++++-----
 nshlib/Kconfig                                     |   6 ++
 nshlib/nsh_telnetd.c                               |  10 +--
 system/nsh/nsh_main.c                              |   3 +-
 system/telnetd/Kconfig                             |  39 ++++++++
 system/{adb => telnetd}/Make.defs                  |   6 +-
 system/{ping => telnetd}/Makefile                  |  14 +--
 .../set_img_main.c => system/telnetd/telnetd.c     |  36 ++++----
 11 files changed, 234 insertions(+), 55 deletions(-)
 create mode 100644 system/telnetd/Kconfig
 copy system/{adb => telnetd}/Make.defs (92%)
 copy system/{ping => telnetd}/Makefile (80%)
 copy examples/mcuboot/swap_test/set_img_main.c => system/telnetd/telnetd.c (66%)


[incubator-nuttx-apps] 03/04: system: telnetd: Add telnetd app

Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit a86315050d080daed59ec95a8746ab838b43c0a7
Author: Masayuki Ishikawa <ma...@gmail.com>
AuthorDate: Mon Aug 8 09:54:22 2022 +0900

    system: telnetd: Add telnetd app
    
    Summary:
    - This commit adds telnetd app
    
    Impact:
    - None
    
    Testing:
    - Tested with sabre-6quad:netknsh (will be updated later)
    
    Signed-off-by: Masayuki Ishikawa <Ma...@jp.sony.com>
---
 system/telnetd/Kconfig   | 39 +++++++++++++++++++++++++++++++
 system/telnetd/Make.defs | 23 ++++++++++++++++++
 system/telnetd/Makefile  | 34 +++++++++++++++++++++++++++
 system/telnetd/telnetd.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 157 insertions(+)

diff --git a/system/telnetd/Kconfig b/system/telnetd/Kconfig
new file mode 100644
index 000000000..46eb2181e
--- /dev/null
+++ b/system/telnetd/Kconfig
@@ -0,0 +1,39 @@
+#
+# For a description of the syntax of this configuration file,
+# see the file kconfig-language.txt in the NuttX tools repository.
+#
+
+config SYSTEM_TELNETD
+	tristate "Telnet daemon application"
+	default n
+	depends on NETUTILS_TELNETD
+	---help---
+		Enable the Telnet daemon application
+
+config SYSTEM_TELNETD_PROGNAME
+	string "Telnetd program name"
+	default "telnetd"
+	depends on SYSTEM_TELNETD
+	---help---
+		This is the name of the program that will be used when the NSH ELF
+		program is installed.
+
+config SYSTEM_TELNETD_PRIORITY
+	int "Telnetd task priority"
+	default 100
+	depends on SYSTEM_TELNETD
+
+config SYSTEM_TELNETD_STACKSIZE
+	int "Telnetd task stack size"
+	default DEFAULT_TASK_STACKSIZE
+	depends on SYSTEM_TELNETD
+
+config SYSTEM_TELNETD_SESSION_PRIORITY
+	int "Telnetd session task priority"
+	default 100
+	depends on SYSTEM_TELNETD
+
+config SYSTEM_TELNETD_SESSION_STACKSIZE
+	int "Telnetd session task stack size"
+	default 3072
+	depends on SYSTEM_TELNETD
diff --git a/system/telnetd/Make.defs b/system/telnetd/Make.defs
new file mode 100644
index 000000000..dceb475ea
--- /dev/null
+++ b/system/telnetd/Make.defs
@@ -0,0 +1,23 @@
+############################################################################
+# apps/system/telnetd/Make.defs
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the
+# License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+############################################################################
+
+ifneq ($(CONFIG_SYSTEM_TELNETD),)
+CONFIGURED_APPS += $(APPDIR)/system/telnetd
+endif
diff --git a/system/telnetd/Makefile b/system/telnetd/Makefile
new file mode 100644
index 000000000..414e90ca5
--- /dev/null
+++ b/system/telnetd/Makefile
@@ -0,0 +1,34 @@
+############################################################################
+# apps/system/telnetd/Makefile
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the
+# License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+############################################################################
+
+include $(APPDIR)/Make.defs
+
+# telnetd
+
+PROGNAME  := $(CONFIG_SYSTEM_TELNETD_PROGNAME)
+PRIORITY  := $(CONFIG_SYSTEM_TELNETD_PRIORITY)
+STACKSIZE := $(CONFIG_SYSTEM_TELNETD_STACKSIZE)
+MODULE    := $(CONFIG_SYSTEM_TELNETD)
+
+# Files
+
+MAINSRC := telnetd.c
+
+include $(APPDIR)/Application.mk
diff --git a/system/telnetd/telnetd.c b/system/telnetd/telnetd.c
new file mode 100644
index 000000000..674f94160
--- /dev/null
+++ b/system/telnetd/telnetd.c
@@ -0,0 +1,61 @@
+/****************************************************************************
+ * apps/system/telnetd/telnetd.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "netutils/telnetd.h"
+#include "netutils/netlib.h"
+#include "nshlib/nshlib.h"
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+int main(int argc, FAR char *argv[])
+{
+  FAR char *argv1[3];
+  char arg0[sizeof("0x1234567812345678")];
+  struct telnetd_s daemon;
+
+  /* Initialize the daemon structure */
+
+  daemon.port      = HTONS(23);
+  daemon.family    = AF_INET;
+  daemon.entry     = nsh_telnetmain;
+
+  /* NOTE: Settings for telnet session task */
+
+  daemon.priority  = CONFIG_SYSTEM_TELNETD_SESSION_PRIORITY;
+  daemon.stacksize = CONFIG_SYSTEM_TELNETD_SESSION_STACKSIZE;
+
+  snprintf(arg0, sizeof(arg0), "0x%" PRIxPTR, (uintptr_t)&daemon);
+  argv1[0] = "telnetd";
+  argv1[1] = arg0;
+  argv1[2] = NULL;
+
+  telnetd_daemon(2, argv1);
+  return 0;
+}


[incubator-nuttx-apps] 02/04: nshlib: Make nsh_telnetmain() in public

Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 3f70a78dd3684035a1ac16002eafa49db7204a5f
Author: Masayuki Ishikawa <ma...@gmail.com>
AuthorDate: Fri Aug 5 14:37:28 2022 +0900

    nshlib: Make nsh_telnetmain() in public
    
    Summary:
    - This commit makes nsh_telnetmain() in public so that we can
      call it from applications.
    - Also, CONFIG_NSH_DISABLE_TELNETSTART is introduced so that
      we can disable nsh_telnetstart()
    
    Impact:
    - nsh with telnet daemon
    
    Testing:
    - Tested with sabre-6quad:netknsh (will be updated later)
    
    Signed-off-by: Masayuki Ishikawa <Ma...@jp.sony.com>
---
 include/nshlib/nshlib.h | 21 +++++++++++++++++++++
 nshlib/Kconfig          |  6 ++++++
 nshlib/nsh_telnetd.c    | 10 ++++------
 3 files changed, 31 insertions(+), 6 deletions(-)

diff --git a/include/nshlib/nshlib.h b/include/nshlib/nshlib.h
index cea122b5e..5d1157141 100644
--- a/include/nshlib/nshlib.h
+++ b/include/nshlib/nshlib.h
@@ -126,6 +126,27 @@ void nsh_initialize(void);
 
 int nsh_consolemain(int argc, FAR char *argv[]);
 
+/****************************************************************************
+ * Name: nsh_telnetmain
+ *
+ * Description:
+ *   This interface may be called or started with task_start to start a
+ *   single NSH instance that operates on stdin and stdout for telnet daemon.
+ *   This function does not return.
+ *
+ * Input Parameters:
+ *   Standard task start-up arguments.  These are not used.  argc may be
+ *   zero and argv may be NULL.
+ *
+ * Returned Values:
+ *   This function does not normally return.  exit() is usually called to
+ *   terminate the NSH session.  This function will return in the event of
+ *   an error.  In that case, a non-zero value is returned (EXIT_FAILURE=1).
+
+ ****************************************************************************/
+
+int nsh_telnetmain(int argc, FAR char *argv[]);
+
 /****************************************************************************
  * Name: nsh_telnetstart
  *
diff --git a/nshlib/Kconfig b/nshlib/Kconfig
index b75e95245..f584e9fc3 100644
--- a/nshlib/Kconfig
+++ b/nshlib/Kconfig
@@ -1157,6 +1157,12 @@ config NSH_IOBUFFER_SIZE
 		Determines the size of the I/O buffer to use for sending/
 		receiving TELNET commands/responses.  Default: 512
 
+config NSH_DISABLE_TELNETSTART
+	bool "Disable to start telnetd"
+	default false
+	---help---
+		Determines if the nsh starts telnetd automatically
+
 endif # NSH_TELNET
 endmenu # Telnet Configuration
 
diff --git a/nshlib/nsh_telnetd.c b/nshlib/nsh_telnetd.c
index 76ba97b50..19b701b8d 100644
--- a/nshlib/nsh_telnetd.c
+++ b/nshlib/nsh_telnetd.c
@@ -59,14 +59,14 @@ enum telnetd_state_e
 };
 
 /****************************************************************************
- * Private Functions
+ * Public Functions
  ****************************************************************************/
 
 /****************************************************************************
  * Name: nsh_telnetmain
  ****************************************************************************/
 
-static int nsh_telnetmain(int argc, char *argv[])
+int nsh_telnetmain(int argc, FAR char *argv[])
 {
   FAR struct console_stdio_s *pstate = nsh_newconsole(true);
   FAR struct nsh_vtbl_s *vtbl;
@@ -192,10 +192,6 @@ static int nsh_telnetmain(int argc, char *argv[])
   return OK;
 }
 
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
 /****************************************************************************
  * Name: nsh_telnetstart
  *
@@ -218,6 +214,7 @@ static int nsh_telnetmain(int argc, char *argv[])
  *
  ****************************************************************************/
 
+#ifndef CONFIG_NSH_DISABLE_TELNETSTART
 int nsh_telnetstart(sa_family_t family)
 {
   static enum telnetd_state_e state = TELNETD_NOTRUNNING;
@@ -325,6 +322,7 @@ int nsh_telnetstart(sa_family_t family)
 
   return ret;
 }
+#endif
 
 /****************************************************************************
  * Name: cmd_telnetd


[incubator-nuttx-apps] 04/04: system:nsh : Apply CONFIG_NSH_DISABLE_TELNETSTART to nsh_main.c

Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 41fe4f177ab49e81c8c8088b787f1ead1dc465c1
Author: Masayuki Ishikawa <ma...@gmail.com>
AuthorDate: Mon Aug 8 10:26:19 2022 +0900

    system:nsh : Apply CONFIG_NSH_DISABLE_TELNETSTART to nsh_main.c
    
    Summary:
    - This commit applies CONFIG_NSH_DISABLE_TELNETSTART to nsh_main.c
    
    Impact:
    - None
    
    Testing:
    - Tested with sabre-6quad:netknsh (will be updated later)
    
    Signed-off-by: Masayuki Ishikawa <Ma...@jp.sony.com>
---
 system/nsh/nsh_main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/system/nsh/nsh_main.c b/system/nsh/nsh_main.c
index 87fa48a08..5db22980f 100644
--- a/system/nsh/nsh_main.c
+++ b/system/nsh/nsh_main.c
@@ -127,7 +127,8 @@ int main(int argc, FAR char *argv[])
 
   nsh_initialize();
 
-#if defined(CONFIG_NSH_TELNET) && !defined(CONFIG_NETINIT_NETLOCAL)
+#if defined(CONFIG_NSH_TELNET) && !defined(CONFIG_NSH_DISABLE_TELNETSTART) && \
+  !defined(CONFIG_NETINIT_NETLOCAL)
   /* If the Telnet console is selected as a front-end, then start the
    * Telnet daemon UNLESS network initialization is deferred via
    * CONFIG_NETINIT_NETLOCAL.  In that case, the telnet daemon must be


[incubator-nuttx-apps] 01/04: netutils: Make telnetd_daemon() in public

Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 000d1455b49878d707ed94abea3f3f33120ce322
Author: Masayuki Ishikawa <ma...@gmail.com>
AuthorDate: Fri Aug 5 14:34:49 2022 +0900

    netutils: Make telnetd_daemon() in public
    
    Summary:
    - This commit makes telnetd_daemon() in public so that we
      can call it from applications.
    - Also, adds new configs to support posix_spawnp()
    
    Impact:
    - telnetd only
    
    Testing:
    - Tested with sabre-6quad:netknsh (will be updated later)
    
    Signed-off-by: Masayuki Ishikawa <Ma...@jp.sony.com>
---
 include/netutils/telnetd.h        |  31 ++++++++++++
 netutils/telnetd/Kconfig          |  23 ++++++++-
 netutils/telnetd/telnetd_daemon.c | 100 ++++++++++++++++++++++++++++++--------
 3 files changed, 131 insertions(+), 23 deletions(-)

diff --git a/include/netutils/telnetd.h b/include/netutils/telnetd.h
index 11fb39f58..5ccfcb720 100644
--- a/include/netutils/telnetd.h
+++ b/include/netutils/telnetd.h
@@ -65,6 +65,20 @@ 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
  ****************************************************************************/
@@ -77,6 +91,23 @@ 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 eff726523..582dc5e76 100644
--- a/netutils/telnetd/Kconfig
+++ b/netutils/telnetd/Kconfig
@@ -11,5 +11,24 @@ config NETUTILS_TELNETD
 	---help---
 		Enable support for the Telnet daemon.
 
-if NETUTILS_TELNETD
-endif
+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.
diff --git a/netutils/telnetd/telnetd_daemon.c b/netutils/telnetd/telnetd_daemon.c
index 2756831e8..fda5b172d 100644
--- a/netutils/telnetd/telnetd_daemon.c
+++ b/netutils/telnetd/telnetd_daemon.c
@@ -41,6 +41,7 @@
 #include <assert.h>
 #include <errno.h>
 #include <debug.h>
+#include <spawn.h>
 
 #include <netinet/in.h>
 #include <arpa/inet.h>
@@ -54,24 +55,14 @@
  * Private Types
  ****************************************************************************/
 
-/* 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. */
-};
-
 /****************************************************************************
  * Private Functions
  ****************************************************************************/
 
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
 /****************************************************************************
  * Name: telnetd_daemon
  *
@@ -87,7 +78,7 @@ struct telnetd_s
  *
  ****************************************************************************/
 
-static int telnetd_daemon(int argc, FAR char *argv[])
+int telnetd_daemon(int argc, FAR char *argv[])
 {
   FAR struct telnetd_s *daemon;
   union
@@ -101,6 +92,11 @@ static 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;
@@ -316,6 +312,29 @@ static 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.
        */
@@ -328,6 +347,7 @@ static 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. */
 
@@ -339,6 +359,11 @@ static 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:
@@ -346,10 +371,6 @@ errout_with_daemon:
   return 1;
 }
 
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
 /****************************************************************************
  * Name: telnetd_start
  *
@@ -371,11 +392,47 @@ errout_with_daemon:
 
 int telnetd_start(FAR struct telnetd_config_s *config)
 {
-  FAR struct telnetd_s *daemon;
   FAR char *argv[2];
-  char arg0[sizeof("0x1234567812345678")];
   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;
+  char arg0[sizeof("0x1234567812345678")];
+
   /* Allocate a state structure for the new daemon */
 
   daemon = (FAR struct telnetd_s *)malloc(sizeof(struct telnetd_s));
@@ -411,4 +468,5 @@ int telnetd_start(FAR struct telnetd_config_s *config)
   /* Return success */
 
   return pid;
+#endif
 }