Abhishekmishra2808 opened a new pull request, #3735:
URL: https://github.com/apache/nuttx-apps/pull/3735

   ## Summary
   
   Adds an NSH `chroot` helper that `chdir`s into the new root, calls 
`chroot(".")`, then `chdir("/")` so relative paths stay in the jail. The 
command form `chroot <newroot> <command>` closes non-stdio, non-`O_CLOEXEC` 
descriptors before `execvp` so inherited host fds cannot bypass the jail. 
ostest covers jail visibility, host-path isolation, child inheritance, and 
leftover pre-opened fds.
   
   ## Impact
   
   The NSH command is gated by `CONFIG_FS_CHROOT` and can be disabled with 
`CONFIG_NSH_DISABLE_CHROOT`. ostest runs the new case only when 
`CONFIG_FS_CHROOT` and `CONFIG_SCHED_WAITPID` are set and the build is not 
kernel. Companion kernel change is apache/nuttx#19900.
   
   ## Testing
   
   Host: WSL2 x86_64. Board: `sim` (`CONFIG_FS_CHROOT=y`, 
`CONFIG_TESTING_OSTEST=y`), with nuttx `feature/fs-chroot`.
   
   ```
   $ ./tools/checkpatch.sh -f apps/nshlib/nsh_envcmds.c 
apps/testing/ostest/chroot.c
   ✔️ All checks pass.
   ```
   
   ```
   login: root
   User Logged-in!
   nsh> ostest
   ...
   user_main: chroot test
   chroot_test: Starting test
   chroot_test: /marker is visible inside the jail
   chroot_test: host paths are not visible inside the jail
   chroot_test: pre-opened host fd still usable after chroot
   chroot_test: grandchild still sees the jail
   chroot_test: PASSED
   ```
   
   
   Made with [Cursor](https://cursor.com)


-- 
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]

Reply via email to