mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 08:25:20 +09:00
TEST-46-HOMED: Add tests for blob directories
This commit is contained in:
committed by
Luca Boccassi
parent
25c89b8977
commit
bbdd9c8d97
@@ -156,9 +156,7 @@ PASSWORD=xEhErW0ndafV4s homectl with test-user -- test ! -f /home/test-user/xyz
|
||||
(! PASSWORD=xEhErW0ndafV4s homectl with test-user -- test -f /home/test-user/xyz)
|
||||
PASSWORD=xEhErW0ndafV4s homectl with test-user -- touch /home/test-user/xyz
|
||||
PASSWORD=xEhErW0ndafV4s homectl with test-user -- test -f /home/test-user/xyz
|
||||
PASSWORD=xEhErW0ndafV4s homectl with test-user -- rm /home/test-user/xyz
|
||||
PASSWORD=xEhErW0ndafV4s homectl with test-user -- test ! -f /home/test-user/xyz
|
||||
(! PASSWORD=xEhErW0ndafV4s homectl with test-user -- test -f /home/test-user/xyz)
|
||||
# CAREFUL adding more `homectl with` tests here. Auth can get rate-limited and cause the tests to fail.
|
||||
|
||||
wait_for_state test-user inactive
|
||||
homectl remove test-user
|
||||
@@ -170,6 +168,139 @@ if ! systemd-detect-virt -cq ; then
|
||||
homectl remove test-user2
|
||||
fi
|
||||
|
||||
# blob directory tests
|
||||
# See docs/USER_RECORD_BLOB_DIRS.md
|
||||
checkblob() {
|
||||
test -f "/var/cache/systemd/home/blob-user/$1"
|
||||
stat -c "%u %#a" "/var/cache/systemd/home/blob-user/$1" | grep "^0 0644"
|
||||
test -f "/home/blob-user/.identity-blob/$1"
|
||||
stat -c "%u %#a" "/home/blob-user/.identity-blob/$1" | grep "^12345 0644"
|
||||
|
||||
diff "/var/cache/systemd/home/blob-user/$1" "$2"
|
||||
diff "/var/cache/systemd/home/blob-user/$1" "/home/blob-user/.identity-blob/$1"
|
||||
}
|
||||
|
||||
mkdir /tmp/blob1 /tmp/blob2
|
||||
echo data1 blob1 > /tmp/blob1/test1
|
||||
echo data1 blob2 > /tmp/blob2/test1
|
||||
echo data2 blob1 > /tmp/blob1/test2
|
||||
echo data2 blob2 > /tmp/blob2/test2
|
||||
echo invalid filename > /tmp/blob1/файл
|
||||
echo data3 > /tmp/external-test3
|
||||
echo avatardata > /tmp/external-avatar
|
||||
ln -s /tmp/external-avatar /tmp/external-avatar-lnk
|
||||
dd if=/dev/urandom of=/tmp/external-barely-fits bs=1M count=64
|
||||
dd if=/dev/urandom of=/tmp/external-toobig bs=1M count=65
|
||||
|
||||
# create w/ prepopulated blob dir
|
||||
NEWPASSWORD=EMJuc3zQaMibJo homectl create blob-user \
|
||||
--disk-size=min --luks-discard=yes \
|
||||
--luks-pbkdf-type=pbkdf2 --luks-pbkdf-time-cost=1ms \
|
||||
--uid=12345 \
|
||||
--blob=/tmp/blob1
|
||||
inspect blob-user
|
||||
PASSWORD=EMJuc3zQaMibJo homectl activate blob-user
|
||||
inspect blob-user
|
||||
|
||||
test -d /var/cache/systemd/home/blob-user
|
||||
stat -c "%u %#a" /var/cache/systemd/home/blob-user | grep "^0 0755"
|
||||
test -d /home/blob-user/.identity-blob
|
||||
stat -c "%u %#a" /home/blob-user/.identity-blob | grep "^12345 0700"
|
||||
|
||||
checkblob test1 /tmp/blob1/test1
|
||||
(! checkblob test1 /tmp/blob2/test1 )
|
||||
checkblob test2 /tmp/blob1/test2
|
||||
(! checkblob test2 /tmp/blob2/test2 )
|
||||
(! checkblob фаил /tmp/blob1/фаил )
|
||||
(! checkblob test3 /tmp/external-test3 )
|
||||
(! checkblob avatar /tmp/external-avatar )
|
||||
|
||||
# append files to existing blob, both well-known and other
|
||||
PASSWORD=EMJuc3zQaMibJo homectl update blob-user \
|
||||
-b test3=/tmp/external-test3 --avatar=/tmp/external-avatar
|
||||
inspect blob-user
|
||||
checkblob test1 /tmp/blob1/test1
|
||||
(! checkblob test1 /tmp/blob2/test1 )
|
||||
checkblob test2 /tmp/blob1/test2
|
||||
(! checkblob test2 /tmp/blob2/test2 )
|
||||
(! checkblob фаил /tmp/blob1/фаил )
|
||||
checkblob test3 /tmp/external-test3
|
||||
checkblob avatar /tmp/external-avatar
|
||||
|
||||
# delete files from existing blob, both well-known and other
|
||||
PASSWORD=EMJuc3zQaMibJo homectl update blob-user \
|
||||
-b test3= --avatar=
|
||||
inspect blob-user
|
||||
checkblob test1 /tmp/blob1/test1
|
||||
(! checkblob test1 /tmp/blob2/test1 )
|
||||
checkblob test2 /tmp/blob1/test2
|
||||
(! checkblob test2 /tmp/blob2/test2 )
|
||||
(! checkblob фаил /tmp/blob1/фаил )
|
||||
(! checkblob test3 /tmp/external-test3 )
|
||||
(! checkblob avatar /tmp/external-avatar )
|
||||
|
||||
# swap entire blob directory
|
||||
PASSWORD=EMJuc3zQaMibJo homectl update blob-user \
|
||||
-b /tmp/blob2
|
||||
inspect blob-user
|
||||
(! checkblob test1 /tmp/blob1/test1 )
|
||||
checkblob test1 /tmp/blob2/test1
|
||||
(! checkblob test2 /tmp/blob1/test2 )
|
||||
checkblob test2 /tmp/blob2/test2
|
||||
(! checkblob фаил /tmp/blob1/фаил )
|
||||
(! checkblob test3 /tmp/external-test3 )
|
||||
(! checkblob avatar /tmp/external-avatar )
|
||||
|
||||
# create and delete files while swapping blob directory. Also symlinks.
|
||||
PASSWORD=EMJuc3zQaMibJo homectl update blob-user \
|
||||
-b /tmp/blob1 -b test2= -b test3=/tmp/external-test3 --avatar=/tmp/external-avatar-lnk
|
||||
inspect blob-user
|
||||
checkblob test1 /tmp/blob1/test1
|
||||
(! checkblob test1 /tmp/blob2/test1 )
|
||||
(! checkblob test2 /tmp/blob1/test2 )
|
||||
(! checkblob test2 /tmp/blob2/test2 )
|
||||
(! checkblob фаил /tmp/blob1/фаил )
|
||||
checkblob test3 /tmp/external-test3
|
||||
checkblob avatar /tmp/external-avatar # target of the link
|
||||
|
||||
# clear the blob directory
|
||||
PASSWORD=EMJuc3zQaMibJo homectl update blob-user \
|
||||
-b /tmp/blob2 -b test3=/tmp/external-test3 --blob=
|
||||
inspect blob-user
|
||||
(! checkblob test1 /tmp/blob1/test1 )
|
||||
(! checkblob test1 /tmp/blob2/test1 )
|
||||
(! checkblob test2 /tmp/blob1/test2 )
|
||||
(! checkblob test2 /tmp/blob2/test2 )
|
||||
(! checkblob фаил /tmp/blob1/фаил )
|
||||
(! checkblob test3 /tmp/external-test3 )
|
||||
(! checkblob avatar /tmp/external-avatar )
|
||||
|
||||
# file that's exactly 64M still fits
|
||||
PASSWORD=EMJuc3zQaMibJo homectl update blob-user \
|
||||
-b barely-fits=/tmp/external-barely-fits
|
||||
(! checkblob test1 /tmp/blob1/test1 )
|
||||
(! checkblob test1 /tmp/blob2/test1 )
|
||||
(! checkblob test2 /tmp/blob1/test2 )
|
||||
(! checkblob test2 /tmp/blob2/test2 )
|
||||
(! checkblob фаил /tmp/blob1/фаил )
|
||||
(! checkblob test3 /tmp/external-test3 )
|
||||
(! checkblob avatar /tmp/external-avatar )
|
||||
checkblob barely-fits /tmp/external-barely-fits
|
||||
|
||||
# error out if the file is too big
|
||||
(! PASSWORD=EMJuc3zQaMibJo homectl update blob-user -b huge=/tmp/external-toobig )
|
||||
|
||||
# error out if filenames are invalid
|
||||
(! PASSWORD=EMJuc3zQaMibJo homectl update blob-user -b .hidden=/tmp/external-test3 )
|
||||
(! PASSWORD=EMJuc3zQaMibJo homectl update blob-user -b "with spaces=/tmp/external-test3" )
|
||||
(! PASSWORD=EMJuc3zQaMibJo homectl update blob-user -b with=equals=/tmp/external-test3 )
|
||||
(! PASSWORD=EMJuc3zQaMibJo homectl update blob-user -b файл=/tmp/external-test3 )
|
||||
(! PASSWORD=EMJuc3zQaMibJo homectl update blob-user -b special@chars=/tmp/external-test3 )
|
||||
|
||||
homectl deactivate blob-user
|
||||
wait_for_state blob-user inactive
|
||||
homectl remove blob-user
|
||||
|
||||
# userdbctl tests
|
||||
export PAGER=
|
||||
|
||||
|
||||
Reference in New Issue
Block a user