simbit18 commented on code in PR #19321:
URL: https://github.com/apache/nuttx/pull/19321#discussion_r3531073165
##########
cmake/nuttx_add_romfs.cmake:
##########
@@ -284,12 +284,39 @@ function(process_all_directory_romfs)
# Auto-generate /etc/passwd at build time if configured
if(CONFIG_BOARD_ETC_ROMFS_PASSWD_ENABLE)
+ execute_process(COMMAND "${NUTTX_DIR}/tools/apply_romfs_credentials.sh"
+ "${NUTTX_DIR}/.config" RESULT_VARIABLE _cred_rc)
+ if(NOT _cred_rc EQUAL 0)
+ message(FATAL_ERROR "apply_romfs_credentials.sh failed (rc=${_cred_rc})")
+ endif()
Review Comment:
@Abhishekmishra2808 Is this a Multi-platform solution
(${NUTTX_DIR}/tools/apply_romfs_credentials.sh") ?
##########
cmake/nuttx_add_romfs.cmake:
##########
@@ -317,22 +344,78 @@ function(process_all_directory_romfs)
add_custom_target(build_host_mkpasswd DEPENDS ${MKPASSWD_BIN})
endif()
- # Pass TEA key overrides when the user has changed them from defaults
- set(MKPASSWD_KEY_ARGS "")
- if(CONFIG_FSUTILS_PASSWD_KEY1)
- list(APPEND MKPASSWD_KEY_ARGS --key1 ${CONFIG_FSUTILS_PASSWD_KEY1})
- endif()
- if(CONFIG_FSUTILS_PASSWD_KEY2)
- list(APPEND MKPASSWD_KEY_ARGS --key2 ${CONFIG_FSUTILS_PASSWD_KEY2})
- endif()
- if(CONFIG_FSUTILS_PASSWD_KEY3)
- list(APPEND MKPASSWD_KEY_ARGS --key3 ${CONFIG_FSUTILS_PASSWD_KEY3})
+ set(GENPASSWD_OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/etc/passwd)
+
+ # Delegate detection and generation to the shell helpers so the logic is
+ # testable outside of cmake. check_passwd_keys.sh prints "yes" when keys
+ # are absent or at insecure defaults; gen_passwd_keys.sh writes fresh
+ # /dev/urandom values in-place.
+ #
+ # RANDOMIZE_KEYS — single-invocation path: 1. gen_passwd_keys.sh writes new
+ # keys to .config at configure time. 2. We re-read .config below so
+ # CONFIG_FSUTILS_PASSWD_KEY1..4 carry the new values for the rest of this
+ # cmake configure run. 3. add_custom_command is registered with the updated
+ # key values, so both mkpasswd (passwd hash) and the firmware use the same
+ # keys — login works without a second cmake invocation.
+ #
+ # Note: config.h is regenerated at build time from .config (its
dependency),
+ # so the firmware uses the correct keys automatically.
+
+ execute_process(
+ COMMAND "${NUTTX_DIR}/tools/check_passwd_keys.sh" "${NUTTX_DIR}/.config"
+ OUTPUT_VARIABLE _passwd_keys_need_setup
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ RESULT_VARIABLE _check_rc)
+ if(NOT _check_rc EQUAL 0)
+ message(
+ FATAL_ERROR
+ "check_passwd_keys.sh failed — check
${NUTTX_DIR}/tools/check_passwd_keys.sh"
+ )
endif()
Review Comment:
@Abhishekmishra2808 Is this a Multi-platform solution
(${NUTTX_DIR}/tools/check_passwd_keys.sh") ?
--
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]