]>
Commit | Line | Data |
---|---|---|
ff12a795 | 1 | #!/usr/bin/env bash |
7b3cec95 | 2 | # SPDX-License-Identifier: LGPL-2.1-or-later |
084575ff | 3 | set -eux |
6ead3917 LP |
4 | set -o pipefail |
5 | ||
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 | |
0ee99483 | 8 | echo OK >/testok |
6ead3917 LP |
9 | exit 0 |
10 | fi | |
11 | ||
12 | inspect() { | |
68bb821e ZJS |
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 | |
17 | # comparison. | |
38825267 FS |
18 | local USERNAME="${1:?missing argument}" |
19 | homectl inspect "$USERNAME" | tee /tmp/a | |
20 | userdbctl user "$USERNAME" | tee /tmp/b | |
68bb821e | 21 | |
12852528 FS |
22 | # diff uses the grep BREs for pattern matching |
23 | diff -I '^\s*Disk \(Size\|Free\|Floor\|Ceiling\):' /tmp/{a,b} | |
68bb821e | 24 | rm /tmp/{a,b} |
6ead3917 LP |
25 | } |
26 | ||
27 | systemd-analyze log-level debug | |
28 | systemd-analyze log-target console | |
c42234ab | 29 | systemctl service-log-level systemd-homed debug |
6ead3917 | 30 | |
41caad6f LP |
31 | # Create a tmpfs to use as backing store for the home dir. That way we can enforce a size limit nicely. |
32 | mkdir -p /home-pool | |
33 | mount -t tmpfs tmpfs /home-pool -o size=290M | |
34 | ||
30548633 | 35 | # we enable --luks-discard= since we run our tests in a tight VM, hence don't |
41caad6f LP |
36 | # needlessly pressure for storage. We also set the cheapest KDF, since we don't |
37 | # want to waste CI CPU cycles on it. | |
38 | NEWPASSWORD=xEhErW0ndafV4s homectl create test-user \ | |
75f6ae06 | 39 | --disk-size=min \ |
41caad6f LP |
40 | --luks-discard=yes \ |
41 | --image-path=/home-pool/test-user.home \ | |
42 | --luks-pbkdf-type=pbkdf2 \ | |
43 | --luks-pbkdf-time-cost=1ms | |
6ead3917 LP |
44 | inspect test-user |
45 | ||
46 | PASSWORD=xEhErW0ndafV4s homectl authenticate test-user | |
47 | ||
48 | PASSWORD=xEhErW0ndafV4s homectl activate test-user | |
49 | inspect test-user | |
50 | ||
51 | PASSWORD=xEhErW0ndafV4s homectl update test-user --real-name="Inline test" | |
52 | inspect test-user | |
53 | ||
54 | homectl deactivate test-user | |
55 | inspect test-user | |
56 | ||
57 | PASSWORD=xEhErW0ndafV4s NEWPASSWORD=yPN4N0fYNKUkOq homectl passwd test-user | |
58 | inspect test-user | |
59 | ||
60 | PASSWORD=yPN4N0fYNKUkOq homectl activate test-user | |
61 | inspect test-user | |
62 | ||
63 | SYSTEMD_LOG_LEVEL=debug PASSWORD=yPN4N0fYNKUkOq NEWPASSWORD=xEhErW0ndafV4s homectl passwd test-user | |
64 | inspect test-user | |
65 | ||
66 | homectl deactivate test-user | |
67 | inspect test-user | |
68 | ||
69 | PASSWORD=xEhErW0ndafV4s homectl activate test-user | |
70 | inspect test-user | |
71 | ||
993b9057 | 72 | homectl deactivate test-user |
6ead3917 LP |
73 | inspect test-user |
74 | ||
75 | PASSWORD=xEhErW0ndafV4s homectl update test-user --real-name="Offline test" | |
76 | inspect test-user | |
77 | ||
78 | PASSWORD=xEhErW0ndafV4s homectl activate test-user | |
79 | inspect test-user | |
80 | ||
993b9057 | 81 | homectl deactivate test-user |
6ead3917 LP |
82 | inspect test-user |
83 | ||
a89b6750 LP |
84 | # Do some resize tests, but only if we run on real kernels, as quota inside of containers will fail |
85 | if ! systemd-detect-virt -cq ; then | |
86 | # grow while inactive | |
87 | PASSWORD=xEhErW0ndafV4s homectl resize test-user 300M | |
88 | inspect test-user | |
89 | ||
90 | # minimize while inactive | |
9f5827e0 | 91 | PASSWORD=xEhErW0ndafV4s homectl resize test-user min |
a89b6750 LP |
92 | inspect test-user |
93 | ||
94 | PASSWORD=xEhErW0ndafV4s homectl activate test-user | |
95 | inspect test-user | |
96 | ||
97 | # grow while active | |
9f5827e0 | 98 | PASSWORD=xEhErW0ndafV4s homectl resize test-user max |
a89b6750 LP |
99 | inspect test-user |
100 | ||
101 | # minimize while active | |
102 | PASSWORD=xEhErW0ndafV4s homectl resize test-user 0 | |
103 | inspect test-user | |
104 | ||
105 | # grow while active | |
106 | PASSWORD=xEhErW0ndafV4s homectl resize test-user 300M | |
107 | inspect test-user | |
108 | ||
109 | # shrink to original size while active | |
110 | PASSWORD=xEhErW0ndafV4s homectl resize test-user 256M | |
111 | inspect test-user | |
112 | ||
993b9057 | 113 | homectl deactivate test-user |
a89b6750 LP |
114 | inspect test-user |
115 | fi | |
116 | ||
b9bfa250 ZJS |
117 | PASSWORD=xEhErW0ndafV4s homectl with test-user -- test ! -f /home/test-user/xyz |
118 | PASSWORD=xEhErW0ndafV4s homectl with test-user -- test -f /home/test-user/xyz \ | |
119 | && { echo 'unexpected success'; exit 1; } | |
6ead3917 LP |
120 | PASSWORD=xEhErW0ndafV4s homectl with test-user -- touch /home/test-user/xyz |
121 | PASSWORD=xEhErW0ndafV4s homectl with test-user -- test -f /home/test-user/xyz | |
122 | PASSWORD=xEhErW0ndafV4s homectl with test-user -- rm /home/test-user/xyz | |
b9bfa250 ZJS |
123 | PASSWORD=xEhErW0ndafV4s homectl with test-user -- test ! -f /home/test-user/xyz |
124 | PASSWORD=xEhErW0ndafV4s homectl with test-user -- test -f /home/test-user/xyz \ | |
125 | && { echo 'unexpected success'; exit 1; } | |
6ead3917 LP |
126 | |
127 | homectl remove test-user | |
128 | ||
129 | systemd-analyze log-level info | |
130 | ||
0ee99483 | 131 | echo OK >/testok |
6ead3917 LP |
132 | |
133 | exit 0 |