Merge "[Feature][T8TSK-11][TCAM_T800_SW_0246]add uart root user set password to login" into GSW3.0
diff --git a/meta/meta-mediatek-mt2735/recipes-core/autologin/systemd-serialgetty.bbappend b/meta/meta-mediatek-mt2735/recipes-core/autologin/systemd-serialgetty.bbappend
deleted file mode 100644
index c11630a..0000000
--- a/meta/meta-mediatek-mt2735/recipes-core/autologin/systemd-serialgetty.bbappend
+++ /dev/null
@@ -1,3 +0,0 @@
-do_install_prepend() {
- sed -i 's/sbin\/agetty/sbin\/agetty --autologin root/g' ${WORKDIR}/serial-getty@.service
-}
diff --git a/meta/meta-mediatek-mt2735/recipes-core/images/mtk-image-2735.bb b/meta/meta-mediatek-mt2735/recipes-core/images/mtk-image-2735.bb
index 71da4aa..cab152a 100755
--- a/meta/meta-mediatek-mt2735/recipes-core/images/mtk-image-2735.bb
+++ b/meta/meta-mediatek-mt2735/recipes-core/images/mtk-image-2735.bb
@@ -201,3 +201,11 @@
ROOTFS_POSTPROCESS_COMMAND += " gen_feature_property;"
addtask modem_align_4kb after do_image_complete before do_build
+
+#dongyu@2022.8.22 add uart root user set password to login start
+ROOTFS_POSTPROCESS_COMMAND += "change_root_psw;"
+change_root_psw() {
+ mv ${IMAGE_ROOTFS}/etc/shadow ${IMAGE_ROOTFS}/etc/config/shadow;
+ ln -s /etc/config/shadow ${IMAGE_ROOTFS}/etc/shadow;
+}
+#dongyu@2022.8.22 add uart root user set password to login end
diff --git a/meta/meta-mediatek-mt2735/recipes-lynq/lynq-uart-service/files/lynq_uart_password.service b/meta/meta-mediatek-mt2735/recipes-lynq/lynq-uart-service/files/lynq_uart_password.service
new file mode 100644
index 0000000..66d89d8
--- /dev/null
+++ b/meta/meta-mediatek-mt2735/recipes-lynq/lynq-uart-service/files/lynq_uart_password.service
@@ -0,0 +1,10 @@
+[Unit]
+Description=uart root user set password to login
+
+[Service]
+Type=simple
+ExecStart=/bin/sh /etc/lynq_uart_password.sh
+ExecStopPost=/etc/lynq_uart_password.sh
+
+[Install]
+WantedBy=multi-user.target
diff --git a/meta/meta-mediatek-mt2735/recipes-lynq/lynq-uart-service/files/lynq_uart_password.sh b/meta/meta-mediatek-mt2735/recipes-lynq/lynq-uart-service/files/lynq_uart_password.sh
new file mode 100644
index 0000000..7fa2ae6
--- /dev/null
+++ b/meta/meta-mediatek-mt2735/recipes-lynq/lynq-uart-service/files/lynq_uart_password.sh
@@ -0,0 +1,24 @@
+#!/bin/sh
+# uart root user set password to login
+
+# uart generate random alphanumeric string
+randstr() {
+ index=0
+ str=""
+ for i in {a..z}; do arr[index]=$i; index=`expr ${index} + 1`; done
+ for i in {A..Z}; do arr[index]=$i; index=`expr ${index} + 1`; done
+ for i in {0..9}; do arr[index]=$i; index=`expr ${index} + 1`; done
+ for i in {1..20}; do str="$str${arr[$RANDOM%$index]}"; done
+ echo $str
+}
+
+raw_passwd=`randstr`
+echo "The plaintext secret key for uart login: $raw_passwd" > /tmp/uart_login_password.log
+
+# The root user configures the secret key
+password=`openssl passwd -6 -salt lynq $raw_passwd`
+echo "Ciphertext secret key for uart login: $password"
+sed "s%^root:[^:]*:%root:$password:%" \
+ < /etc/shadow \
+ > /etc/config/shadow.new;
+mv /etc/config/shadow.new /etc/config/shadow;
diff --git a/meta/meta-mediatek-mt2735/recipes-lynq/lynq-uart-service/lynq-uart-service.bb b/meta/meta-mediatek-mt2735/recipes-lynq/lynq-uart-service/lynq-uart-service.bb
new file mode 100644
index 0000000..11309d9
--- /dev/null
+++ b/meta/meta-mediatek-mt2735/recipes-lynq/lynq-uart-service/lynq-uart-service.bb
@@ -0,0 +1,21 @@
+DESCRIPTION = "uart root user set password to login"
+LICENSE = "MediaTekProprietary"
+LIC_FILES_CHKSUM = "file://${COREBASE}/bitbake/COPYING;md5=751419260aa954499f7abaabaa882bbe"
+
+SRC_URI = "file://lynq_uart_password.service \
+ file://lynq_uart_password.sh "
+
+inherit systemd
+
+SYSTEMD_PACKAGES = "${PN}"
+FILES_${PN} += "/etc/lynq_uart_password.sh"
+
+SYSTEMD_SERVICE_${PN} = "lynq_uart_password.service"
+
+do_install() {
+ install -d ${D}/etc
+ install -d ${D}/${systemd_unitdir}/system
+ install -m 755 ${WORKDIR}/lynq_uart_password.sh ${D}/etc/
+ install -m 755 ${WORKDIR}/lynq_uart_password.service ${D}${systemd_unitdir}/system/
+}
+
diff --git a/meta/meta-mediatek-mt2735/recipes-lynq/packagegroups/packagegroup-lync-mt2735.bb b/meta/meta-mediatek-mt2735/recipes-lynq/packagegroups/packagegroup-lync-mt2735.bb
index 5edcd36..31f10fd 100755
--- a/meta/meta-mediatek-mt2735/recipes-lynq/packagegroups/packagegroup-lync-mt2735.bb
+++ b/meta/meta-mediatek-mt2735/recipes-lynq/packagegroups/packagegroup-lync-mt2735.bb
@@ -39,6 +39,7 @@
liblynq-system-own \
lynq-wg870 \
lynq-ril-service \
+ lynq-uart-service \
liblynq-call \
liblynq-data \
liblynq-sms \