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

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


The following commit(s) were added to refs/heads/master by this push:
     new 19cbea35a builtin: Give each builtin a uid, gid and mode in the CMake 
build.
19cbea35a is described below

commit 19cbea35a5614a26b1a73b9de99c51f7f3177db4
Author: Marco Casaroli <[email protected]>
AuthorDate: Sun Nov 8 22:16:21 2026 +0100

    builtin: Give each builtin a uid, gid and mode in the CMake build.
    
    With CONFIG_SCHED_USER_IDENTITY, struct builtin_s has uid, gid and mode
    after main.  REGISTER in Make.defs writes the UID, GID and MODE of the
    application, else 0, 0 and 0555.  builtin/CMakeLists.txt wrote only the
    name, priority, stack size and main, so the mode of each builtin was 0.
    With CONFIG_BINFMT_CHECKEXEC (default y with SCHED_USER_IDENTITY),
    binfmt/builtin.c then refuses each builtin with EACCES: nxinit cannot start
    NSH, and NSH cannot start a builtin.
    
    Write uid, gid and mode in the CMake build as REGISTER does: from the
    target properties APP_UID, APP_GID and APP_MODE if they are set, else 0, 0
    and 0555.
    
    Assisted-by: Claude Code:claude-opus-5-5
    Signed-off-by: Marco Casaroli <[email protected]>
---
 builtin/CMakeLists.txt | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/builtin/CMakeLists.txt b/builtin/CMakeLists.txt
index 3d8b244e4..bf84e9f0c 100644
--- a/builtin/CMakeLists.txt
+++ b/builtin/CMakeLists.txt
@@ -39,8 +39,30 @@ if(CONFIG_BUILTIN)
     get_target_property(APP_NAME ${module} APP_NAME)
     get_target_property(APP_PRIORITY ${module} APP_PRIORITY)
     get_target_property(APP_STACK ${module} APP_STACK)
+
+    # With SCHED_USER_IDENTITY, an entry also has uid, gid and mode: the UID,
+    # GID and MODE of the application, else 0, 0 and 0555, as REGISTER in
+    # Make.defs gives.
+
+    set(APP_IDENTITY)
+    if(CONFIG_SCHED_USER_IDENTITY)
+      get_target_property(APP_UID ${module} APP_UID)
+      get_target_property(APP_GID ${module} APP_GID)
+      get_target_property(APP_MODE ${module} APP_MODE)
+      if(NOT APP_UID)
+        set(APP_UID 0)
+      endif()
+      if(NOT APP_GID)
+        set(APP_GID 0)
+      endif()
+      if(NOT APP_MODE)
+        set(APP_MODE 0555)
+      endif()
+      set(APP_IDENTITY ", ${APP_UID}, ${APP_GID}, ${APP_MODE}")
+    endif()
+
     set(builtin_list_string
-        "${builtin_list_string}\{ \"${APP_NAME}\", ${APP_PRIORITY}, 
${APP_STACK}, ${APP_MAIN} \},  \n"
+        "${builtin_list_string}\{ \"${APP_NAME}\", ${APP_PRIORITY}, 
${APP_STACK}, ${APP_MAIN}${APP_IDENTITY} \},  \n"
     )
 
     # builtin_proto.h Example: int hello_main(int argc, char *argv[]);

Reply via email to