sched/nsh: Remove Hard-coded Default Password#18396
sched/nsh: Remove Hard-coded Default Password#18396Abhishekmishra2808 wants to merge 3 commits intoapache:masterfrom
Conversation
|
@Abhishekmishra2808 the Documentation and the boardshould be (each one) in a separated. Normally we separate the logic implementation from the board support and Documentation. |
53b43ad to
0670d28
Compare
|
Thank you @Abhishekmishra2808 :-)
|
0670d28 to
0214816
Compare
|
Hi @cederom , I used AI tools only to help refine wording and improve clarity in the description, but the implementation, debugging, and testing were done by me. |
|
@acassis I have fixed the changes suggested by you, and CI was failing because password generation was enabled in the defconfig files without setting a password. I have now removed |
There was a problem hiding this comment.
Thank you @Abhishekmishra2808 :-)
- Thanks for updating the PR description to closed match the change, it looks a lot better now :-)
- Please update "tools/mkpasswd: replace mkpasswd.py with C host tool" git commit title and body.
- It does not match the content, it touches more things.
- We did not have this tool before so we cannot reference it out of nowhere.
- Looks like you were working directly from a master of your clone, and had your local changes over there, thus confusion. I can see you use working branch for the PR already, very good! This is why clone master should always resemble upstream master and then you work on your local branch to have a solid reference point :-)
- Please update "sched: Remove hard-coded default password and add build-time generation" git commit title and body.
- This is BOARD functionality but not SCHED as @xiaoxiang781216 noted :-)
- Please describe other changes introduced in this commit.
- As there is one functional change you can put all passwd related changes into one single commit. But we prefer having incremental changes, like tools/mkpasswd introduction into one commit, boards changes separate commit, documentation changes separate commit, etc :-)
9e21da9 to
6ff1299
Compare
|
@cederom! I've addressed the feedback
Documentation and commit messages were updated to clarify that Please let me know if anything else should be adjusted. |
6ff1299 to
33816b2
Compare
f6a23b4
|
@Abhishekmishra2808 please fix |
f4779d5 to
67a17ff
Compare
61dc245 to
da1f7b4
Compare
|
CI turned red agaim ! :-( |
@Abhishekmishra2808 not, everything is fine, the error in the ESP32 is not related to this PR |
|
Yup, CI needs a fix, will show up soon, guys are working on this already :-) #18501 (comment) |
|
@Abhishekmishra2808 after the esp32 fix, please update your upstream branch and rebase your branch to it. |
cederom
left a comment
There was a problem hiding this comment.
Very cool, thank you @Abhishekmishra2808, lets just wait with merge until CI is fixed :-)
@xiaoxiang781216 sources updated could you please take a look? :-)
|
@Abhishekmishra2808 One question: |
|
@simbit18
CMake:
All 5 builds completed successfully. The mkpasswd host tool compiles and produces the correct 5-field passwd entry format, and empty passwords are correctly rejected at build time. |
|
@Abhishekmishra2808 please update your upstream branch and rebase your branch to upstream |
Add tools/mkpasswd.c, a self-contained C99 host tool that generates a single /etc/passwd entry at build time. The tool is invoked by the board ROMFS build step when CONFIG_BOARD_ETC_ROMFS_PASSWD_ENABLE is set. The TEA encryption algorithm and custom base64 encoding match the runtime implementations in: libs/libc/misc/lib_tea_encrypt.c apps/fsutils/passwd/passwd_encrypt.c so passwords generated at build time are directly usable by the NuttX login subsystem without any runtime re-hashing. The plaintext password is never stored in the firmware image. Changes: - tools/mkpasswd.c: new C host tool (pure C99, no external dependencies) - tools/Makefile.host: add mkpasswd build rule - tools/.gitignore: exclude compiled mkpasswd binary - .gitignore: exclude etctmp/ (generated at build time, not to be committed) Signed-off-by: Abhishek Mishra <mishra.abhishek2808@gmail.com>
…ation Fixes apache#16822 Introduce CONFIG_BOARD_ETC_ROMFS_PASSWD_ENABLE (and companion options BOARD_ETC_ROMFS_PASSWD_USER/PASSWORD/UID/GID/HOME) in boards/Kconfig to control build-time /etc/passwd generation. Placing the option under boards/ reflects that this is board-level functionality, not scheduler functionality. When BOARD_ETC_ROMFS_PASSWD_ENABLE=y the ROMFS build step calls tools/mkpasswd to hash the configured plaintext password with TEA and write the result into etctmp/<mountpoint>/passwd before genromfs packs it into the ROMFS image. The build fails if the password is left empty, preventing firmware from shipping without credentials (CWE-798). Changes: - boards/Kconfig: new CONFIG_BOARD_ETC_ROMFS_PASSWD_ENABLE option and companion BOARD_ETC_ROMFS_PASSWD_{USER,PASSWORD,UID,GID,HOME} options; depends on ETC_ROMFS - boards/Board.mk: invoke tools/mkpasswd under BOARD_ETC_ROMFS_PASSWD_ENABLE - cmake/nuttx_add_romfs.cmake: same guard for CMake builds - boards/sim/sim/sim/src/{Makefile,CMakeLists.txt,etc/passwd}: remove static passwd file; let the build step generate it instead - boards/risc-v/esp32c3-legacy/.../Make.defs,etc/passwd: same cleanup Signed-off-by: Abhishek Mishra <mishra.abhishek2808@gmail.com>
Add a central reference section in Documentation/components/tools/index.rst that describes the build-time /etc/passwd generation mechanism: - why it is needed (avoids hard-coded default password, CWE-798) - how it works: tools/mkpasswd hashes the plaintext password with TEA, identical to the runtime algorithm in lib_tea_encrypt.c; the plaintext is never stored in firmware - the Kconfig options to enable and configure it (CONFIG_BOARD_ETC_ROMFS_PASSWD_ENABLE and companion options) - the /etc/passwd file format - step-by-step verification instructions Update board-level documentation to reference the central section instead of duplicating the explanation, and update all CONFIG_ names to the new BOARD_ETC_ROMFS_PASSWD_* naming: - Documentation/platforms/sim/sim/boards/sim/index.rst - Documentation/platforms/renesas/rx65n/boards/rx65n-grrose/index.rst - Documentation/platforms/risc-v/esp32c3-legacy/boards/esp32c3-legacy-devkit/ROMFS.txt Signed-off-by: Abhishek Mishra <mishra.abhishek2808@gmail.com>
da1f7b4 to
d7b5de0
Compare
Summary
This PR introduces build-time generation of the
/etc/passwdfile for the ROMFS image when authentication is enabled.Instead of relying on a static
etc/passwdfile embedded in the source tree, the passwd entry is now generated during the build using the configuration values:CONFIG_ETC_ROMFS_PASSWD_USERCONFIG_ETC_ROMFS_PASSWD_PASSWORDCONFIG_ETC_ROMFS_PASSWD_UIDCONFIG_ETC_ROMFS_PASSWD_GIDCONFIG_ETC_ROMFS_PASSWD_HOMEThe generated passwd entry is written into the ROMFS staging directory and included in the firmware image.
Behavior
Authentication disabled
Authentication enabled
/etc/passwdautomatically.Password missing
CONFIG_ETC_ROMFS_GENPASSWD=ybut the password is empty, the build fails with an explicit error.This ensures that credentials are always explicitly configured when authentication is enabled and prevents firmware images from being built with empty passwords.
Security Improvement
Previously
/etc/passwdcould be included as a static file in the ROMFS source tree.With this change, the credentials are generated at build time and must be explicitly configured, avoiding implicit or default credentials in firmware images.
Testing
Generated passwd entry
Plaintext password check

Build failure when password is empty