我无法在 Yocto 中添加用户,我不确定为什么。我的食谱是
useradd.bb
,它包含
DESCRIPTION = "Add a new user 'nfi' with sudo privileges and change root password"
LICENSE = "CLOSED"
# Inherit necessary classes
inherit useradd
inherit extrausers
# Ensure the 'sudo' group exists and set the root password
# Replace 'hashed_root_password' with the actual hashed password
EXTRA_USERS_PARAMS = "\
groupadd -f sudo; \
usermod -p toor root; \
"
# Configure the new user 'nfi'
USERADD_PACKAGES = "${PN}"
USERADD_PARAM_${PN} = "--user nfi --password nfi --create-home --groups sudo"
do_install() {
echo 'nfi ALL=(ALL) NOPASSWD:ALL' >> ${D}${sysconfdir}/sudoers.d/nfi
}
FILES_${PN} += "${sysconfdir}/sudoers.d"
这应该很简单,但我经常看到 log.do_prepare_recipe_sysroot 行
Running useradd commands...
NOTE: useradd: Performing useradd with [--root /mnt/YoctoDrive/Documents/master/EVCC_Application/build-fb/tmp/work/cortexa7t2hf-neon-poky-linux-gnueabi/useradd/1.0-r0/recipe-sysroot --user nfi --password nfi --create-home]
useradd: listing attributes of /etc/skel/.bashrc: No data available
ERROR: useradd: useradd command did not succeed.
WARNING: exit code 1 from a shell command.
ERROR: Error executing a python function in exec_python_func() autogenerated:
接下来是一大块Python代码。任何人都可以在这里解释这个问题吗?
编辑:我正在使用 Hardknott。我尝试过使用两台计算机和多个工作区。
您必须使用
extrausers
类在系统中创建新用户,并使用 useradd
类创建具有特定配方的用户。
我会尝试:
DESCRIPTION = "Add a new user 'nfi' with sudo privileges and change root password"
LICENSE = "CLOSED"
EXCLUDE_FROM_WORLD = "1"
INHIBIT_DEFAULT_DEPS = "1"
ALLOW_EMPTY:${PN} = "1"
inherit useradd
USERADD_PACKAGES = "${PN}"
GROUPADD_PARAM:${PN} = "nfi"
USERADD_PARAM:${PN} = "-G adm,sudo,users,plugdev,audio,video,dialout,input -m -d /home/nfi -p <PASSWORD_HERE> nfi"