2 # SPDX-License-Identifier: LGPL-2.1-or-later
6 # Check if homectl is installed, and if it isn't bail out early instead of failing
7 if ! test -x /usr
/bin
/homectl
; then
8 echo "no homed" >/skipped
13 # As updating disk-size-related attributes can take some time on some
14 # filesystems, let's drop these fields before comparing the outputs to
15 # avoid unexpected fails. To see the full outputs of both homectl &
16 # userdbctl (for debugging purposes) drop the fields just before the
18 local USERNAME
="${1:?missing argument}"
19 homectl inspect
"$USERNAME" |
tee /tmp
/a
20 userdbctl user
"$USERNAME" |
tee /tmp
/b
22 # diff uses the grep BREs for pattern matching
23 diff -I '^\s*Disk \(Size\|Free\|Floor\|Ceiling\):' /tmp
/{a
,b
}
26 homectl inspect
--json=pretty
"$USERNAME"
30 for ((i
=0;i
<10;i
++)) ; do
31 homectl inspect
"$1" |
grep -qF "State: $2" && break
36 systemd-analyze log-level debug
37 systemd-analyze log-target console
38 systemctl service-log-level systemd-homed debug
40 # Create a tmpfs to use as backing store for the home dir. That way we can enforce a size limit nicely.
42 mount
-t tmpfs tmpfs
/home
-o size
=290M
44 # we enable --luks-discard= since we run our tests in a tight VM, hence don't
45 # needlessly pressure for storage. We also set the cheapest KDF, since we don't
46 # want to waste CI CPU cycles on it.
47 NEWPASSWORD
=xEhErW0ndafV4s homectl create test-user \
50 --image-path=/home
/test-user.home \
51 --luks-pbkdf-type=pbkdf2 \
52 --luks-pbkdf-time-cost=1ms
55 PASSWORD
=xEhErW0ndafV4s homectl authenticate test-user
57 PASSWORD
=xEhErW0ndafV4s homectl activate test-user
60 PASSWORD
=xEhErW0ndafV4s homectl update test-user
--real-name="Inline test"
63 homectl deactivate test-user
66 PASSWORD
=xEhErW0ndafV4s NEWPASSWORD
=yPN4N0fYNKUkOq homectl passwd test-user
69 PASSWORD
=yPN4N0fYNKUkOq homectl activate test-user
72 SYSTEMD_LOG_LEVEL
=debug PASSWORD
=yPN4N0fYNKUkOq NEWPASSWORD
=xEhErW0ndafV4s homectl passwd test-user
75 homectl deactivate test-user
78 PASSWORD
=xEhErW0ndafV4s homectl activate test-user
81 homectl deactivate test-user
84 PASSWORD
=xEhErW0ndafV4s homectl update test-user
--real-name="Offline test"
87 PASSWORD
=xEhErW0ndafV4s homectl activate test-user
90 homectl deactivate test-user
93 # Do some resize tests, but only if we run on real kernels, as quota inside of containers will fail
94 if ! systemd-detect-virt
-cq ; then
96 PASSWORD
=xEhErW0ndafV4s homectl resize test-user
300M
99 # minimize while inactive
100 PASSWORD
=xEhErW0ndafV4s homectl resize test-user min
103 PASSWORD
=xEhErW0ndafV4s homectl activate test-user
107 PASSWORD
=xEhErW0ndafV4s homectl resize test-user max
110 # minimize while active
111 PASSWORD
=xEhErW0ndafV4s homectl resize test-user
0
115 PASSWORD
=xEhErW0ndafV4s homectl resize test-user
300M
118 # shrink to original size while active
119 PASSWORD
=xEhErW0ndafV4s homectl resize test-user
256M
123 PASSWORD
=xEhErW0ndafV4s homectl resize test-user min
126 # Increase space, so that we can reasonably rebalance free space between to home dirs
127 mount
/home
-o remount
,size
=800M
130 NEWPASSWORD
=uuXoo8ei homectl create test-user2 \
133 --image-path=/home
/test-user2.home \
134 --luks-pbkdf-type=pbkdf2 \
135 --luks-pbkdf-time-cost=1ms
138 # activate second user
139 PASSWORD
=uuXoo8ei homectl activate test-user2
142 # set second user's rebalance weight to 100
143 PASSWORD
=uuXoo8ei homectl update test-user2
--rebalance-weight=100
146 # set first user's rebalance weight to quarter of that of the second
147 PASSWORD
=xEhErW0ndafV4s homectl update test-user
--rebalance-weight=25
150 # synchronously rebalance
156 PASSWORD
=xEhErW0ndafV4s homectl with test-user
-- test ! -f /home
/test-user
/xyz
157 PASSWORD
=xEhErW0ndafV4s homectl with test-user
-- test -f /home
/test-user
/xyz \
158 && { echo 'unexpected success'; exit 1; }
159 PASSWORD
=xEhErW0ndafV4s homectl with test-user
-- touch /home
/test-user
/xyz
160 PASSWORD
=xEhErW0ndafV4s homectl with test-user
-- test -f /home
/test-user
/xyz
161 PASSWORD
=xEhErW0ndafV4s homectl with test-user
-- rm /home
/test-user
/xyz
162 PASSWORD
=xEhErW0ndafV4s homectl with test-user
-- test ! -f /home
/test-user
/xyz
163 PASSWORD
=xEhErW0ndafV4s homectl with test-user
-- test -f /home
/test-user
/xyz \
164 && { echo 'unexpected success'; exit 1; }
166 wait_for_state test-user inactive
167 homectl remove test-user
169 if ! systemd-detect-virt
-cq ; then
170 wait_for_state test-user2 active
171 homectl deactivate test-user2
172 wait_for_state test-user2 inactive
173 homectl remove test-user2
176 systemd-analyze log-level info