mirror of
https://github.com/LibreELEC/LibreELEC.tv.git
synced 2025-07-29 05:36:47 +00:00
config/buildsystem: generate password hash in add_user using python
Python3's crypt module is capable of generating password hashes. Use that instead of busybox:host's cryptpw function. Move password hashing into config/function's add_user(), so one need not remember to generate the hash and then pass it into add_user(). Signed-off-by: Ian Leonard <antonlacon@gmail.com>
This commit is contained in:
parent
e0f9e2db10
commit
2cb6f17526
@ -1480,6 +1480,8 @@ add_user() {
|
|||||||
PASSWORD="$2"
|
PASSWORD="$2"
|
||||||
if [ "$PASSWORD" = "x" ]; then
|
if [ "$PASSWORD" = "x" ]; then
|
||||||
PASSWORD="*"
|
PASSWORD="*"
|
||||||
|
else
|
||||||
|
PASSWORD=$(python -c "import crypt; print(crypt.crypt('$PASSWORD', crypt.mksalt(crypt.METHOD_SHA512)))")
|
||||||
fi
|
fi
|
||||||
if ! grep -q "^$1:" ${INSTALL}/usr/cache/shadow; then
|
if ! grep -q "^$1:" ${INSTALL}/usr/cache/shadow; then
|
||||||
echo "$1:$PASSWORD:::::::" >> ${INSTALL}/usr/cache/shadow
|
echo "$1:$PASSWORD:::::::" >> ${INSTALL}/usr/cache/shadow
|
||||||
|
@ -180,12 +180,10 @@ makeinstall_target() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
post_install() {
|
post_install() {
|
||||||
ROOT_PWD="$(${TOOLCHAIN}/bin/cryptpw -m sha512 ${ROOT_PASSWORD})"
|
|
||||||
|
|
||||||
echo "chmod 4755 ${INSTALL}/usr/bin/busybox" >> ${FAKEROOT_SCRIPT}
|
echo "chmod 4755 ${INSTALL}/usr/bin/busybox" >> ${FAKEROOT_SCRIPT}
|
||||||
echo "chmod 000 ${INSTALL}/usr/cache/shadow" >> ${FAKEROOT_SCRIPT}
|
echo "chmod 000 ${INSTALL}/usr/cache/shadow" >> ${FAKEROOT_SCRIPT}
|
||||||
|
|
||||||
add_user root "${ROOT_PWD}" 0 0 "Root User" "/storage" "/bin/sh"
|
add_user root "${ROOT_PASSWORD}" 0 0 "Root User" "/storage" "/bin/sh"
|
||||||
add_group root 0
|
add_group root 0
|
||||||
add_group users 100
|
add_group users 100
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user