我喜欢为 yocto 项目的内置用户做一些事情:
1.) 将 root 的密码设置为“abc”
2.) 将 ssh 登录形式 /bin/sh 的 root shell 设置为 /bin/bash
3.) 添加用户“customUser”,密码为“xyz”
认为一个简单的食谱就可以做到这一点。到目前为止我尝试过@myUser.bb:
SUMMARY = "admin + user"
SECTION = "USR"
LICENSE = "CLOSED"
inherit extrausers useradd
# how to
# pw: abc
# at bash: usermod -p $(openssl passwd abc) root
# get a salted hash: openssl passwd abc
# one possible result: 1Cw5PHLy76ps2
# the command now looks: usermod -p 1Cw5PHLy76ps2 root
# set image root password
EXTRA_USERS_PARAMS = "usermod -p 1Cw5PHLy76ps2 root;"
USERADD_PACKAGES = "${PN}"
# password
# "xyz"
# openssl passwd xyz
# result: y5UyLBO4GNAwc
USERADD_PARAM_${PN} = "-u 1200 -d /home/customUser -r -s /bin/bash -p y5UyLBO4GNAwc customUser"
do_install_append () {
install -d -m 755 ${D}${datadir}/customUser
# The new users and groups are created before the do_install
# step, so you are now free to make use of them:
chown -R customUser ${D}${datadir}/customUser
# groups
# chgrp -R group1 ${D}${datadir}/customUser
}
FILES_${PN} = "${datadir}/*"
#ALLOW_EMPTY_${PN} = "1"
知道如何完成这件事吗?
您可以使用EXTRA_USERS_PARAMS
全局在你的主食谱中。
inherit extrausers
EXTRA_USERS_PARAMS = " useradd customUser1; \
useradd customUser2; \
usermod -p 'Password_1' customUser1; \
usermod -p 'Password_2' customUser2; \
usermod -a -G sudo customUser1; \
usermod -a -G sudo customUser2;"
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)