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.git

commit 66eac21f687ddf8eb0e19c73914358703bd444ef
Author: Royyan Zahir <[email protected]>
AuthorDate: Fri Oct 2 06:56:45 2026 +0400

    boards: reset and power-off need PR_CAP_ADMIN
    
    boardctl(BOARDIOC_RESET) and boardctl(BOARDIOC_POWEROFF) refuse a task
    group without it.
    
    Signed-off-by: Royyan Zahir <[email protected]>
---
 boards/boardctl.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/boards/boardctl.c b/boards/boardctl.c
index f78d0e77cc2..df128042a14 100644
--- a/boards/boardctl.c
+++ b/boards/boardctl.c
@@ -41,6 +41,7 @@
 #include <nuttx/binfmt/symtab.h>
 #include <nuttx/drivers/ramdisk.h>
 #include <nuttx/reboot_notifier.h>
+#include <nuttx/sched.h>
 #include <nuttx/trace.h>
 
 #ifdef CONFIG_NX
@@ -413,6 +414,12 @@ int boardctl(unsigned int cmd, uintptr_t arg)
 
       case BOARDIOC_POWEROFF:
         {
+          if (!nxsched_capable(PR_CAP_ADMIN))
+            {
+              ret = -EPERM;
+              break;
+            }
+
           reboot_notifier_call_chain(SYS_POWER_OFF, (FAR void *)arg);
           up_flush_dcache_all();
           ret = board_power_off((int)arg);
@@ -430,6 +437,12 @@ int boardctl(unsigned int cmd, uintptr_t arg)
 
       case BOARDIOC_RESET:
         {
+          if (!nxsched_capable(PR_CAP_ADMIN))
+            {
+              ret = -EPERM;
+              break;
+            }
+
           g_nx_initstate = OSINIT_RESET;
           sched_trace_mark("RESET");
           reboot_notifier_call_chain(SYS_RESTART, (FAR void *)arg);

Reply via email to