mirror of
https://github.com/godotengine/buildroot.git
synced 2026-01-05 14:09:53 +03:00
package/shadow: new package
shadow provides utilities to deal with user accounts. The shadow package includes the necessary programs for converting UNIX password files to the shadow password format, plus programs for managing user and group accounts. Especially it is useful if rootless podman container should be used, which requires newuidmap and newgidmap. Co-authored-by: Nicolas Carrier <Nicolas.Carrier@orolia.com> [Nicolas.Carrier@orolia.com provided the test case] Signed-off-by: Raphael Pavlidis <raphael.pavlidis@gmail.com> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
This commit is contained in:
committed by
Thomas Petazzoni
parent
97c40266b1
commit
f78c5cb5ca
55
support/testing/tests/package/test_shadow.py
Normal file
55
support/testing/tests/package/test_shadow.py
Normal file
@@ -0,0 +1,55 @@
|
||||
import os
|
||||
|
||||
from infra.basetest import BRTest, BASIC_TOOLCHAIN_CONFIG
|
||||
|
||||
|
||||
class TestShadow(BRTest):
|
||||
username = 'user_test'
|
||||
config = BASIC_TOOLCHAIN_CONFIG + \
|
||||
"""
|
||||
BR2_arm=y
|
||||
BR2_PACKAGE_SHADOW=y
|
||||
BR2_TARGET_ROOTFS_EXT2=y
|
||||
BR2_TARGET_ROOTFS_EXT2_4=y
|
||||
BR2_TARGET_ROOTFS_EXT2_SIZE="65536"
|
||||
"""
|
||||
timeout = 60
|
||||
|
||||
def login(self):
|
||||
img = os.path.join(self.builddir, "images", "rootfs.ext4")
|
||||
self.emulator.boot(arch="armv7",
|
||||
kernel="builtin",
|
||||
kernel_cmdline=["root=/dev/mmcblk0",
|
||||
"rootfstype=ext4"],
|
||||
options=["-drive", f"file={img},if=sd,format=raw"])
|
||||
self.emulator.login()
|
||||
|
||||
def test_nologin(self):
|
||||
self.login()
|
||||
|
||||
self.assertRunOk("! nologin")
|
||||
cmd = 'test "$(nologin)" = "This account is currently not available."'
|
||||
self.assertRunOk(cmd)
|
||||
|
||||
def test_useradd_del(self):
|
||||
username = self.username
|
||||
self.login()
|
||||
|
||||
self.assertRunOk(f'userdel {username} || true')
|
||||
self.assertRunOk(f'groupdel {username} || true')
|
||||
self.assertRunOk(f'useradd -s /bin/sh {username}')
|
||||
self.assertRunOk(f'test $(su {username} -c "whoami") = {username}')
|
||||
self.assertRunOk(f'userdel {username}')
|
||||
|
||||
def test_usermod(self):
|
||||
username = self.username
|
||||
new_home = '/tmp'
|
||||
self.login()
|
||||
|
||||
self.assertRunOk(f'userdel {username} || true')
|
||||
self.assertRunOk(f'groupdel {username} || true')
|
||||
self.assertRunOk(f'useradd -s /bin/sh {username}')
|
||||
self.assertRunOk(f'usermod {username} --home {new_home}')
|
||||
self.assertRunOk(f'test $(su {username} -c \'echo $HOME\') = {new_home}')
|
||||
self.assertRunOk(f'userdel {username}')
|
||||
|
||||
Reference in New Issue
Block a user