mirror of
https://github.com/godotengine/buildroot.git
synced 2026-01-04 06:10:16 +03:00
system: allow/disallow root login, accept encoded passwords
Currently, there are only two possibilities regarding the root account:
- it is enabled with no password (the default)
- it is enabled, using a clear-text, user-provided password
This is deemed insufficient in many cases, especially when the .config
file has to be published (e.g. for the GPL compliance, or any other
reason.).
Fix that in two ways:
- add a boolean option that allows/disallows root login altogether,
which defaults to 'y' to keep backward compatibility;
- accept already-encoded passwords, which we recognise as starting
with either of $1$, $5$ or $6$ (resp. for md5, sha256 or sha512).
Signed-off-by: Lorenzo M. Catucci <lorenzo@sancho.ccd.uniroma2.it>
[yann.morin.1998@free.fr:
- don't add a choice to select between clear-text/encoded password,
use a single prompt;
- differentiate in the password hook itself;
- rewrite parts of the help entry;
- rewrite and expand the commit log
]
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Cc: Arnout Vandecappelle <arnout@mind.be>
Reviewed-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
Tested-by: "Lorenzo M. Catucci" <lorenzo@sancho.ccd.uniroma2.it>
Acked-by: "Lorenzo M. Catucci" <lorenzo@sancho.ccd.uniroma2.it>
Tested-by: Gergely Imreh <imrehg@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
This commit is contained in:
committed by
Thomas Petazzoni
parent
9a42ba3eeb
commit
18fa4a32a6
@@ -34,10 +34,6 @@ endef
|
||||
TARGET_FINALIZE_HOOKS += SYSTEM_ISSUE
|
||||
endif
|
||||
|
||||
ifneq ($(TARGET_GENERIC_ROOT_PASSWD),)
|
||||
PACKAGES += host-mkpasswd
|
||||
endif
|
||||
|
||||
define SET_NETWORK_LOCALHOST
|
||||
( \
|
||||
echo "# interface file auto-generated by buildroot"; \
|
||||
@@ -69,12 +65,25 @@ TARGET_FINALIZE_HOOKS += SET_NETWORK
|
||||
|
||||
ifeq ($(BR2_ROOTFS_SKELETON_DEFAULT),y)
|
||||
|
||||
define SYSTEM_ROOT_PASSWD
|
||||
[ -n "$(TARGET_GENERIC_ROOT_PASSWD)" ] && \
|
||||
TARGET_GENERIC_ROOT_PASSWD_HASH=$$($(MKPASSWD) -m "$(TARGET_GENERIC_PASSWD_METHOD)" "$(TARGET_GENERIC_ROOT_PASSWD)"); \
|
||||
$(SED) "s,^root:[^:]*:,root:$$TARGET_GENERIC_ROOT_PASSWD_HASH:," $(TARGET_DIR)/etc/shadow
|
||||
ifeq ($(BR2_TARGET_ENABLE_ROOT_LOGIN),y)
|
||||
ifeq ($(TARGET_GENERIC_ROOT_PASSWD),)
|
||||
SYSTEM_ROOT_PASSWORD =
|
||||
else ifneq ($(filter $$1$$% $$5$$% $$6$$%,$(TARGET_GENERIC_ROOT_PASSWD)),)
|
||||
SYSTEM_ROOT_PASSWORD = $(TARGET_GENERIC_ROOT_PASSWD)
|
||||
else
|
||||
PACKAGES += host-mkpasswd
|
||||
# This variable will only be evaluated in the finalize stage, so we can
|
||||
# be sure that host-mkpasswd will have already been built by that time.
|
||||
SYSTEM_ROOT_PASSWORD = $(shell $(MKPASSWD) -m "$(TARGET_GENERIC_PASSWD_METHOD)" "$(TARGET_GENERIC_ROOT_PASSWD)")
|
||||
endif
|
||||
else # !BR2_TARGET_ENABLE_ROOT_LOGIN
|
||||
SYSTEM_ROOT_PASSWORD = *
|
||||
endif
|
||||
|
||||
define SYSTEM_SET_ROOT_PASSWD
|
||||
$(SED) 's,^root:[^:]*:,root:$(SYSTEM_ROOT_PASSWORD):,' $(TARGET_DIR)/etc/shadow
|
||||
endef
|
||||
TARGET_FINALIZE_HOOKS += SYSTEM_ROOT_PASSWD
|
||||
TARGET_FINALIZE_HOOKS += SYSTEM_SET_ROOT_PASSWD
|
||||
|
||||
ifeq ($(BR2_SYSTEM_BIN_SH_NONE),y)
|
||||
define SYSTEM_BIN_SH
|
||||
|
||||
Reference in New Issue
Block a user