From 7cfa02ca1112b294c7e8d3bc6e2d8626076861ef Mon Sep 17 00:00:00 2001 From: Huang Xin Date: Wed, 29 Jun 2022 09:15:08 -0700 Subject: [PATCH] 1. Support create avs user and root password --- .../recipes-apps/useradd/useradd.bb | 71 +++++++++++++++++++ .../recipes-apps/useradd/useradd/dot.bashrc | 16 +++++ .../recipes-apps/useradd/useradd/dot.profile | 10 +++ .../images/mtk-image-aud-8516.bb | 5 +- .../base-files/base-files_3.0.14.bb | 11 ++- 5 files changed, 105 insertions(+), 8 deletions(-) create mode 100644 meta/meta-mediatek-aud/recipes-apps/useradd/useradd.bb create mode 100644 meta/meta-mediatek-aud/recipes-apps/useradd/useradd/dot.bashrc create mode 100644 meta/meta-mediatek-aud/recipes-apps/useradd/useradd/dot.profile diff --git a/meta/meta-mediatek-aud/recipes-apps/useradd/useradd.bb b/meta/meta-mediatek-aud/recipes-apps/useradd/useradd.bb new file mode 100644 index 000000000..9b453a9fb --- /dev/null +++ b/meta/meta-mediatek-aud/recipes-apps/useradd/useradd.bb @@ -0,0 +1,71 @@ +SUMMARY = "Example recipe for using inherit useradd" +DESCRIPTION = "This recipe serves as an example for using features from useradd.bbclass" +SECTION = "examples" +PR = "r1" +LICENSE = "MIT" +LIC_FILES_CHKSUM = "file://${COREBASE}/LICENSE;md5=4d92cd373abda3937c2bc47fbc49d690 \ + file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420" + +SRC_URI = "file://dot.bashrc \ + file://dot.profile \ + " + + + +S = "${WORKDIR}" + +#PACKAGES =+ "${PN}-user3 ${PN}-root" + +inherit useradd + +# You must set USERADD_PACKAGES when you inherit useradd. This +# lists which output packages will include the user/group +# creation code. +USERADD_PACKAGES = "${PN}" +#USERADD_PACKAGES = "${PN} ${PN}-user3 ${PN}-root" + +# You must also set USERADD_PARAM and/or GROUPADD_PARAM when +# you inherit useradd. + +# USERADD_PARAM specifies command line options to pass to the +# useradd command. Multiple users can be created by separating +# the commands with a semicolon. Here we'll create two users, +# user1 and user2: +USERADD_PARAM_${PN} = "-u 1000 -m -d /home/avs -r -s /bin/bash -P 'avs123!@#' avs" + +# user3 will be managed in the useradd-example-user3 pacakge: +# As an example, we use the -P option to set clear text password for user3 +#USERADD_PARAM_${PN}-user3 = "-u 1202 -d /home/user3 -r -s /bin/bash -P 'user3' user3" + +# root will be managed in the useradd-root pacakge: +# As an example, we use the -P option to set clear text password for root +#USERADD_PARAM_${PN}-root = "-u 0 -d /home/root -r -s /bin/bash -P '123321' root" + +# GROUPADD_PARAM works the same way, which you set to the options +# you'd normally pass to the groupadd command. This will create +# groups group1 and group2: +#GROUPADD_PARAM_${PN} = "-g 881 group1; -g 890 group2" + +# Likewise, we'll manage group3 in the useradd-example-user3 package: +#GROUPADD_PARAM_${PN}-user3 = "-g 900 group3" + +# Likewise, we'll manage group3 in the useradd-example-root package: +#GROUPADD_PARAM_${PN}-root = "-g 0 root" + +do_install_append() { + install -m 0755 -o root -g root -d ${D}/home/root/ + install -m 0755 -o root -g root ${S}/dot.bashrc ${D}/home/root/.bashrc + install -m 0755 -o root -g root ${S}/dot.profile ${D}/home/root/.profile + + install -d -m 755 ${D}/home/avs/ + install -m 0755 -o avs -g avs ${S}/dot.bashrc ${D}/home/avs/.bashrc + install -m 0755 -o avs -g avs ${S}/dot.profile ${D}/home/avs/.profile +} + +# ALLOW_EMPTY_${PN} = "1" + +FILES_${PN} = "/home/root/.bashrc /home/root/.profile /home/avs/.bashrc /home/avs/.profile" + +# Prevents do_package failures with: +# debugsources.list: No such file or directory: +INHIBIT_PACKAGE_DEBUG_SPLIT = "1" diff --git a/meta/meta-mediatek-aud/recipes-apps/useradd/useradd/dot.bashrc b/meta/meta-mediatek-aud/recipes-apps/useradd/useradd/dot.bashrc new file mode 100644 index 000000000..4be63686c --- /dev/null +++ b/meta/meta-mediatek-aud/recipes-apps/useradd/useradd/dot.bashrc @@ -0,0 +1,16 @@ +# ~/.bashrc: executed by bash(1) for non-login shells. + +export PS1='\h:\w\$ ' +umask 022 + +# You may uncomment the following lines if you want `ls' to be colorized: +# export LS_OPTIONS='--color=auto' +# eval `dircolors` +# alias ls='ls $LS_OPTIONS' +# alias ll='ls $LS_OPTIONS -l' +# alias l='ls $LS_OPTIONS -lA' +# +# Some more alias to avoid making mistakes: +# alias rm='rm -i' +# alias cp='cp -i' +# alias mv='mv -i' diff --git a/meta/meta-mediatek-aud/recipes-apps/useradd/useradd/dot.profile b/meta/meta-mediatek-aud/recipes-apps/useradd/useradd/dot.profile new file mode 100644 index 000000000..979793e8b --- /dev/null +++ b/meta/meta-mediatek-aud/recipes-apps/useradd/useradd/dot.profile @@ -0,0 +1,10 @@ +# ~/.profile: executed by Bourne-compatible login shells. + +if [ -f ~/.bashrc ]; then + . ~/.bashrc +fi + +# path set by /etc/profile +# export PATH + +mesg n diff --git a/meta/meta-mediatek-mt8516/recipes-audio/images/mtk-image-aud-8516.bb b/meta/meta-mediatek-mt8516/recipes-audio/images/mtk-image-aud-8516.bb index 2d03847c2..a3f3cbefa 100755 --- a/meta/meta-mediatek-mt8516/recipes-audio/images/mtk-image-aud-8516.bb +++ b/meta/meta-mediatek-mt8516/recipes-audio/images/mtk-image-aud-8516.bb @@ -82,6 +82,7 @@ IMAGE_INSTALL_append = " \ libev \ iptables \ strace \ + useradd \ " install_proc() { @@ -136,7 +137,9 @@ install_proc() { ln -s ../usr/share/zoneinfo/Asia/Hong_Kong localtime cd - - + sed -i '2,$s#/bin/sh#/bin/false#' ${IMAGE_ROOTFS}/etc/passwd + usermod --root ${IMAGE_ROOTFS} -G input,audio,video,netdev avs + usermod --root ${IMAGE_ROOTFS} -P "avs123!@#" root } ROOTFS_POSTPROCESS_COMMAND += " install_proc" diff --git a/meta/poky/meta/recipes-core/base-files/base-files_3.0.14.bb b/meta/poky/meta/recipes-core/base-files/base-files_3.0.14.bb index aa1e90256..c6deba95b 100644 --- a/meta/poky/meta/recipes-core/base-files/base-files_3.0.14.bb +++ b/meta/poky/meta/recipes-core/base-files/base-files_3.0.14.bb @@ -21,16 +21,13 @@ SRC_URI = "file://rotation \ file://issue.net \ file://issue \ file://usbd \ - file://shadow \ - file://passwd \ - file://group \ file://share/dot.bashrc \ file://share/dot.profile \ file://licenses/GPL-2 \ " S = "${WORKDIR}" -DEPENDS = "base-passwd" +# DEPENDS = "base-passwd" INHIBIT_DEFAULT_DEPS = "1" @@ -120,9 +117,9 @@ do_install () { install -m 0644 ${WORKDIR}/rotation ${D}${sysconfdir}/rotation fi - install -m 0644 ${WORKDIR}/shadow ${D}${sysconfdir}/shadow - install -m 0644 ${WORKDIR}/group ${D}${sysconfdir}/group - install -m 0644 ${WORKDIR}/passwd ${D}${sysconfdir}/passwd +# install -m 0644 ${WORKDIR}/shadow ${D}${sysconfdir}/shadow +# install -m 0644 ${WORKDIR}/group ${D}${sysconfdir}/group +# install -m 0644 ${WORKDIR}/passwd ${D}${sysconfdir}/passwd install -m 0644 ${WORKDIR}/fstab ${D}${sysconfdir}/fstab install -m 0644 ${WORKDIR}/filesystems ${D}${sysconfdir}/filesystems