-
Notifications
You must be signed in to change notification settings - Fork 1.5k
sched/nsh: Remove Hard-coded Default Password #18396
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2008,24 +2008,22 @@ mounted at ``/etc`` and will look like this at run-time: | |
| nsh> | ||
| ``/etc/init.d/rc.sysinit`` is system init script; ``/etc/init.d/rcS`` is the | ||
| start-up script; ``/etc/passwd`` is a the password file. It supports a single | ||
| user: | ||
| start-up script; ``/etc/passwd`` is the password file. | ||
|
|
||
| .. code:: text | ||
| USERNAME: admin | ||
| PASSWORD: Administrator | ||
| .. code:: console | ||
| The ``/etc/passwd`` file is auto-generated at build time when | ||
| ``CONFIG_ETC_ROMFS_GENPASSWD`` is enabled. To configure the admin user and | ||
| password, run ``make menuconfig`` and set: | ||
|
|
||
| nsh> cat /etc/passwd | ||
| admin:8Tv+Hbmr3pLVb5HHZgd26D:0:0:/ | ||
| * ``CONFIG_ETC_ROMFS_GENPASSWD=y`` | ||
| * ``CONFIG_ETC_ROMFS_PASSWD_USER`` (default: ``admin``) | ||
| * ``CONFIG_ETC_ROMFS_PASSWD_PASSWORD`` (required, build fails if empty) | ||
|
|
||
| The encrypted passwords in the provided passwd file are only valid if the | ||
| TEA key is set to: 012345678 9abcdef0 012345678 9abcdef0. | ||
| The password is hashed with TEA at build time using | ||
| ``tools/mkpasswd.py``; the plaintext is **not** stored in the firmware. | ||
|
Comment on lines
+2017
to
+2022
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not critical, but maybe this documentation which is repeated for multiple boards could be put somewhere common (i.e. a page about password usage) and then linked to from these boards instead. |
||
|
|
||
| Changes to either the key or the password word will require regeneration of the | ||
| ``nsh_romfimg.h`` header file. | ||
| The encrypted passwords are only valid if the TEA key matches the one | ||
| configured in ``CONFIG_FSUTILS_PASSWD_KEY1..4`` (default: | ||
| ``012345678 9abcdef0 012345678 9abcdef0``). | ||
|
|
||
| The format of the password file is: | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,6 +35,19 @@ $(ETCSRC): $(foreach raw,$(RCRAWS), $(if $(wildcard $(BOARD_DIR)$(DELIM)src$(DEL | |
| $(shell rm -rf $(ETCDIR)$(DELIM)$(raw)) \ | ||
| $(shell mkdir -p $(dir $(ETCDIR)$(DELIM)$(raw))) \ | ||
| $(shell cp -rfp $(if $(wildcard $(BOARD_DIR)$(DELIM)src$(DELIM)$(raw)), $(BOARD_DIR)$(DELIM)src$(DELIM)$(raw), $(if $(wildcard $(BOARD_COMMON_DIR)$(DELIM)$(raw)), $(BOARD_COMMON_DIR)$(DELIM)$(raw), $(BOARD_DIR)$(DELIM)src$(DELIM)$(raw))) $(ETCDIR)$(DELIM)$(raw))) | ||
| ifeq ($(CONFIG_ETC_ROMFS_GENPASSWD),y) | ||
| ifeq ($(CONFIG_ETC_ROMFS_PASSWD_PASSWORD),) | ||
| $(error CONFIG_ETC_ROMFS_PASSWD_PASSWORD must be set when ETC_ROMFS_GENPASSWD is enabled. Run 'make menuconfig' to set a password.) | ||
| endif | ||
| $(Q) mkdir -p $(ETCDIR)$(DELIM)$(CONFIG_ETC_ROMFSMOUNTPT) | ||
| $(Q) python3 $(TOPDIR)$(DELIM)tools$(DELIM)mkpasswd.py \ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this introduces python3 as mandatory build component, which may not be welcome, and it was not necessary, so probably there it another way :-) |
||
| --user $(CONFIG_ETC_ROMFS_PASSWD_USER) \ | ||
| --password $(CONFIG_ETC_ROMFS_PASSWD_PASSWORD) \ | ||
| --uid $(CONFIG_ETC_ROMFS_PASSWD_UID) \ | ||
| --gid $(CONFIG_ETC_ROMFS_PASSWD_GID) \ | ||
| --home $(CONFIG_ETC_ROMFS_PASSWD_HOME) \ | ||
| -o $(ETCDIR)$(DELIM)$(CONFIG_ETC_ROMFSMOUNTPT)$(DELIM)passwd | ||
| endif | ||
| $(Q) genromfs -f romfs.img -d $(ETCDIR)$(DELIM)$(CONFIG_ETC_ROMFSMOUNTPT) -V "NSHInitVol" | ||
| $(Q) echo "#include <nuttx/compiler.h>" > $@ | ||
| $(Q) xxd -i romfs.img | sed -e "s/^unsigned char/const unsigned char aligned_data(4)/g" >> $@ | ||
|
|
||
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -623,6 +623,46 @@ config ETC_FATMOUNTPT | |
| will mount a FAT FS under /tmp. This is the location where the FAT | ||
| FS will be mounted. Default is "/tmp". | ||
|
|
||
| config ETC_ROMFS_GENPASSWD | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| bool "Auto-generate /etc/passwd at build time" | ||
| default n | ||
| ---help--- | ||
| Generate the /etc/passwd file at build time from a user-supplied | ||
| password. This avoids shipping a hard-coded default password | ||
| (CWE-798). When enabled, the build will fail if no password | ||
| is configured, forcing each build to set its own credentials. | ||
|
|
||
| if ETC_ROMFS_GENPASSWD | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should you move the opion to boards/Kconfig and add BOARD_ prefix |
||
|
|
||
| config ETC_ROMFS_PASSWD_USER | ||
| string "Admin username" | ||
| default "admin" | ||
| ---help--- | ||
| The username for the auto-generated /etc/passwd entry. | ||
|
|
||
| config ETC_ROMFS_PASSWD_PASSWORD | ||
| string "Admin password (required)" | ||
| default "" | ||
| ---help--- | ||
| The plaintext password for the auto-generated /etc/passwd entry. | ||
| This value is hashed with TEA at build time; the plaintext is NOT | ||
| stored in the firmware image. The build will fail if this is left | ||
| empty. Set this via 'make menuconfig'. | ||
|
|
||
| config ETC_ROMFS_PASSWD_UID | ||
| int "Admin user ID" | ||
| default 0 | ||
|
|
||
| config ETC_ROMFS_PASSWD_GID | ||
| int "Admin group ID" | ||
| default 0 | ||
|
|
||
| config ETC_ROMFS_PASSWD_HOME | ||
| string "Admin home directory" | ||
| default "/" | ||
|
|
||
| endif # ETC_ROMFS_GENPASSWD | ||
|
|
||
| endif # ETC_ROMFS | ||
|
|
||
| config RR_INTERVAL | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This information was important because it explained how key was related to firmware code, where it was stored, and how to update. I would not remove it. Merge result should be more informative not less :-)